org.mmtk.vm
Class ObjectModel

java.lang.Object
  extended by org.mmtk.vm.ObjectModel
Direct Known Subclasses:
ObjectModel

public abstract class ObjectModel
extends Object


Constructor Summary
ObjectModel()
           
 
Method Summary
(package private) static Offset arrayBaseOffsetTrapdoor(ObjectModel o)
           
abstract  boolean attemptAvailableBits(ObjectReference object, Word oldVal, Word newVal)
          Attempts to set the bits available for memory manager use in an object.
abstract  ObjectReference copy(ObjectReference from, int allocator)
          Copy an object using a plan's allocCopy to get space and install the forwarding pointer.
abstract  Address copyTo(ObjectReference from, ObjectReference to, Address region)
          Copy an object to be pointer to by the to address.
abstract  void dumpObject(ObjectReference object)
          Dump debugging information for an object.
abstract  Offset GC_HEADER_OFFSET()
          Gets the offset of the memory management header from the object reference address.
abstract  int getAlignOffsetWhenCopied(ObjectReference object)
          Return the alignment offset requirements for a copy of this object
abstract  int getAlignWhenCopied(ObjectReference object)
          Return the alignment requirement for a copy of this object
protected abstract  Offset getArrayBaseOffset()
           
abstract  int getArrayLength(ObjectReference object)
          Get the length of an array object.
abstract  int getCurrentSize(ObjectReference object)
          Return the size used by an object
abstract  ObjectReference getNextObject(ObjectReference object)
          Return the next object in the heap under contiguous allocation
abstract  Address getObjectEndAddress(ObjectReference object)
          Gets a pointer to the address just past the end of the object.
abstract  ObjectReference getObjectFromStartAddress(Address start)
          Return an object reference from knowledge of the low order word
abstract  ObjectReference getReferenceWhenCopiedTo(ObjectReference from, Address to)
          Return the reference that an object will be referred to after it is copied to the specified region.
abstract  int getSizeWhenCopied(ObjectReference object)
          Return the size required to copy an object
abstract  byte[] getTypeDescriptor(ObjectReference ref)
          Get the type descriptor for an object.
abstract  boolean isAcyclic(ObjectReference typeRef)
          Checks if a reference of the given type in another object is inherently acyclic.
abstract  boolean isArray(ObjectReference object)
          Is the passed object an array?
abstract  boolean isPrimitiveArray(ObjectReference object)
          Is the passed object a primitive array?
abstract  Address objectStartRef(ObjectReference object)
          Returns the lowest address of the storage associated with an object.
abstract  Word prepareAvailableBits(ObjectReference object)
          Gets the value of bits available for memory manager use in an object, in preparation for setting those bits.
abstract  Word readAvailableBitsWord(ObjectReference object)
          Read the bits available for memory manager use in an object.
abstract  byte readAvailableByte(ObjectReference object)
          Read the byte available for memory manager use in an object.
abstract  Address refToAddress(ObjectReference object)
          Returns an address guaranteed to be inside the storage assocatied with and object.
abstract  void writeAvailableBitsWord(ObjectReference object, Word val)
          Sets the bits available for memory manager use in an object.
abstract  void writeAvailableByte(ObjectReference object, byte val)
          Sets the byte available for memory manager use in an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectModel

public ObjectModel()
Method Detail

copy

public abstract ObjectReference copy(ObjectReference from,
                                     int allocator)
Copy an object using a plan's allocCopy to get space and install the forwarding pointer. On entry, from must have been reserved for copying by the caller. This method calls the plan's getStatusForCopy() method to establish a new status word for the copied object and postCopy() to allow the plan to perform any post copy actions.

Parameters:
from - the address of the object to be copied
allocator - The allocator to use.
Returns:
the address of the new object

copyTo

public abstract Address copyTo(ObjectReference from,
                               ObjectReference to,
                               Address region)
Copy an object to be pointer to by the to address. This is required for delayed-copy collectors such as compacting collectors. During the collection, MMTk reserves a region in the heap for an object as per requirements found from ObjectModel and then asks ObjectModel to determine what the object's reference will be post-copy.

Parameters:
from - the address of the object to be copied
to - The target location.
region - The start of the region that was reserved for this object
Returns:
Address The address past the end of the copied object

getReferenceWhenCopiedTo

public abstract ObjectReference getReferenceWhenCopiedTo(ObjectReference from,
                                                         Address to)
Return the reference that an object will be referred to after it is copied to the specified region. Used in delayed-copy collectors such as compacting collectors.

Parameters:
from - The object to be copied.
to - The region to be copied to.
Returns:
The resulting reference.

getSizeWhenCopied

