org.jikesrvm.compilers.opt.runtimesupport
Class OptMachineCodeMap

java.lang.Object
  extended by org.jikesrvm.compilers.opt.runtimesupport.OptMachineCodeMap
All Implemented Interfaces:
OptConstants, Constants, HeapLayoutConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public final class OptMachineCodeMap
extends Object
implements Constants, OptConstants

A class that encapsulates mapping information about generated machine code. Since there will be an instance of this class with every OptCompiledMethod, we attempt to pack the data into a reasonably small number of bits.

The supported functions are:

Note: This file contains two types of methods


Field Summary
private static int BCI_MASK
           
private static int BCI_SHIFT
           
private static int BIG_BCI_IDX_ADJ
           
private static int BIG_BCI_MASK
           
private static int BIG_BCI_SHIFT
           
private static int BIG_CALL_IDX_ADJ
           
private static int BIG_CALL_MASK
           
private static int BIG_CALL_SHIFT
           
private static int BIG_GCI_IDX_ADJ
           
private static int BIG_GCI_MASK
           
private static int BIG_GCI_SHIFT
           
private static int BIG_IEI_IDX_ADJ
           
private static int BIG_IEI_MASK
           
private static int BIG_IEI_SHIFT
           
private static int BIG_INVALID_BCI
           
private static int BIG_INVALID_GCI
           
private static int BIG_INVALID_IEI
           
private static int BIG_OFFSET_IDX_ADJ
           
private static int BIG_OFFSET_MASK
           
private static int BIG_OFFSET_SHIFT
           
private static int CALL_MASK
           
private static int CALL_SHIFT
           
private static OptMachineCodeMap emptyMachineCodeMap
          A machine code map when no information is present
private static int GCI_MASK
           
private static int GCI_SHIFT
           
private  int[] gcMaps
          array of GC maps as defined by OptGCMap
private static int HUGE_BCI_IDX_ADJ
           
private static int HUGE_BCI_MASK
           
private static int HUGE_BCI_SHIFT
           
private static int HUGE_CALL_IDX_ADJ
           
private static int HUGE_CALL_MASK
           
private static int HUGE_CALL_SHIFT
           
private static int HUGE_GCI_IDX_ADJ
           
private static int HUGE_GCI_MASK
           
private static int HUGE_GCI_SHIFT
           
private static int HUGE_IEI_IDX_ADJ
           
private static int HUGE_IEI_MASK
           
private static int HUGE_IEI_SHIFT
           
private static int HUGE_INVALID_BCI
           
private static int HUGE_INVALID_GCI
           
private static int HUGE_INVALID_IEI
           
private static int HUGE_OFFSET_IDX_ADJ
           
private static int HUGE_OFFSET_MASK
           
private static int HUGE_OFFSET_SHIFT
           
private static int IEI_MASK
           
private static int IEI_SHIFT
           
 int[] inlineEncoding
          encoded data as defined by OptEncodedCallSiteTree.
private static int INVALID_BCI
           
private static int INVALID_GCI
           
private static int INVALID_IEI
           
private static int IS_GUARDED_CALL
           
private static int IS_UNGUARDED_CALL
           
private  int[] MCInformation
          Hold entries as defined by the constants above.
private static int OFFSET_MASK
           
private static int OFFSET_SHIFT
           
private static int SIZEOF_BIG_ENTRY
           
private static int SIZEOF_ENTRY
           
private static int SIZEOF_HUGE_ENTRY
           
private static int START_BITS
           
private static int START_OF_BIG_ENTRY
           
private static int START_OF_ENTRY
           
private static int START_OF_HUGE_ENTRY
           
private static int totalMapSize
           
private static int totalMCSize
          Running totals for the size of machine code and maps
private static TypeReference TYPE
           
 
Fields inherited from interface org.jikesrvm.Constants
NOT_REACHED, REFLECTION_FPRS_BITS, REFLECTION_FPRS_MASK, REFLECTION_GPRS_BITS, REFLECTION_GPRS_MASK
 
