copy_object_simple copies the object and sets a forwarding pointer. To
avoid leaving dangling refs, you must make a scan after all copying is
done and fix-up any references that still point to old locations. The
scan that does fix-up occurs after all objects have been moved, using
get_copied_object rather than copy_object_simple. In the book, the
section entitled "Relocation Fix-up" gives a brief account of this -
sorry it wasn't more clearly explained.

With regards to question #2, I certainly agree that the scavenging code
is very convoluted. Remember that in gen1, a first fit algorithm is used
for allocation. While objects are being promoted into gen1 freespace in
the copy phase, space that is allocated is remembered by threading a
"scavenge list" together, stashing the next pointer directly in the
object's memory. (This is what thread_scavenge_list is doing, which is
called from allocate_in_older_generation, which in turn is called from
copy_object_simple.) scavenge_phase goes through this list once all of
the top-level objects have been copied, clearing marked and pinned bits
and calling copy_object_simple for any object references that are
contained inside the already copied objects. Of course, this results in
more calls on allocate_in_older_generation, which causes more references
to be stashed in the scavenge list...you get the idea... To make matters
worse, once the entire set of refs has been scavenged, a new scavenge
list can be created by the checks on the finalization queue and the
handle table.

-- David


> -----Original Message-----
> From: Discussion of the Rotor Shared Source CLI
> implementation [mailto:[EMAIL PROTECTED] On
> Behalf Of Pedro Felix
> Sent: Tuesday, June 17, 2003 9:05 AM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET-ROTOR] rotor GC
>
>
> I've two doubts regarding the garbage collection in Rotor.
> I've tried to look in the sources and the in Stutz's book but
> I didn't manage to figure them out.
>
>  1)The first part of the "copy_phase" promotes survivors in
> gen 0 to gen 1 (assuming 2 generations) by calling
> "copy_object_simple". This function copies the objects to gen
> 1 and UPDATES (?) the references. If so, why is it necessary
> the second part of "copy_phase" (calls to
> "get_copied_object" and "GCHeap::Relocate" to perform the
> relocation fix up.
>
>  2)What is the purpose of the scavenger_phase?
>
>
> I thank in advance.
>
> Best regards
> P. Felix
>
>

Reply via email to