1 /* calling.doc *****************************************************************
3 Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
5 See file COPYRIGHT for information on usage and disclaimer of warranties
7 A short description of Alpha calling conventions and register usage.
9 Authors: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at
10 Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at
12 Last Change: 2003/03/07
14 *******************************************************************************/
16 Short documentation of the Java calling conventions for the Alpha.
18 --------------------------------------------------------------------------------
21 The calling conventions basically follow the conventions for normal C
22 functions. However, the R28 register has a special meaning:
24 R28 ..... contains a pointer to the correct 'methodinfo' structure for this
25 method, in case it has to be passed on to the JIT compiler.
27 If Java methods call C functions directly (C functions don't have
28 'methodinfo' structures associated naturally), the value of this
29 register is undefined. Every function called by the JavaVM
30 (builtin_new, etc.) is called this way.
32 R27 (pv) This register needs to maintain its value all the time. It must
33 be restored after each method call. More importantly, the code
34 sequence for this operation is standardized and is interpreted
35 by the exception handling code.
38 The other registers are used according to the standard Alpha calling
39 conventions. Here is a summary of the usage:
44 R0 ........ method result value for types INT, LONG and ADDRESS
46 R1-R8 ..... temporary registers (destroyed by called method)
48 R9-R15 .... saved registers (left unchanged by called method)
50 R16-R21 ... argument registers 0 - 5 (contain the first six method arguments
51 of type INT, LONG and ADDRESS. Argument registers are destroyed
54 R22-R24 ... temporary registers (destroyed by called method)
56 R25 ....... code generator temporary register (destroyed by called method)
58 R26 (ra) .. return address (left unchanged by called method)
60 R27 (pv) .. procedure vector, points to the first instruction of the called
61 method. This vector is used for addressing the entries in the
62 data segment. The ov of the caller is recomputed from the ra.
63 Therefore it is necessary that a return is always done using ra.
65 R28 ....... pointer to 'methodinfo' structure. This register has to be set
66 correctly, because it is needed in the case the jit is invoked.
67 Also used as code generator temporary register. It isdestroyed
70 R29 ....... code generator temporary register (destroyed by called method)
72 R30 (sp) .. stack pointer. The stack grows from high to low.
74 R31 ....... always contains zero
77 floating point registers:
79 F0 ........ method result value for types FLOAT and DOUBLE
81 F1 ........ temporary register (destroyed by called method)
83 F2-F9 ..... saved registers (left unchanged by called method)
85 F10-F15 ... temporary registers (destroyed by called method)
87 F16-F21 ... argument registers 0 - 5 (contain the first six method arguments
88 of type FLOAT and DOUBLE. Argument registers are destroyed
90 F22-F27 ... temporary registers (destroyed by called method)
92 F28-F30 ... code generator temporary register (destroyed by called method)
94 F31 ....... always contains zero
99 PARAMETER PASSING ON THE STACK:
101 Only six parameters can be passed in registers, so every argument beginning
102 from the seventh needs to use the stack, according to the following
107 --------------------------------------------------
108 | Parameter 9 ( 64 bit regardless of type) |
109 --------------------------------------------------
110 | Parameter 8 ( 64 bit regardless of type) |
111 --------------------------------------------------
112 R30 (sp) ---> | Parameter 7 ( 64 bit regardless of type) |
113 --------------------------------------------------
115 The stack pointer points at the bottom of the parameter passing area.
121 ENTIRE STACK FRAME LAYOUT:
123 Each method (except leaf methods which make no further calls) need to save
124 some registers on the stack. Possibly a method also needs to use part of the
125 stack frame as spill area for local values. Parameter passing for more than
126 six parameters requires stack space as well.
128 An entire stack frame looks like this (each entry is exactly 64 bits long,
129 sizes are given in multiples of 64 bit units):
131 ---------------------------------------------
132 | parameter n (passed from caller) |
133 ---------------------------------------------
135 ---------------------------------------------
137 ---------------------------------------------
139 old SP ---> ============================================= --- parentargs_base
141 --------------------------------------------- savedregs_num
142 | others saved registers |
143 ============================================= --- maxmemuse + 1
144 | optional monitor_exit argument |
145 ============================================= --- maxmemuse
146 | area for spilled registers |
147 =============================================
149 ---------------------------------------------
151 ---------------------------------------------
152 | parameter 7 (passed to called method) |
153 new SP ---> =============================================