org.jikesrvm.osr
Class EncodedOSRMap

java.lang.Object
  extended by org.jikesrvm.osr.EncodedOSRMap
All Implemented Interfaces:
ArchitectureSpecificOpt.OptGCMapIteratorConstants, ClassLoaderConstants, PhysicalRegisterConstants, OptGCMapIteratorConstants, RegisterConstants, OSRConstants, SizeConstants

public final class EncodedOSRMap
extends Object
implements ArchitectureSpecificOpt.OptGCMapIteratorConstants, OSRConstants

EncodedOSRMap provides the similar function as GC map in OptMachineCodeMap.

In OptCompiledMethod, an instance of this class will represent all OSR map info for that method.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jikesrvm.ia32.RegisterConstants
RegisterConstants.FloatingPointMachineRegister, RegisterConstants.FPR, RegisterConstants.GPR, RegisterConstants.MachineRegister, RegisterConstants.MM, RegisterConstants.XMM
 
Field Summary
private static EncodedOSRMap emptyMap
          map used when there are no OSR instructions
private  int lastEntry
          the last entry index.
private  long[] mapEntries
          osr info entries
private  int[] osrMaps
          the OSR map
 
Fields inherited from interface org.jikesrvm.compilers.opt.runtimesupport.ia32.OptGCMapIteratorConstants
FIRST_GCMAP_REG, LAST_GCMAP_REG
 
Fields inherited from interface org.jikesrvm.compilers.opt.regalloc.ia32.PhysicalRegisterConstants
AF, C0, C1, C2, C3, CF, CONDITION_VALUE, DOUBLE_REG, DOUBLE_VALUE, FIRST_DOUBLE, FIRST_INT, FIRST_SPECIAL, FLOAT_VALUE, INT_REG, INT_VALUE, NUM_SPECIALS, NUMBER_TYPE, OF, PF, SF, SPECIAL_REG, ST0, ST1, ZF
 
Fields inherited from interface org.jikesrvm.ia32.RegisterConstants
ALL_FPRS, ALL_GPRS, EAX, EBP, EBX, ECX, EDI, EDX, ESI, ESP, FP0, FP1, FP2, FP3, FP4, FP5, FP6, FP7, INSTRUCTION_WIDTH, LG_INSTRUCTION_WIDTH, MM0, MM1, MM10, MM11, MM12, MM13, MM14, MM15, MM2, MM3, MM4, MM5, MM6, MM7, MM8, MM9, NATIVE_NONVOLATILE_FPRS, NATIVE_NONVOLATILE_GPRS, NATIVE_PARAMETER_FPRS, NATIVE_PARAMETER_GPRS, NATIVE_VOLATILE_FPRS, NATIVE_VOLATILE_GPRS, NONVOLATILE_FPRS, NONVOLATILE_GPRS, NUM_FPRS, NUM_GPRS, NUM_NONVOLATILE_FPRS, NUM_NONVOLATILE_GPRS, NUM_PARAMETER_FPRS, NUM_PARAMETER_GPRS, NUM_RETURN_FPRS, NUM_RETURN_GPRS, NUM_VOLATILE_FPRS, NUM_VOLATILE_GPRS, PARAMETER_FPRS, PARAMETER_GPRS, R0, R1, R10, R11, R12, R13, R14, R15, R2, R3, R4, R5, R6, R7, R8, R9, RETURN_FPRS, RETURN_GPRS, STACK_POINTER, THREAD_REGISTER, VOLATILE_FPRS, VOLATILE_GPRS, XMM0, XMM1, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, XMM8, XMM9
 
