@@ -31,8 +31,8 @@ C_FUNC(\Name):
31
31
.endm
32
32
33
33
.macro LEAF_END_MARKED Name , Section
34
- . global C_FUNC(\Name\()_End)
35
34
C_FUNC(\Name\()_End):
35
+ . global C_FUNC(\Name\()_End)
36
36
LEAF_END \Name , \Section
37
37
.endm
38
38
@@ -48,40 +48,54 @@ C_FUNC(\Name\()_End):
48
48
49
49
.macro EPILOG_STACK_FREE Size
50
50
add sp , sp , \Size
51
+ .cfi_adjust_cfa_offset - \Size
51
52
.endm
52
53
53
54
.macro EPILOG_STACK_RESTORE
54
55
mov sp , fp
56
+ .cfi_restore sp
55
57
.endm
56
58
57
59
.macro PROLOG_SAVE_REG reg , ofs
58
60
str \reg , [ sp , \ofs ]
61
+ .cfi_rel_offset \reg , \ofs
59
62
.endm
60
63
61
64
.macro PROLOG_SAVE_REG_PAIR reg1 , reg2 , ofs
62
65
stp \reg1 , \reg2 , [ sp , \ofs ]
66
+ .cfi_rel_offset \reg1 , \ofs
67
+ .cfi_rel_offset \reg2 , \ofs + 8
63
68
.ifc \reg1 , fp
64
69
mov fp , sp
65
70
.endif
66
71
.endm
67
72
68
73
.macro PROLOG_SAVE_REG_PAIR_INDEXED reg1 , reg2 , ofs
69
74
stp \reg1 , \reg2 , [ sp , \ofs ] !
75
+ .cfi_adjust_cfa_offset - \ofs
76
+ .cfi_rel_offset \reg1 , 0
77
+ .cfi_rel_offset \reg2 , 8
70
78
.ifc \reg1 , fp
71
79
mov fp , sp
72
80
.endif
73
81
.endm
74
82
75
83
.macro EPILOG_RESTORE_REG reg , ofs
76
84
ldr \reg , [ sp , \ofs ]
85
+ .cfi_restore \reg1
77
86
.endm
78
87
79
88
.macro EPILOG_RESTORE_REG_PAIR reg1 , reg2 , ofs
80
89
ldp \reg1 , \reg2 , [ sp , \ofs ]
90
+ .cfi_restore \reg1
91
+ .cfi_restore \reg2
81
92
.endm
82
93
83
94
.macro EPILOG_RESTORE_REG_PAIR_INDEXED reg1 , reg2 , ofs
84
95
ldp \reg1 , \reg2 , [ sp ], \ofs
96
+ .cfi_restore \reg1
97
+ .cfi_restore \reg2
98
+ .cfi_adjust_cfa_offset - \ofs
85
99
.endm
86
100
87
101
.macro EPILOG_RETURN
@@ -94,14 +108,14 @@ C_FUNC(\Name\()_End):
94
108
95
109
// -----------------------------------------------------------------------------
96
110
// Define the prolog for a TransitionFrame - based method. This macro should be called first in the method and
97
- // comprises the entire prolog (i.e. don't modify SP after calling this).The locals must be 8 byte aligned
111
+ // comprises the entire prolog (i.e. don't modify SP after calling this).The locals must be 8 byte aligned
98
112
//
99
113
// Stack layout:
100
114
//
101
115
// (stack parameters)
102
116
// ...
103
117
// fp
104
- // lr
118
+ // lr
105
119
// CalleeSavedRegisters::x28
106
120
// CalleeSavedRegisters::x27
107
121
// CalleeSavedRegisters::x26
@@ -133,81 +147,122 @@ C_FUNC(\Name\()_End):
133
147
.macro PROLOG_WITH_TRANSITION_BLOCK extraLocals = 0 , SaveFPArgs = 1
134
148
135
149
__PWTB_FloatArgumentRegisters = \extraLocals
150
+ __PWTB_SaveFPArgs = \SaveFPArgs
136
151
137
152
.if ((__PWTB_FloatArgumentRegisters % 16 ) != 0 )
138
153
__PWTB_FloatArgumentRegisters = __PWTB_FloatArgumentRegisters + 8
139
154
.endif
140
155
141
156
__PWTB_TransitionBlock = __PWTB_FloatArgumentRegisters
142
157
143
- .if \SaveFPArgs > 0
158
+ .if (__PWTB_SaveFPArgs == 1 )
144
159
__PWTB_TransitionBlock = __PWTB_TransitionBlock + SIZEOF__FloatArgumentRegisters
145
160
.endif
146
161
147
162
__PWTB_StackAlloc = __PWTB_TransitionBlock
148
- __PWTB_ArgumentRegisters = __PWTB_StackAlloc + 96
149
-
150
- PROLOG_SAVE_REG_PAIR_INDEXED fp , lr , # - 160
151
- // Spill callee saved registers
152
- PROLOG_SAVE_REG_PAIR x19 , x20 , # 16
153
- PROLOG_SAVE_REG_PAIR x21 , x22 , # 32
154
- PROLOG_SAVE_REG_PAIR x23 , x24 , # 48
155
- PROLOG_SAVE_REG_PAIR x25 , x26 , # 64
156
- PROLOG_SAVE_REG_PAIR x27 , x28 , # 80
157
-
163
+ __PWTB_ArgumentRegisters = __PWTB_StackAlloc + 96
164
+
165
+ PROLOG_SAVE_REG_PAIR_INDEXED fp , lr , - 176
166
+ // Spill callee saved registers
167
+ PROLOG_SAVE_REG_PAIR x19 , x20 , 16
168
+ PROLOG_SAVE_REG_PAIR x21 , x22 , 32
169
+ PROLOG_SAVE_REG_PAIR x23 , x24 , 48
170
+ PROLOG_SAVE_REG_PAIR x25 , x26 , 64
171
+ PROLOG_SAVE_REG_PAIR x27 , x28 , 80
172
+
158
173
// Allocate space for the rest of the frame
159
174
PROLOG_STACK_ALLOC __PWTB_StackAlloc
160
-
175
+
161
176
// Spill argument registers.
162
177
SAVE_ARGUMENT_REGISTERS sp , __PWTB_ArgumentRegisters
163
178
164
- .if \SaveFPArgs > 0
179
+ .if (__PWTB_SaveFPArgs == 1 )
165
180
SAVE_FLOAT_ARGUMENT_REGISTERS sp , \extraLocals
166
181
.endif
167
182
168
183
.endm
169
184
170
185
// -----------------------------------------------------------------------------
171
- // The Following sets of SAVE_ * _REGISTERS expect the memory to be reserved and
186
+ // The Following sets of SAVE_ * _REGISTERS expect the memory to be reserved and
172
187
// base address to be passed in $ reg
173
188
//
174
189
175
190
// Reserve 64 bytes of memory before calling SAVE_ARGUMENT_REGISTERS
176
- .macro SAVE_ARGUMENT_REGISTERS reg , ofs
191
+ .macro SAVE_ARGUMENT_REGISTERS reg , ofs
177
192
178
193
stp x0 , x1 , [ \reg , #(\ofs) ]
194
+ .cfi_rel_offset x0 , \ofs
195
+ .cfi_rel_offset x1 , \ofs + 8
179
196
stp x2 , x3 , [ \reg , #(\ofs + 16 ) ]
197
+ .cfi_rel_offset x2 , \ofs + 16
198
+ .cfi_rel_offset x3 , \ofs + 24
180
199
stp x4 , x5 , [ \reg , #(\ofs + 32 ) ]
200
+ .cfi_rel_offset x4 , \ofs + 32
201
+ .cfi_rel_offset x5 , \ofs + 40
181
202
stp x6 , x7 , [ \reg , #(\ofs + 48 ) ]
203
+ .cfi_rel_offset x6 , \ofs + 48
204
+ .cfi_rel_offset x7 , \ofs + 56
205
+ str x8 , [ \reg , #(\ofs + 64 ) ]
206
+ .cfi_rel_offset x8 , \ofs + 64
182
207
183
208
.endm
184
209
185
210
// Reserve 64 bytes of memory before calling SAVE_FLOAT_ARGUMENT_REGISTERS
186
- .macro SAVE_FLOAT_ARGUMENT_REGISTERS reg , ofs
211
+ .macro SAVE_FLOAT_ARGUMENT_REGISTERS reg , ofs
187
212
188
213
stp d0 , d1 , [ \reg , #(\ofs) ]
214
+ .cfi_rel_offset d0 , \ofs + 0
215
+ .cfi_rel_offset d1 , \ofs + 8
189
216
stp d2 , d3 , [ \reg , #(\ofs + 16 ) ]
217
+ .cfi_rel_offset d2 , \ofs + 16
218
+ .cfi_rel_offset d3 , \ofs + 24
190
219
stp d4 , d5 , [ \reg , #(\ofs + 32 ) ]
220
+ .cfi_rel_offset d4 , \ofs + 32
221
+ .cfi_rel_offset d5 , \ofs + 40
191
222
stp d6 , d7 , [ \reg , #(\ofs + 48 ) ]
223
+ .cfi_rel_offset d6 , \ofs + 48
224
+ .cfi_rel_offset d7 , \ofs + 56
192
225
193
226
.endm
194
227
195
- .macro RESTORE_ARGUMENT_REGISTERS reg , ofs
228
+ .macro RESTORE_ARGUMENT_REGISTERS reg , ofs
196
229
197
230
ldp x0 , x1 , [ \reg , #(\ofs) ]
231
+ .cfi_restore x0
232
+ .cfi_restore x1
198
233
ldp x2 , x3 , [ \reg , #(\ofs + 16 ) ]
234
+ .cfi_restore x2
235
+ .cfi_restore x3
199
236
ldp x4 , x5 , [ \reg , #(\ofs + 32 ) ]
237
+ .cfi_restore x4
238
+ .cfi_restore x5
200
239
ldp x6 , x7 , [ \reg , #(\ofs + 48 ) ]
240
+ .cfi_restore x6
241
+ .cfi_restore x7
242
+ ldr x8 , [ \reg , #(\ofs + 64 ) ]
243
+ .cfi_restore x8
201
244
202
245
.endm
203
246
204
- .macro RESTORE_FLOAT_ARGUMENT_REGISTERS reg , ofs
247
+ .macro RESTORE_FLOAT_ARGUMENT_REGISTERS reg , ofs
205
248
206
249
ldp d0 , d1 , [ \reg , #(\ofs) ]
250
+ .cfi_restore d0
251
+ .cfi_restore d1
207
252
ldp d2 , d3 , [ \reg , #(\ofs + 16 ) ]
253
+ .cfi_restore d2
254
+ .cfi_restore d3
208
255
ldp d4 , d5 , [ \reg , #(\ofs + 32 ) ]
256
+ .cfi_restore d4
257
+ .cfi_restore d5
209
258
ldp d6 , d7 , [ \reg , #(\ofs + 48 ) ]
259
+ .cfi_restore d6
260
+ .cfi_restore d7
261
+
262
+ .endm
210
263
264
+ .macro EPILOG_BRANCH Target
265
+ b \Target
211
266
.endm
212
267
213
268
.macro EPILOG_BRANCH_REG reg
@@ -216,40 +271,42 @@ C_FUNC(\Name\()_End):
216
271
217
272
.endm
218
273
219
- // -----------------------------------------------------------------------------
220
- // Provides a matching epilog to PROLOG_WITH_TRANSITION_BLOCK and ends by preparing for tail - calling.
221
- // Since this is a tail call argument registers are restored.
222
- //
223
- .macro EPILOG_WITH_TRANSITION_BLOCK_TAILCALL extraLocals = 0 , SaveFPArgs = 1
224
274
225
- __PWTB_FloatArgumentRegisters = \extraLocals
275
+ .macro EPILOG_WITH_TRANSITION_BLOCK_RETURN
226
276
227
- .if ((__PWTB_FloatArgumentRegisters % 16 ) != 0 )
228
- __PWTB_FloatArgumentRegisters = __PWTB_FloatArgumentRegisters + 8
229
- .endif
277
+ EPILOG_STACK_FREE __PWTB_StackAlloc
230
278
231
- __PWTB_TransitionBlock = __PWTB_FloatArgumentRegisters
279
+ EPILOG_RESTORE_REG_PAIR x19 , x20 , 16
280
+ EPILOG_RESTORE_REG_PAIR x21 , x22 , 32
281
+ EPILOG_RESTORE_REG_PAIR x23 , x24 , 48
282
+ EPILOG_RESTORE_REG_PAIR x25 , x26 , 64
283
+ EPILOG_RESTORE_REG_PAIR x27 , x28 , 80
284
+ EPILOG_RESTORE_REG_PAIR_INDEXED fp , lr , 176
285
+ ret
232
286
233
- .if \SaveFPArgs > 0
234
- __PWTB_TransitionBlock = __PWTB_TransitionBlock + SIZEOF__FloatArgumentRegisters
235
- .endif
287
+ .endm
236
288
237
- __PWTB_StackAlloc = __PWTB_TransitionBlock
238
- __PWTB_ArgumentRegisters = __PWTB_StackAlloc + 96
239
289
240
- .if \SaveFPArgs > 0
241
- RESTORE_FLOAT_ARGUMENT_REGISTERS sp , __PWTB_FloatArgumentRegisters
290
+ // -----------------------------------------------------------------------------
291
+ // Provides a matching epilog to PROLOG_WITH_TRANSITION_BLOCK and ends by preparing for tail - calling.
292
+ // Since this is a tail call argument registers are restored.
293
+ //
294
+ .macro EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
295
+
296
+ .if (__PWTB_SaveFPArgs == 1 )
297
+ RESTORE_FLOAT_ARGUMENT_REGISTERS sp , __PWTB_FloatArgumentRegisters
242
298
.endif
243
299
244
300
RESTORE_ARGUMENT_REGISTERS sp , __PWTB_ArgumentRegisters
301
+
245
302
EPILOG_STACK_FREE __PWTB_StackAlloc
246
-
247
- EPILOG_RESTORE_REG_PAIR x19 , x20 , # 16
248
- EPILOG_RESTORE_REG_PAIR x21 , x22 , # 32
249
- EPILOG_RESTORE_REG_PAIR x23 , x24 , # 48
250
- EPILOG_RESTORE_REG_PAIR x25 , x26 , # 64
251
- EPILOG_RESTORE_REG_PAIR x27 , x28 , # 80
252
- EPILOG_RESTORE_REG_PAIR_INDEXED fp , lr , # 160
303
+
304
+ EPILOG_RESTORE_REG_PAIR x19 , x20 , 16
305
+ EPILOG_RESTORE_REG_PAIR x21 , x22 , 32
306
+ EPILOG_RESTORE_REG_PAIR x23 , x24 , 48
307
+ EPILOG_RESTORE_REG_PAIR x25 , x26 , 64
308
+ EPILOG_RESTORE_REG_PAIR x27 , x28 , 80
309
+ EPILOG_RESTORE_REG_PAIR_INDEXED fp , lr , 176
253
310
254
311
.endm
255
312
@@ -273,8 +330,8 @@ __RedirectionFuncName SETS "|?RedirectedHandledJITCaseFor":CC:"$reason":CC:"@Thr
273
330
IMPORT $ __RedirectionFuncName
274
331
275
332
NESTED_ENTRY $ __RedirectionStubFuncName
276
- PROLOG_SAVE_REG_PAIR fp , lr , # - 16
277
- sub sp , sp , # 16 // stack slot for CONTEXT * and padding
333
+ PROLOG_SAVE_REG_PAIR fp , lr , - 16
334
+ sub sp , sp , # 16 // stack slot for CONTEXT * and padding
278
335
279
336
//REDIRECTSTUB_SP_OFFSET_CONTEXT is defined in asmconstants.h and is used in GetCONTEXTFromRedirectedStubStackFrame
280
337
//If CONTEXT is not saved at 0 offset from SP it must be changed as well.
0 commit comments