org.mmtk.utility
Class ForwardingWord

java.lang.Object
  extended by org.mmtk.utility.ForwardingWord

public class ForwardingWord
extends Object

This class provides generic support for object forwarding, which is specific to a few policies that support copying. The broad idea is two-fold: 1) the two low-order bits of the GC byte (which are also the two low-order bits of the header word) are used to indicate whether an object has been forwarded or is being forwarded, and 2) if an object has been forwarded then the entire header word of the dead object is used to store a pointer to the forwarded pointer. This is a standard implementation of forwarding.

The two lowest order bits are used for object forwarding because forwarding generally must steal the unused two low order bits of the forwarding pointer.


Field Summary
private static byte BEING_FORWARDED
          If this bit is set, then forwarding of this object is incomplete
private static byte FORWARDED
          If this bit is set, then forwarding of this object has commenced
static int FORWARDING_BITS
           
static byte FORWARDING_MASK
          This mask is used to reveal which state this object is in with respect to forwarding
 
Constructor Summary
ForwardingWord()
           
 
Method Summary
static Word attemptToForward(ObjectReference object)
          Either return the forwarding pointer if the object is already forwarded (or being forwarded) or write the bit pattern that indicates that the object is being forwarded
static void clearForwardingBits(ObjectReference object)
          Clear the GC forwarding portion of the header for an object.
static ObjectReference extractForwardingPointer(Word forwardingWord)
           
static ObjectReference forwardObject(ObjectReference object, int allocator)
           
static boolean isForwarded(ObjectReference object)
          Has an object been forwarded?
static boolean isForwardedOrBeingForwarded(ObjectReference object)
          Has an object been forwarded or is it being forwarded?
static void setForwardingPointer(ObjectReference object, ObjectReference ptr)
          Non-atomic write of forwarding pointer word (assumption, thread doing the set has done attempt to forward and owns the right to copy the object)
static ObjectReference spinAndGetForwardedObject(ObjectReference object, Word statusWord)
           
static boolean stateIsBeingForwarded(Word header)
          Has an object been forwarded or being forwarded?
static boolean stateIsForwardedOrBeingForwarded(Word header)
          Has an object been forwarded or being forwarded?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEING_FORWARDED

private static final byte BEING_FORWARDED
If this bit is set, then forwarding of this object is incomplete

See Also:
Constant Field Values

FORWARDED

private static final byte FORWARDED
If this bit is set, then forwarding of this object has commenced

See Also:
Constant Field Values

FORWARDING_MASK

public static final byte FORWARDING_MASK
This mask is used to reveal which state this object is in with respect to forwarding

See Also:
Constant Field Values

FORWARDING_BITS

public static final int FORWARDING_BITS
See Also:
Constant Field Values
Constructor Detail

ForwardingWord

public ForwardingWord()
Method Detail

attemptToForward

public static Word attemptToForward(ObjectReference object)
Either return the forwarding pointer if the object is already forwarded (or being forwarded) or write the bit pattern that indicates that the object is being forwarded

Parameters:
object - The object to be forwarded
Returns:
The forwarding pointer for the object if it has already been forwarded.

spinAndGetForwardedObject

public static ObjectReference spinAndGetForwardedObject(ObjectReference object,
                                                        Word statusWord)

forwardObject

public static ObjectReference forwardObject(ObjectReference object,
                                            int allocator)

setForwardingPointer

public static void setForwardingPointer(ObjectReference object,
                                        ObjectReference ptr)
Non-atomic write of forwarding pointer word (assumption, thread doing the set has done attempt to forward and owns the right to copy the object)

Parameters:
object - The object whose forwarding pointer is to be set
ptr - The forwarding pointer to be stored in the object's forwarding word

isForwarded

public static boolean isForwarded(ObjectReference object)
Has an object been forwarded?

Parameters:
object - The object to be checked
Returns:
true if the object has been forwarded

isForwardedOrBeingForwarded

public static boolean isForwardedOrBeingForwarded(ObjectReference object)
Has an object been forwarded or is it being forwarded?

Parameters:
object - The object to be checked
Returns:
true if the object has been forwarded

stateIsForwardedOrBeingForwarded

public static boolean stateIsForwardedOrBeingForwarded(Word header)
Has an object been forwarded or being forwarded?

Parameters:
header - The object header to be checked
Returns:
true if the object has been forwarded

stateIsBeingForwarded

public static boolean stateIsBeingForwarded(Word header)
Has an object been forwarded or being forwarded?

Parameters:
header - The object header to be checked
Returns:
true if the object has been forwarded

clearForwardingBits

public static void clearForwardingBits(ObjectReference object)
Clear the GC forwarding portion of the header for an object.

Parameters:
object - the object ref to the storage to be initialized

extractForwardingPointer

public static ObjectReference extractForwardingPointer(Word forwardingWord)