public class RuntimeCompiler extends Object implements Callbacks.ExitMonitor
A place to put code common to all runtime compilers. This includes instrumentation code to get equivalent data for each of the runtime compilers.
We collect the following data for each compiler
Modifier and Type | Field and Description |
---|---|
static byte |
BASELINE_COMPILER |
protected static boolean |
compilationInProgress
is opt compiler currently in use?
|
protected static boolean |
compilerEnabled
is the opt compiler usable?
|
private static String[] |
earlyOptArgs |
static byte |
JNI_COMPILER |
private static String[] |
name |
static byte |
OPT_COMPILER |
static Object |
optimizationPlan |
static Object |
options |
private static int[] |
totalBCLength |
private static double[] |
totalCompTime |
private static double[] |
totalLogOfRates |
private static int[] |
totalLogValueMethods |
private static int[] |
totalMCLength |
private static int[] |
totalMethods |
Constructor and Description |
---|
RuntimeCompiler() |
Modifier and Type | Method and Description |
---|---|
static CompiledMethod |
baselineCompile(NormalMethod method)
This method will compile the passed method using the baseline compiler.
|
static void |
boot() |
static CompiledMethod |
compile(NativeMethod method)
Compile the stub for a native method when it is first invoked.
|
static CompiledMethod |
compile(NormalMethod method)
Compile a Java method when it is first invoked.
|
protected static CompiledMethod |
fallback(NormalMethod method)
This method uses the default compiler (baseline) to compile a method
It is typically called when a more aggressive compilation fails.
|
static double |
getBaselineRate() |
static String |
getCompilerName(byte compiler)
returns the string version of compiler number, using the naming scheme
in this file
|
static long |
getTotalCompilationTime() |
static double |
getTotalCompilationTime(byte compilerType)
Returns the total compilation time of compiler number, using the naming scheme
from this class
|
void |
notifyExit(int value)
To be called when the VM is about to exit.
|
private static CompiledMethod |
optCompile(NormalMethod method,
CompilationPlan plan)
Attempt to compile the passed method with the Compiler.
|
static CompiledMethod |
optCompileWithFallBack(NormalMethod method)
This method tries to compile the passed method with the Compiler,
using the default compilation plan.
|
static CompiledMethod |
optCompileWithFallBack(NormalMethod method,
CompilationPlan plan)
This method tries to compile the passed method with the Compiler
with the passed compilation plan.
|
private static CompiledMethod |
optCompileWithFallBackInternal(NormalMethod method,
CompilationPlan plan)
This real method that performs the opt compilation.
|
static void |
processCommandLineArg(String prefix,
String arg) |
static void |
processOptCommandLineArg(String prefix,
String arg)
Processes a command line argument destined for the opt compiler.
|
static int |
recompileWithOpt(CompilationPlan plan)
This method tries to compile the passed method with the Compiler.
|
static int |
recompileWithOpt(NormalMethod method)
A wrapper method for those callers who don't want to make
optimization plans
|
static CompiledMethod |
recompileWithOptOnStackSpecialization(CompilationPlan plan) |
static void |
record(byte compiler,
NativeMethod method,
CompiledMethod compiledMethod)
This method records the time and sizes (bytecode and machine code) for
a compilation
|
static void |
record(byte compiler,
NormalMethod method,
CompiledMethod compiledMethod)
This method records the time and sizes (bytecode and machine code) for
a compilation.
|
private static void |
recordCompilation(byte compiler,
int BCLength,
int MCLength,
double compTime)
This method does the actual recording
|
static void |
report(boolean explain)
This method produces a summary report of compilation activities
|
public static final byte JNI_COMPILER
public static final byte BASELINE_COMPILER
public static final byte OPT_COMPILER
private static int[] totalMethods
private static double[] totalCompTime
private static int[] totalBCLength
private static int[] totalMCLength
private static double[] totalLogOfRates
private static int[] totalLogValueMethods
private static String[] earlyOptArgs
protected static boolean compilerEnabled
protected static boolean compilationInProgress
NOTE: The associated code can be quite subtle, so please be absolutely sure you know what you're doing before modifying it!!!
public static Object optimizationPlan
public RuntimeCompiler()
public void notifyExit(int value)
notifyExit
in interface Callbacks.ExitMonitor
value
- the exit valuepublic static void record(byte compiler, NormalMethod method, CompiledMethod compiledMethod)
compiler
- the compiler usedmethod
- the resulting RVMMethodcompiledMethod
- the resulting compiled methodpublic static void record(byte compiler, NativeMethod method, CompiledMethod compiledMethod)
compiler
- the compiler usedmethod
- the resulting RVMMethodcompiledMethod
- the resulting compiled methodprivate static void recordCompilation(byte compiler, int BCLength, int MCLength, double compTime)
compiler
- the compiler usedBCLength
- the number of bytecodes in method sourceMCLength
- the length of the generated machine codecompTime
- the compilation time in mspublic static void report(boolean explain)
explain
- Explains the metrics used in the reportpublic static double getBaselineRate()
public static CompiledMethod baselineCompile(NormalMethod method)
method
- the method to compilepublic static void processOptCommandLineArg(String prefix, String arg)
prefix
- the prefix, e.g. "-X:opt:"arg
- everything after the last ':'private static CompiledMethod optCompile(NormalMethod method, CompilationPlan plan) throws OptimizingCompilerException
Precondition: compilationInProgress "lock" has been acquired
method
- the method to compileplan
- the plan to use for compiling the methodOptimizingCompilerException
public static CompiledMethod optCompileWithFallBack(NormalMethod method)
method
- the method to compilepublic static CompiledMethod optCompileWithFallBack(NormalMethod method, CompilationPlan plan)
method
- the method to compileplan
- the compilation plan to use for the compileprivate static CompiledMethod optCompileWithFallBackInternal(NormalMethod method, CompilationPlan plan)
method
- the method to compileplan
- the compilation plan to usepublic static CompiledMethod recompileWithOptOnStackSpecialization(CompilationPlan plan)
public static int recompileWithOpt(CompilationPlan plan)
NOTE: the recompile method should never be invoked via RuntimeCompiler.compile; it does not have sufficient guards against recursive recompilation.
plan
- the compilation plan to usepublic static int recompileWithOpt(NormalMethod method)
method
- the method to recompileprotected static CompiledMethod fallback(NormalMethod method)
method
- method to compilepublic static void boot()
public static void processCommandLineArg(String prefix, String arg)
public static CompiledMethod compile(NormalMethod method)
method
- the method to compilepublic static CompiledMethod compile(NativeMethod method)
method
- the method to compilepublic static String getCompilerName(byte compiler)
compiler
- the compiler of interestpublic static long getTotalCompilationTime()
public static double getTotalCompilationTime(byte compilerType)
compilerType
- the compiler of interest