org.jikesrvm.compilers.common
Class CompiledMethods

java.lang.Object
  extended by org.jikesrvm.compilers.common.CompiledMethods
All Implemented Interfaces:
SizeConstants

public class CompiledMethods
extends Object
implements SizeConstants

Manage pool of compiled methods.

Original extracted from RVMClassLoader.


Field Summary
private static CompiledMethod[][] compiledMethods
          Java methods that have been compiled into machine code.
private static int currentCompiledMethodId
          Index of most recently allocated slot in compiledMethods[].
private static int LOG_ROW_SIZE
          2^LOG_ROW_SIZE is the number of elements per row
private static int ROW_MASK
          Mask to ascertain row from id number
private static boolean scanForObsoleteMethods
          Used to communicate between setCompiledMethodObsolete(org.jikesrvm.compilers.common.CompiledMethod) and snipObsoleteCompiledMethods()
 
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
CompiledMethods()
           
 
Method Summary
static CompiledMethod createCompiledMethod(RVMMethod m, int compilerType)
          Create a CompiledMethod appropriate for the given compilerType
static CompiledMethod createHardwareTrapCompiledMethod()
          Create a CompiledMethod for the synthetic hardware trap frame
private static void ensureCapacity(int id)
          Ensure space in backing array for id
static CompiledMethod findMethodForInstruction(Address ip)
          Find the method whose machine code contains the specified instruction.
static CompiledMethod getCompiledMethod(int compiledMethodId)
          Fetch a previously compiled method.
static CompiledMethod getCompiledMethodUnchecked(int cmid)
          Fetch a previously compiled method without checking
static int numCompiledMethods()
          Get number of methods compiled so far.
private static void setCompiledMethod(int cmid, CompiledMethod cm)
          Set entry in compiled method lookup
static void setCompiledMethodObsolete(CompiledMethod compiledMethod)
           
static void snipObsoleteCompiledMethods()
          Snip reference to CompiledMethod so that we can reclaim code space.
static void spaceReport()
          Report on the space used by compiled code and associated mapping information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_ROW_SIZE

private static final int LOG_ROW_SIZE
2^LOG_ROW_SIZE is the number of elements per row

See Also:
Constant Field Values

ROW_MASK

private static final int ROW_MASK
Mask to ascertain row from id number

See Also:
Constant Field Values

compiledMethods

private static CompiledMethod[][] compiledMethods
Java methods that have been compiled into machine code. Note that there may be more than one compiled versions of the same method (i.e. at different levels of optimization).


currentCompiledMethodId

private static int currentCompiledMethodId
Index of most recently allocated slot in compiledMethods[].


scanForObsoleteMethods

private static boolean scanForObsoleteMethods
Used to communicate between setCompiledMethodObsolete(org.jikesrvm.compilers.common.CompiledMethod) and snipObsoleteCompiledMethods()

Constructor Detail

CompiledMethods

public CompiledMethods()
Method Detail

ensureCapacity

private static void ensureCapacity(int id)
Ensure space in backing array for id


getCompiledMethodUnchecked

public static CompiledMethod getCompiledMethodUnchecked(int cmid)
Fetch a previously compiled method without checking


setCompiledMethod

private static void setCompiledMethod(int cmid,
                                      CompiledMethod cm)
Set entry in compiled method lookup


getCompiledMethod

public static CompiledMethod getCompiledMethod(int compiledMethodId)
Fetch a previously compiled method.


createCompiledMethod

public static CompiledMethod createCompiledMethod(RVMMethod m,
                                                  int compilerType)
Create a CompiledMethod appropriate for the given compilerType


createHardwareTrapCompiledMethod

public static CompiledMethod createHardwareTrapCompiledMethod()
Create a CompiledMethod for the synthetic hardware trap frame


numCompiledMethods

public static int numCompiledMethods()
Get number of methods compiled so far.


findMethodForInstruction

public static CompiledMethod findMethodForInstruction(Address ip)
Find the method whose machine code contains the specified instruction.

Assumption: caller has disabled gc (otherwise collector could move objects without fixing up the raw ip pointer)

Note: this method is highly inefficient. Normally you should use the following instead: RVMClassLoader.getCompiledMethod(Magic.getCompiledMethodID(fp))

Parameters:
ip - instruction address. Usage note: ip must point to the instruction *following* the actual instruction whose method 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".
Returns:
method (null --> not found)

setCompiledMethodObsolete

public static void setCompiledMethodObsolete(CompiledMethod compiledMethod)

snipObsoleteCompiledMethods

public static void snipObsoleteCompiledMethods()
Snip reference to CompiledMethod so that we can reclaim code space. If the code is currently being executed, stack scanning is responsible for marking it NOT obsolete. Keep such reference until a future GC.

NOTE: It's expected that this is processed during GC, after scanning stacks to determine which methods are currently executing.


spaceReport

public static void spaceReport()
Report on the space used by compiled code and associated mapping information