org.jikesrvm.mm.mminterface
Class AlignmentEncoding

java.lang.Object
  extended by org.jikesrvm.mm.mminterface.AlignmentEncoding

public class AlignmentEncoding
extends Object

Support for encoding a small amount of metadata in the alignment of a TIB. We choose the alignment of the TIB so that the pointer looks like

     31      24      16      8       0
     +-------+-------+-------+-------+
     xxxxxxxxxxxxxxxxxxxxxxxxxxxxfff00
 
where the natural alignment of the object is preserved (the low-order bits are zero), and the next least significant n bits contain the encoded metadata.

With the cooperation of MemoryManager, the idea is that we allocate 2^n additional words of memory, then offset the object within the allocated region so that the value of fff is encoded.

The current implementation specifically encodes the TIB pointer, because this is the only pointer field where this technique can give a speedup that makes it worthwhile.


Field Summary
static int ALIGN_CODE_NONE
           
private static int ALIGNMENT_INCREMENT
          How far do we need to shift the object to increment the encoded field by 1
private static int FIELD_SHIFT
          First bit of the encoded field
(package private) static int FIELD_WIDTH
          Bits of metadata that we encode
private static int MAX_ALIGN_WORDS
          Maximum distance (in words) that we shift an object
private static int TIB_ALIGN_MASK
          Bit-mask to select out the encoded field
private static boolean VERBOSE
           
 
Constructor Summary
AlignmentEncoding()
           
 
Method Summary
static Address adjustRegion(int alignCode, Address region)
          Adjust a region address so that the object pointer of an object that starts at this address will be aligned so as to encode the specified value.
(package private) static void assertSanity(int alignCode)
          Assert that a prospective encoded value is sane
static int extractTibCode(Address address)
          Extract the encoded value from a TIB pointer, represented as a raw address.
static int getTibCode(ObjectReference object)
          Extract the encoded value from an object's TIB pointer
private static int getTibCodeForRegion(Address region)
           
static int padding(int alignCode)
          Number of padding bytes required.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALIGN_CODE_NONE

public static final int ALIGN_CODE_NONE
See Also:
Constant Field Values

FIELD_WIDTH

static final int FIELD_WIDTH
Bits of metadata that we encode

See Also:
Constant Field Values

MAX_ALIGN_WORDS

private static final int MAX_ALIGN_WORDS
Maximum distance (in words) that we shift an object

See Also:
Constant Field Values

FIELD_SHIFT

private static final int FIELD_SHIFT
First bit of the encoded field

See Also:
Constant Field Values

ALIGNMENT_INCREMENT

private static final int ALIGNMENT_INCREMENT
How far do we need to shift the object to increment the encoded field by 1

See Also:
Constant Field Values

TIB_ALIGN_MASK

private static final int TIB_ALIGN_MASK
Bit-mask to select out the encoded field

See Also:
Constant Field Values

VERBOSE

private static final boolean VERBOSE
See Also:
Constant Field Values
Constructor Detail

AlignmentEncoding

public AlignmentEncoding()
Method Detail

assertSanity

static void assertSanity(int alignCode)
Assert that a prospective encoded value is sane

Parameters:
alignCode - Prospective encoded value

padding

public static int padding(int alignCode)
Number of padding bytes required.

Parameters:
alignCode - Prospective encoded value.
Returns:
the number of padding bytes required

adjustRegion

public static Address adjustRegion(int alignCode,
                                   Address region)
Adjust a region address so that the object pointer of an object that starts at this address will be aligned so as to encode the specified value.

Parameters:
alignCode - Value to encode
region - The initial region
Returns:
the aligned address

getTibCodeForRegion

private static int getTibCodeForRegion(Address region)

extractTibCode

public static int extractTibCode(Address address)
Extract the encoded value from a TIB pointer, represented as a raw address.

Parameters:
address -
Returns:
the encoded value from a TIB pointer

getTibCode

public static int getTibCode(ObjectReference object)
Extract the encoded value from an object's TIB pointer

Parameters:
object -
Returns:
the encoded value from a TIB pointer