Skip to end of metadata
Go to start of metadata

AIX/PowerPC VM Conventions

This section describes register, stack, and calling conventions that apply to Jikes RVM on AIX/PowerPC.

Stackframe layout and calling conventions may evolve as our understanding of Jikes RVM's performance improves. Where possible, API's should be used to protect code against such changes. In particular, we may move to the AIX conventions at a later date. Where code differs from the AIX conventions, it should be marked with a comment to that effect containing the string "AIX".
Register conventions

Registers (general purpose, gp, and floating point, fp) can be roughly categorized into four types:

  • Scratch: Needed for method prologue/epilogue. Can be used by compiler between calls.
  • Dedicated: Reserved registers with known contents:
    • JTOC - Jikes RVM Table Of Contents. Globally accessible data: constants, static fields and methods.
    • FP - Frame Pointer Current stack frame (thread specific).
    • PR - Processor register. An object representing the current virtual processor (the one executing on the CPU containing these registers). A field in this object contains a reference to the object representing the RVMThread being executed.
  • Volatile ("caller save", or "parameter"): Like scratch registers, these can be used by the compiler as temporaries, but they are not preserved across calls. Volatile registers differ from scratch registers in that volatiles can be used to pass parameters and result(s) to and from methods.
  • Nonvolatile ("callee save", or "preserved"): These can be used (and are preserved across calls), but they must be saved on method entry and restored at method exit. Highest numbered registers are to be used first. (At least initially, nonvolatile registers will not be used to pass parameters.)
  • Condition Register's 4-bit fields: We follow the AIX conventions to minimize cost in JNI transitions between C and Java code. The baseline compiler only uses CR0. The opt compiler allocates CR0, CR1, CR5 and CR6 and reserves CR7 for use in yieldpoints. None of the compilers use CR2, CR3, or CR4 to avoid saving/restoring condition registers when doing a JNI transition from C to Java code.
    • CR0, CR1, CR5, CR6, CR7 - volatile
    • CR2, CR3, CR4 - non-volatile

Stack conventions

Stacks grow from high memory to low memory. The layout of the stackframe appears in a block comment in ppc/StackframeLayoutConstants.java.

Calling Conventions

Parameters

All parameters (that fit) are passed in VOLATILE registers. Object reference and int parameters (or results) consume one GP register; long parameters, two gp registers (low-order half in the first); float and double parameters, one fp register. Parameters are assigned to registers starting with the lowest volatile register through the highest volatile register of the required kind (gp or fp).

Any additional parameters are passed on the stack in a parameter spill area of the caller's stack frame. The first spilled parameter occupies the lowest memory slot. Slots are filled in the order that parameters are spilled.

An int, or object reference, result is returned in the first volatile gp register; a float or double result is returned in the first volatile fp register; a long result is returned in the first two volatile gp registers (low-order half in the first);

Method prologue responsibilities

(some of these can be omitted for leaf methods):

  1. Execute a stackoverflow check, and grow the thread stack if necessary.
  2. Save the caller's next instruction pointer (callee's return address, from the Link Register).
  3. Save any nonvolatile floating-point registers used by callee.
  4. Save any nonvolatile general-purpose registers used by callee.
  5. Store and update the frame pointer FP.
  6. Store callee's compiled method ID
  7. Check to see if the Java thread must yield the Processor (and yield if threadswitch was requested).

Method epilogue responsibilities

(some of these can be ommitted for leaf methods):

  1. Restore FP to point to caller's stack frame.
  2. Restore any nonvolatile general-purpose registers used by callee.
  3. Restore any nonvolatile floating-point registers used by callee.
  4. Branch to the return address in caller.

Linux/x86-32 VM Conventions

This section describes register, stack, and calling conventions that apply to Jikes RVM on Linux®/x86-32.

Register conventions

  • EAX: First GPR parameter register, first GPR result value (high-order part of a long result), otherwise volatile (caller-save).
  • ECX: Scratch.
  • EDX: Second GPR parameter register, second GPR result value (low-order part of a long result), otherwise volatile (caller-save).
  • EBX: Nonvolatile.
  • ESP: Stack pointer.
  • EBP: Nonvolatile.
  • ESI: Processor register, reference to the Processor object for the current virtual processor.
  • EDI: Nonvolatile. (used to hold JTOC in baseline compiled code)

Stack conventions

Stacks grow from high memory to low memory. The layout of the stackframe appears in a block comment in ia32/StackframeLayoutConstants.java.

Calling Conventions

At the beginning of callee's prologue

The first two areas of the callee's stackframe (see above) have been established. ESP points to caller's return address. Parameters from caller to callee are as mandated by ia32/RegisterConstants.java.

After callee's epilogue

Callee's stackframe has been removed. ESP points to the word above where callee's frame was. The framePointer field of the Processor object pointed to by ESI points to A's frame. If B returns a floating-point result, this is at the top of the fp register stack. If B returns a long, the low-order word is in EAX and the high-order word is in EDX. Otherwise, if B has a result, it is in EAX.

OS X VM Conventions

Calling Conventions

The calling conventions we use for OS X are the same as those listed at:

http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachORuntime/MachORuntime.pdf

They're similar to the Linux PowerPC calling conventions. One major difference is how the two operating systems handle the case of a long parameter when you only have a single parameter register left.

  • No labels