* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / doc / stack_frames.txt
1 STACK FRAME FORMAT
2 =====================
3 Author: Edwin Steiner
4
5
6 Overview
7 --------
8
9 For the sake of efficiency CACAO uses its own stack frame layout that does
10 not comply with the usual frame layout on the native ABI. This document
11 tries to collect the stack frame layouts used on the various architectures.
12
13
14 i386 stack frames
15 -----------------
16
17 ,--memory address rising
18 |
19 V   >>>> sp in method (after initial sub) <<<<
20 |          
21 |   u4[]  v  arguments for calling methods              \__ rd->memuse slots
22 V   u4[]  v  local variable slots allocated on stack    /
23 |
24 |   u4[1..2] synchronized object / saved return value       (only for synched methods)
25 V
26 |   u8[]  ^  callee-saved float registers
27 |   u4[]  ^  callee-saved integer registers
28 V          
29 |   >>>> sp on method entry, stack base for replacement <<<<
30 |
31 V   u4       return address
32 |   u4[]     arguments on stack
33 |
34 V
35
36
37 x86_64 stack frames
38 -----------------
39
40 ,--memory address rising
41 |
42 V   >>>> sp in method (after initial sub) (16-byte aligned in non-leaf methods) <<<<
43 |          
44 |   u8[]  v  arguments for calling methods              \__ rd->memuse slots
45 V   u8[]  v  local variable slots allocated on stack    /
46 |
47 |   u8    v  synchronized object / saved return value       (only for synched methods)
48 V   u8[0..1] alignment dummy slot                           (in non-leaf methods to ensure
49 |                                                            16-byte alignment of stack)
50 |   u8[]  ^  callee-saved float registers
51 V   u8[]  ^  callee-saved integer registers
52 |          
53 |   >>>> sp on method entry, stack base for replacement  (8-byte odd) <<<<
54 V
55 |   u8       return address
56 |
57 V                                                 >>>>> (16-byte aligned) <<<<
58 |
59 |   u8[]     arguments on stack
60 V
61
62
63
64 alpha stack frames
65 ------------------
66
67 ,--memory address rising
68 |
69 V   >>>> sp in method (after initial sub) <<<<
70 |          
71 |   u8[]  v  arguments for calling methods              \__ rd->memuse slots
72 V   u8[]  v  local variable slots allocated on stack    /
73 |
74 |   u8       synchronized object / saved return value       (only for synched methods)
75 |   u8[0..1] alignment dummy slot
76 V
77 |   u8[]  ^  callee-saved float registers
78 |   u8[]  ^  callee-saved integer registers
79 V
80 |     >>>> !!!replacement code regards this point as stack base!!! <<<<
81 |                 
82 V   u8    ^  saved return address                           (only for non-leaf methods)
83 |
84 |   >>>> sp on method entry <<<<
85 V
86 |   u8[]     arguments on stack
87 |
88 V
89
90
91 mips stack frames
92 -----------------
93
94 ,--memory address rising
95 |
96 V   >>>> sp in method (after initial sub) (16-byte aligned) <<<<
97 |          
98 |   u8[]  v  arguments for calling methods              \__ rd->memuse slots
99 V   u8[]  v  local variable slots allocated on stack    /
100 |
101 |   u8       synchronized object / saved return value       (only for synched methods)
102 |   u8[0..1] alignment dummy slot                           (to ensure 16-byte alignment of sp)
103 V
104 |   u8[]  ^  callee-saved float registers
105 |   u8[]  ^  callee-saved integer registers
106 V
107 |     >>>> !!!replacement code regards this point as stack base!!!  <<<<
108 |                 
109 V   u8    ^  saved return address                           (only for non-leaf methods)
110 |
111 |   >>>> sp on method entry (16-byte aligned) <<<<
112 V
113 |   u8[]     arguments on stack
114 |
115 V
116
117
118 powerpc stack frames
119 --------------------
120
121 ,--memory address rising
122 |
123 V   >>>> sp in method (after initial sub) (16-byte aligned) <<<<
124 |          
125 |   u4[]  v  arguments for calling methods (incl. LA)   \__ rd->memuse slots
126 V   u4[]  v  local variable slots allocated on stack    /
127 |
128 |   u4[2..3] synchronized object / saved return value       (only for synched methods)
129 |   u4[0..3] alignment slots
130 V
131 |   u8[]  ^  callee-saved float registers
132 |   u4[]  ^  callee-saved integer registers
133 V          
134 |   >>>> sp on method entry, stack base for replacement (16-byte aligned) <<<<
135 |
136 |   u4[]     arguments on stack (inludes LA == linkage area)
137 |
138 V
139
140