org.jikesrvm.compilers.opt.runtimesupport
Class OptCompiledMethod

java.lang.Object
  extended by org.jikesrvm.compilers.common.CompiledMethod
      extended by org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod
All Implemented Interfaces:
SizeConstants

public final class OptCompiledMethod
extends CompiledMethod

An implementation of CompiledMethod for the OPT compiler.

NOTE: OptCompiledMethod live as long as their corresponding compiled machine code. Therefore, they should only contain state that is really required to be persistent. Anything transitory should be stored on the IR object.


Field Summary
private  OptMachineCodeMap _mcMap
          The primary machine code maps
private  EncodedOSRMap _osrMap
           
private static RVMThread.SoftHandshakeVisitor codePatchSyncRequestVisitor
           
private  int[] eTable
          The encoded exception tables (null if there are none)
private static ArchitectureSpecificOpt.OptExceptionDeliverer exceptionDeliverer
           
private  char exceptionObjectOffset
          unsigned offset (off the framepointer) of caught exception object in bytes
private  byte firstNonvolatileFPR
          first saved nonvolatile floating point register (-1 if no nonvolatile FPRs)
private  byte firstNonvolatileGPR
          first saved nonvolatile integer register (-1 if no nonvolatile GPRs)
private  boolean instrumented
          is the current method executing with instrumentation
private  char nonvolatileOffset
          unsigned offset (off the framepointer) of nonvolatile save area in bytes
private  byte optLevel
          opt level at which the method was compiled
private  int[] patchMap
           
private  char stackFrameFixedSize
          size of the fixed portion of the stackframe
private  boolean volatilesSaved
          were the volatile registers saved?
 
Fields inherited from class org.jikesrvm.compilers.common.CompiledMethod
BASELINE, cmid, compilationTime, instructions, JNI, method, NUM_COMPILER_TYPES, OPT, osrJTOCoffset, TRAP
 
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
 
