public abstract class OutOfLineMachineCode extends Object
Hand coding of small inline instruction sequences is typically handled by each compiler's implementation of Magic methods. A few Magic methods are so complex that their implementations require many instructions. But our compilers do not inline arbitrary amounts of machine code. We therefore write such code blocks here, out of line.
These code blocks can be shared by all compilers. They can be branched to via a jtoc offset (obtained from Entrypoints.XXXInstructionsField).
Modifier and Type | Field and Description |
---|---|
private static Offset |
CODE_FP_OFFSET |
private static Offset |
FPRMETA_FP_OFFSET |
private static Offset |
FPRS_FP_OFFSET |
private static Offset |
GPRS_FP_OFFSET |
private static Offset |
PARAMS_FP_OFFSET |
private static CodeArray |
pcThunkEAXInstructions |
private static CodeArray |
pcThunkEBPInstructions |
private static CodeArray |
pcThunkEBXInstructions |
private static CodeArray |
pcThunkECXInstructions |
private static CodeArray |
pcThunkEDIInstructions |
private static CodeArray |
pcThunkEDXInstructions |
private static CodeArray |
pcThunkESIInstructions |
static RVMField[] |
pcThunkInstructionsField |
private static CodeArray |
reflectiveMethodInvokerInstructions |
private static CodeArray |
restoreHardwareExceptionStateInstructions |
private static CodeArray |
saveThreadStateInstructions |
private static CodeArray |
threadSwitchInstructions |
Constructor and Description |
---|
OutOfLineMachineCode() |
Modifier and Type | Method and Description |
---|---|
private static void |
generatePcThunkInstructions()
Machine code to get the address of the instruction after the call to this
method
|
private static CodeArray |
generateReflectiveMethodInvokerInstructions()
Machine code for reflective method invocation.
|
private static CodeArray |
generateRestoreHardwareExceptionStateInstructions()
Machine code to implement "Magic.restoreHardwareExceptionState()".
|
private static CodeArray |
generateSaveThreadStateInstructions()
Machine code to implement "Magic.saveThreadState()".
|
private static CodeArray |
generateStackTrampolineBridgeInstructions()
Machine code to perform a stack trampoline bridge for
implementing a return barrier.
|
private static CodeArray |
generateThreadSwitchInstructions()
Machine code to implement "Magic.threadSwitch()".
|
static void |
init() |
public static final RVMField[] pcThunkInstructionsField
private static CodeArray pcThunkEAXInstructions
private static CodeArray pcThunkEBXInstructions
private static CodeArray pcThunkECXInstructions
private static CodeArray pcThunkEDXInstructions
private static CodeArray pcThunkEBPInstructions
private static CodeArray pcThunkESIInstructions
private static CodeArray pcThunkEDIInstructions
private static CodeArray reflectiveMethodInvokerInstructions
private static CodeArray saveThreadStateInstructions
private static CodeArray threadSwitchInstructions
private static CodeArray restoreHardwareExceptionStateInstructions
private static final Offset PARAMS_FP_OFFSET
private static final Offset FPRMETA_FP_OFFSET
private static final Offset FPRS_FP_OFFSET
private static final Offset GPRS_FP_OFFSET
private static final Offset CODE_FP_OFFSET
public OutOfLineMachineCode()
public static void init()
private static void generatePcThunkInstructions()
private static CodeArray generateReflectiveMethodInvokerInstructions()
VM compiled with NUM_PARAMETERS_GPRS == 0 Registers taken at runtime: none Stack taken at runtime: hi-mem address of method entrypoint to be called address of gpr registers to be loaded address of fpr registers to be loaded address of parameters area in calling frame return address low-mem VM compiled with NUM_PARAMETERS_GPRS == 1 T0 == address of method entrypoint to be called Stack taken at runtime: hi-mem space ??? address of gpr registers to be loaded address of fpr registers to be loaded address of parameters area in calling frame return address low-mem VM compiled with NUM_PARAMETERS_GPRS == 2 T0 == address of method entrypoint to be called T1 == address of gpr registers to be loaded Stack taken at runtime: hi-mem space ??? space ??? address of fpr registers to be loaded address of parameters area in calling frame return address low-mem Registers returned at runtime: standard return value conventions used Side effects at runtime: artificial stackframe created and destroyed volatile, and scratch registers destroyed
private static CodeArray generateSaveThreadStateInstructions()
Registers taken at runtime: T0 == address of Registers object Registers returned at runtime: none Side effects at runtime: S0, T1 destroyed Thread state stored into Registers object
private static CodeArray generateStackTrampolineBridgeInstructions()
This code is used to hijack a return and bridge to some other method (which implements the return barrier) before falling back to the intended return address.
The key here is to preserve register and stack state so that the caller is oblivious of the detour that occurred during the return.
private static CodeArray generateThreadSwitchInstructions()
NOTE: Currently not functional for PNT: left as a guide for possible reimplementation. Parameters taken at runtime: T0 == address of Thread object for the current thread T1 == address of Registers object for the new thread Registers returned at runtime: none Side effects at runtime: sets current Thread's beingDispatched field to false saves current Thread's nonvolatile hardware state in its Registers object restores new thread's Registers nonvolatile hardware state. execution resumes at address specificed by restored thread's Registers ip field
private static CodeArray generateRestoreHardwareExceptionStateInstructions()
Registers taken at runtime: T0 == address of Registers object Registers returned at runtime: none Side effects at runtime: all registers are restored except THREAD_REGISTER and EFLAGS; execution resumes at "registers.ip"