Fields inherited from interface org.jikesrvm.objectmodel.ThinLockConstants
TL_DEDICATED_U16_OFFSET, TL_DEDICATED_U16_SHIFT, TL_LOCK_COUNT_MASK, TL_LOCK_COUNT_SHIFT, TL_LOCK_COUNT_UNIT, TL_LOCK_ID_MASK, TL_LOCK_ID_SHIFT, TL_NUM_BITS_RC, TL_NUM_BITS_STAT, TL_NUM_BITS_TID, TL_STAT_BIASABLE, TL_STAT_FAT, TL_STAT_MASK, TL_STAT_SHIFT, TL_STAT_THIN, TL_THREAD_ID_MASK, TL_THREAD_ID_SHIFT, TL_UNLOCK_MASK
 
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
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Fields inherited from interface org.jikesrvm.compilers.opt.driver.OptConstants
EPILOGUE_BCI, EPILOGUE_BLOCK_BCI, EXTANT_ANALYSIS_BCI, INSTRUMENTATION_BCI, MAYBE, METHOD_COUNTER_BCI, NO, OSR_PROLOGUE, PROLOGUE_BCI, PROLOGUE_BLOCK_BCI, RECTIFY_BCI, RUNTIME_SERVICES_BCI, SSA_SYNTH_BCI, SYNCHRONIZED_MONITORENTER_BCI, SYNCHRONIZED_MONITOREXIT_BCI, SYNTH_CATCH_BCI, SYNTH_LOOP_VERSIONING_BCI, UNKNOWN_BCI, YES
 
Constructor Summary
private OptMachineCodeMap()
          Private constructor for no information.
private OptMachineCodeMap(int[] _MCInformation, int[] _gcMaps, int[] _inlineEncoding)
          Private constructor, object should be created via create
 
Method Summary
(package private) static OptMachineCodeMap create(IR ir, int machineCodeSize)
          Create the map, called during compilation
 void dumpMCInformation(boolean DUMP_MAPS)
           
 int findGCMapIndex(Offset MCOffset)
          This method searches for the GC map corresponding to the passed machine code offset.
private  int findMCEntry(Offset MCOffset)
          Do a binary search of the machine code maps to find the index in MCInformation where the entry for the argument machine code offset starts.
 int gcMapInformation(int index)
          Returns the GC map information for the GC map information entry passed
private static OptMachineCodeMap generateMCInformation(GCIRMap irMap, boolean DUMP_MAPS)
          This method walks the IR map, and for each entry it creates the machine code mapping information for the entry.
private  int getBytecodeIndex(int entry)
          Returns the Bytecode index for the entry passed
 int getBytecodeIndexForMCOffset(Offset MCOffset)
          Get the bytecode index for a machine instruction offset.
private  int getCallInfo(int entry)
          Returns the call info for the entry passed.
private  int getGCMapIndex(int entry)
          Returns the GC map index for the entry passed
 int getInlineEncodingForMCOffset(Offset MCOffset)
          Return the inlining encoding index for the machine instruction offset.
private  int getInlineEncodingIndex(int entry)
          Returns the inline encoding index for the entry passed.
private  int getMCOffset(int entry)
          Returns the MCOffset for the entry passed
 NormalMethod getMethodForMCOffset(Offset MCOffset)
          Get the RVMMethod for a machine instruction offset.
 ArrayList<CallSite> getNonInlinedCallSites()
           
 boolean hasInlinedEdge(RVMMethod caller, int bcIndex, RVMMethod callee)
          This method searches the machine code maps and determines if the given call edge is definitely inlined into the method.
private  boolean isBigEntry(int entry)
          Is the entry a big entry?
private  boolean isHugeEntry(int entry)
          Is the entry a big entry?
private  int nextEntry(int entry)
           
 int nextLocation(int currentIndex)
           
private  void printMCInformationEntry(int entry, boolean DUMP_MAPS)
          Prints the MCInformation for this entry
private  void recordStats(RVMMethod method, int mapSize, int machineCodeSize, boolean DUMP_MAP_SIZES)
          Gather cumulative stats about the space consumed by maps.
 boolean registerIsSet(int entry, int registerNumber)
          Determines if the register map information for the entry passed is true
