public abstract class BaselineCompiler extends TemplateCompilerFramework
Platform dependent versions extend this class and define the host of abstract methods defined by TemplateCompilerFramework to complete the implementation of a baseline compiler for a particular target.
In addition to the framework provided by TemplateCompilerFramework, this compiler also provides hooks for bytecode merging for some common bytecode combinations. By default, bytecode merging is active but has no effect. Subclasses that want to implement the merging need to override the hook methods.
TemplateCompilerFramework.BranchCondition, TemplateCompilerFramework.MachineCode
Modifier and Type | Field and Description |
---|---|
private static long |
codeGenNanos |
protected int |
edgeCounterIdx
Next edge counter entry to allocate
|
private static long |
encodingNanos |
private static long |
gcMapNanos |
protected byte[] |
localTypes
The types that locals can take.
|
private static boolean |
mergeBytecodes
Merge commonly adjacent bytecodes?
|
static BaselineOptions |
options
Options used during base compiler execution
|
private static long |
osrSetupNanos |
(package private) ReferenceMaps |
refMaps
Reference maps for method being compiled
|
bcodes, biStart, bytecodeMap, compiledMethod, doesCheckStore, isInterruptible, isUninterruptible, isUnpreemptible, klass, lockOffset, method, shouldPrint, stackHeights
Modifier | Constructor and Description |
---|---|
protected |
BaselineCompiler(BaselineCompiledMethod cm) |
Modifier and Type | Method and Description |
---|---|
private boolean |
basicBlockBoundary() |
static boolean |
checkForActualCall(MethodReference methodToBeCalled)
Indicate if specified Magic method causes a frame to be created on the runtime stack.
|
protected void |
compile()
Top level driver for baseline compilation of a method.
|
static CompiledMethod |
compile(NormalMethod method)
Compile the given method with the baseline compiler.
|
private void |
do_DFcmpGL_if(boolean single,
boolean unorderedGT,
TemplateCompilerFramework.BranchCondition bc)
Handles the bytecode pattern
DFcmpGL; if.. |
private void |
do_lcmp_if(TemplateCompilerFramework.BranchCondition bc)
Handles the bytecode pattern
lcmp; if.. |
protected void |
emit_aload_resolved_getfield(int index,
FieldReference fieldRef)
Emits code to load a reference local variable and then perform a field load
By default, this method emits code for aload and then for resolved_getfield.
|
protected void |
emit_aload(int index)
Emits code to load a reference local variable
|
protected void |
emit_DFcmpGL_if(boolean single,
boolean unorderedGT,
int bTarget,
TemplateCompilerFramework.BranchCondition bc)
Emits code to perform an [df]cmp[gl] followed by ifeq
By default, this method emits code for [df]cmp[gl] and then for ifeq.
|
protected void |
emit_DFcmpGL(boolean single,
boolean unorderedGT)
Emits code to handle all [df]cmp[gl] cases
|
protected void |
emit_iload_caload(int index)
Emits code to load an int local variable and then load from a character array.
|
protected void |
emit_iload(int index)
Emits code to load an int local variable
|
protected void |
emit_lcmp_if(int bTarget,
TemplateCompilerFramework.BranchCondition bc)
Emits code to perform an lcmp followed by ifeq.
|
protected void |
emit_lcmp()
Emit code to implement the lcmp bytecode
|
protected abstract void |
emit_regular_aload(int index)
Emits code to load a reference local variable
|
protected abstract void |
emit_regular_DFcmpGL(boolean single,
boolean unorderedGT)
Emits code to implement the [df]cmp[gl] bytecodes
|
protected abstract void |
emit_regular_iload(int index)
Emits code to load an int local variable
|
protected abstract void |
emit_regular_lcmp()
Emits code to implement the lcmp bytecode
|
static void |
fullyBootedVM()
Now that VM is fully booted, enable options
such as PRINT_MACHINE_CODE that require a fully booted VM.
|
static void |
generateBaselineCompilerSubsystemReport(boolean explain)
Generate a report of time spent in various phases of the baseline compiler.
|
protected String |
getCompilerName() |
protected int |
getEdgeCounterIndex() |
protected Offset |
getEdgeCounterOffset() |
(package private) static short |
getEmptyStackOffset(NormalMethod m) |
(package private) static short |
getFloatLocalLocation(int localIndex,
short[] localFixedLocations,
NormalMethod method) |
(package private) static short |
getGeneralLocalLocation(int localIndex,
short[] localFixedLocations,
NormalMethod method) |
abstract byte |
getLastFixedStackRegister() |
abstract byte |
getLastFloatStackRegister() |
protected abstract void |
initializeCompiler() |
static void |
initOptions()
Clear out crud from bootimage writing
|
static short |
offsetToLocation(int offset) |
static void |
processCommandLineArg(String prefix,
String arg)
Process a command line argument
|
checkTarget, emit_aaload, emit_aastore, emit_aconst_null, emit_areturn, emit_arraylength, emit_astore, emit_athrow, emit_baload, emit_bastore, emit_caload, emit_castore, emit_checkcast_final, emit_checkcast_resolvedClass, emit_checkcast_resolvedInterface, emit_checkcast, emit_d2f, emit_d2i, emit_d2l, emit_dadd, emit_daload, emit_dastore, emit_dconst_0, emit_dconst_1, emit_ddiv, emit_deferred_prologue, emit_dload, emit_dmul, emit_dneg, emit_drem, emit_dreturn, emit_dstore, emit_dsub, emit_dup_x1, emit_dup_x2, emit_dup, emit_dup2_x1, emit_dup2_x2, emit_dup2, emit_f2d, emit_f2i, emit_f2l, emit_fadd, emit_faload, emit_fastore, emit_fconst_0, emit_fconst_1, emit_fconst_2, emit_fdiv, emit_fload, emit_fmul, emit_fneg, emit_frem, emit_freturn, emit_fstore, emit_fsub, emit_goto, emit_i2b, emit_i2c, emit_i2d, emit_i2f, emit_i2l, emit_i2s, emit_iadd, emit_iaload, emit_iand, emit_iastore, emit_iconst, emit_idiv, emit_if_acmpeq, emit_if_acmpne, emit_if_icmp, emit_if, emit_ifnonnull, emit_ifnull, emit_iinc, emit_imul, emit_ineg, emit_instanceof_final, emit_instanceof_resolvedClass, emit_instanceof_resolvedInterface, emit_instanceof, emit_invoke_compiledmethod, emit_invokeinterface, emit_ior, emit_irem, emit_ireturn, emit_ishl, emit_ishr, emit_istore, emit_isub, emit_iushr, emit_ixor, emit_jsr, emit_l2d, emit_l2f, emit_l2i, emit_ladd, emit_laload, emit_land, emit_lastore, emit_lconst, emit_ldc, emit_ldc2, emit_ldiv, emit_lload, emit_lmul, emit_lneg, emit_loadretaddrconst, emit_lookupswitch, emit_lor, emit_lrem, emit_lreturn, emit_lshl, emit_lshr, emit_lstore, emit_lsub, emit_lushr, emit_lxor, emit_Magic, emit_monitorenter, emit_monitorexit, emit_multianewarray, emit_pending_goto, emit_pop, emit_pop2, emit_prologue, emit_resolved_getfield, emit_resolved_getstatic, emit_resolved_invokespecial, emit_resolved_invokestatic, emit_resolved_invokevirtual, emit_resolved_new, emit_resolved_newarray, emit_resolved_putfield, emit_resolved_putstatic, emit_ret, emit_return, emit_saload, emit_sastore, emit_swap, emit_tableswitch, emit_threadSwitchTest, emit_unresolved_getfield, emit_unresolved_getstatic, emit_unresolved_invokespecial, emit_unresolved_invokestatic, emit_unresolved_invokevirtual, emit_unresolved_new, emit_unresolved_newarray, emit_unresolved_putfield, emit_unresolved_putstatic, ending_bytecode, forbiddenBytecode, forbiddenBytecode, genCode, getAssembler, getBytecodeMap, printEndHeader, printMethodMessage, printStartHeader, stackHeightForEmptyBasicBlock, starting_bytecode
private static final boolean mergeBytecodes
private static long gcMapNanos
private static long osrSetupNanos
private static long codeGenNanos
private static long encodingNanos
public static BaselineOptions options
protected int edgeCounterIdx
ReferenceMaps refMaps
protected final byte[] localTypes
protected BaselineCompiler(BaselineCompiledMethod cm)
public abstract byte getLastFixedStackRegister()
public abstract byte getLastFloatStackRegister()
static short getGeneralLocalLocation(int localIndex, short[] localFixedLocations, NormalMethod method)
static short getFloatLocalLocation(int localIndex, short[] localFixedLocations, NormalMethod method)
static short getEmptyStackOffset(NormalMethod m)
public static short offsetToLocation(int offset)
protected final Offset getEdgeCounterOffset()
protected final int getEdgeCounterIndex()
public static boolean checkForActualCall(MethodReference methodToBeCalled)
methodToBeCalled
- RVMMethod of the magic method being calledpublic static void initOptions()
public static void fullyBootedVM()
public static void processCommandLineArg(String prefix, String arg)
prefix
- the argument's prefixarg
- Command line argument with prefix stripped offpublic static void generateBaselineCompilerSubsystemReport(boolean explain)
NB: This method may be called in a context where class loading and/or GC cannot be allowed. Therefore we must use primitive sysWrites for output and avoid string appends and other allocations.
FIXME should this method be uninterruptible?
explain
- Should an explanation of the metrics be generated?public static CompiledMethod compile(NormalMethod method)
method
- the NormalMethod to compile.protected abstract void initializeCompiler()
protected void compile()
protected String getCompilerName()
getCompilerName
in class TemplateCompilerFramework
private boolean basicBlockBoundary()
protected final void emit_iload(int index)
emit_iload
in class TemplateCompilerFramework
index
- the local index to loadprotected abstract void emit_regular_iload(int index)
index
- the local index to loadprotected void emit_iload_caload(int index)
By default, this method emits code for iload and then for caload. Subclasses that want to implement bytecode merging for this pattern must override this method.
index
- the local index to loadprotected final void emit_aload(int index)
emit_aload
in class TemplateCompilerFramework
index
- the local index to loadprotected abstract void emit_regular_aload(int index)
index
- the local index to loadprotected void emit_aload_resolved_getfield(int index, FieldReference fieldRef)
By default, this method emits code for aload and then for resolved_getfield. Subclasses that want to implement bytecode merging for this pattern must override this method.
index
- the local index to loadfieldRef
- the referenced fieldprotected final void emit_lcmp()
TemplateCompilerFramework
emit_lcmp
in class TemplateCompilerFramework
private void do_lcmp_if(TemplateCompilerFramework.BranchCondition bc)
lcmp; if..
bc
- branch conditionprotected abstract void emit_regular_lcmp()
protected void emit_lcmp_if(int bTarget, TemplateCompilerFramework.BranchCondition bc)
By default, this method emits code for lcmp and then for ifeq. Subclasses that want to implement bytecode merging for this pattern must override this method.
bTarget
- target bytecode of the branchbc
- branch conditionprotected final void emit_DFcmpGL(boolean single, boolean unorderedGT)
TemplateCompilerFramework
emit_DFcmpGL
in class TemplateCompilerFramework
single
- true
for float [f], false
for double [d]unorderedGT
- true
for [g], false
for [l]private void do_DFcmpGL_if(boolean single, boolean unorderedGT, TemplateCompilerFramework.BranchCondition bc)
DFcmpGL; if..
single
- true
for float [f], false
for double [d]unorderedGT
- true
for [g], false
for [l]bc
- branch conditionprotected abstract void emit_regular_DFcmpGL(boolean single, boolean unorderedGT)
single
- true
for float [f], false
for double [d]unorderedGT
- true
for [g], false
for [l]protected void emit_DFcmpGL_if(boolean single, boolean unorderedGT, int bTarget, TemplateCompilerFramework.BranchCondition bc)
By default, this method emits code for [df]cmp[gl] and then for ifeq. Subclasses that want to implement bytecode merging for this pattern must override this method.
single
- true
for float [f], false
for double [d]unorderedGT
- true
for [g], false
for [l]bTarget
- target bytecode of the branchbc
- branch condition