org.jikesrvm.compilers.baseline
Class BaselineCompiledMethod

java.lang.Object
  extended by org.jikesrvm.compilers.common.CompiledMethod
      extended by org.jikesrvm.compilers.baseline.BaselineCompiledMethod
All Implemented Interfaces:
ArchitectureSpecific.BaselineConstants, Constants, HeapLayoutConstants, ArchConstants, BaselineConstants, RegisterConstants, StackframeLayoutConstants, TrapConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public final class BaselineCompiledMethod
extends CompiledMethod
implements ArchitectureSpecific.BaselineConstants

Compiler-specific information associated with a method's machine instructions.


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  byte[] bytecodeMap
          Encoded representation of bytecode index to offset in code array map.
private  short emptyStackOffset
          Offset into stack frame when operand stack is empty
private  int[] eTable
          Exception table, null if not present.
private static ExceptionDeliverer exceptionDeliverer
          Baseline exception deliverer object
private  boolean hasCounters
          Does the baseline compiled method have a counters array?
private  byte lastFixedStackRegister
          PPC only: last general purpose register holding part of the operand stack
private  byte lastFloatStackRegister
          PPC only: last floating point register holding part of the operand stack
private  short[] localFixedLocations
          PPC only: location of general purpose local variables, positive values are register numbers, negative are stack offsets
private  short[] localFloatLocations
          PPC only: location of floating point local variables, positive values are register numbers, negative are stack offsets
private  char lockOffset
          The lock acquisition offset for synchronized methods.
 ReferenceMaps referenceMaps
          Stack-slot reference maps for the compiled method.
 
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.ia32.BaselineConstants
BRIDGE_FRAME_EXTRA_SIZE, EBP_SAVE_OFFSET, EBX_SAVE_OFFSET, EDI_SAVE_OFFSET, FPU_SAVE_OFFSET, LG_WORDSIZE, S0, S1, SAVED_GPRS, SAVED_GPRS_FOR_SAVE_LS_REGISTERS, SP, STACKFRAME_FIRST_PARAMETER_OFFSET, STACKFRAME_REG_SAVE_OFFSET, T0, T0_int, T0_SAVE_OFFSET, T1, T1_int, T1_SAVE_OFFSET, TR, WORDSIZE, XMM_SAVE_OFFSET
 
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.ia32.ArchConstants
SSE2_BASE, SSE2_FULL
 
Fields inherited from interface org.jikesrvm.ia32.StackframeLayoutConstants
BYTES_IN_STACKSLOT, FPU_STATE_SIZE, INVISIBLE_METHOD_ID, LOG_BYTES_IN_STACKSLOT, STACK_SIZE_BOOT, STACK_SIZE_COLLECTOR, STACK_SIZE_DLOPEN, STACK_SIZE_GCDISABLED, STACK_SIZE_GROW, STACK_SIZE_GUARD, STACK_SIZE_JNINATIVE_GROW, STACK_SIZE_MAX, STACK_SIZE_NORMAL, STACK_SIZE_SYSCALL, STACKFRAME_ALIGNMENT, STACKFRAME_BODY_OFFSET, STACKFRAME_FRAME_POINTER_OFFSET, STACKFRAME_HEADER_SIZE, STACKFRAME_METHOD_ID_OFFSET, STACKFRAME_RETURN_ADDRESS_OFFSET, STACKFRAME_SENTINEL_FP, XMM_STATE_SIZE
 
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.ia32.TrapConstants
RVM_TRAP_BASE
 
Constructor Summary
BaselineCompiledMethod(int id, RVMMethod m)
          Constructor
 
Method Summary
 void compile()
          Compile method
 void encodeMappingInfo(ReferenceMaps referenceMaps, int[] bcMap)
          Encode/compress the bytecode map, reference (GC) map and exception table
 int findBytecodeIndexForInstruction(Offset instructionOffset)
          Find bytecode index corresponding to one of this method's machine instructions.
 int findCatchBlockForInstruction(Offset instructionOffset, RVMType exceptionType)
          Find a catch block within the compiled 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.
 int getEmptyStackOffset()
           
 ExceptionDeliverer getExceptionDeliverer()
          Get the exception deliverer for this kind of compiled method
 short getFloatLocalLocation(int localIndex)
          Location of local floating point variable.
 short getFloatStackLocation(int stackIndex)
          Offset onto stack of a particular operand stack location for a floating point value
 short getGeneralLocalLocation(int localIndex)
          Location of local general purpose variable.
 short getGeneralStackLocation(int stackIndex)
          Offset onto stack of a particular general purpose operand stack location
 int getLastFixedStackRegister()
          Last general purpose register holding part of the operand stack
 int getLastFloatStackRegister()
          Last floating point register holding part of the operand stack
 Offset getLockAcquisitionOffset()
          Get the lock acquisition offset
 boolean hasCounterArray()
          Does the method have a counters array?
 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
(package private)  void setHasCounterArray()
          Set the method has a counters array
 void setLockAcquisitionOffset(int off)
          Set the lock acquisition offset for synchronized methods
 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

hasCounters

private boolean hasCounters
Does the baseline compiled method have a counters array?


lockOffset

private char lockOffset
The lock acquisition offset for synchronized methods. For synchronized methods, the offset (in the method prologue) after which the monitor has been obtained. At, or before, this point, the method does not own the lock. Used by deliverException to determine whether the lock needs to be released. Note: for this scheme to work, Lock must not allow a yield after it has been obtained.


