org.jikesrvm.objectmodel
Class FieldLayout

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

public abstract class FieldLayout
extends Object
implements SizeConstants

This abstract class defines the interface for schemes that layout fields in an object. Not header fields, (scalar) object fields.

The field layout object encapsulates layout state.


Field Summary
private  boolean clusterReferenceFields
          Lay out reference fields in a block
protected static boolean DEBUG
          Enable debugging
private  boolean largeFieldsFirst
          Whether to lay out 8byte values first in order to avoid some holes
 
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
FieldLayout(boolean largeFieldsFirst, boolean clusterReferenceFields)
           
 
Method Summary
protected abstract  FieldLayoutContext getLayoutContext(RVMClass klass)
          Return the appropriate layout context object for the given class.
protected  void layoutField(FieldLayoutContext layout, RVMClass klass, RVMField field, int fieldSize)
          Lay out a given field.
 void layoutInstanceFields(RVMClass klass)
          This is where a class gets laid out.
protected static int log2(int x)
          Log base 2 of an integer
protected static int max(int x, int y)
          Maximum of two integers
protected  void setOffset(RVMClass klass, RVMField field, int offset)
          Update a field to set its offset within the object.
protected  void updateClass(RVMClass klass, FieldLayoutContext fieldLayout)
          Update the RVMClass with context info.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
Enable debugging

See Also:
Constant Field Values

largeFieldsFirst

private final boolean largeFieldsFirst
Whether to lay out 8byte values first in order to avoid some holes


clusterReferenceFields

private final boolean clusterReferenceFields
Lay out reference fields in a block

Constructor Detail

FieldLayout

public FieldLayout(boolean largeFieldsFirst,
                   boolean clusterReferenceFields)
Method Detail

max

protected static int max(int x,
                         int y)
Maximum of two integers


log2

protected static int log2(int x)
Log base 2 of an integer


getLayoutContext

protected abstract FieldLayoutContext getLayoutContext(RVMClass klass)
Return the appropriate layout context object for the given class.

Parameters:
klass - The class
Returns:
The layout context

layoutInstanceFields

public void layoutInstanceFields(RVMClass klass)
This is where a class gets laid out. Differences in layout strategy are largely encapsulated in the layoutContext object.

Parameters:
klass - The class to lay out.

updateClass

protected void updateClass(RVMClass klass,
                           FieldLayoutContext fieldLayout)
Update the RVMClass with context info.

Parameters:
klass -
fieldLayout -

setOffset

protected void setOffset(RVMClass klass,
                         RVMField field,
                         int offset)
Update a field to set its offset within the object.

Parameters:
klass -
field -
offset -

layoutField

protected void layoutField(FieldLayoutContext layout,
                           RVMClass klass,
                           RVMField field,
                           int fieldSize)
Lay out a given field.

Parameters:
layout - State for the layout process
klass - The class whose fields we're laying out.
field - The field we are laying out.
fieldSize - The size of the field.