org.jikesrvm.mm.mmtk
Class ObjectModel

java.lang.Object
  extended by org.mmtk.vm.ObjectModel
      extended by org.jikesrvm.mm.mmtk.ObjectModel
All Implemented Interfaces:
Constants, HeapLayoutConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public final class ObjectModel
extends ObjectModel
implements Constants, Constants


Field Summary
 
Fields inherited from interface org.mmtk.utility.Constants
ALIGNMENT_VALUE, ARRAY_ELEMENT, BITS_IN_ADDRESS, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_INT, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_INT, BYTES_IN_KBYTE, BYTES_IN_MBYTE, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, CARD_MASK, CARD_META_PAGES_PER_REGION, INSTANCE_FIELD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_INT, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_ADDRESS_SPACE, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_INT, LOG_BYTES_IN_KBYTE, LOG_BYTES_IN_MBYTE, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD, LOG_CARD_BYTES, LOG_CARD_GRAIN, LOG_CARD_META_BYTES, LOG_CARD_META_PAGES, LOG_CARD_META_SIZE, LOG_CARD_UNITS, LOG_MIN_ALIGNMENT, MAX_ALIGNMENT, MAX_BYTES_PADDING, MAX_INT, MIN_ALIGNMENT, MIN_INT, SUPPORT_CARD_SCANNING
 
Fields inherited from interface org.jikesrvm.Constants
NOT_REACHED, REFLECTION_FPRS_BITS, REFLECTION_FPRS_MASK, REFLECTION_GPRS_BITS, REFLECTION_GPRS_MASK
 
Fields inherited from interface org.jikesrvm.objectmodel.ThinLockConstants
TL_DEDICATED_U16_OFFSET, TL_DEDICATED_U16_SHIFT, TL_LOCK_COUNT_MASK, TL_LOCK_COUNT_SHIFT, TL_LOCK_COUNT_UNIT, TL_LOCK_ID_MASK, TL_LOCK_ID_SHIFT, TL_NUM_BITS_RC, TL_NUM_BITS_STAT, TL_NUM_BITS_TID, TL_STAT_BIASABLE, TL_STAT_FAT, TL_STAT_MASK, TL_STAT_SHIFT, TL_STAT_THIN, TL_THREAD_ID_MASK, TL_THREAD_ID_SHIFT, TL_UNLOCK_MASK
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_BOOLEAN, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_LONG, BITS_IN_OFFSET, BYTES_IN_BOOLEAN, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_LONG, BYTES_IN_OFFSET, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Constructor Summary
ObjectModel()
           
 
Method Summary
 boolean attemptAvailableBits(ObjectReference object, Word oldVal, Word newVal)
          Attempts to set the bits available for memory manager use in an object.
 ObjectReference copy(ObjectReference from, int allocator)
          Copy an object using a plan's allocCopy to get space and install the forwarding pointer.
private  ObjectReference copyArray(ObjectReference from, TIB tib, RVMArray type, int allocator)
           
private  ObjectReference copyScalar(ObjectReference from, TIB tib, RVMClass type, int allocator)
           
 Address copyTo(ObjectReference from, ObjectReference to, Address region)
          Copy an object to be pointer to by the to address.
 void dumpObject(ObjectReference object)
          Dump debugging information for an object.
 Offset GC_HEADER_OFFSET()
          Gets the offset of the memory management header from the object reference address.
 int getAlignOffsetWhenCopied(ObjectReference object)
          Return the alignment offset requirements for a copy of this object
 int getAlignWhenCopied(ObjectReference object)
          Return the alignment requirement for a copy of this object
protected  Offset getArrayBaseOffset()
           
 int getArrayLength(ObjectReference object)
          Get the length of an array object.
 int getCurrentSize(ObjectReference object)
          Return the size used by an object
 ObjectReference getNextObject(ObjectReference object)
          Return the next object in the heap under contiguous allocation
 Address getObjectEndAddress(ObjectReference object)
          Gets a pointer to the address just past the end of the object.
 ObjectReference getObjectFromStartAddress(Address start)
          Return an object reference from knowledge of the low order word
