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 intptr_t* AnchorMark::anchor_mark_set_pd() { 338 return _top_frame.sp(); 339 } 340 341 inline void AnchorMark::anchor_mark_clear_pd() { 342 } 343 344 //////// Thaw 345 346 // Fast path 347 348 inline void ThawBase::prefetch_chunk_pd(void* start, int size) { 349 size <<= LogBytesPerWord; 350 Prefetch::read(start, size); 351 Prefetch::read(start, size - 64); 352 } 353 354 // Set back chain links of fast thawed frames such that *sp == callers_sp. 355 // See https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#STACK 356 template <typename ConfigT> 357 inline void Thaw<ConfigT>::patch_caller_links(intptr_t* sp, intptr_t* bottom) { 358 for (intptr_t* callers_sp; sp < bottom; sp = callers_sp) { 359 address pc = (address)((frame::java_abi*) sp)->lr; 360 assert(pc != nullptr, ""); 361 // see ThawBase::patch_return() which gets called just before 362 bool is_entry_frame = pc == StubRoutines::cont_returnBarrier() || pc == _cont.entryPC(); 363 if (is_entry_frame) { 364 callers_sp = _cont.entryFP(); 365 } else { 366 assert(!Interpreter::contains(pc), "sp:" PTR_FORMAT " pc:" PTR_FORMAT, p2i(sp), p2i(pc)); 367 CodeBlob* cb = CodeCache::find_blob_fast(pc); 368 callers_sp = sp + cb->frame_size(); 369 } 370 // set the back link 371 ((frame::java_abi*) sp)->callers_sp = (intptr_t) callers_sp; 372 } 373 } 374 375 // Slow path 376 377 inline frame ThawBase::new_entry_frame() { 378 intptr_t* sp = _cont.entrySP(); 379 return frame(sp, _cont.entryPC(), sp, _cont.entryFP()); 380 } 381 382 // === New Interpreted Frame ================================================================================================================ 383 // 384 // ### Non-Interpreted Caller (compiled, enterSpecial): No Overlap 385 // 386 // Heap Frame `hf` `hf` gets copied to stack _without_ overlapping the caller 387 // 388 // | | Non-Interpreted | | 389 // | |<- bottom Caller |----------------------| 390 // |----------------------| ^ | frame::java_abi |<- unextended SP 391 // | L0 aka P0 | | --- ======================== 392 // | : : | | ^ | L0 aka P0 | 393 // | : Pn | | | | : : | Parameters do 394 // | : | | | | : Pn | not overlap with 395 // | Lm | | | | : | caller! 396 // |----------------------| `fsize` | | : | 397 // | frame::java_abi | | | : | 398 // ======================== | `fsize` + padding | Lm | 399 // | | | |----------------------| 400 // | ijava_state | | | | Opt. Align. Padding | 401 // | | | | |----------------------| 402 // |----------------------| | | | frame::java_abi |<- new SP of caller 403 // | L0 aka P0 | | | ======================== / FP of new frame 404 // | : : | | | | | (aligned) 405 // | : Pn |<- unext. SP + metadata | | ijava_state | 406 // | : | | | | | 407 // | Lm | | | |----------------------| 408 // |----------------------| v | | P0 | 409 // | frame::java_abi |<- SP / unextended SP | | : | 410 // ======================== | | Pi |<- unextended SP + metadata 411 // | |----------------------| 412 // | Growth | v | frame::java_abi |<- unextended SP / SP of new frame 413 // v v --- ======================== (not yet aligned(1)) 414 // 415 // 416 // ### Interpreted Caller: Overlap with Caller 417 // 418 // Caller New frame with resized/aligned Caller 419 // 420 // | | | | 421 // | ijava_state | | ijava_state | 422 // |----------------------| |----------------------| 423 // | non param. expr. | bottom | non param. expr. | 424 // | - - - - - - - - - - | --- ^ | - - - - - - - - - - | 425 // | P0 | ^ | | L0 aka P0 | 426 // | : | | | | : : | 427 // | Pn |<- unextended SP overlap | | : Pn |<- unextended SP 428 // |----------------------| + metadata_words_at_top | | | : | + metadata_words_at_top 429 // | frame::java_abi |<- unextended SP v | | : | (unaligned) 430 // ======================== / SP of new frame --- | | : | of caller 431 // (not yet aligned(1)) | | Lm | 432 // `fsize` |----------------------| 433 // overlap = stack_argsize(hf) + padding| Opt. Align. Padding | 434 // + frame::metadata_words_at_top | |----------------------| 435 // | | frame::java_abi |<- new SP of caller 436 // | ======================== / FP of new frame 437 // | | | (aligned) 438 // | Growth | | | ijava_state | 439 // v v | | | 440 // | |----------------------| 441 // | | P0 | 442 // | | : | 443 // | | Pi |<- unextended SP 444 // | |----------------------| + metadata_words_at_top 445 // v | frame::java_abi |<- unextended SP / SP of new frame 446 // --- ======================== (not yet aligned(1)) 447 // 448 // 449 // (1) The SP / unextended SP of the new interpreted frame is not aligned. It 450 // gets aligned when its callee is pushed on stack or in finish_thaw() if 451 // it is the top frame. This allows addressing parameters: unextended SP + metadata_words_at_top 452 // 453 // (2) If caller is interpreted then its ijava_state::top_frame_sp will be used as sender sp 454 // of the new frame (see ContinuationHelper::InterpretedFrame::patch_sender_sp() and diagram at the end of this file) 455 // 456 // (3) The size of alignment padding required when thawing frames is accounted for 457 // in FreezeBase::_align_size. 458 // 459 // === New Compiled Frame =================================================================================================================== 460 // 461 // Compiled Caller Interpreted Caller 462 // 463 // - stackargs+abi overlap with caller - gets resized for stackargs 464 // - no alignment padding - SP gets aligned 465 // - no overlap with orig. 466 // caller 467 // O C 468 // r a | | | | 469 // i l | | | | 470 // g l |----------------------| | | 471 // i e | Stack Args | | | 472 // n r | (if any) | |----------------------| 473 // a |----------------------| | frame::java_abi | 474 // l | frame::java_abi |<- unext. SP / SP | (unused) |<- unal.unext.SP 475 // - - - ======================== - - - - - - - - - - |----------------------|- - - - - - - - - - - - - - - - - - - - - - - - - - - - 476 // N | | | Opt. Align. Padding | 477 // e | | |----------------------| 478 // w |----------------------| | Stack Args | 479 // | frame::java_abi |<- unext. SP / SP | (if any) | 480 // F ======================== |----------------------| 481 // r | frame::java_abi |<- caller's SP 482 // a ======================== / new frame's FP 483 // m | | (aligned) 484 // e | | 485 // |----------------------| 486 // | frame::java_abi |<- unext. SP / SP 487 // ======================== 488 // 489 // If the new frame is at the bottom just above the ContinuationEntry frame then the stackargs 490 // don't overlap the caller either even though it is compiled because the size is not 491 // limited/known. In contrast to the interpreted caller case the abi overlaps with the caller 492 // if there are no stackargs. This is to comply with shared code (see e.g. StackChunkFrameStream::frame_size()) 493 // 494 template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame& caller, bool bottom) { 495 assert(FKind::is_instance(hf), ""); 496 497 assert(is_aligned(caller.fp(), frame::frame_alignment), PTR_FORMAT, p2i(caller.fp())); 498 // caller.sp() can be unaligned. This is fixed below. 499 if (FKind::interpreted) { 500 // Note: we have to overlap with the caller, at least if it is interpreted, to match the 501 // max_thawing_size calculation during freeze. See also comment above. 502 intptr_t* heap_sp = hf.unextended_sp(); 503 const int fsize = ContinuationHelper::InterpretedFrame::frame_bottom(hf) - hf.unextended_sp(); 504 const int overlap = !caller.is_interpreted_frame() ? 0 505 : ContinuationHelper::InterpretedFrame::stack_argsize(hf) + frame::metadata_words_at_top; 506 intptr_t* frame_sp = caller.unextended_sp() + overlap - fsize; 507 intptr_t* fp = frame_sp + (hf.fp() - heap_sp); 508 // align fp 509 int padding = fp - align_down(fp, frame::frame_alignment); 510 fp -= padding; 511 // alignment of sp is done by callee or in finish_thaw() 512 frame_sp -= padding; 513 514 // On ppc esp points to the next free slot on the expression stack and sp + metadata points to the last parameter 515 DEBUG_ONLY(intptr_t* esp = fp + *hf.addr_at(ijava_idx(esp));) 516 assert(frame_sp + frame::metadata_words_at_top == esp+1, " frame_sp=" PTR_FORMAT " esp=" PTR_FORMAT, p2i(frame_sp), p2i(esp)); 517 caller.set_sp(fp); 518 frame f(frame_sp, hf.pc(), frame_sp, fp); 519 // we need to set the locals so that the caller of new_stack_frame() can call 520 // ContinuationHelper::InterpretedFrame::frame_bottom 521 // copy relativized locals from the heap frame 522 *f.addr_at(ijava_idx(locals)) = *hf.addr_at(ijava_idx(locals)); 523 524 return f; 525 } else { 526 int fsize = FKind::size(hf); 527 int argsize = FKind::stack_argsize(hf); 528 intptr_t* frame_sp = caller.sp() - fsize; 529 530 if ((bottom && argsize > 0) || caller.is_interpreted_frame()) { 531 frame_sp -= argsize + frame::metadata_words_at_top; 532 frame_sp = align_down(frame_sp, frame::alignment_in_bytes); 533 caller.set_sp(frame_sp + fsize); 534 } 535 536 assert(hf.cb() != nullptr, ""); 537 assert(hf.oop_map() != nullptr, ""); 538 intptr_t* fp = frame_sp + fsize; 539 return frame(frame_sp, frame_sp, fp, hf.pc(), hf.cb(), hf.oop_map(), false); 540 } 541 } 542 543 inline intptr_t* ThawBase::align(const frame& hf, intptr_t* frame_sp, frame& caller, bool bottom) { 544 // Unused. Alignment is done directly in new_stack_frame() / finish_thaw(). 545 return nullptr; 546 } 547 548 inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, const frame& f) { 549 intptr_t* vfp = f.fp(); 550 551 // Make sure that monitors is still relativized. 552 assert(f.at_absolute(ijava_idx(monitors)) <= -(frame::ijava_state_size / wordSize), ""); 553 554 // Make sure that esp is still relativized. 555 assert(f.at_absolute(ijava_idx(esp)) <= f.at_absolute(ijava_idx(monitors)), ""); 556 557 // Keep top_frame_sp relativized. 558 } 559 560 inline intptr_t* ThawBase::push_cleanup_continuation() { 561 frame enterSpecial = new_entry_frame(); 562 frame::common_abi* enterSpecial_abi = (frame::common_abi*)enterSpecial.sp(); 563 564 enterSpecial_abi->lr = (intptr_t)ContinuationEntry::cleanup_pc(); 565 566 log_develop_trace(continuations, preempt)("push_cleanup_continuation enterSpecial sp: " INTPTR_FORMAT " cleanup pc: " INTPTR_FORMAT, 567 p2i(enterSpecial_abi), 568 p2i(ContinuationEntry::cleanup_pc())); 569 570 return enterSpecial.sp(); 571 } 572 573 inline intptr_t* ThawBase::push_preempt_adapter() { 574 Unimplemented(); 575 return nullptr; 576 } 577 578 inline void ThawBase::patch_pd(frame& f, const frame& caller) { 579 patch_callee_link(caller, caller.fp()); 580 // Prevent assertion if f gets deoptimized right away before it's fully initialized 581 f.mark_not_fully_initialized(); 582 } 583 584 inline void ThawBase::patch_pd(frame& f, intptr_t* caller_sp) { 585 assert(f.own_abi()->callers_sp == (uint64_t)caller_sp, "should have been fixed by patch_caller_links"); 586 } 587 588 // 589 // Interpreter Calling Procedure on PPC 590 // 591 // Caller Resized Caller before the Call New Callee Frame 592 // 593 // - SP/FP are 16 byte aligned. - The unused part of the expression stack - The caller's original SP is passed as 594 // Padding is added as necessary. is removed sender SP (in R21_sender_SP) also by 595 // - SP is _not_ used as esp - Slots for the callee's nonparameter locals compiled callers. It is saved in the 596 // (expression stack pointer) are added. ijava_state::sender_sp slot and 597 // - Has reserved slots for the - The large ABI is replaced with a minimal restored when returning. 598 // maximal expression stack ABI. This removes a c2i extension if there 599 // - Has a larger ABI section on - The original SP was saved in is one. 600 // top that is required to call ijava_state::top_frame_sp slot. - ijava_state::sender_sp will be set 601 // C++ code From there it is restored as SP _after_ as the caller's unextended sp when 602 // returning from a call. This reverts the iterating stack frames 603 // resizing described above. It is also (see frame::unextended_sp() and 604 // required to undo potential i2c extensions frame::sender_for_interpreter_frame()) 605 // if the calle should be compiled. 606 // - Note that unextended SP < SP 607 // is possible on ppc. 608 // 609 // | | | | | | 610 // | (frame::java_abi) | | (frame::java_abi) | | (frame::java_abi) | 611 // | 4 words | | 4 words | | 4 words | 612 // | Caller's SP |<- FP of caller | Caller's SP |<- FP of caller | Caller's SP |<- FP of caller 613 // ======================== (aligned) ======================== ======================== 614 // | frame:: | | frame:: | | frame:: | 615 // | ijava_state | | ijava_state | | ijava_state | 616 // | | | | | | 617 // |----------------------| |----------------------| |----------------------| 618 // | P0 | | L0 aka P0 | | L0 aka P0 | 619 // | | | : | | : | 620 // | Pn | | : Pn | | : Pn | 621 // |----------------------| | : | | : | 622 // | | | Lm | | Lm | 623 // | Reserved Expr. Stack | |----------------------| |----------------------| 624 // | | | Opt. Alignm. Padding | | Opt. Alignm. Padding | 625 // | |<- ConstMethod |----------------------| |----------------------| 626 // |----------------------| ::_max_stack | | | | 627 // | Opt. Alignm. Padding | | (frame::java_abi) | | (frame::java_abi) | 628 // |----------------------| | 4 words | | 4 words | 629 // | Large ABI | | Caller's SP |<- new SP of caller | Caller's SP |<- SP of caller / 630 // | for C++ calls | ======================== (aligned) ======================== FP of callee 631 // | (frame:: | | frame:: | (aligned) 632 // | native_abi_reg_args)| | ijava_state | 633 // | | | | 634 // | | |----------------------| 635 // | | | | 636 // | Caller's SP |<- SP of caller <- unextended SP | Reserved Expr. Stack |<- unextended SP 637 // ======================== (aligned) of caller | | of caller 638 // (aligned) | | 639 // | | 640 // | | 641 // | | 642 // | |<- ConstMethod 643 // |----------------------| ::_max_stack 644 // Resize Caller Push new Callee Frame | Opt. Alignm. Padding | 645 // --------------------> ------------------------> |----------------------| 646 // (ABI, expressions, locals) | Large ABI | 647 // | for C++ calls | 648 // | (frame:: | 649 // | native_abi_reg_args)| 650 // | Growth | | | 651 // v v | | 652 // | | 653 // | Caller's SP |<- SP of callee 654 // ======================== (aligned) 655 // 656 // 657 #endif // CPU_PPC_CONTINUATION_PPC_INLINE_HPP