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: 1998/11/05
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 The other registers are used according to the standard Alpha calling
33 conventions. Here is a summary of the usage:
38 R0 ........ method result value for types INT, LONG and ADDRESS
40 R1-R8 ..... temporary registers (destroyed by called method)
42 R9-R15 .... saved registers (left unchanged by called method)
44 R16-R21 ... argument registers 0 - 5 (contain the first six method arguments
45 of type INT, LONG and ADDRESS. Argument registers are destroyed
48 R22-R24 ... temporary registers (destroyed by called method)
50 R25 ....... code generator temporary register (destroyed by called method)
52 R26 (ra) .. return address (left unchanged by called method)
54 R27 (pv) .. procedure vector, points to the first instruction of the called
55 method. This vector is used for addressing the entries in the
56 data segment. The ov of the caller is recomputed from the ra.
57 Therefore it is necessary that a return is always done using ra.
59 R28 ....... pointer to 'methodinfo' structure. This register has to be set
60 correctly, because it is needed in the case the jit is invoked.
61 Also used as code generator temporary register. It isdestroyed
64 R29 ....... code generator temporary register (destroyed by called method)
66 R30 (sp) .. stack pointer. The stack grows from high to low.
68 R31 ....... always contains zero
71 floating point registers:
73 F0 ........ method result value for types FLOAT and DOUBLE
75 F1 ........ temporary register (destroyed by called method)
77 F2-F9 ..... saved registers (left unchanged by called method)
79 F10-F15 ... temporary registers (destroyed by called method)
81 F16-F21 ... argument registers 0 - 5 (contain the first six method arguments
82 of type FLOAT and DOUBLE. Argument registers are destroyed
84 F22-F27 ... temporary registers (destroyed by called method)
86 F28-F30 ... code generator temporary register (destroyed by called method)
88 F31 ....... always contains zero
93 PARAMETER PASSING ON THE STACK:
95 Only six parameters can be passed in registers, so every argument beginning
96 from the seventh needs to use the stack, according to the following
101 --------------------------------------------------
102 | Parameter 9 ( 64 bit regardless of type) |
103 --------------------------------------------------
104 | Parameter 8 ( 64 bit regardless of type) |
105 --------------------------------------------------
106 R30 (sp) ---> | Parameter 7 ( 64 bit regardless of type) |
107 --------------------------------------------------
109 The stack pointer points at the bottom of the parameter passing area.
115 ENTIRE STACK FRAME LAYOUT:
117 Each method (except leaf methods which make no further calls) need to save
118 some registers on the stack. Possibly a method also needs to use part of the
119 stack frame as spill area for local values. Parameter passing for more than
120 six parameters requires stack space as well.
122 An entire stack frame looks like this (each entry is exactly 64 bits long,
123 sizes are given in multiples of 64 bit units):
125 ---------------------------------------------
126 | parameter n (passed from caller) |
127 ---------------------------------------------
129 ---------------------------------------------
131 ---------------------------------------------
133 old SP ---> ============================================= --- parentargs_base
135 --------------------------------------------- savedregs_num
136 | others saved registers |
137 ============================================= --- maxmemuse + 1
138 | optional monitor_exit argument |
139 ============================================= --- maxmemuse
140 | area for spilled registers |
141 =============================================
143 ---------------------------------------------
145 ---------------------------------------------
146 | parameter 7 (passed to called method) |
147 new SP ---> =============================================