(package private)  int size()
          Total bytes of machine code maps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_OF_ENTRY

private static final int START_OF_ENTRY
See Also:
Constant Field Values

START_OF_BIG_ENTRY

private static final int START_OF_BIG_ENTRY
See Also:
Constant Field Values

START_OF_HUGE_ENTRY

private static final int START_OF_HUGE_ENTRY
See Also:
Constant Field Values

START_BITS

private static final int START_BITS
See Also:
Constant Field Values

CALL_MASK

private static final int CALL_MASK
See Also:
Constant Field Values

CALL_SHIFT

private static final int CALL_SHIFT
See Also:
Constant Field Values

BCI_MASK

private static final int BCI_MASK
See Also:
Constant Field Values

BCI_SHIFT

private static final int BCI_SHIFT
See Also:
Constant Field Values

IEI_MASK

private static final int IEI_MASK
See Also:
Constant Field Values

IEI_SHIFT

private static final int IEI_SHIFT
See Also:
Constant Field Values

GCI_MASK

private static final int GCI_MASK
See Also:
Constant Field Values

GCI_SHIFT

private static final int GCI_SHIFT
See Also:
Constant Field Values

OFFSET_MASK

private static final int OFFSET_MASK
See Also:
Constant Field Values

OFFSET_SHIFT

private static final int OFFSET_SHIFT
See Also:
Constant Field Values

INVALID_GCI

private static final int INVALID_GCI
See Also:
Constant Field Values

INVALID_BCI

private static final int INVALID_BCI
See Also:
Constant Field Values

INVALID_IEI

private static final int INVALID_IEI
See Also:
Constant Field Values

SIZEOF_ENTRY

private static final int SIZEOF_ENTRY
See Also:
Constant Field Values

BIG_CALL_MASK

private static final int BIG_CALL_MASK
See Also:
Constant Field Values

BIG_CALL_SHIFT

private static final int BIG_CALL_SHIFT
See Also:
Constant Field Values

BIG_CALL_IDX_ADJ

private static final int BIG_CALL_IDX_ADJ
See Also:
Constant Field Values

BIG_BCI_MASK

private static final int BIG_BCI_MASK
See Also:
Constant Field Values

BIG_BCI_SHIFT

private static final int BIG_BCI_SHIFT
See Also:
Constant Field Values

BIG_BCI_IDX_ADJ

private static final int BIG_BCI_IDX_ADJ
See Also:
Constant Field Values

BIG_IEI_MASK

private static final int BIG_IEI_MASK
See Also:
Constant Field Values

BIG_IEI_SHIFT

private static final int BIG_IEI_SHIFT
See Also:
Constant Field Values

BIG_IEI_IDX_ADJ

private static final int BIG_IEI_IDX_ADJ
See Also:
Constant Field Values

BIG_GCI_MASK

private static final int BIG_GCI_MASK
See Also:
Constant Field Values

BIG_GCI_SHIFT

private static final int BIG_GCI_SHIFT
See Also:
Constant Field Values

BIG_GCI_IDX_ADJ

private static final int BIG_GCI_IDX_ADJ
See Also:
Constant Field Values

BIG_OFFSET_MASK

private static final int BIG_OFFSET_MASK
See Also:
Constant Field Values

BIG_OFFSET_SHIFT

private static final int BIG_OFFSET_SHIFT
See Also:
Constant Field Values

BIG_OFFSET_IDX_ADJ

private static final int BIG_OFFSET_IDX_ADJ
See Also:
Constant Field Values

BIG_INVALID_GCI

private static final int BIG_INVALID_GCI
See Also:
Constant Field Values

BIG_INVALID_BCI

private static final int BIG_INVALID_BCI
See Also:
Constant Field Values

BIG_INVALID_IEI

private static final int BIG_INVALID_IEI
See Also:
Constant Field Values

SIZEOF_BIG_ENTRY

private static final int SIZEOF_BIG_ENTRY
See Also:
Constant Field Values

HUGE_CALL_MASK

private static final int HUGE_CALL_MASK
See Also:
Constant Field Values

HUGE_CALL_SHIFT