Fields inherited from interface org.jikesrvm.osr.OSRConstants
ACONST, BCI_MASK, BCI_SHIFT, CLEANREFS, DOUBLE, FLOAT, GETREFAT, HIGH_64BIT, ICONST, IEI_MASK, IEI_SHIFT, INT, INVALID_BCI, INVALID_IEI, KIND_MASK, KIND_SHIFT, LCONST, LOCAL, LONG, NEXT_BIT, NO_OSR_ENTRY, NUM_MASK, NUM_SHIFT, OFFSET_MASK, OFFSET_SHIFT, OSRI_MASK, OSRI_SHIFT, PHYREG, PSEUDO_CheckCast, PSEUDO_InvokeCompiledMethod, PSEUDO_InvokeStatic, PSEUDO_LoadDoubleConst, PSEUDO_LoadFloatConst, PSEUDO_LoadIntConst, PSEUDO_LoadLongConst, PSEUDO_LoadRetAddrConst, PSEUDO_LoadWordConst, PSEUDO_ParamInitEnd, REF, RET_ADDR, ReturnAddressTypeCode, SPILL, STACK, TCODE_MASK, TCODE_SHIFT, VTYPE_MASK, VTYPE_SHIFT, WORD, WordTypeCode
 
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.classloader.ClassLoaderConstants
ACC_ABSTRACT, ACC_ANNOTATION, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VOLATILE, APPLICABLE_TO_CLASSES, APPLICABLE_TO_FIELDS, APPLICABLE_TO_METHODS, ArrayTypeCode, BooleanTypeCode, BRIDGE, ByteTypeCode, CharTypeCode, CLASS_INITIALIZED, CLASS_INITIALIZER_FAILED, CLASS_INITIALIZING, CLASS_INSTANTIATED, CLASS_LOADED, CLASS_RESOLVED, CLASS_VACANT, ClassTypeCode, CP_CLASS, CP_DOUBLE, CP_FLOAT, CP_INT, CP_LONG, CP_MEMBER, CP_STRING, CP_UTF, DoubleTypeCode, FloatTypeCode, IntTypeCode, LongTypeCode, ShortTypeCode, TAG_DOUBLE, TAG_FIELDREF, TAG_FLOAT, TAG_INT, TAG_INTERFACE_METHODREF, TAG_LONG, TAG_MEMBERNAME_AND_DESCRIPTOR, TAG_METHODREF, TAG_STRING, TAG_TYPEREF, TAG_UNUSED, TAG_UTF, VARARGS, VoidTypeCode
 
Constructor Summary
private EncodedOSRMap()
          Constructor to build empty map
private EncodedOSRMap(VariableMap varMap)
          Constructor that builds EncodedOSRMap from variable map
 
Method Summary
private  void _generateMapForOneMethodVariable(ArrayList<Integer> tempOsrMaps, int regMapIndex, MethodVariables mVar, boolean lastMid)
          Generate value in the Osr map
private  int findOSREntry(Offset mcOffset)
          Do a binary search, find the entry for the machine code offset.
private  int generateOsrMaps(ArrayList<Integer> tempOsrMaps, LinkedList<MethodVariables> mVarList)
          Generate value in the Osr map, return the index of the first integer in the map.
private  int getBCIndex(int entry)
           
 int getBytecodeIndexForMCOffset(Offset mcOffset)
          Get bytecode index for a given instruction offset in bytes.
private  int getIEIndex(int entry)
           
 int getInlineEncodingForMCOffset(Offset mcOffset)
           
 int[] getMCIndexes()
           
private  int getMCOffset(int entry)
           
private  int getOSRMapIndex(int entry)
           
 OSRMapIterator getOsrMapIteratorForMCOffset(Offset mcOffset)
          given a MC offset, return an iterator over the elements of this map.
private static int getRegBitPosition(int regnum)
          get register bit position
 int getRegisterMapForMCOffset(Offset mcOffset)
          get register's reference map for the machine instruction offset
 boolean hasOSRMap(Offset mcOffset)
          Does the OSR map exist for a machine instruction offset
static EncodedOSRMap makeMap(VariableMap varMap)
          Encode the given variable map returning the canonical empty map if the map is empty
 void printMap()
          print the encoded map for debugging.
private  void processTuple(ArrayList<Integer> tempOsrMaps, LocalRegPair tuple, boolean isLast)
          Process on 32-bit tuple.
static boolean registerIsSet(int map, int regnum)
           
private  void setBCIndex(int entry, int index)
           
private  void setIEIndex(int entry, int index)
           
private  void setMCOffset(int entry, int offset)
           
private  void setOSRMapIndex(int entry, int index)
           
private static int setRegister(int map, int regnum)
          mark a register as reference type
