org.jikesrvm.objectmodel
Class FieldLayoutContext

java.lang.Object
  extended by org.jikesrvm.objectmodel.FieldLayoutContext
All Implemented Interfaces:
SizeConstants
Direct Known Subclasses:
FieldLayoutPacked.LayoutContext, FieldLayoutUnpacked.LayoutContext

public abstract class FieldLayoutContext
extends Object
implements SizeConstants

State for the field layout engine. Subtypes of this are closely tied to field layout schemes, and are generally defined in same.

A FieldLayoutContext deals in an abstract offset space, where there is no header, and fields are laid out relative to 0.

This abstract superclass looks after the total object size and alignment.


Field Summary
private  byte alignment
          Alignment requirements.
protected static int OBJECT_SIZE_ALIGN
           
private  int objectSize
          The size of the current object as laid out
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Constructor Summary
protected FieldLayoutContext(byte alignment)
          Constructor for a (the) top-level object.
protected FieldLayoutContext(byte alignment, FieldLayoutContext superLayout)
          Constructor for an object with a superclass.
 
Method Summary
protected  void adjustAlignment(int fieldSize)
          Adjust alignment to the next highest value.
protected  void ensureObjectSize(int size)
          Adjust the size of the object if necessary to accommodate a field.
(package private)  int getAlignment()
           
protected  int getObjectSize()
           
(package private) abstract  int nextOffset(int size, boolean isReference)
          Return the offset of a new field of the given size
protected  void setObjectSize(int size)
          Set the current size of the object (excluding header)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_SIZE_ALIGN

protected static final int OBJECT_SIZE_ALIGN
See Also:
Constant Field Values

alignment

private byte alignment
Alignment requirements.


objectSize

private int objectSize
The size of the current object as laid out

Constructor Detail

FieldLayoutContext

protected FieldLayoutContext(byte alignment)
Constructor for a (the) top-level object.

Parameters:
alignment -

FieldLayoutContext

protected FieldLayoutContext(byte alignment,
                             FieldLayoutContext superLayout)
Constructor for an object with a superclass. The superclass is used to initialize the layout.

Parameters:
alignment -
superLayout -
Method Detail

nextOffset

abstract int nextOffset(int size,
                        boolean isReference)
Return the offset of a new field of the given size


adjustAlignment

protected void adjustAlignment(int fieldSize)
Adjust alignment to the next highest value. In Java, the only 2 possibilities are int-aligned or long-aligned.

Parameters:
fieldSize -

getAlignment

int getAlignment()
Returns:
the current alignment value

getObjectSize

protected int getObjectSize()
Returns:
The current size of the object (excluding header)

setObjectSize

protected void setObjectSize(int size)
Set the current size of the object (excluding header)


ensureObjectSize

protected void ensureObjectSize(int size)
Adjust the size of the object if necessary to accommodate a field.

Parameters:
size - The size occupied by data fields in the object.