Hi Carry,

On 29/03/2007, at 12:15 PM, Carry wrote:

hi,everyone!
 
When I research the plan of SemiSpace, I was puzzsled about the reference upodate problem.  It is happened when an object has been copied from the fromspace to tospace, then for other objects  who had a reference to this object, when and how to update their reference to the object moved?  For example, if A has a reference to B, C also has a reference to B, When B has been copied from the fromspace to the tospace, how do A and C update the reference to B's copy in tospace. 
 
Could anyone explain it to me and give me some advice to find the process of refernce update through  the source code?

The mechanism involved is called "forwarding".  The problem is made slightly more interesting by virtue of our collectors being parallel, so multiple threads may try to copy the object at once.

At the first attempt to copy an object;
  1. The mark state in the from-space object's header word (2 least significant bits) is set to "BEING_FORWARDED"
  2. The from-space object is copied to to-space
  3. A "forwarding pointer" is written into the header of the from-space object, with the two least significant bits set to reflect the "FORWARDED" state.

Subsequent attempts to copy the object will either see:
  1. The object is BEING_FORWARED, so the thread spins until the state changes to FORWARDED
  2. The object is FORWARDED, so the thread gets the forwarding address from the from-space object's header.

I suggest you take a look at org.mmtk.policy.CopySpace.traceObject().

Cheers,

--Steve