Constructor Summary
OptCompiledMethod(int id, RVMMethod m)
           
 
Method Summary
 void applyCodePatches(CompiledMethod cm)
          Apply the code patches to the INSTRUCTION array of cm
 void createCodePatchMaps(IR ir)
          Create the code patching maps from the IR for the method
 void createFinalExceptionTable(IR ir)
          Create the final exception table from the IR for the method.
 void createFinalMCMap(IR ir, int machineCodeLength)
          Create the final machine code map for the compiled method.
 void createFinalOSRMap(IR ir)
           
 int findCatchBlockForInstruction(Offset instructionOffset, RVMType exceptionType)
          Find "catch" block for a machine instruction of this method.
 int findLineNumberForInstruction(Offset instructionOffset)
          Find source line number corresponding to one of this method's machine instructions.
 String getCompilerName()
           
 int getCompilerType()
          Identify the compiler that produced this compiled method.
 void getDynamicLink(DynamicLink dynamicLink, Offset instructionOffset)
          Fetch symbolic reference to a method that's called by one of this method's instructions.
 ExceptionDeliverer getExceptionDeliverer()
          Get handler to deal with stack unwinding and exception delivery for this compiled method's stackframes.
 int getFirstNonVolatileFPR()
           
 int getFirstNonVolatileGPR()
           
 int getFrameFixedSize()
           
 OptMachineCodeMap getMCMap()
           
 int getNumberOfNonvolatileFPRs()
          Return the number of non-volatile FPRs used by this method.
 int getNumberOfNonvolatileGPRs()
          Return the number of non-volatile GPRs used by this method.
 int getOptLevel()
           
 EncodedOSRMap getOSRMap()
           
 int getUnsignedExceptionOffset()
           
 int getUnsignedNonVolatileOffset()
           
 boolean isInstrumentedMethod()
           
 boolean isSaveVolatile()
           
 boolean isWithinUninterruptibleCode(Offset instructionOffset)
          Return whether or not the given address (which is purported to be inside of the compiled method's code array) corresponds to an uninterruptible context.
 void printExceptionTable()
          Print the eTable
 void printStackTrace(Offset instructionOffset, PrintLN out)
          Print this compiled method's portion of a stack trace
 void set(StackBrowser browser, Offset instr)
          Set the stack browser to the innermost logical stack frame of this method
 void setFirstNonVolatileFPR(int x)
           
 void setFirstNonVolatileGPR(int x)
           
 void setFrameFixedSize(int x)
           
 void setInstrumentedMethod(boolean _instrumented)
           
 void setNumberOfNonvolatileFPRs(short n)
          Set the number of non-volatile FPRs used by this method.
 void setNumberOfNonvolatileGPRs(short n)
          Set the number of non-volatile GPRs used by this method.
 void setOptLevel(int x)
           
 void setSaveVolatile(boolean sv)
           
 void setUnsignedExceptionOffset(int x)
           
 void setUnsignedNonVolatileOffset(int x)
           
 int size()
          Return the number of bytes used to encode the compiler-specific mapping information for this compiled method.
 boolean up(StackBrowser browser)
          Advance the StackBrowser up one internal stack frame, if possible
 
Methods inherited from class org.jikesrvm.compilers.common.CompiledMethod
clearActiveOnStack, codeArrayForOffset, compileComplete, compilerTypeToString, containsReturnAddress, getCompilationTime, getEntryCodeArray, getId, getInstructionAddress, getInstructionOffset, getInstructionOffset, getMethod, getOsrJTOCoffset, getSamplesReset, hasBridgeFromNativeAnnotation, isActiveOnStack, isCompiled, isInvalid, isObsolete, isOutdated, isSpecialForOSR, numberOfInstructions, setActiveOnStack, setCompilationTime, setInvalid, setObsolete, setOutdated, setSamplesReset, setSpecialForOSR
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exceptionDeliverer

private static final ArchitectureSpecificOpt.OptExceptionDeliverer exceptionDeliverer

_osrMap

private EncodedOSRMap _osrMap

_mcMap

private OptMachineCodeMap _mcMap
The primary machine code maps


eTable

private int[] eTable
The encoded exception tables (null if there are none)


patchMap

private int[] patchMap

nonvolatileOffset

private char nonvolatileOffset
unsigned offset (off the framepointer) of nonvolatile save area in bytes


exceptionObjectOffset

private char exceptionObjectOffset
unsigned offset (off the framepointer) of caught exception object in bytes


stackFrameFixedSize

private char stackFrameFixedSize
size of the fixed portion of the stackframe


firstNonvolatileGPR

private byte firstNonvolatileGPR
first saved nonvolatile integer register (-1 if no nonvolatile GPRs)


firstNonvolatileFPR

private byte firstNonvolatileFPR
first saved nonvolatile floating point register (-1 if no nonvolatile FPRs)


optLevel

private byte optLevel
opt level at which the method was compiled


volatilesSaved

private boolean volatilesSaved
were the volatile registers saved?


instrumented

private boolean instrumented
is the current method executing with instrumentation


codePatchSyncRequestVisitor

private static RVMThread.SoftHandshakeVisitor codePatchSyncRequestVisitor
Constructor Detail

OptCompiledMethod

public OptCompiledMethod(int id,
                         RVMMethod m)
Method Detail

getCompilerType

public int getCompilerType()
Description copied from class: CompiledMethod
Identify the compiler that produced this compiled method.

Specified by:
getCompilerType in class CompiledMethod
Returns:
CompiledMethod.OPT

getCompilerName

public String getCompilerName()
Specified by:
getCompilerName in class CompiledMethod
Returns:
Name of the compiler that produced this compiled method.

getExceptionDeliverer

public ExceptionDeliverer getExceptionDeliverer()
Description copied from class: CompiledMethod
Get handler to deal with stack unwinding and exception delivery for this compiled method's stackframes.

Specified by:
getExceptionDeliverer in class CompiledMethod

findCatchBlockForInstruction

public int findCatchBlockForInstruction(Offset instructionOffset,
                                        RVMType exceptionType)
Find "catch" block for a machine instruction of this method.

Specified by:
findCatchBlockForInstruction in class CompiledMethod
Parameters:
instructionOffset - offset of machine instruction from start of this method, in bytes
exceptionType - type of exception being thrown - something like "NullPointerException"
Returns:
offset of machine instruction for catch block (-1 --> no catch block)

getDynamicLink

public void getDynamicLink(DynamicLink dynamicLink,
                           Offset instructionOffset)
Fetch symbolic reference to a method that's called by one of this method's instructions.

Specified by:
getDynamicLink in class CompiledMethod
Parameters:
dynamicLink - place to put return information
instructionOffset - offset of machine instruction that issued the call

isWithinUninterruptibleCode

public boolean isWithinUninterruptibleCode(Offset instructionOffset)
Description copied from class: CompiledMethod
Return whether or not the given address (which is purported to be inside of the compiled method's code array) corresponds to an uninterruptible context.

Specified by:
isWithinUninterruptibleCode in class CompiledMethod
Parameters:
instructionOffset - of addr from start of instructions in bytes
Returns:
true if the IP is within an Uninterruptible method, false otherwise.

findLineNumberForInstruction

public int findLineNumberForInstruction(Offset instructionOffset)
Find source line number corresponding to one of this method's machine instructions.

Overrides:
findLineNumberForInstruction in class CompiledMethod
Parameters:
instructionOffset - of machine instruction from start of this method, in bytes
Returns:
source line number (0 == no line info available, 1 == first line of source file)

set

public void set(StackBrowser browser,
                Offset instr)
Description copied from class: CompiledMethod
Set the stack browser to the innermost logical stack frame of this method

Specified by:
set in class CompiledMethod

up

public boolean up(StackBrowser browser)
Description copied from class: CompiledMethod
Advance the StackBrowser up one internal stack frame, if possible

Overrides:
up in class CompiledMethod

printStackTrace

public void printStackTrace(Offset instructionOffset,
                            PrintLN out)
Description copied from class: CompiledMethod
Print this compiled method's portion of a stack trace

Specified by:
printStackTrace in class CompiledMethod
Parameters:
instructionOffset - offset of machine instruction from start of method
out - the PrintLN to print the stack trace to.

size

public int size()
Description copied from class: CompiledMethod
Return the number of bytes used to encode the compiler-specific mapping information for this compiled method. Used to gather statistics on the space costs of mapping schemes.

Overrides:
size in class CompiledMethod

createFinalOSRMap

public void createFinalOSRMap(IR ir)

getOSRMap

public EncodedOSRMap getOSRMap()

getUnsignedNonVolatileOffset

public int getUnsignedNonVolatileOffset()

getUnsignedExceptionOffset

public int getUnsignedExceptionOffset()

getFirstNonVolatileGPR

public int getFirstNonVolatileGPR()

getFirstNonVolatileFPR

public int getFirstNonVolatileFPR()

getOptLevel

public int getOptLevel()

isSaveVolatile

public boolean isSaveVolatile()

isInstrumentedMethod

public boolean isInstrumentedMethod()

getFrameFixedSize

public int getFrameFixedSize()

setUnsignedNonVolatileOffset

public void setUnsignedNonVolatileOffset(int x)

setUnsignedExceptionOffset

public void setUnsignedExceptionOffset(int x)

setFirstNonVolatileGPR

public void setFirstNonVolatileGPR(int x)

setFirstNonVolatileFPR

public void setFirstNonVolatileFPR(int x)

setOptLevel

public void setOptLevel(int x)

setSaveVolatile

public void setSaveVolatile(boolean sv)

setInstrumentedMethod

public void setInstrumentedMethod(boolean _instrumented)

setFrameFixedSize

public void setFrameFixedSize(int x)

getNumberOfNonvolatileGPRs

public int getNumberOfNonvolatileGPRs()
Return the number of non-volatile GPRs used by this method.


getNumberOfNonvolatileFPRs

public int getNumberOfNonvolatileFPRs()
Return the number of non-volatile FPRs used by this method.


setNumberOfNonvolatileGPRs

public void setNumberOfNonvolatileGPRs(short n)
Set the number of non-volatile GPRs used by this method.


setNumberOfNonvolatileFPRs

public void setNumberOfNonvolatileFPRs(short n)
Set the number of non-volatile FPRs used by this method.


printExceptionTable

public void printExceptionTable()
Print the eTable


getMCMap

public OptMachineCodeMap getMCMap()
Returns:
the machine code map for the compiled method.

createFinalMCMap

public void createFinalMCMap(IR ir,
                             int machineCodeLength)
Create the final machine code map for the compiled method. Remember the offset for the end of prologue too for debugger.

Parameters:
ir - the ir
machineCodeLength - the number of machine code instructions.

createFinalExceptionTable

public void createFinalExceptionTable(IR ir)
Create the final exception table from the IR for the method.

Parameters:
ir - the ir

createCodePatchMaps

public void createCodePatchMaps(IR ir)
Create the code patching maps from the IR for the method

Parameters:
ir - the ir

applyCodePatches

public void applyCodePatches(CompiledMethod cm)
Apply the code patches to the INSTRUCTION array of cm