(package private) static int getObjectSize(ObjectReference object)
          Return the size of a given object, in bytes
 ObjectReference getReferenceWhenCopiedTo(ObjectReference from, Address to)
          Return the reference that an object will be referred to after it is copied to the specified region.
 int getSizeWhenCopied(ObjectReference object)
          Return the size required to copy an object
 byte[] getTypeDescriptor(ObjectReference ref)
          Get the type descriptor for an object.
 boolean isAcyclic(ObjectReference typeRef)
          Checks if a reference of the given type in another object is inherently acyclic.
 boolean isArray(ObjectReference object)
          Is the passed object an array?
 boolean isPrimitiveArray(ObjectReference object)
          Is the passed object a primitive array?
 Address objectStartRef(ObjectReference object)
          Returns the lowest address of the storage associated with an object.
 Word prepareAvailableBits(ObjectReference object)
          Gets the value of bits available for memory manager use in an object, in preparation for setting those bits.
 Word readAvailableBitsWord(ObjectReference object)
          Read the bits available for memory manager use in an object.
 byte readAvailableByte(ObjectReference object)
          Read the byte available for memory manager use in an object.
 Address refToAddress(ObjectReference object)
          Returns an address guaranteed to be inside the storage assocatied with and object.
 void setAvailableBit(ObjectReference object, int idx, boolean flag)
          Sets a bit available for memory manager use in an object.
 boolean testAvailableBit(ObjectReference object, int idx)
          Tests a bit available for memory manager use in an object.
 void writeAvailableBitsWord(ObjectReference object, Word val)
          Sets the bits available for memory manager use in an object.
 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

getArrayBaseOffset

protected Offset getArrayBaseOffset()
Specified by:
getArrayBaseOffset in class ObjectModel
Returns:
The offset from array reference to element zero

copy

public ObjectReference copy(ObjectReference from,
                            int allocator)
Description copied from class: ObjectModel
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.

Specified by:
copy in class ObjectModel
Parameters:
from - the address of the object to be copied
allocator - The allocator to use.
Returns:
the address of the new object

copyScalar

private ObjectReference copyScalar(ObjectReference from,
                                   TIB tib,
                                   RVMClass type,
                                   int allocator)

copyArray

private ObjectReference copyArray(ObjectReference from,
                                  TIB tib,
                                  RVMArray type,
                                  int allocator)

getObjectSize

static int getObjectSize(ObjectReference object)
Return the size of a given object, in bytes

Parameters:
object - The object whose size is being queried
Returns:
The size (in bytes) of the given object.

copyTo

public Address copyTo(ObjectReference from,
                      ObjectReference to,
                      Address region)
Description copied from class: ObjectModel
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.

Specified by:
copyTo in class ObjectModel
Parameters:
region - The start (or an address less than) the region that was reserved for this object.
from - the address of the object to be copied
to - The target location.
Returns:
Address The address past the end of the copied object

getReferenceWhenCopiedTo

public ObjectReference getReferenceWhenCopiedTo(ObjectReference from,
                                                Address to)
Description copied from class: ObjectModel
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.

Specified by:
getReferenceWhenCopiedTo in class ObjectModel
Parameters:
from - The object to be copied.
to - The region to be copied to.
Returns:
The resulting reference.

getObjectEndAddress

public Address getObjectEndAddress(ObjectReference object)
Description copied from class: ObjectModel
Gets a pointer to the address just past the end of the object.

Specified by:
getObjectEndAddress in class ObjectModel
Parameters:
object - The objecty.

getSizeWhenCopied

public int getSizeWhenCopied(ObjectReference object)
Description copied from class: ObjectModel
Return the size required to copy an object

Specified by:
getSizeWhenCopied in class ObjectModel
Parameters:
object - The object whose size is to be queried
Returns:
The size required to copy obj

getAlignWhenCopied

public int getAlignWhenCopied(ObjectReference object)
Description copied from class: ObjectModel
Return the alignment requirement for a copy of this object

Specified by:
getAlignWhenCopied in class ObjectModel
Parameters:
object - The object whose size is to be queried
Returns:
The alignment required for a copy of obj

getAlignOffsetWhenCopied

public int getAlignOffsetWhenCopied(ObjectReference object)
Description copied from class: ObjectModel
Return the alignment offset requirements for a copy of this object

Specified by:
getAlignOffsetWhenCopied in class ObjectModel
Parameters:
object - The object whose size is to be queried
Returns:
The alignment offset required for a copy of obj

getCurrentSize

public int getCurrentSize(ObjectReference object)
Description copied from class: ObjectModel
Return the size used by an object

Specified by:
getCurrentSize in class ObjectModel
Parameters:
object - The object whose size is to be queried
Returns:
The size of obj

getNextObject

public ObjectReference getNextObject(ObjectReference object)
Description copied from class: ObjectModel
Return the next object in the heap under contiguous allocation

Specified by:
getNextObject in class ObjectModel

getObjectFromStartAddress

public ObjectReference getObjectFromStartAddress(Address start)
Description copied from class: ObjectModel
Return an object reference from knowledge of the low order word