private static final int HUGE_CALL_SHIFT
See Also:
Constant Field Values

HUGE_CALL_IDX_ADJ

private static final int HUGE_CALL_IDX_ADJ
See Also:
Constant Field Values

HUGE_BCI_MASK

private static final int HUGE_BCI_MASK
See Also:
Constant Field Values

HUGE_BCI_SHIFT

private static final int HUGE_BCI_SHIFT
See Also:
Constant Field Values

HUGE_BCI_IDX_ADJ

private static final int HUGE_BCI_IDX_ADJ
See Also:
Constant Field Values

HUGE_IEI_MASK

private static final int HUGE_IEI_MASK
See Also:
Constant Field Values

HUGE_IEI_SHIFT

private static final int HUGE_IEI_SHIFT
See Also:
Constant Field Values

HUGE_IEI_IDX_ADJ

private static final int HUGE_IEI_IDX_ADJ
See Also:
Constant Field Values

HUGE_GCI_MASK

private static final int HUGE_GCI_MASK
See Also:
Constant Field Values

HUGE_GCI_SHIFT

private static final int HUGE_GCI_SHIFT
See Also:
Constant Field Values

HUGE_GCI_IDX_ADJ

private static final int HUGE_GCI_IDX_ADJ
See Also:
Constant Field Values

HUGE_OFFSET_MASK

private static final int HUGE_OFFSET_MASK
See Also:
Constant Field Values

HUGE_OFFSET_SHIFT

private static final int HUGE_OFFSET_SHIFT
See Also:
Constant Field Values

HUGE_OFFSET_IDX_ADJ

private static final int HUGE_OFFSET_IDX_ADJ
See Also:
Constant Field Values

HUGE_INVALID_GCI

private static final int HUGE_INVALID_GCI
See Also:
Constant Field Values

HUGE_INVALID_BCI

private static final int HUGE_INVALID_BCI
See Also:
Constant Field Values

HUGE_INVALID_IEI

private static final int HUGE_INVALID_IEI
See Also:
Constant Field Values

SIZEOF_HUGE_ENTRY

private static final int SIZEOF_HUGE_ENTRY
See Also:
Constant Field Values

IS_UNGUARDED_CALL

private static final int IS_UNGUARDED_CALL
See Also:
Constant Field Values

IS_GUARDED_CALL

private static final int IS_GUARDED_CALL
See Also:
Constant Field Values

MCInformation

private final int[] MCInformation
Hold entries as defined by the constants above.


gcMaps

private final int[] gcMaps
array of GC maps as defined by OptGCMap


inlineEncoding

public final int[] inlineEncoding
encoded data as defined by OptEncodedCallSiteTree.


totalMCSize

private static int totalMCSize
Running totals for the size of machine code and maps


totalMapSize

private static int totalMapSize

emptyMachineCodeMap

private static final OptMachineCodeMap emptyMachineCodeMap
A machine code map when no information is present


TYPE

private static final TypeReference TYPE
Constructor Detail

OptMachineCodeMap

private OptMachineCodeMap(int[] _MCInformation,
                          int[] _gcMaps,
                          int[] _inlineEncoding)
Private constructor, object should be created via create


OptMachineCodeMap

private OptMachineCodeMap()
Private constructor for no information.

Method Detail

create

static OptMachineCodeMap create(IR ir,
                                int machineCodeSize)
Create the map, called during compilation

Parameters:
ir - the ir object for this method
machineCodeSize - the number of machine code instructions generated.

getBytecodeIndexForMCOffset

public int getBytecodeIndexForMCOffset(Offset MCOffset)
Get the bytecode index for a machine instruction offset.

Parameters:
MCOffset - the machine code offset of interest
Returns:
-1 if unknown.

getMethodForMCOffset

public NormalMethod getMethodForMCOffset(Offset MCOffset)
Get the RVMMethod for a machine instruction offset. This method is the source method that the instruction came from.

Parameters:
MCOffset - the machine code offset of interest
Returns:
null if unknown

getInlineEncodingForMCOffset

public int getInlineEncodingForMCOffset(Offset MCOffset)
Return the inlining encoding index for the machine instruction offset.

