public class ScanBootImage extends Object
Modifier and Type | Field and Description |
---|---|
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 |
Constructor and Description |
---|
ScanBootImage() |
Modifier and Type | Method and Description |
---|---|
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.
|
private static final boolean DEBUG
private static final boolean FILTER
private static final int LOG_CHUNK_BYTES
private static final int CHUNK_BYTES
private static final int LONGENCODING_MASK
private static final int RUN_MASK
private static final int MAX_RUN
private static final int LONGENCODING_OFFSET_BYTES
private static final int GUARD_REGION
static int roots
static int refs
private static int lastOffset
private static int oldIndex
private static int codeIndex
private static int shortRefs
private static int runRefs
private static int longRefs
private static int startRefs
public ScanBootImage()
public static void scanBootImage(TraceLocal trace)
trace
- The trace object to which the roots should be addedprivate static void processChunk(Address chunkStart, Address imageStart, Address mapStart, Address mapEnd, TraceLocal trace)
chunkStart
- The address of the first byte of encoded dataimageStart
- The address of the start of the boot imagemapStart
- The address of the start of the encoded reference mapmapEnd
- The address of the end of the encoded reference maptrace
- The TraceLocal
into which roots should
be enqueued.private static void checkReference(Address refaddr)
refaddr
- The address of the reference in question.private static boolean isAddressAligned(Offset offset)
offset
- the offset to be checkprivate static boolean isAddressAligned(Address address)
address
- the address to be checkpublic static int encodeRMap(byte[] bootImageRMap, byte[] referenceMap, int referenceMapLimit)
bootImageRMap
- space for the compressed reference map. The map
is initially empty and will be filled during execution of this method.referenceMap
- the (uncompressed) reference map for the bootimagereferenceMapLimit
- the highest index in the referenceMap that
contains a referencepublic static void encodingStats()
private static void addOffset(byte[] code, int offset)
code
- A byte array into which the value should be encodedoffset
- The offset value to be encodedprivate static int getOffset(byte[] code, int index, int lastOffset)
code
- A byte array containing the encoded valueindex
- The offset into the code array from which to
commence decodinglastOffset
- The current (last) encoded offsetprivate static Offset decodeLongEncoding(Address cursor)
Offset
cursor
- A pointer to the first byte of encoded dataOffset
private static int decodeLongEncoding(byte[] code, int index)
code
- A byte array containing the encoded valueindex
- The offset into the code array from which to
commence decodingprivate static int encodeLongEncoding(byte[] code, int index, int value)
code
- A byte array to contain the encoded valueindex
- The current offset into the code arrayvalue
- The value to be encoded