private  void translateMap(ArrayList<Integer> tempOsrMaps, LinkedList<VariableMapElement> osrlist)
          Translates a list of OSR_MapElement to encoding, we can not trust the osrlist is in the increasing order of machine code offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapEntries

private final long[] mapEntries
osr info entries


lastEntry

private final int lastEntry
the last entry index.


osrMaps

private final int[] osrMaps
the OSR map


emptyMap

private static final EncodedOSRMap emptyMap
map used when there are no OSR instructions

Constructor Detail

EncodedOSRMap

private EncodedOSRMap()
Constructor to build empty map


EncodedOSRMap

private EncodedOSRMap(VariableMap varMap)
Constructor that builds EncodedOSRMap from variable map

Method Detail

registerIsSet

public static boolean registerIsSet(int map,
                                    int regnum)

setRegister

private static int setRegister(int map,
                               int regnum)
mark a register as reference type


getRegBitPosition

private static int getRegBitPosition(int regnum)
get register bit position


makeMap

public static EncodedOSRMap makeMap(VariableMap varMap)
Encode the given variable map returning the canonical empty map if the map is empty


translateMap

private void translateMap(ArrayList<Integer> tempOsrMaps,
                          LinkedList<VariableMapElement> osrlist)
Translates a list of OSR_MapElement to encoding, we can not trust the osrlist is in the increasing order of machine code offset. Sort it first.


generateOsrMaps

private int generateOsrMaps(ArrayList<Integer> tempOsrMaps,
                            LinkedList<MethodVariables> mVarList)
Generate value in the Osr map, return the index of the first integer in the map.

An OSR Map has following structure:

 | regmap || mid, mpc, (n1, n2) ... ||
          || mid, mpc, (n1, n2) ... ||
 
Regmap indicates the value of which register is a reference, the execution state extractor can convert the value to an object to avoid confusing GC. The MSB of regmap indicates next mid is valid.

The MSB of mid indicates if the next mid item will be available.

The MSB of mpc indicates if the next is a valid pair


_generateMapForOneMethodVariable

private void _generateMapForOneMethodVariable(ArrayList<Integer> tempOsrMaps,
                                              int regMapIndex,
                                              MethodVariables mVar,
                                              boolean lastMid)
Generate value in the Osr map

Parameters:
tempOsrMaps - the maps under construction
regMapIndex - used to patch the register map
mVar - the method variables
lastMid -

processTuple

private void processTuple(ArrayList<Integer> tempOsrMaps,
                          LocalRegPair tuple,
                          boolean isLast)
Process on 32-bit tuple.

tuple, maps the local to register, spill isLast, indicates to set NEXT_BIT


hasOSRMap

public boolean hasOSRMap(Offset mcOffset)
Does the OSR map exist for a machine instruction offset


getBytecodeIndexForMCOffset

public int getBytecodeIndexForMCOffset(Offset mcOffset)
Get bytecode index for a given instruction offset in bytes.


getInlineEncodingForMCOffset

public int getInlineEncodingForMCOffset(Offset mcOffset)

getRegisterMapForMCOffset

public int getRegisterMapForMCOffset(Offset mcOffset)
get register's reference map for the machine instruction offset


getOsrMapIteratorForMCOffset

public OSRMapIterator getOsrMapIteratorForMCOffset(Offset mcOffset)
given a MC offset, return an iterator over the elements of this map. NOTE: the map index is gotten from 'findOSRMapIndex'. This has to be changed....


findOSREntry

private int findOSREntry(Offset mcOffset)
Do a binary search, find the entry for the machine code offset. Return -1 if no entry was found.


getMCOffset

private int getMCOffset(int entry)

getOSRMapIndex

private int getOSRMapIndex(int entry)

getBCIndex

private int getBCIndex(int entry)

getIEIndex

private int getIEIndex(int entry)

setMCOffset

private void setMCOffset(int entry,
                         int offset)

setOSRMapIndex

private void setOSRMapIndex(int entry,
                            int index)

setBCIndex

private void setBCIndex(int entry,
                        int index)

setIEIndex

private void setIEIndex(int entry,
                        int index)

printMap

public void printMap()
print the encoded map for debugging.


getMCIndexes

public int[] getMCIndexes()