1 /*
  2  * Copyright (c) 2019, 2021, 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_X86_CONTINUATION_X86_INLINE_HPP
 26 #define CPU_X86_CONTINUATION_X86_INLINE_HPP
 27 
 28 #include "oops/instanceStackChunkKlass.inline.hpp"
 29 #include "runtime/frame.hpp"
 30 #include "runtime/frame.inline.hpp"
 31 
 32 const int ContinuationHelper::frame_metadata = frame::sender_sp_offset;
 33 const int ContinuationHelper::align_wiggle = 1;
 34 
 35 #ifdef ASSERT
 36 bool Frame::assert_frame_laid_out(frame f) {
 37   intptr_t* sp = f.sp();
 38   address pc = *(address*)(sp - frame::sender_sp_ret_address_offset());
 39   intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
 40   assert (f.raw_pc() == pc, "f.ra_pc: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.raw_pc()), p2i(pc));
 41   assert (f.fp() == fp, "f.fp: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.fp()), p2i(fp));
 42   return f.raw_pc() == pc && f.fp() == fp;
 43 }
 44 #endif
 45 
 46 inline intptr_t** Frame::callee_link_address(const frame& f) {
 47   return (intptr_t**)(f.sp() - frame::sender_sp_offset);
 48 }
 49 
 50 template<typename FKind>
 51 static inline intptr_t* real_fp(const frame& f) {
 52   assert (FKind::is_instance(f), "");
 53   assert (FKind::interpreted || f.cb() != nullptr, "");
 54 
 55   return FKind::interpreted ? f.fp() : f.unextended_sp() + f.cb()->frame_size();
 56 }
 57 
 58 template<typename FKind> // TODO: maybe do the same CRTP trick with Interpreted and Compiled as with hframe
 59 static inline intptr_t** link_address(const frame& f) {
 60   assert (FKind::is_instance(f), "");
 61   return FKind::interpreted
 62             ? (intptr_t**)(f.fp() + frame::link_offset)
 63             : (intptr_t**)(real_fp<FKind>(f) - frame::sender_sp_offset);
 64 }
 65 
 66 static void patch_callee_link(const frame& f, intptr_t* fp) {
 67   *Frame::callee_link_address(f) = fp;
 68   log_trace(jvmcont)("patched link at " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(Frame::callee_link_address(f)), p2i(fp));
 69 }
 70 
 71 static void patch_callee_link_relative(const frame& f, intptr_t* fp) {
 72   intptr_t* la = (intptr_t*)Frame::callee_link_address(f);
 73   intptr_t new_value = fp - la;
 74   *la = new_value;
 75   log_trace(jvmcont)("patched link at " INTPTR_FORMAT ": to relative " INTPTR_FORMAT, p2i(Frame::callee_link_address(f)), new_value);
 76 }
 77 
 78 inline address* Interpreted::return_pc_address(const frame& f) {
 79   return (address*)(f.fp() + frame::return_addr_offset);
 80 }
 81 
 82 template <bool relative>
 83 void Interpreted::patch_sender_sp(frame& f, intptr_t* sp) {
 84   assert (f.is_interpreted_frame(), "");
 85   intptr_t* la = f.addr_at(frame::interpreter_frame_sender_sp_offset);
 86   *la = relative ? (intptr_t)(sp - f.fp()) : (intptr_t)sp;
 87   log_trace(jvmcont)("patched sender_sp: " INTPTR_FORMAT, *la);
 88 }
 89 
 90 inline address* Frame::return_pc_address(const frame& f) {
 91   return (address*)(f.real_fp() - 1);
 92 }
 93 
 94 // inline address* Frame::pc_address(const frame& f) {
 95 //   return (address*)(f.sp() - frame::return_addr_offset);
 96 // }
 97 
 98 inline address Frame::real_pc(const frame& f) {
 99   address* pc_addr = &(((address*) f.sp())[-1]);
100   return *pc_addr;
101 }
102 
103 inline void Frame::patch_pc(const frame& f, address pc) {
104   address* pc_addr = &(((address*) f.sp())[-1]);
105   *pc_addr = pc;
106   log_develop_trace(jvmcont)("patch_pc at " INTPTR_FORMAT ": " INTPTR_FORMAT, p2i(pc_addr), p2i(pc));
107 }
108 
109 inline intptr_t* Interpreted::frame_top(const frame& f, InterpreterOopMap* mask) { // inclusive; this will be copied with the frame
110   // interpreter_frame_last_sp_offset, points to unextended_sp includes arguments in the frame
111   // interpreter_frame_initial_sp_offset excludes expression stack slots
112   int expression_stack_sz = expression_stack_size(f, mask);
113   intptr_t* res = *(intptr_t**)f.addr_at(frame::interpreter_frame_initial_sp_offset) - expression_stack_sz;
114   assert (res == (intptr_t*)f.interpreter_frame_monitor_end() - expression_stack_sz, "");
115   assert (res >= f.unextended_sp(),
116     "res: " INTPTR_FORMAT " initial_sp: " INTPTR_FORMAT " last_sp: " INTPTR_FORMAT " unextended_sp: " INTPTR_FORMAT " expression_stack_size: %d", 
117     p2i(res), p2i(f.addr_at(frame::interpreter_frame_initial_sp_offset)), f.at(frame::interpreter_frame_last_sp_offset), p2i(f.unextended_sp()), expression_stack_sz);
118   return res;
119   // Not true, but using unextended_sp might work
120   // assert (res == f.unextended_sp(), "res: " INTPTR_FORMAT " unextended_sp: " INTPTR_FORMAT, p2i(res), p2i(f.unextended_sp() + 1));
121 }
122 
123 template <bool relative>
124 inline intptr_t* Interpreted::frame_bottom(const frame& f) { // exclusive; this will not be copied with the frame
125   return (intptr_t*)f.at<relative>(frame::interpreter_frame_locals_offset) + 1; // exclusive, so we add 1 word
126 }
127 
128 inline intptr_t* Interpreted::frame_top(const frame& f, int callee_argsize, bool callee_interpreted) {
129   // tty->print_cr(">>> f.unextended_sp(): %p callee_argsize: %d callee_interpreted: %d", f.unextended_sp(), callee_argsize, callee_interpreted);
130   return f.unextended_sp() + (callee_interpreted ? callee_argsize : 0);
131 }
132 
133 template<typename FKind, typename RegisterMapT>
134 inline void ContinuationHelper::update_register_map(RegisterMapT* map, const frame& f) {
135   frame::update_map_with_saved_link(map, link_address<FKind>(f));
136 }
137 
138 template<typename RegisterMapT>
139 inline void ContinuationHelper::update_register_map_with_callee(RegisterMapT* map, const frame& f) {
140   frame::update_map_with_saved_link(map, Frame::callee_link_address(f));
141 }
142 
143 inline void ContinuationHelper::push_pd(const frame& f) {
144   log_develop_trace(jvmcont)("ContinuationHelper::push_pd: " INTPTR_FORMAT, p2i(f.fp()));
145   // os::print_location(tty, (intptr_t)f.fp());
146   *(intptr_t**)(f.sp() - frame::sender_sp_offset) = f.fp();
147 }
148 
149 // creates the yield stub frame faster than JavaThread::last_frame
150 inline frame ContinuationHelper::last_frame(JavaThread* thread) {
151   JavaFrameAnchor* anchor = thread->frame_anchor();
152   assert (anchor->last_Java_sp() != nullptr, "");
153   assert (anchor->last_Java_pc() != nullptr, "");
154 
155   assert (StubRoutines::cont_doYield_stub()->contains(anchor->last_Java_pc()), "must be");
156   assert (StubRoutines::cont_doYield_stub()->oop_maps()->count() == 1, "must be");
157 
158   return frame(anchor->last_Java_sp(), anchor->last_Java_sp(), anchor->last_Java_fp(), anchor->last_Java_pc(), nullptr, nullptr, true);
159   // return frame(anchor->last_Java_sp(), anchor->last_Java_sp(), anchor->last_Java_fp(), anchor->last_Java_pc(), 
160   //   StubRoutines::cont_doYield_stub(), StubRoutines::cont_doYield_stub()->oop_map_for_slot(0, anchor->last_Java_pc()), true);
161 }
162 
163 frame ContinuationEntry::to_frame() {
164   static CodeBlob* cb = CodeCache::find_blob(entry_pc());
165   return frame(entry_sp(), entry_sp(), entry_fp(), entry_pc(), cb);
166 }
167 
168 void ContinuationEntry::update_register_map(RegisterMap* map) {
169   intptr_t** fp = (intptr_t**)(bottom_sender_sp() - frame::sender_sp_offset);
170   frame::update_map_with_saved_link(map, fp);
171 }
172 
173 void ContinuationHelper::set_anchor_to_entry_pd(JavaFrameAnchor* anchor, ContinuationEntry* cont) {
174   anchor->set_last_Java_fp(cont->entry_fp());
175 }
176 
177 void ContinuationHelper::set_anchor_pd(JavaFrameAnchor* anchor, intptr_t* sp) {
178   intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
179   anchor->set_last_Java_fp(fp);
180 }
181 
182 /////
183 
184 template <typename ConfigT>
185 inline void Freeze<ConfigT>::set_top_frame_metadata_pd(const frame& hf) {
186   stackChunkOop chunk = _cont.tail();
187   assert (chunk->is_in_chunk(hf.sp() - 1), "");
188   assert (chunk->is_in_chunk(hf.sp() - frame::sender_sp_offset), "");
189 
190   *(hf.sp() - 1) = (intptr_t)hf.pc();
191 
192   intptr_t* fp_addr = hf.sp() - frame::sender_sp_offset;
193   *fp_addr = hf.is_interpreted_frame() ? (intptr_t)(hf.fp() - fp_addr) 
194                                        : (intptr_t)hf.fp();
195 
196   log_develop_trace(jvmcont)("set_top_frame_metadata_pd pc: " INTPTR_FORMAT " fp: " INTPTR_FORMAT, p2i(hf.pc()), *fp_addr);
197 }
198 
199 template <typename ConfigT>
200 inline intptr_t* Freeze<ConfigT>::align_bottom(intptr_t* bottom, int argsize) {
201 #ifdef _LP64
202   bottom -= (argsize & 1);
203 #endif
204   return bottom;
205 }
206 
207 template <typename ConfigT>
208 template<typename FKind>
209 inline frame Freeze<ConfigT>::sender(const frame& f) {
210   assert (FKind::is_instance(f), "");
211   if (FKind::interpreted) {
212     return frame(f.sender_sp(), f.interpreter_frame_sender_sp(), f.link(), f.sender_pc());
213   }
214   intptr_t** link_addr = link_address<FKind>(f);
215 
216   intptr_t* sender_sp = (intptr_t*)(link_addr + frame::sender_sp_offset); //  f.unextended_sp() + (fsize/wordSize); // 
217   address sender_pc = (address) *(sender_sp-1);
218   assert(sender_sp != f.sp(), "must have changed");
219 
220   int slot = 0;
221   CodeBlob* sender_cb = CodeCache::find_blob_and_oopmap(sender_pc, slot);
222   return sender_cb != nullptr
223     ? frame(sender_sp, sender_sp, *link_addr, sender_pc, sender_cb, slot == -1 ? nullptr : sender_cb->oop_map_for_slot(slot, sender_pc))
224     : frame(sender_sp, sender_sp, *link_addr, sender_pc);
225 }
226 
227 template <typename ConfigT>
228 template<typename FKind> frame Freeze<ConfigT>::new_hframe(frame& f, frame& caller) {
229   assert (FKind::is_instance(f), "");
230   assert (!caller.is_interpreted_frame() || caller.unextended_sp() == (intptr_t*)caller.at<true>(frame::interpreter_frame_last_sp_offset), "");
231 
232   intptr_t *sp, *fp; // sp is really our unextended_sp
233   if (FKind::interpreted) {
234     assert ((intptr_t*)f.at<false>(frame::interpreter_frame_last_sp_offset) == nullptr || f.unextended_sp() == (intptr_t*)f.at<false>(frame::interpreter_frame_last_sp_offset), "");
235     int locals = f.interpreter_frame_method()->max_locals();
236     bool overlap_caller = caller.is_interpreted_frame() || caller.is_empty();
237     fp = caller.unextended_sp() - (locals + frame::sender_sp_offset) + (overlap_caller ? Interpreted::stack_argsize(f) : 0);
238     sp = fp - (f.fp() - f.unextended_sp());
239     assert (sp <= fp && fp <= caller.unextended_sp(), "");
240     caller.set_sp(fp + frame::sender_sp_offset);
241 
242     assert (_cont.tail()->is_in_chunk(sp), "sp: " INTPTR_FORMAT " caller.sp(): " INTPTR_FORMAT " start_address: " INTPTR_FORMAT, p2i(sp), p2i(caller.sp()), p2i(_cont.tail()->start_address()));
243     
244     frame hf(sp, sp, fp, f.pc(), nullptr, nullptr, false);
245     *hf.addr_at(frame::interpreter_frame_locals_offset) = frame::sender_sp_offset + locals - 1;
246     return hf;
247   } else {
248     fp = *(intptr_t**)(f.sp() - frame::sender_sp_offset); // we need to re-read fp because it may be an oop and we might have had a safepoint in finalize_freeze, after constructing f.
249     int fsize = FKind::size(f);
250     sp = caller.unextended_sp() - fsize;
251     if (caller.is_interpreted_frame()) {
252       int argsize = FKind::stack_argsize(f);
253       sp -= argsize;
254     }
255     caller.set_sp(sp + fsize);
256 
257     assert (_cont.tail()->is_in_chunk(sp), "sp: " INTPTR_FORMAT " caller.sp(): " INTPTR_FORMAT " start_address: " INTPTR_FORMAT, p2i(sp), p2i(caller.sp()), p2i(_cont.tail()->start_address()));
258     
259     return frame(sp, sp, fp, f.pc(), nullptr, nullptr, false);
260   }
261 }
262 
263 template <typename ConfigT>
264 inline void Freeze<ConfigT>::relativize_interpreted_frame_metadata(const frame& f, const frame& hf) {
265   intptr_t* vfp = f.fp();
266   intptr_t* hfp = hf.fp();
267   assert (hfp == hf.unextended_sp() + (f.fp() - f.unextended_sp()), "");
268   assert ((f.at<false>(frame::interpreter_frame_last_sp_offset) != 0) || (f.unextended_sp() == f.sp()), "");
269   assert (f.fp() > (intptr_t*)f.at<false>(frame::interpreter_frame_initial_sp_offset), "");
270 
271   // at(frame::interpreter_frame_last_sp_offset) can be NULL at safepoint preempts
272   *hf.addr_at(frame::interpreter_frame_last_sp_offset) = hf.unextended_sp() - hf.fp();
273   *hf.addr_at(frame::interpreter_frame_locals_offset) = frame::sender_sp_offset + f.interpreter_frame_method()->max_locals() - 1;
274   
275   relativize(vfp, hfp, frame::interpreter_frame_initial_sp_offset); // == block_top == block_bottom
276 
277   assert ((hf.fp() - hf.unextended_sp()) == (f.fp() - f.unextended_sp()), "");
278   assert (hf.unextended_sp() == (intptr_t*)hf.at<true>(frame::interpreter_frame_last_sp_offset), "");
279   assert (hf.unextended_sp() <= (intptr_t*)hf.at<true>(frame::interpreter_frame_initial_sp_offset), "");
280   assert (hf.fp()            >  (intptr_t*)hf.at<true>(frame::interpreter_frame_initial_sp_offset), "");
281   assert (hf.fp()            <= (intptr_t*)hf.at<true>(frame::interpreter_frame_locals_offset), "");
282 }
283 
284 template <typename ConfigT>
285 template <typename FKind, bool bottom>
286 inline void Freeze<ConfigT>::patch_pd(frame& hf, const frame& caller) {
287   if (caller.is_interpreted_frame()) {
288     assert (!caller.is_empty(), "");
289     patch_callee_link_relative(caller, caller.fp());
290   } else {
291     patch_callee_link(caller, caller.fp());
292   }
293 }
294 
295 template <typename ConfigT>
296 inline void Freeze<ConfigT>::patch_chunk_pd(intptr_t* vsp, intptr_t* hsp) {
297   *(vsp - frame::sender_sp_offset) = *(hsp - frame::sender_sp_offset);
298 }
299 
300 template <typename ConfigT>
301 inline frame Thaw<ConfigT>::new_entry_frame() {
302   // if (Interpreter::contains(_cont.entryPC())) _cont.set_entrySP(_cont.entrySP() - 1);
303   intptr_t* sp = _cont.entrySP();
304   return frame(sp, sp, _cont.entryFP(), _cont.entryPC()); // TODO PERF: This finds code blob and computes deopt state
305 }
306 
307 template <typename ConfigT>
308 template<typename FKind> frame Thaw<ConfigT>::new_frame(const frame& hf, frame& caller, bool bottom) {
309   assert (FKind::is_instance(hf), "");
310 
311   if (FKind::interpreted) {
312     intptr_t* hsp = hf.unextended_sp();
313     const int fsize = Interpreted::frame_bottom<true>(hf) - hf.unextended_sp();
314     const int locals = hf.interpreter_frame_method()->max_locals();
315     intptr_t* vsp = caller.unextended_sp() - fsize;
316     intptr_t* fp = vsp + (hf.fp() - hsp);
317     DEBUG_ONLY(intptr_t* unextended_sp = fp + *hf.addr_at(frame::interpreter_frame_last_sp_offset);)
318     assert (vsp == unextended_sp, "vsp: " INTPTR_FORMAT " unextended_sp: " INTPTR_FORMAT, p2i(vsp), p2i(unextended_sp));
319     caller.set_sp(fp + frame::sender_sp_offset);
320     frame f(vsp, vsp, fp, hf.pc());
321     // it's set again later in derelativize_interpreted_frame_metadata, but we need to set the locals now so that we'll have the frame's bottom
322     intptr_t offset = *hf.addr_at(frame::interpreter_frame_locals_offset);
323     assert ((int)offset == locals + frame::sender_sp_offset - 1, "");
324     *(intptr_t**)f.addr_at(frame::interpreter_frame_locals_offset) = fp + offset;
325     return f;
326   } else {
327     int fsize = FKind::size(hf);
328     intptr_t* vsp = caller.unextended_sp() - fsize;
329     if (bottom || caller.is_interpreted_frame()) {
330       int argsize = hf.compiled_frame_stack_argsize();
331       log_develop_trace(jvmcont)("thaw_compiled_frame add argsize: fsize: %d argsize: %d fsize: %d", fsize, argsize, fsize + argsize);
332       
333       fsize += argsize;
334       vsp   -= argsize;
335       caller.set_sp(caller.sp() - argsize);
336       assert (caller.sp() == vsp + (fsize-argsize), "");
337 
338       vsp = align(hf, vsp, caller, bottom);
339     }
340 
341     assert (hf.cb() != nullptr && hf.oop_map() != nullptr, "");
342     intptr_t* fp = *(intptr_t**)(hf.sp() - frame::sender_sp_offset); // we need to re-read fp because it may be an oop and we might have fixed the frame.
343     return frame(vsp, vsp, fp, hf.pc(), hf.cb(), hf.oop_map()); // TODO PERF : this computes deopt state; is it necessary?
344   }
345 }
346 
347 template <typename ConfigT>
348 inline void Thaw<ConfigT>::set_interpreter_frame_bottom(const frame& f, intptr_t* bottom) {
349   *(intptr_t**)f.addr_at(frame::interpreter_frame_locals_offset) = bottom - 1;
350 }
351 
352 template <typename ConfigT>
353 inline void Thaw<ConfigT>::derelativize_interpreted_frame_metadata(const frame& hf, const frame& f) {
354   intptr_t* vfp = f.fp();
355 
356   derelativize(vfp, frame::interpreter_frame_last_sp_offset);
357   derelativize(vfp, frame::interpreter_frame_initial_sp_offset);
358 }
359 
360 template <typename ConfigT>
361 inline intptr_t* Thaw<ConfigT>::align(const frame& hf, intptr_t* vsp, frame& caller, bool bottom) {
362   // if (caller.is_interpreted_frame()) {
363   //   // Deoptimization likes ample room between interpreted frames and compiled frames. 
364   //   // This is due to caller_adjustment calculation in Deoptimization::fetch_unroll_info_helper.
365   //   // An attempt to simplify that calculation and make more room during deopt has failed some tests.
366 
367   //   int addedWords = 0;
368 
369   //   // SharedRuntime::gen_i2c_adapter makes room that's twice as big as required for the stack-passed arguments by counting slots but subtracting words from rsp 
370   //   assert (VMRegImpl::stack_slot_size == 4, "");
371   //   int argsize = hf.compiled_frame_stack_argsize();
372   //   assert (argsize >= 0, "");
373   //   addedWords += (argsize /* / 2*/) >> LogBytesPerWord; // Not sure why dividing by 2 is not big enough.
374 
375   //   log_develop_trace(jvmcont)("Aligning compiled frame 0: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(vsp), p2i(vsp - addedWords));
376   //   vsp -= addedWords;
377   //   log_develop_trace(jvmcont)("Aligning sender sp: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(caller.sp()), p2i(caller.sp() - addedWords));
378   //   caller.set_sp(caller.sp() - addedWords);
379   // }
380 #ifdef _LP64
381   if (((intptr_t)vsp & 0xf) != 0) {
382     log_develop_trace(jvmcont)("Aligning compiled frame 1: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(vsp), p2i(vsp - 1));
383     assert(caller.is_interpreted_frame() || (bottom && hf.compiled_frame_stack_argsize() % 2 != 0), "");
384     vsp--;
385 
386     log_develop_trace(jvmcont)("Aligning sender sp: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(caller.sp()), p2i(caller.sp() - 1));
387     caller.set_sp(caller.sp() - 1);
388   }
389   assert((intptr_t)vsp % 16 == 0, "");
390 #endif
391 
392   return vsp;
393 }
394 
395 template <typename ConfigT>
396 template<typename FKind, bool bottom>
397 inline void Thaw<ConfigT>::patch_pd(frame& f, const frame& caller) {
398   assert (!bottom || caller.fp() == _cont.entryFP(), "caller.fp: " INTPTR_FORMAT " entryFP: " INTPTR_FORMAT, p2i(caller.fp()), p2i(_cont.entryFP()));
399   patch_callee_link(caller, caller.fp());
400 }
401 
402 template <typename ConfigT>
403 intptr_t* Thaw<ConfigT>::push_interpreter_return_frame(intptr_t* sp) {
404   address pc = StubRoutines::cont_interpreter_forced_preempt_return();
405   intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
406 
407   log_develop_trace(jvmcont)("push_interpreter_return_frame initial sp: " INTPTR_FORMAT " final sp: " INTPTR_FORMAT " fp: " INTPTR_FORMAT, p2i(sp), p2i(sp - ContinuationHelper::frame_metadata), p2i(fp));
408 
409   sp -= ContinuationHelper::frame_metadata;
410   *(address*)(sp - frame::sender_sp_ret_address_offset()) = pc;
411   *(intptr_t**)(sp - frame::sender_sp_offset) = fp;
412   return sp;
413 }
414 
415 template <typename ConfigT>
416 void Thaw<ConfigT>::patch_chunk_pd(intptr_t* sp) {
417   intptr_t* fp = _cont.entryFP();
418   *(intptr_t**)(sp - frame::sender_sp_offset) = fp;
419   log_develop_trace(jvmcont)("thaw_chunk patching fp at " INTPTR_FORMAT " to " INTPTR_FORMAT, p2i(sp - frame::sender_sp_offset), p2i(fp));
420 }
421 
422 template <typename ConfigT>
423 inline void Thaw<ConfigT>::prefetch_chunk_pd(void* start, int size) {
424   size <<= LogBytesPerWord;
425   Prefetch::read(start, size);
426   Prefetch::read(start, size - 64);
427 }
428 
429 template <typename ConfigT>
430 inline intptr_t* Thaw<ConfigT>::align_chunk(intptr_t* vsp) {
431 #ifdef _LP64
432   vsp = align_down(vsp, 16);
433   assert((intptr_t)vsp % 16 == 0, "");
434 #endif
435   return vsp;
436 }
437 ////////
438 
439 #endif // CPU_X86_CONTINUATION_X86_INLINE_HPP