public final class ReferenceMaps extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
ReferenceMaps.MergeOperation
Kinds of merge operation when merging delta maps into table maps
|
Modifier and Type | Field and Description |
---|---|
private static int |
BITS_PER_MAP_ELEMENT
Number of bits in each map element
|
private int |
bitsPerMap
Number of bits in each map
|
(package private) short[] |
byteToBlockMap
identify which block a byte is part of
|
static byte |
JSR_INDEX_MASK |
static byte |
JSR_MASK |
private JSRInfo |
jsrInfo |
static SpinLock |
jsrLock
Serializes JSR processing
|
private int |
mapCount
Number of maps
|
private int[] |
MCSites |
static int |
NOMORE |
private byte[] |
referenceMaps |
static int |
STARTINDEX |
Constructor and Description |
---|
ReferenceMaps(BaselineCompiledMethod cm,
int[] stackHeights,
byte[] localTypes) |
Modifier and Type | Method and Description |
---|---|
private int |
addUnusualMap(UnusualMaps jsrSiteMap)
Add an UnusualMap to the array of unusual maps, expand the array
and referencemap array if necessary
|
private int |
bytesPerMap() |
void |
cleanupPointers()
This routine is used to clean out the MethodMap of structures that
were allocated from temporary storage.
|
private UnusualMaps |
combineDeltaMaps(int jsrUnusualMapid)
Merges unusual maps (occurs in nested jsr conditions) by merging each nested
delta map ( as represented by the jsrMapid of the location site) into the
jsrInfo.extraUnusualMap where the deltas are accumulated
|
private byte |
convertMapElement(byte[] curBBMap,
int offset,
int len,
byte reftype)
Convert a portion of an array word of Bytes into a bitmap of references.
|
private void |
copyBitMap(int extramapindex,
int index)
Copies a bit map into the extra unusualmap.
|
private void |
finalMergeMaps(int jsrBaseMapIndex,
UnusualMaps deltaMap)
This method will merge the jsr invoker's base map with changes
due to *all* nested jsr subroutines.
|
(package private) int |
findUnusualMap(int mapid)
Finds an unsual map with an index greater than 127.
|
int |
getNextJSRAddressIndex(Offset nextMachineCodeOffset,
NormalMethod m) |
int |
getNextJSRRefIndex(int index)
Given an offset in the jsr reference map,
return the offset where the next returnAddress can be found.
|
int |
getNextJSRReturnAddrIndex(int index)
Given an offset in the jsr returnAddress map,
return the offset where the next returnAddress can be found.
|
private int |
getNextMapElement() |
int |
getNextRefIndex(int index,
int siteindex) |
int |
getStackDepth(int mapid) |
boolean |
isLocalRefType(RVMMethod method,
Offset mcoff,
int lidx)
Query if a local variable has a reference type value
|
int |
locateGCPoint(Offset machCodeOffset,
RVMMethod method)
Given a machine code instruction offset, return an index to
identify the stack map closest to the offset ( but not beyond).
|
private void |
mergeMap(int targetindex,
int deltaindex,
ReferenceMaps.MergeOperation Op)
Merges a delta map into a target map.
|
void |
recordingComplete()
Called when all the recording for this map is complete.
|
void |
recordJSRSubroutineMap(int byteindex,
byte[] currReferenceMap,
int BBLastPtr,
int returnAddrIndex,
boolean replacemap)
Record a map for a point within a JSR Subroutine.
|
void |
recordStkMap(int byteindex,
byte[] byteMap,
int BBLastPtr,
boolean replacemap)
Given the information about a GC point, record the information in the proper tables.
|
private int |
scanByte(int bitnum,
int bytenum,
int toscan,
byte[] map)
Scans for a reference in a byte.
|
(package private) int |
scanByteArray(byte[] byteMap,
int BBLastPtr,
byte refType,
int mapslot,
boolean skipOneBit)
Scans the byte array to look for the type of information that was requested.
|
private int |
scanForNextRef(int bitnum,
int wordnum,
int remaining,
byte[] map)
Scans the map for the next reference.
|
int |
setupJSRSubroutineMap(int mapid)
Setup a map within a JSR Subroutine.
|
void |
showAMap(int MCSiteIndex)
Show the basic information for a single map.
|
void |
showInfo()
Shows the basic information for each of the maps.
|
void |
showOffsets()
Show the offsets for all the maps.
|
int |
showReferenceMapStatistics(RVMMethod method) |
int |
size() |
void |
startNewMaps(int gcPointCount,
int jsrCount,
int parameterWords) |
void |
translateByte2Machine(int[] b2m)
After code is generated, translate the bytecode indices
recorded in MCSites array into real machine code offsets.
|
private void |
unusualMapcopy(UnusualMaps from)
Makes a deep copy of
from into jsrInfo.extraUnusualMap |
public static final byte JSR_MASK
public static final byte JSR_INDEX_MASK
public static final int STARTINDEX
public static final int NOMORE
private static final int BITS_PER_MAP_ELEMENT
private byte[] referenceMaps
private int[] MCSites
private final int bitsPerMap
private int mapCount
final short[] byteToBlockMap
ReferenceMaps(BaselineCompiledMethod cm, int[] stackHeights, byte[] localTypes)
private int bytesPerMap()
public int locateGCPoint(Offset machCodeOffset, RVMMethod method)
Usage note: "machCodeOffset" must point to the instruction *following* the actual instruction whose stack map is sought. This allows us to properly handle the case where the only address we have to work with is a return address (i.e. from a stackframe) or an exception address (i.e. from a null pointer dereference, array bounds check, or divide by zero) on a machine architecture with variable length instructions. In such situations we'd have no idea how far to back up the instruction pointer to point to the "call site" or "exception site".
If the located site is within the scope of a jsr subroutine the index value returned is a negative number.
machCodeOffset
- offset into machine code (see above for constraints)method
- the method that contains the gc pointpublic int getNextRefIndex(int index, int siteindex)
index
- offset in the reference stack frame,siteindex
- index that indicates the callsite (siteindex),NOMORE
when no more pointers can be foundpublic int getNextJSRRefIndex(int index)
NOTE: There is only one JSR map for the entire method because it has to be constructed at GC time and would normally require additional storage.
To avoid this, the space for one map is pre-allocated and the map is built in that space. When multiple threads exist and if GC runs in multiple threads concurrently, then the MethodMap must be locked when a JSR map is being scanned. This should be a low probability event.
index
- offset in the JSR reference map,NOMORE
when no more pointers can be foundpublic int getNextJSRReturnAddrIndex(int index)
NOTE: there is only one jsr returnAddress map for the entire method because it has to be be constructed a GC time and would normally require additional storage. To avoid this, the space for one map is pre-allocated and the map is built in that space. When multiple threads exist and if GC runs in multiple threads concurrently, then the MethodMap must be locked when a jsr map is being scanned. This should be a low probability event.
NOTE: return addresses are handled separately from references because they point inside an object ( internal pointers)
index
- offset in the JSR returnAddress map,NOMORE
when no more pointers can be foundpublic int getStackDepth(int mapid)
public int size()
public void startNewMaps(int gcPointCount, int jsrCount, int parameterWords)
public void recordStkMap(int byteindex, byte[] byteMap, int BBLastPtr, boolean replacemap)
byteindex
- the index in the bytecode of this sitebyteMap
- a byte array that describes the contents of the local variables and the java stackBBLastPtr
- the last offset of a byte that contains information about the mapreplacemap
- whether this map is a replacement for a currently
existing mappublic void recordJSRSubroutineMap(int byteindex, byte[] currReferenceMap, int BBLastPtr, int returnAddrIndex, boolean replacemap)
byteindex
- index into the byte code array of the point for the mapcurrReferenceMap
- map of references and return addresses that were set
within the JSR SubroutineBBLastPtr
- map runs from -1 to BBLastPtr inclusivelyreturnAddrIndex
- Index in the stack where the return address
for the jsr routine (in which this gcpoint is located)
can be foundreplacemap
- false
if this is the first time this map point has been
recorded.private int addUnusualMap(UnusualMaps jsrSiteMap)
jsrSiteMap
- unusualMap to be added to arraypublic int setupJSRSubroutineMap(int mapid)
locateGCPoint(org.vmmagic.unboxed.Offset, org.jikesrvm.classloader.RVMMethod)
. This routine
searches the map tables and uses its stack frameAddress input to build
reference and returnAddress maps. The caller uses the getNext...
routines to scan these maps for offsets in the frame of the
related references.Steps for this routine:
mapid
- Index of map of instruction where map is required
( this value was returned by locateGCpoint)public int getNextJSRAddressIndex(Offset nextMachineCodeOffset, NormalMethod m)
public void recordingComplete()
public void translateByte2Machine(int[] b2m)
b2m
- map of byte code index to machine code offsetsprivate byte convertMapElement(byte[] curBBMap, int offset, int len, byte reftype)
curBBMap
- a byte array that describes the contents of the local variables and the java stackoffset
- a starting offset in the arraylen
- length of the scan, max is BITS_PER_MAP_ELEMENT
reftype
- the type of byte to scan forprivate int getNextMapElement()
private int scanForNextRef(int bitnum, int wordnum, int remaining, byte[] map)
bitnum
- starting bitnumber in a map (inclusive)wordnum
- index of the corresponding byte,remaining
- remaining number of bits in the map,map
- map to searchprivate int scanByte(int bitnum, int bytenum, int toscan, byte[] map)
bitnum
- bitnumber in the mapbytenum
- index of the corresponding map bytetoscan
- the remaining number of bits in the byte,map
- the mapint scanByteArray(byte[] byteMap, int BBLastPtr, byte refType, int mapslot, boolean skipOneBit)
byteMap
- bytearray where each byte describes the corresponding word on a stackBBLastPtr
- length of the byte arrayrefType
- type of information that is to be scannedmapslot
- slot where map should be stored, 0 for next free slotskipOneBit
- should a bit in the bitarray be skipped? Necessary for setRef and
setNonRef maps so so they are properly merged with jsr base maps.private void unusualMapcopy(UnusualMaps from)
from
into jsrInfo.extraUnusualMap
from
- the map to copy fromprivate void copyBitMap(int extramapindex, int index)
extramapindex
- the index of the map in the jsrInfo.extraUnusualMap ie the "to" mapindex
- he index of the map to copy ie the "from" mapprivate UnusualMaps combineDeltaMaps(int jsrUnusualMapid)
jsrUnusualMapid
- the delta map's idprivate void mergeMap(int targetindex, int deltaindex, ReferenceMaps.MergeOperation Op)
targetindex
- the delta map's index in the reference map tabledeltaindex
- the target map's index in the reference map tbaleOp
- the merge operation to useprivate void finalMergeMaps(int jsrBaseMapIndex, UnusualMaps deltaMap)
The nested jsr subroutine maps were merged into a single delta map prior to the calling of this method. We therefore know that the base map can never be due to a subroutine (since all subroutines have been merged), and therefore that there are no return address maps due to the invoker (since return addresses are only due to the subroutine maps).
jsrBaseMapIndex
- The map index for the invokerdeltaMap
- The map for the invoked subroutine/s (all nested
subroutine maps are guaranteed to have been combined prior to
calling this)public void cleanupPointers()
int findUnusualMap(int mapid)
mapid
- the map's idpublic void showInfo()
public void showAMap(int MCSiteIndex)
MCSiteIndex
- index of the machine code sitepublic void showOffsets()
public int showReferenceMapStatistics(RVMMethod method)
public boolean isLocalRefType(RVMMethod method, Offset mcoff, int lidx)
method
- The method we're asking about.mcoff
- The machine code offset of the instruction *following* the
actual instruction.lidx
- the local indextrue
, if it is a reference type. false
, otherwise