public abstract int getSizeWhenCopied(ObjectReference object)
Return the size required to copy an object

Parameters:
object - The object whose size is to be queried
Returns:
The size required to copy obj

getAlignWhenCopied

public abstract int getAlignWhenCopied(ObjectReference object)
Return the alignment requirement for a copy of this object

Parameters:
object - The object whose size is to be queried
Returns:
The alignment required for a copy of obj

getAlignOffsetWhenCopied

public abstract int getAlignOffsetWhenCopied(ObjectReference object)
Return the alignment offset requirements for a copy of this object

Parameters:
object - The object whose size is to be queried
Returns:
The alignment offset required for a copy of obj

getCurrentSize

public abstract int getCurrentSize(ObjectReference object)
Return the size used by an object

Parameters:
object - The object whose size is to be queried
Returns:
The size of obj

getNextObject

public abstract ObjectReference getNextObject(ObjectReference object)
Return the next object in the heap under contiguous allocation


getObjectFromStartAddress

public abstract ObjectReference getObjectFromStartAddress(Address start)
Return an object reference from knowledge of the low order word


getObjectEndAddress

public abstract Address getObjectEndAddress(ObjectReference object)
Gets a pointer to the address just past the end of the object.

Parameters:
object - The objecty.

getTypeDescriptor

public abstract byte[] getTypeDescriptor(ObjectReference ref)
Get the type descriptor for an object.

Parameters:
ref - address of the object
Returns:
byte array with the type descriptor

isArray

public abstract boolean isArray(ObjectReference object)
Is the passed object an array?

Parameters:
object - address of the object

isPrimitiveArray

public abstract boolean isPrimitiveArray(ObjectReference object)
Is the passed object a primitive array?

Parameters:
object - address of the object

getArrayLength

public abstract int getArrayLength(ObjectReference object)
Get the length of an array object.

Parameters:
object - address of the object
Returns:
The array length, in elements

attemptAvailableBits

public abstract boolean attemptAvailableBits(ObjectReference object,
                                             Word oldVal,
                                             Word newVal)
Attempts to set the bits available for memory manager use in an object. The attempt will only be successful if the current value of the bits matches oldVal. The comparison with the current value and setting are atomic with respect to other allocators.

Parameters:
object - the address of the object
oldVal - the required current value of the bits
newVal - the desired new value of the bits
Returns:
true if the bits were set, false otherwise

prepareAvailableBits

public abstract Word prepareAvailableBits(ObjectReference object)
Gets the value of bits available for memory manager use in an object, in preparation for setting those bits.

Parameters:
object - the address of the object
Returns:
the value of the bits

writeAvailableByte

public abstract void writeAvailableByte(ObjectReference object,
                                        byte val)
Sets the byte available for memory manager use in an object.

Parameters:
object - the address of the object
val - the new value of the byte

readAvailableByte

public abstract byte readAvailableByte(ObjectReference object)
Read the byte available for memory manager use in an object.

Parameters:
object - the address of the object
Returns:
the value of the byte

writeAvailableBitsWord

public abstract void writeAvailableBitsWord(ObjectReference object,
                                            Word val)
Sets the bits available for memory manager use in an object.

Parameters:
object - the address of the object
val - the new value of the bits

readAvailableBitsWord

public abstract Word readAvailableBitsWord(ObjectReference object)
Read the bits available for memory manager use in an object.

Parameters:
object - the address of the object
Returns:
the value of the bits

GC_HEADER_OFFSET

public abstract Offset GC_HEADER_OFFSET()
Gets the offset of the memory management header from the object reference address. XXX The object model / memory manager interface should be improved so that the memory manager does not need to know this.

Returns:
the offset, relative the object reference address

objectStartRef

public abstract Address objectStartRef(ObjectReference object)
Returns the lowest address of the storage associated with an object.

Parameters:
object - the reference address of the object
Returns:
the lowest address of the object

refToAddress

public abstract Address refToAddress(ObjectReference object)
Returns an address guaranteed to be inside the storage assocatied with and object.

Parameters:
object - the reference address of the object
Returns:
an address inside the object

isAcyclic

public abstract boolean isAcyclic(ObjectReference typeRef)
Checks if a reference of the given type in another object is inherently acyclic. The type is given as a TIB.

Returns:
true if a reference of the type is inherently acyclic

dumpObject

public abstract void dumpObject(ObjectReference object)
Dump debugging information for an object.

Parameters:
object - The object whose information is to be dumped

getArrayBaseOffset

protected abstract Offset getArrayBaseOffset()
Returns:
The offset from array reference to element zero

arrayBaseOffsetTrapdoor

static Offset arrayBaseOffsetTrapdoor(ObjectModel o)