org.jikesrvm.mm.mmtk
Class ScanBootImage

java.lang.Object
  extended by org.jikesrvm.mm.mmtk.ScanBootImage
All Implemented Interfaces:
Constants

public class ScanBootImage
extends Object
implements Constants

Scan the boot image for references using the boot image reference map


Field Summary
private static int CHUNK_BYTES
           
private static int codeIndex
           
private static boolean DEBUG
           
private static boolean FILTER
           
private static int GUARD_REGION
           
private static int lastOffset
           
private static int LOG_CHUNK_BYTES
           
private static int LONGENCODING_MASK
           
private static int LONGENCODING_OFFSET_BYTES
           
private static int longRefs
           
private static int MAX_RUN
           
private static int oldIndex
           
(package private) static int refs
           
(package private) static int roots
           
private static int RUN_MASK
           
private static int runRefs
           
private static int shortRefs
           
private static int startRefs
           
 
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
 
Constructor Summary
ScanBootImage()
           
 
Method Summary
private static void addOffset(byte[] code, int offset)
          Encode a given offset (distance from the start of the boot image) into the code array.
private static void checkReference(Address refaddr)
          Check that a reference encountered during scanning is valid.
private static Offset decodeLongEncoding(Address cursor)
          Decode a 4-byte encoding, taking a pointer to the first byte of the encoding, and returning the encoded value as an Offset
private static int decodeLongEncoding(byte[] code, int index)
          Decode a 4-byte encoding, taking a byte array and an index into it and returning the encoded value as an integer
private static int encodeLongEncoding(byte[] code, int index, int value)
          Encode a 4-byte encoding, taking a byte array, the current index into it, and the value to be encoded.
static int encodeRMap(byte[] bootImageRMap, byte[] referenceMap, int referenceMapLimit)
          Take a bytemap encoding of all references in the boot image, and produce an encoded byte array.
static void encodingStats()
          Print some basic statistics about the encoded references, for debugging purposes.
private static int getOffset(byte[] code, int index, int lastOffset)
          Decode an encoded offset given the coded byte array, and index into it, and the current (last) offset.
private static boolean isAddressAligned(Address address)
          Return true if the given address is address-aligned
private static boolean isAddressAligned(Offset offset)
          Return true if the given offset is address-aligned
private static void processChunk(Address chunkStart, Address imageStart, Address mapStart, Address mapEnd, TraceLocal trace)
          Process a chunk of encoded reference data, enqueuing each reference (optionally filtering them on whether they point outside the boot image).
static void scanBootImage(TraceLocal trace)
          Scan the boot image for object references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

FILTER

private static final boolean FILTER
See Also:
Constant Field Values

LOG_CHUNK_BYTES

private static final int LOG_CHUNK_BYTES
See Also:
Constant Field Values

CHUNK_BYTES

private static final int CHUNK_BYTES
See Also:
Constant Field Values

LONGENCODING_MASK

private static final int LONGENCODING_MASK
See Also:
Constant Field Values

RUN_MASK

private static final int RUN_MASK
See Also:
Constant Field Values

MAX_RUN

private static final int MAX_RUN
See Also:
Constant Field Values

LONGENCODING_OFFSET_BYTES

private static final int LONGENCODING_OFFSET_BYTES
See Also:
Constant Field Values

GUARD_REGION

private static final int GUARD_REGION
See Also:
Constant Field Values

roots

static int roots

refs

static int refs

lastOffset

private static int lastOffset

oldIndex

private static int oldIndex

codeIndex

private static int codeIndex

shortRefs

private static int shortRefs

runRefs

private static int runRefs

longRefs

private static int longRefs

startRefs

private static int startRefs
Constructor Detail

ScanBootImage

public ScanBootImage()
Method Detail

scanBootImage

public static void scanBootImage(TraceLocal trace)
Scan the boot image for object references. Executed by all GC threads in parallel, with each doing a portion of the boot image.

Parameters:
trace - The trace object to which the roots should be added

processChunk

private static void processChunk(Address chunkStart,
                                 Address imageStart,
                                 Address mapStart,
                                 Address mapEnd,
                                 TraceLocal trace)
Process a chunk of encoded reference data, enqueuing each reference (optionally filtering them on whether they point outside the boot image).

Parameters:
chunkStart - The address of the first byte of encoded data
imageStart - The address of the start of the boot image
mapStart - The address of the start of the encoded reference map
mapEnd - The address of the end of the encoded reference map
trace - The TraceLocal into which roots should be enqueued.

checkReference

private static void checkReference(Address refaddr)
Check that a reference encountered during scanning is valid. If the reference is invalid, dump stack and die.

Parameters:
refaddr - The address of the reference in question.

isAddressAligned

private static boolean isAddressAligned(Offset offset)
Return true if the given offset is address-aligned

Parameters:
offset - the offset to be check
Returns:
true if the offset is address aligned.

isAddressAligned

private static boolean isAddressAligned(Address address)
Return true if the given address is address-aligned

Parameters:
address - the address to be check
Returns:
true if the address is address aligned.

encodeRMap

public static int encodeRMap(byte[] bootImageRMap,
                             byte[] referenceMap,
                             int referenceMapLimit)
Take a bytemap encoding of all references in the boot image, and produce an encoded byte array. Return the total length of the encoding.


encodingStats

public static void encodingStats()
Print some basic statistics about the encoded references, for debugging purposes.


addOffset

private static void addOffset(byte[] code,
                              int offset)
Encode a given offset (distance from the start of the boot image) into the code array.

Parameters:
code - A byte array into which the value should be encoded
offset - The offset value to be encoded

getOffset

private static int getOffset(byte[] code,
                             int index,
                             int lastOffset)
Decode an encoded offset given the coded byte array, and index into it, and the current (last) offset.

Parameters:
code - A byte array containing the encoded value
index - The offset into the code array from which to commence decoding
lastOffset - The current (last) encoded offset
Returns:
The next offset, which is either explicitly encoded in the byte array or inferred from an encoded delta and the last offset.

decodeLongEncoding

private static Offset decodeLongEncoding(Address cursor)
Decode a 4-byte encoding, taking a pointer to the first byte of the encoding, and returning the encoded value as an Offset

Parameters:
cursor - A pointer to the first byte of encoded data
Returns:
The encoded value as an Offset

decodeLongEncoding

private static int decodeLongEncoding(byte[] code,
                                      int index)
Decode a 4-byte encoding, taking a byte array and an index into it and returning the encoded value as an integer

Parameters:
code - A byte array containing the encoded value
index - The offset into the code array from which to commence decoding
Returns:
The encoded value as an integer

encodeLongEncoding

private static int encodeLongEncoding(byte[] code,
                                      int index,
                                      int value)
Encode a 4-byte encoding, taking a byte array, the current index into it, and the value to be encoded.

Parameters:
code - A byte array to contain the encoded value
index - The current offset into the code array
value - The value to be encoded
Returns:
The updated index into the code array