Seite 1 von 1

### Exercise 7

Verfasst: 31. Jan 2019 18:28
Hi I am studying Exercise 7 now and I have questions in Task2.

we have to do non-moving GC.

This is what I thought how to do it:

Env: res->15
so need to follow the reference.
like this: (loc, Value) = (15, Box(14)) and then, (14, 11), then , (11, Box(10)), (10, Box(6)), (6, 5), (5, Box(4)), (4, Num(11).
I just need to follow the location that the value refers.
As a result, loc(15, 14, 11, 10, 6, 5, 4) are marked.

However, if I do it like this way, loc 12 is unmarked.
But the answer says loc 12 is marked and it wasn't swept after GC.

Is my thought wrong?

+) I feel little bit confused about the gap between lecture and the exercise..

in the exercise solution, I can get the Int type data (e.g. (loc, val) = (14, 11)).
However, in the def allAddrInVal (from SRCFLAEInterpWithGC.scala),
this Int data is the 'case NumV(_)' and results Set().
Then back to def mark,
newAddresses becomes empty. -> no marking from now

It is so hard to explain what I am confused of.
If you don't understand what I mean, just comment under my text.

### Re: Exercise 7

Verfasst: 31. Jan 2019 21:55
In this interpreter, each value has a mutable field "marked" which is used during the marking phase.

A number in the Data column does not mean it is a NumV. The task description says:
Note: The numbers in the Data column are store locations and are referencing
the same Scala object the given store location, e.g. store location 2 references
the same Scala object as store location 1 (Box(0)).
So, the locations 11, 12 and 14 point to the same object with the same "marked" field. Now there are only two things that can happen: Either the object is marked which means that all three locations are kept, or the object is not marked which means that locations 11, 12 and 14 are swept.

Marking works as follows: You start with res -> 15, so you check location 15. Location 15 points to Box(14). You mark that box and need to check location 14 next. Location 14 points to Box(10). You mark that box and need to check location 14 next. And so on...

The NumV case in allAddrInVal is not used until you check location 4.