exceptionDeliverer

private static final ExceptionDeliverer exceptionDeliverer
Baseline exception deliverer object


referenceMaps

public ReferenceMaps referenceMaps
Stack-slot reference maps for the compiled method.


bytecodeMap

private byte[] bytecodeMap
Encoded representation of bytecode index to offset in code array map. Currently needed to support dynamic bridge magic; Consider integrating with GC maps


eTable

private int[] eTable
Exception table, null if not present.


emptyStackOffset

private final short emptyStackOffset
Offset into stack frame when operand stack is empty


lastFixedStackRegister

private byte lastFixedStackRegister
PPC only: last general purpose register holding part of the operand stack


lastFloatStackRegister

private byte lastFloatStackRegister
PPC only: last floating point register holding part of the operand stack


localFixedLocations

private final short[] localFixedLocations
PPC only: location of general purpose local variables, positive values are register numbers, negative are stack offsets


localFloatLocations

private final short[] localFloatLocations
PPC only: location of floating point local variables, positive values are register numbers, negative are stack offsets

Constructor Detail

BaselineCompiledMethod

public BaselineCompiledMethod(int id,
                              RVMMethod m)
Constructor

Method Detail

getEmptyStackOffset

public int getEmptyStackOffset()
Returns:
offset into stack frame when operand stack is empty

getGeneralLocalLocation

public short getGeneralLocalLocation(int localIndex)
Location of local general purpose variable. These Locations are positioned at the top of the stackslot that contains the value before accessing, substract size of value you want to access.

e.g. to load int: load at BaselineCompilerImpl.locationToOffset(location) - BYTES_IN_INT
e.g. to load long: load at BaselineCompilerImpl.locationToOffset(location) - BYTES_IN_LONG


getFloatLocalLocation

public short getFloatLocalLocation(int localIndex)
Location of local floating point variable. These Locations are positioned at the top of the stackslot that contains the value before accessing, substract size of value you want to access.

e.g. to load float: load at BaselineCompilerImpl.locationToOffset(location) - BYTES_IN_FLOAT
e.g. to load double: load at BaselineCompilerImpl.locationToOffset(location) - BYTES_IN_DOUBLE


getGeneralStackLocation

public short getGeneralStackLocation(int stackIndex)
Offset onto stack of a particular general purpose operand stack location


getFloatStackLocation

public short getFloatStackLocation(int stackIndex)
Offset onto stack of a particular operand stack location for a floating point value


getLastFixedStackRegister

public int getLastFixedStackRegister()
Last general purpose register holding part of the operand stack


getLastFloatStackRegister

public int getLastFloatStackRegister()
Last floating point register holding part of the operand stack


compile

public void compile()
Compile method


getCompilerType

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

Specified by:
getCompilerType in class CompiledMethod
Returns:
BASELINE

getCompilerName

public String getCompilerName()
Specified by:
getCompilerName in class CompiledMethod
Returns:
"baseline compiler"

getExceptionDeliverer

public ExceptionDeliverer getExceptionDeliverer()
Get the exception deliverer for this kind of compiled method

Specified by:
getExceptionDeliverer in class CompiledMethod

findCatchBlockForInstruction

public int findCatchBlockForInstruction(Offset instructionOffset,
                                        RVMType exceptionType)
Find a catch block within the compiled method

Specified by:
findCatchBlockForInstruction in class CompiledMethod
Parameters:
instructionOffset - offset of faulting instruction in compiled code
exceptionType - the type of the thrown exception
Returns:
the machine code offset of the catch block.

getDynamicLink

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

Notes:


findLineNumberForInstruction

public int findLineNumberForInstruction(Offset instructionOffset)
Description copied from class: CompiledMethod
Find source line number corresponding to one of this method's machine instructions.

Usage note: "instructionOffset" must point to the instruction following the actual instruction whose line number is sought. This allows us to properly handle the case where the only address we have to work with is a return address (ie. from a stackframe) or an exception address (ie. 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".

Overrides:
findLineNumberForInstruction in class CompiledMethod
Parameters:
instructionOffset - of machine instruction from start of this method, in bytes
Returns:
The line number, a positive integer. Zero means unable to find.

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.

findBytecodeIndexForInstruction

public int findBytecodeIndexForInstruction(Offset instructionOffset)
Find bytecode index corresponding to one of this method's machine instructions.

Parameters:
instructionOffset - instruction offset to map to a bytecode index.
Note: This method expects the offset to refer to the machine instruction immediately FOLLOWING the bytecode in question. just like findLineNumberForInstruction. See CompiledMethod for rationale.
NOTE: instructionIndex is in units of instructions, not bytes (different from all the other methods in this interface!!)
Returns:
the bytecode index for the machine instruction, -1 if not available or not found.

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.

printExceptionTable

public void printExceptionTable()
Print the eTable


setLockAcquisitionOffset

public void setLockAcquisitionOffset(int off)
Set the lock acquisition offset for synchronized methods


getLockAcquisitionOffset

public Offset getLockAcquisitionOffset()
Get the lock acquisition offset


setHasCounterArray

void setHasCounterArray()
Set the method has a counters array


hasCounterArray

public boolean hasCounterArray()
Does the method have a counters array?


encodeMappingInfo

public void encodeMappingInfo(ReferenceMaps referenceMaps,
                              int[] bcMap)
Encode/compress the bytecode map, reference (GC) map and exception table

Parameters:
referenceMaps - to encode
bcMap - unencoded bytecode to code array offset map

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