Specified by:
getObjectFromStartAddress in class ObjectModel

getTypeDescriptor

public byte[] getTypeDescriptor(ObjectReference ref)
Description copied from class: ObjectModel
Get the type descriptor for an object.

Specified by:
getTypeDescriptor in class ObjectModel
Parameters:
ref - address of the object
Returns:
byte array with the type descriptor

getArrayLength

public int getArrayLength(ObjectReference object)
Description copied from class: ObjectModel
Get the length of an array object.

Specified by:
getArrayLength in class ObjectModel
Parameters:
object - address of the object
Returns:
The array length, in elements

isArray

public boolean isArray(ObjectReference object)
Description copied from class: ObjectModel
Is the passed object an array?

Specified by:
isArray in class ObjectModel
Parameters:
object - address of the object

isPrimitiveArray

public boolean isPrimitiveArray(ObjectReference object)
Description copied from class: ObjectModel
Is the passed object a primitive array?

Specified by:
isPrimitiveArray in class ObjectModel
Parameters:
object - address of the object

testAvailableBit

public boolean testAvailableBit(ObjectReference object,
                                int idx)
Tests a bit available for memory manager use in an object.

Parameters:
object - the address of the object
idx - the index of the bit

setAvailableBit

public void setAvailableBit(ObjectReference object,
                            int idx,
                            boolean flag)
Sets a bit available for memory manager use in an object.

Parameters:
object - the address of the object
idx - the index of the bit
flag - true to set the bit to 1, false to set it to 0

attemptAvailableBits

public boolean attemptAvailableBits(ObjectReference object,
                                    Word oldVal,
                                    Word newVal)
Description copied from class: ObjectModel
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.

Specified by:
attemptAvailableBits in class ObjectModel
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 Word prepareAvailableBits(ObjectReference object)
Description copied from class: ObjectModel
Gets the value of bits available for memory manager use in an object, in preparation for setting those bits.

Specified by:
prepareAvailableBits in class ObjectModel
Parameters:
object - the address of the object
Returns:
the value of the bits

writeAvailableByte

public void writeAvailableByte(ObjectReference object,
                               byte val)
Description copied from class: ObjectModel
Sets the byte available for memory manager use in an object.

Specified by:
writeAvailableByte in class ObjectModel
Parameters:
object - the address of the object
val - the new value of the byte

readAvailableByte

public byte readAvailableByte(ObjectReference object)
Description copied from class: ObjectModel
Read the byte available for memory manager use in an object.

Specified by:
readAvailableByte in class ObjectModel
Parameters:
object - the address of the object
Returns:
the value of the byte

writeAvailableBitsWord

public void writeAvailableBitsWord(ObjectReference object,
                                   Word val)
Description copied from class: ObjectModel
Sets the bits available for memory manager use in an object.

Specified by:
writeAvailableBitsWord in class ObjectModel
Parameters:
object - the address of the object
val - the new value of the bits

readAvailableBitsWord

public Word readAvailableBitsWord(ObjectReference object)
Description copied from class: ObjectModel
Read the bits available for memory manager use in an object.

Specified by:
readAvailableBitsWord in class ObjectModel
Parameters:
object - the address of the object
Returns:
the value of the bits

GC_HEADER_OFFSET

public Offset GC_HEADER_OFFSET()
Description copied from class: ObjectModel
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.

Specified by:
GC_HEADER_OFFSET in class ObjectModel
Returns:
the offset, relative the object reference address

objectStartRef

public Address objectStartRef(ObjectReference object)
Description copied from class: ObjectModel
Returns the lowest address of the storage associated with an object.

Specified by:
objectStartRef in class ObjectModel
Parameters:
object - the reference address of the object
Returns:
the lowest address of the object

refToAddress

public Address refToAddress(ObjectReference object)
Description copied from class: ObjectModel
Returns an address guaranteed to be inside the storage assocatied with and object.

Specified by:
refToAddress in class ObjectModel
Parameters:
object - the reference address of the object
Returns:
an address inside the object

isAcyclic

public boolean isAcyclic(ObjectReference typeRef)
Description copied from class: ObjectModel
Checks if a reference of the given type in another object is inherently acyclic. The type is given as a TIB.

Specified by:
isAcyclic in class ObjectModel
Returns:
true if a reference of the type is inherently acyclic

dumpObject

public void dumpObject(ObjectReference object)
Description copied from class: ObjectModel
Dump debugging information for an object.

Specified by:
dumpObject in class ObjectModel
Parameters:
object - The object whose information is to be dumped