1 /*
2 * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef CPU_PPC_CONTINUATION_PPC_INLINE_HPP
26 #define CPU_PPC_CONTINUATION_PPC_INLINE_HPP
27
28 #include "oops/stackChunkOop.inline.hpp"
29 #include "runtime/frame.hpp"
30 #include "runtime/frame.inline.hpp"
31
32 inline void patch_callee_link(const frame& f, intptr_t* fp) {
33 *ContinuationHelper::Frame::callee_link_address(f) = fp;
34 }
35
36 inline void patch_callee_link_relative(const frame& f, intptr_t* fp) {
37 intptr_t* la = (intptr_t*)ContinuationHelper::Frame::callee_link_address(f);
38 intptr_t new_value = fp - la;
39 *la = new_value;
40 }
41
42 ////// Freeze
43
44 // Fast path
45
46 inline void FreezeBase::patch_stack_pd(intptr_t* frame_sp, intptr_t* heap_sp) {
47 // Nothing to do. The backchain is reconstructed when thawing (see Thaw<ConfigT>::patch_caller_links())
48 }
49
50 // Slow path
51
52 template<typename FKind>
53 inline frame FreezeBase::sender(const frame& f) {
54 assert(FKind::is_instance(f), "");
55 if (FKind::interpreted) {
56 return frame(f.sender_sp(), f.sender_pc(), f.interpreter_frame_sender_sp());
57 }
58
59 intptr_t* sender_sp = f.sender_sp();
60 address sender_pc = f.sender_pc();
61 assert(sender_sp != f.sp(), "must have changed");
62
63 int slot = 0;
64 CodeBlob* sender_cb = CodeCache::find_blob_and_oopmap(sender_pc, slot);
65 return sender_cb != nullptr
66 ? frame(sender_sp, sender_sp, nullptr, sender_pc, sender_cb, slot == -1 ? nullptr : sender_cb->oop_map_for_slot(slot, sender_pc))
67 : frame(sender_sp, sender_pc, sender_sp);
68 }
69
70 void FreezeBase::adjust_interpreted_frame_unextended_sp(frame& f) {
71 // nothing to do
72 }
73
74 inline void FreezeBase::prepare_freeze_interpreted_top_frame(frame& f) {
75 // nothing to do
76 DEBUG_ONLY( intptr_t* lspp = (intptr_t*) &(f.get_ijava_state()->top_frame_sp); )
77 assert(*lspp == f.unextended_sp() - f.fp(), "should be " INTPTR_FORMAT " usp:" INTPTR_FORMAT " fp:" INTPTR_FORMAT, *lspp, p2i(f.unextended_sp()), p2i(f.fp()));
78 }
79
80 inline void FreezeBase::relativize_interpreted_frame_metadata(const frame& f, const frame& hf) {
81 intptr_t* vfp = f.fp();
82 intptr_t* hfp = hf.fp();
83 assert(f.fp() > (intptr_t*)f.interpreter_frame_esp(), "");
84
85 // There is alignment padding between vfp and f's locals array in the original
86 // frame, because we freeze the padding (see recurse_freeze_interpreted_frame)
87 // in order to keep the same relativized locals pointer, we don't need to change it here.
88
89 // Make sure that monitors is already relativized.
90 assert(hf.at_absolute(ijava_idx(monitors)) <= -(frame::ijava_state_size / wordSize), "");
91
92 // Make sure that esp is already relativized.
93 assert(hf.at_absolute(ijava_idx(esp)) <= hf.at_absolute(ijava_idx(monitors)), "");
94
95 // top_frame_sp is already relativized
96
97 // hfp == hf.sp() + (f.fp() - f.sp()) is not true on ppc because the stack frame has room for
98 // the maximal expression stack and the expression stack in the heap frame is trimmed.
99 assert(hf.fp() == hf.interpreter_frame_esp() + (f.fp() - f.interpreter_frame_esp()), "");
100 assert(hf.fp() <= (intptr_t*)hf.at(ijava_idx(locals)), "");
101 }
102
103 inline void FreezeBase::set_top_frame_metadata_pd(const frame& hf) {
104 stackChunkOop chunk = _cont.tail();
105 assert(chunk->is_in_chunk(hf.sp()), "hf.sp()=" PTR_FORMAT, p2i(hf.sp()));
106
107 hf.own_abi()->lr = (uint64_t)hf.pc();
108 if (hf.is_interpreted_frame()) {
109 patch_callee_link_relative(hf, hf.fp());
110 }
111 #ifdef ASSERT
112 else {
113 // See also FreezeBase::patch_pd()
114 patch_callee_link(hf, (intptr_t*)badAddress);
115 }
116 #endif
117 }
118
119 //
120 // Heap frames differ from stack frames in the following aspects
121 //
122 // - they are just word aligned
123 // - the unextended sp of interpreted frames is set such that
124 // unextended sp + frame::metadata_words_at_top + 1 points to the last call parameter
125 // (the comment at the file end explains the unextended sp for interpreted frames on the stack)
126 //
127 // The difference in respect to the unextended sp is required to comply with shared code.
128 // Furthermore fast frozen and compiled frames have invalid back links (see
129 // Thaw<ConfigT>::patch_caller_links() and FreezeBase::patch_pd())
130 //
131 // === New Interpreted Frame ==========================================================================================
132 //
133 // ### Interpreted Caller: Overlap new frame with Caller
134 //
135 // Caller on entry New frame with resized Caller
136 //
137 // | frame::java_abi | | |
138 // | |<- FP of caller | Caller's SP |<- FP of caller
139 // ========================== ==========================
140 // | ijava_state | | ijava_state |
141 // | | | |
142 // |------------------------| ----- |------------------------|
143 // | P0 | ^ | L0 aka P0 |
144 // | : | | | : : |
145 // | Pn |<- unext. SP | | : Pn |<- unext. SP
146 // |------------------------| + metadata overlap | : | + metadata
147 // | frame::java_abi | | | Lm |
148 // | (metadata_words_at_top)|<- SP == unext. SP v |------------------------|<- unextended SP of caller (1)
149 // ========================== of caller ----- | frame::java_abi |
150 // | (metadata_words_at_top)|<- new SP of caller / FP of new frame
151 // overlap = stack_argsize(f) ========================== ^
152 // + frame::metadata_words_at_top | ijava_state | |
153 // | | |
154 // Where f is the frame to be relocated on the heap. |------------------------| |
155 // See also StackChunkFrameStream::frame_size(). | Expressions | FP - esp of f
156 // | P0 | |
157 // | : | |
158 // | Growth | | Pi | v
159 // v v |------------------------| ---
160 // | frame::java_abi |
161 // | (metadata_words_at_top)|<- unextended SP /
162 // ========================== SP of new frame
163 // ### Compiled Caller: No Overlap
164 //
165 // The caller is resized to accomodate the callee's locals and abi but there is _no_ overlap with
166 // the original caller frame.
167 //
168 // Caller on entry New frame with resized Caller
169 //
170 // | frame::java_abi | | |
171 // | (metadata_words_at_top)|<- FP of caller | Caller's SP |<- FP of caller
172 // ========================== ==========================
173 // | | | |
174 // | | | |
175 // |------------------------| |------------------------|
176 // | frame::java_abi | | frame::java_abi |
177 // | (metadata_words_at_top)|<- SP == unext. SP | (metadata_words_at_top)|<- unext. SP of caller
178 // ========================== of caller |------------------------|
179 // | L0 aka P0 |
180 // | : : |
181 // | : Pn |
182 // overlap = 0 | Lm |
183 // |------------------------|
184 // f is the frame to be relocated on the heap | frame::java_abi |
185 // | (metadata_words_at_top)|<- new SP of caller / FP of new frame
186 // ========================== ^
187 // | ijava_state | |
188 // | Growth | | | |
189 // v v |------------------------| |
190 // | Expressions | FP - esp of f
191 // | P0 | |
192 // | : | |
193 // | Pi | v
194 // |------------------------| ---
195 // | frame::java_abi |
196 // | (metadata_words_at_top)|<- unextended SP /
197 // ========================== SP of new frame
198 //
199 // (1) Caller's unextended SP is preserved in callee's frame::ijava_state::sender_sp
200 // (See ContinuationHelper::InterpretedFrame::patch_sender_sp). This is required
201 // by StackChunkFrameStream<frame_kind>::next_for_interpreter_frame().
202 //
203 // === New Compiled Frame =============================================================================================
204 //
205 // ### Interpreted Caller: No Overlap
206 //
207 // The caller is resized to accomodate the callee's stack arguments and abi but there is _no_ overlap with
208 // the original caller frame.
209 //
210 // Note: a new ABI is added to the caller even if there are no stackargs.
211 // This is necessary to comply with shared code.
212 //
213 // Caller on entry New frame with resized Caller
214 //
215 // | frame::java_abi | | frame::java_abi |
216 // | (metadata_words_at_top)|<- FP of caller | (metadata_words_at_top)|<- FP of caller
217 // ========================== ==========================
218 // | ijava_state | | ijava_state |
219 // | | | |
220 // |------------------------| |------------------------|
221 // | P0 | | P0 |
222 // | : | | : |
223 // | Pn |<- unext. SP | Pn |<- unext. SP
224 // |------------------------| + metadata |------------------------| + metadata
225 // | frame::java_abi | | frame::java_abi |
226 // | (metadata_words_at_top)|<- SP == unext. SP | (metadata_words_at_top)|<- unextended SP of caller (1)
227 // ========================== of caller |------------------------|
228 // | Stack Args |
229 // overlap = 0 | (if any) |
230 // |------------------------|
231 // f is the frame to be relocated on the heap | frame::java_abi |
232 // | (metadata_words_at_top)|<- new SP of caller / FP of new frame
233 // ==========================
234 // | |
235 // | Growth | | |
236 // v v |------------------------|
237 // | frame::java_abi |
238 // | (metadata_words_at_top)|<- SP == unext. SP of new frame
239 // ==========================
240 //
241 // ### Compiled Caller: Stackargs + ABI Overlap
242 //
243 // Caller on entry New frame with resized Caller
244 //
245 // | frame::java_abi | | frame::java_abi |
246 // | (metadata_words_at_top)|<- FP of caller | (metadata_words_at_top)|<- FP of caller
247 // ========================== ==========================
248 // | | | |
249 // | | | |
250 // |------------------------| ----- |------------------------|
251 // | Stack Args | ^ | Stack Args |
252 // | (if any) | | | (if any) |
253 // |------------------------| overlap |------------------------|
254 // | frame::java_abi | | | frame::java_abi |
255 // | (metadata_words_at_top)|<- SP == unext. SP v | (metadata_words_at_top)|<- SP == unext. SP of caller
256 // ========================== of caller ----- ========================== / FP of new frame
257 // | |
258 // overlap = stack_argsize(f) | |
259 // + frame::metadata_words_at_top |------------------------|
260 // | frame::java_abi |
261 // Where f is the frame to be relocated on the heap. | (metadata_words_at_top)|<- SP == unext. SP of new frame
262 // See also StackChunkFrameStream::frame_size(). ==========================
263 //
264 template<typename FKind>
265 frame FreezeBase::new_heap_frame(frame& f, frame& caller) {
266 assert(FKind::is_instance(f), "");
267
268 intptr_t *sp, *fp;
269 if (FKind::interpreted) {
270 intptr_t locals_offset = *f.addr_at(ijava_idx(locals));
271 // If the caller.is_empty(), i.e. we're freezing into an empty chunk, then we set
272 // the chunk's argsize in finalize_freeze and make room for it above the unextended_sp
273 // See also comment on StackChunkFrameStream<frame_kind>::interpreter_frame_size()
274 int overlap =
275 (caller.is_interpreted_frame() || caller.is_empty())
276 ? ContinuationHelper::InterpretedFrame::stack_argsize(f) + frame::metadata_words_at_top
277 : 0;
278 fp = caller.unextended_sp() - 1 - locals_offset + overlap;
279 // esp points one slot below the last argument
280 intptr_t* x86_64_like_unextended_sp = f.interpreter_frame_esp() + 1 - frame::metadata_words_at_top;
281 sp = fp - (f.fp() - x86_64_like_unextended_sp);
282
283 assert (sp <= fp && (fp <= caller.unextended_sp() || caller.is_interpreted_frame()),
284 "sp=" PTR_FORMAT " fp=" PTR_FORMAT " caller.unextended_sp()=" PTR_FORMAT " caller.is_interpreted_frame()=%d",
285 p2i(sp), p2i(fp), p2i(caller.unextended_sp()), caller.is_interpreted_frame());
286 caller.set_sp(fp);
287
288 assert(_cont.tail()->is_in_chunk(sp), "");
289
290 frame hf(sp, sp, fp, f.pc(), nullptr, nullptr, true /* on_heap */);
291 // frame_top() and frame_bottom() read these before relativize_interpreted_frame_metadata() is called
292 *hf.addr_at(ijava_idx(locals)) = locals_offset;
293 *hf.addr_at(ijava_idx(esp)) = f.interpreter_frame_esp() - f.fp();
294 return hf;
295 } else {
296 int fsize = FKind::size(f);
297 sp = caller.unextended_sp() - fsize;
298 if (caller.is_interpreted_frame()) {
299 // If the caller is interpreted, our stackargs are not supposed to overlap with it
300 // so we make more room by moving sp down by argsize
301 int argsize = FKind::stack_argsize(f);
302 sp -= argsize + frame::metadata_words_at_top;
303 }
304 fp = sp + fsize;
305 caller.set_sp(fp);
306
307 assert(_cont.tail()->is_in_chunk(sp), "");
308
309 return frame(sp, sp, fp, f.pc(), nullptr, nullptr, true /* on_heap */);
310 }
311 }
312
313 inline void FreezeBase::patch_pd(frame& hf, const frame& caller) {
314 if (caller.is_interpreted_frame()) {
315 assert(!caller.is_empty(), "");
316 patch_callee_link_relative(caller, caller.fp());
317 }
318 #ifdef ASSERT
319 else {
320 // For compiled frames the back link is actually redundant. It gets computed
321 // as unextended_sp + frame_size.
322
323 // Note the difference on x86_64: the link is not made relative if the caller
324 // is a compiled frame because there rbp is used as a non-volatile register by
325 // c1/c2 so it could be a computed value local to the caller.
326
327 // See also:
328 // - FreezeBase::set_top_frame_metadata_pd
329 // - StackChunkFrameStream<frame_kind>::fp()
330 // - UseContinuationFastPath: compiled frames are copied in a batch w/o patching the back link.
331 // The backlinks are restored when thawing (see Thaw<ConfigT>::patch_caller_links())
332 patch_callee_link(hf, (intptr_t*)badAddress);
333 }
334 #endif
335 }
336
337 inline void FreezeBase::patch_pd_unused(intptr_t* sp) {
338 }
339
340 //////// Thaw
341
342 // Fast path
343
344 inline void ThawBase::prefetch_chunk_pd(void* start, int size) {
345 size <<= LogBytesPerWord;
346 Prefetch::read(start, size);
347 Prefetch::read(start, size - 64);
348 }
349
350 // Set back chain links of fast thawed frames such that *sp == callers_sp.
351 // See https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#STACK
352 template <typename ConfigT>
353 inline void Thaw<ConfigT>::patch_caller_links(intptr_t* sp, intptr_t* bottom) {
354 for (intptr_t* callers_sp; sp < bottom; sp = callers_sp) {
355 address pc = (address)((frame::java_abi*) sp)->lr;
356 assert(pc != nullptr, "");
357 // see ThawBase::patch_return() which gets called just before
358 bool is_entry_frame = pc == StubRoutines::cont_returnBarrier() || pc == _cont.entryPC();
359 if (is_entry_frame) {
360 callers_sp = _cont.entryFP();
361 } else {
362 assert(!Interpreter::contains(pc), "sp:" PTR_FORMAT " pc:" PTR_FORMAT, p2i(sp), p2i(pc));
363 CodeBlob* cb = CodeCache::find_blob_fast(pc);
364 callers_sp = sp + cb->frame_size();
365 }
366 // set the back link
367 ((frame::java_abi*) sp)->callers_sp = (intptr_t) callers_sp;
368 }
369 }
370
371 // Slow path
372
373 inline frame ThawBase::new_entry_frame() {
374 intptr_t* sp = _cont.entrySP();
375 return frame(sp, _cont.entryPC(), sp, _cont.entryFP());
376 }
377
378 // === New Interpreted Frame ================================================================================================================
379 //
380 // ### Non-Interpreted Caller (compiled, enterSpecial): No Overlap
381 //
382 // Heap Frame `hf` `hf` gets copied to stack _without_ overlapping the caller
383 //
384 // | | Non-Interpreted | |
385 // | |<- bottom Caller |----------------------|
386 // |----------------------| ^ | frame::java_abi |<- unextended SP
387 // | L0 aka P0 | | --- ========================
388 // | : : | | ^ | L0 aka P0 |
389 // | : Pn | | | | : : | Parameters do
390 // | : | | | | : Pn | not overlap with
391 // | Lm | | | | : | caller!
392 // |----------------------| `fsize` | | : |
393 // | frame::java_abi | | | : |
394 // ======================== | `fsize` + padding | Lm |
395 // | | | |----------------------|
396 // | ijava_state | | | | Opt. Align. Padding |
397 // | | | | |----------------------|
398 // |----------------------| | | | frame::java_abi |<- new SP of caller
399 // | L0 aka P0 | | | ======================== / FP of new frame
400 // | : : | | | | | (aligned)
401 // | : Pn |<- unext. SP + metadata | | ijava_state |
402 // | : | | | | |
403 // | Lm | | | |----------------------|
404 // |----------------------| v | | P0 |
405 // | frame::java_abi |<- SP / unextended SP | | : |
406 // ======================== | | Pi |<- unextended SP + metadata
407 // | |----------------------|
408 // | Growth | v | frame::java_abi |<- unextended SP / SP of new frame
409 // v v --- ======================== (not yet aligned(1))
410 //
411 //
412 // ### Interpreted Caller: Overlap with Caller
413 //
414 // Caller New frame with resized/aligned Caller
415 //
416 // | | | |
417 // | ijava_state | | ijava_state |
418 // |----------------------| |----------------------|
419 // | non param. expr. | bottom | non param. expr. |
420 // | - - - - - - - - - - | --- ^ | - - - - - - - - - - |
421 // | P0 | ^ | | L0 aka P0 |
422 // | : | | | | : : |
423 // | Pn |<- unextended SP overlap | | : Pn |<- unextended SP
424 // |----------------------| + metadata_words_at_top | | | : | + metadata_words_at_top
425 // | frame::java_abi |<- unextended SP v | | : | (unaligned)
426 // ======================== / SP of new frame --- | | : | of caller
427 // (not yet aligned(1)) | | Lm |
428 // `fsize` |----------------------|
429 // overlap = stack_argsize(hf) + padding| Opt. Align. Padding |
430 // + frame::metadata_words_at_top | |----------------------|
431 // | | frame::java_abi |<- new SP of caller
432 // | ======================== / FP of new frame
433 // | | | (aligned)
434 // | Growth | | | ijava_state |
435 // v v | | |
436 // | |----------------------|
437 // | | P0 |
438 // | | : |
439 // | | Pi |<- unextended SP
440 // | |----------------------| + metadata_words_at_top
441 // v | frame::java_abi |<- unextended SP / SP of new frame
442 // --- ======================== (not yet aligned(1))
443 //
444 //
445 // (1) The SP / unextended SP of the new interpreted frame is not aligned. It
446 // gets aligned when its callee is pushed on stack or in finish_thaw() if
447 // it is the top frame. This allows addressing parameters: unextended SP + metadata_words_at_top
448 //
449 // (2) If caller is interpreted then its ijava_state::top_frame_sp will be used as sender sp
450 // of the new frame (see ContinuationHelper::InterpretedFrame::patch_sender_sp() and diagram at the end of this file)
451 //
452 // (3) The size of alignment padding required when thawing frames is accounted for
453 // in FreezeBase::_align_size.
454 //
455 // === New Compiled Frame ===================================================================================================================
456 //
457 // Compiled Caller Interpreted Caller
458 //
459 // - stackargs+abi overlap with caller - gets resized for stackargs
460 // - no alignment padding - SP gets aligned
461 // - no overlap with orig.
462 // caller
463 // O C
464 // r a | | | |
465 // i l | | | |
466 // g l |----------------------| | |
467 // i e | Stack Args | | |
468 // n r | (if any) | |----------------------|
469 // a |----------------------| | frame::java_abi |
470 // l | frame::java_abi |<- unext. SP / SP | (unused) |<- unal.unext.SP
471 // - - - ======================== - - - - - - - - - - |----------------------|- - - - - - - - - - - - - - - - - - - - - - - - - - - -
472 // N | | | Opt. Align. Padding |
473 // e | | |----------------------|
474 // w |----------------------| | Stack Args |
475 // | frame::java_abi |<- unext. SP / SP | (if any) |
476 // F ======================== |----------------------|
477 // r | frame::java_abi |<- caller's SP
478 // a ======================== / new frame's FP
479 // m | | (aligned)
480 // e | |
481 // |----------------------|
482 // | frame::java_abi |<- unext. SP / SP
483 // ========================
484 //
485 // If the new frame is at the bottom just above the ContinuationEntry frame then the stackargs
486 // don't overlap the caller either even though it is compiled because the size is not
487 // limited/known. In contrast to the interpreted caller case the abi overlaps with the caller
488 // if there are no stackargs. This is to comply with shared code (see e.g. StackChunkFrameStream::frame_size())
489 //
490 template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame& caller, bool bottom) {
491 assert(FKind::is_instance(hf), "");
492
493 assert(is_aligned(caller.fp(), frame::frame_alignment), PTR_FORMAT, p2i(caller.fp()));
494 // caller.sp() can be unaligned. This is fixed below.
495 if (FKind::interpreted) {
496 // Note: we have to overlap with the caller, at least if it is interpreted, to match the
497 // max_thawing_size calculation during freeze. See also comment above.
498 intptr_t* heap_sp = hf.unextended_sp();
499 const int fsize = ContinuationHelper::InterpretedFrame::frame_bottom(hf) - hf.unextended_sp();
500 const int overlap = !caller.is_interpreted_frame() ? 0
501 : ContinuationHelper::InterpretedFrame::stack_argsize(hf) + frame::metadata_words_at_top;
502 intptr_t* frame_sp = caller.unextended_sp() + overlap - fsize;
503 intptr_t* fp = frame_sp + (hf.fp() - heap_sp);
504 // align fp
505 int padding = fp - align_down(fp, frame::frame_alignment);
506 fp -= padding;
507 // alignment of sp is done by callee or in finish_thaw()
508 frame_sp -= padding;
509
510 // On ppc esp points to the next free slot on the expression stack and sp + metadata points to the last parameter
511 DEBUG_ONLY(intptr_t* esp = fp + *hf.addr_at(ijava_idx(esp));)
512 assert(frame_sp + frame::metadata_words_at_top == esp+1, " frame_sp=" PTR_FORMAT " esp=" PTR_FORMAT, p2i(frame_sp), p2i(esp));
513 caller.set_sp(fp);
514 frame f(frame_sp, hf.pc(), frame_sp, fp);
515 // we need to set the locals so that the caller of new_stack_frame() can call
516 // ContinuationHelper::InterpretedFrame::frame_bottom
517 // copy relativized locals from the heap frame
518 *f.addr_at(ijava_idx(locals)) = *hf.addr_at(ijava_idx(locals));
519
520 return f;
521 } else {
522 int fsize = FKind::size(hf);
523 int argsize = FKind::stack_argsize(hf);
524 intptr_t* frame_sp = caller.sp() - fsize;
525
526 if ((bottom && argsize > 0) || caller.is_interpreted_frame()) {
527 frame_sp -= argsize + frame::metadata_words_at_top;
528 frame_sp = align_down(frame_sp, frame::alignment_in_bytes);
529 caller.set_sp(frame_sp + fsize);
530 }
531
532 assert(hf.cb() != nullptr, "");
533 assert(hf.oop_map() != nullptr, "");
534 intptr_t* fp = frame_sp + fsize;
535 return frame(frame_sp, frame_sp, fp, hf.pc(), hf.cb(), hf.oop_map(), false);
536 }
537 }
538
539 inline intptr_t* ThawBase::align(const frame& hf, intptr_t* frame_sp, frame& caller, bool bottom) {
540 // Unused. Alignment is done directly in new_stack_frame() / finish_thaw().
541 return nullptr;
542 }
543
544 inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, const frame& f) {
545 intptr_t* vfp = f.fp();
546
547 // Make sure that monitors is still relativized.
548 assert(f.at_absolute(ijava_idx(monitors)) <= -(frame::ijava_state_size / wordSize), "");
549
550 // Make sure that esp is still relativized.
551 assert(f.at_absolute(ijava_idx(esp)) <= f.at_absolute(ijava_idx(monitors)), "");
552
553 // Keep top_frame_sp relativized.
554 }
555
556 inline intptr_t* ThawBase::push_cleanup_continuation() {
557 frame enterSpecial = new_entry_frame();
558 frame::common_abi* enterSpecial_abi = (frame::common_abi*)enterSpecial.sp();
559
560 enterSpecial_abi->lr = (intptr_t)ContinuationEntry::cleanup_pc();
561
562 log_develop_trace(continuations, preempt)("push_cleanup_continuation enterSpecial sp: " INTPTR_FORMAT " cleanup pc: " INTPTR_FORMAT,
563 p2i(enterSpecial_abi),
564 p2i(ContinuationEntry::cleanup_pc()));
565
566 return enterSpecial.sp();
567 }
568
569 inline void ThawBase::patch_pd(frame& f, const frame& caller) {
570 patch_callee_link(caller, caller.fp());
571 // Prevent assertion if f gets deoptimized right away before it's fully initialized
572 f.mark_not_fully_initialized();
573 }
574
575 inline void ThawBase::patch_pd(frame& f, intptr_t* caller_sp) {
576 assert(f.own_abi()->callers_sp == (uint64_t)caller_sp, "should have been fixed by patch_caller_links");
577 }
578
579 //
580 // Interpreter Calling Procedure on PPC
581 //
582 // Caller Resized Caller before the Call New Callee Frame
583 //
584 // - SP/FP are 16 byte aligned. - The unused part of the expression stack - The caller's original SP is passed as
585 // Padding is added as necessary. is removed sender SP (in R21_sender_SP) also by
586 // - SP is _not_ used as esp - Slots for the callee's nonparameter locals compiled callers. It is saved in the
587 // (expression stack pointer) are added. ijava_state::sender_sp slot and
588 // - Has reserved slots for the - The large ABI is replaced with a minimal restored when returning.
589 // maximal expression stack ABI. This removes a c2i extension if there
590 // - Has a larger ABI section on - The original SP was saved in is one.
591 // top that is required to call ijava_state::top_frame_sp slot. - ijava_state::sender_sp will be set
592 // C++ code From there it is restored as SP _after_ as the caller's unextended sp when
593 // returning from a call. This reverts the iterating stack frames
594 // resizing described above. It is also (see frame::unextended_sp() and
595 // required to undo potential i2c extensions frame::sender_for_interpreter_frame())
596 // if the calle should be compiled.
597 // - Note that unextended SP < SP
598 // is possible on ppc.
599 //
600 // | | | | | |
601 // | (frame::java_abi) | | (frame::java_abi) | | (frame::java_abi) |
602 // | 4 words | | 4 words | | 4 words |
603 // | Caller's SP |<- FP of caller | Caller's SP |<- FP of caller | Caller's SP |<- FP of caller
604 // ======================== (aligned) ======================== ========================
605 // | frame:: | | frame:: | | frame:: |
606 // | ijava_state | | ijava_state | | ijava_state |
607 // | | | | | |
608 // |----------------------| |----------------------| |----------------------|
609 // | P0 | | L0 aka P0 | | L0 aka P0 |
610 // | | | : | | : |
611 // | Pn | | : Pn | | : Pn |
612 // |----------------------| | : | | : |
613 // | | | Lm | | Lm |
614 // | Reserved Expr. Stack | |----------------------| |----------------------|
615 // | | | Opt. Alignm. Padding | | Opt. Alignm. Padding |
616 // | |<- ConstMethod |----------------------| |----------------------|
617 // |----------------------| ::_max_stack | | | |
618 // | Opt. Alignm. Padding | | (frame::java_abi) | | (frame::java_abi) |
619 // |----------------------| | 4 words | | 4 words |
620 // | Large ABI | | Caller's SP |<- new SP of caller | Caller's SP |<- SP of caller /
621 // | for C++ calls | ======================== (aligned) ======================== FP of callee
622 // | (frame:: | | frame:: | (aligned)
623 // | native_abi_reg_args)| | ijava_state |
624 // | | | |
625 // | | |----------------------|
626 // | | | |
627 // | Caller's SP |<- SP of caller <- unextended SP | Reserved Expr. Stack |<- unextended SP
628 // ======================== (aligned) of caller | | of caller
629 // (aligned) | |
630 // | |
631 // | |
632 // | |
633 // | |<- ConstMethod
634 // |----------------------| ::_max_stack
635 // Resize Caller Push new Callee Frame | Opt. Alignm. Padding |
636 // --------------------> ------------------------> |----------------------|
637 // (ABI, expressions, locals) | Large ABI |
638 // | for C++ calls |
639 // | (frame:: |
640 // | native_abi_reg_args)|
641 // | Growth | | |
642 // v v | |
643 // | |
644 // | Caller's SP |<- SP of callee
645 // ======================== (aligned)
646 //
647 //
648 #endif // CPU_PPC_CONTINUATION_PPC_INLINE_HPP