* src/vm/jit/code.c (code_get_stack_frame_size): Implement stack alignment
[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  (16-byte aligned) <<<<
54 V
55 |   u8       return address
56 |   u8[]     arguments on stack
57 V
58
59
60
61 alpha stack frames
62 ------------------
63
64 XXX currently the stack on alpha is not 16-byte aligned!
65
66 ,--memory address rising
67 |
68 V   >>>> sp in method (after initial sub) <<<<
69 |          
70 |   u8[]  v  arguments for calling methods              \__ rd->memuse slots
71 V   u8[]  v  local variable slots allocated on stack    /
72 |
73 |   u8       synchronized object / saved return value       (only for synched methods)
74 V
75 |   u8[]  ^  callee-saved float registers
76 |   u8[]  ^  callee-saved integer registers
77 V
78 |     >>>> !!!replacement code regards this point as stack base!!! <<<<
79 |                 
80 V   u8    ^  saved return address                           (only for non-leaf methods)
81 |
82 |   >>>> sp on method entry <<<<
83 V
84 |   u8[]     arguments on stack
85 |
86 V
87
88
89 mips stack frames
90 -----------------
91
92 ,--memory address rising
93 |
94 V   >>>> sp in method (after initial sub) (16-byte aligned) <<<<
95 |          
96 |   u8[]  v  arguments for calling methods              \__ rd->memuse slots
97 V   u8[]  v  local variable slots allocated on stack    /
98 |
99 |   u8       synchronized object / saved return value       (only for synched methods)
100 |   u8[0..1] alignment dummy-slot                           (to ensure 16-byte alignment of sp)
101 V
102 |   u8[]  ^  callee-saved float registers
103 |   u8[]  ^  callee-saved integer registers
104 V
105 |     >>>> !!!replacement code regards this point as stack base!!!  <<<<
106 |                 
107 V   u8    ^  saved return address                           (only for non-leaf methods)
108 |
109 |   >>>> sp on method entry (16-byte aligned) <<<<
110 V
111 |   u8[]     arguments on stack
112 |
113 V
114