Parameters:
MCOffset - the machine code offset of interest
Returns:
-1 if unknown.

findGCMapIndex

public int findGCMapIndex(Offset MCOffset)
This method searches for the GC map corresponding to the passed machine code offset. If no map is present, an error has occurred and OptGCMap.ERROR is returned.

Parameters:
MCOffset - the machine code offset to look for
Returns:
the GC map index or OptGCMap.ERROR

getNonInlinedCallSites

public ArrayList<CallSite> getNonInlinedCallSites()
Returns:
an arraylist of CallSite objects representing all non-inlined callsites in the method. Returns null if there are no such callsites.

hasInlinedEdge

public boolean hasInlinedEdge(RVMMethod caller,
                              int bcIndex,
                              RVMMethod callee)
This method searches the machine code maps and determines if the given call edge is definitely inlined into the method. NOTE: This current implementation may return false even if the edge actually was inlined. This happens when no GC point occurs within the inlined body. This is less than ideal; we need to fix this at some point.

Parameters:
caller - caller RVMMethod
bcIndex - bytecode index of the caller method
callee - callee RVMMethod
Returns:
true if the call edge is definitely inlined in this compiled method.

gcMapInformation

public int gcMapInformation(int index)
Returns the GC map information for the GC map information entry passed

Parameters:
index - GCmap entry

registerIsSet

public boolean registerIsSet(int entry,
                             int registerNumber)
Determines if the register map information for the entry passed is true

Parameters:
entry - map entry
registerNumber - the register number

nextLocation

public int nextLocation(int currentIndex)
Returns:
the next (relative) location or -1 for no more locations

findMCEntry

private int findMCEntry(Offset MCOffset)
Do a binary search of the machine code maps to find the index in MCInformation where the entry for the argument machine code offset starts. Will return -1 if the entry doesn't exist.

Parameters:
MCOffset - the machine code offset of interest

nextEntry

private int nextEntry(int entry)

generateMCInformation

private static OptMachineCodeMap generateMCInformation(GCIRMap irMap,
                                                       boolean DUMP_MAPS)
This method walks the IR map, and for each entry it creates the machine code mapping information for the entry. It is called during the compilation of the method, not at GC time.

Parameters:
irMap - the irmap to translate from
DUMP_MAPS - dump while we work

getMCOffset

private int getMCOffset(int entry)
Returns the MCOffset for the entry passed

Parameters:
entry - the index of the start of the entry
Returns:
the MCOffset for this entry

getGCMapIndex

private int getGCMapIndex(int entry)
Returns the GC map index for the entry passed

Parameters:
entry - the index of the start of the entry
Returns:
the GC map entry index for this entry (or -1 if none)

getBytecodeIndex

private int getBytecodeIndex(int entry)
Returns the Bytecode index for the entry passed

Parameters:
entry - the index of the start of the entry
Returns:
the bytecode index for this entry (-1 if unknown)

getInlineEncodingIndex

private int getInlineEncodingIndex(int entry)
Returns the inline encoding index for the entry passed.

Parameters:
entry - the index of the start of the entry
Returns:
the inline encoding index for this entry (-1 if unknown)

getCallInfo

private int getCallInfo(int entry)
Returns the call info for the entry passed.

Parameters:
entry - the index of the start of the entry
Returns:
the call info for this entry

isBigEntry

private boolean isBigEntry(int entry)
Is the entry a big entry?


isHugeEntry

private boolean isHugeEntry(int entry)
Is the entry a big entry?


dumpMCInformation

public void dumpMCInformation(boolean DUMP_MAPS)

printMCInformationEntry

private void printMCInformationEntry(int entry,
                                     boolean DUMP_MAPS)
Prints the MCInformation for this entry

Parameters:
entry - the entry to print

recordStats

private void recordStats(RVMMethod method,
                         int mapSize,
                         int machineCodeSize,
                         boolean DUMP_MAP_SIZES)
Gather cumulative stats about the space consumed by maps.

Parameters:
method -
mapSize -
machineCodeSize -
DUMP_MAP_SIZES -

size

int size()
Total bytes of machine code maps