< prev index next >

src/hotspot/share/runtime/continuationFreezeThaw.cpp

Print this page

 451   inline frame freeze_start_frame_yield_stub();
 452   template<typename FKind>
 453   inline freeze_result recurse_freeze_java_frame(const frame& f, frame& caller, int fsize, int argsize);
 454   inline void before_freeze_java_frame(const frame& f, const frame& caller, int fsize, int argsize, bool is_bottom_frame);
 455   inline void after_freeze_java_frame(const frame& hf, bool is_bottom_frame);
 456   freeze_result finalize_freeze(const frame& callee, frame& caller, int argsize);
 457   void patch(const frame& f, frame& hf, const frame& caller, bool is_bottom_frame);
 458   NOINLINE freeze_result recurse_freeze_interpreted_frame(frame& f, frame& caller, int callee_argsize, bool callee_interpreted);
 459   freeze_result recurse_freeze_compiled_frame(frame& f, frame& caller, int callee_argsize, bool callee_interpreted);
 460   NOINLINE freeze_result recurse_freeze_stub_frame(frame& f, frame& caller);
 461   NOINLINE freeze_result recurse_freeze_native_frame(frame& f, frame& caller);
 462   NOINLINE void finish_freeze(const frame& f, const frame& top);
 463 
 464   void freeze_lockstack(stackChunkOop chunk);
 465 
 466   inline bool stack_overflow();
 467 
 468   static frame sender(const frame& f) { return f.is_interpreted_frame() ? sender<ContinuationHelper::InterpretedFrame>(f)
 469                                                                         : sender<ContinuationHelper::NonInterpretedUnknownFrame>(f); }
 470   template<typename FKind> static inline frame sender(const frame& f);
 471   template<typename FKind> frame new_heap_frame(frame& f, frame& caller);
 472   inline void set_top_frame_metadata_pd(const frame& hf);
 473   inline void patch_pd(frame& callee, const frame& caller);
 474   inline void patch_pd_unused(intptr_t* sp);
 475   void adjust_interpreted_frame_unextended_sp(frame& f);
 476   inline void prepare_freeze_interpreted_top_frame(frame& f);
 477   static inline void relativize_interpreted_frame_metadata(const frame& f, const frame& hf);
 478 
 479 protected:
 480   void freeze_fast_copy(stackChunkOop chunk, int chunk_start_sp CONT_JFR_ONLY(COMMA bool chunk_is_allocated));
 481   bool freeze_fast_new_chunk(stackChunkOop chunk);
 482 };
 483 
 484 template <typename ConfigT>
 485 class Freeze : public FreezeBase {
 486 private:
 487   stackChunkOop allocate_chunk(size_t stack_size, int argsize_md);
 488 
 489 public:
 490   inline Freeze(JavaThread* thread, ContinuationWrapper& cont, intptr_t* frame_sp, bool preempt)
 491     : FreezeBase(thread, cont, frame_sp, preempt) {}
 492 
 493   freeze_result try_freeze_fast();

1163 
1164   assert((!empty && Continuation::is_return_barrier_entry(entry.pc())) || (empty && Continuation::is_continuation_enterSpecial(entry)), "");
1165   assert(callee.is_interpreted_frame() || entry.sp() == entry.unextended_sp(), "");
1166 #endif
1167 
1168   return freeze_ok_bottom;
1169 }
1170 
1171 // After freezing a frame we need to possibly adjust some values related to the caller frame.
1172 void FreezeBase::patch(const frame& f, frame& hf, const frame& caller, bool is_bottom_frame) {
1173   if (is_bottom_frame) {
1174     // If we're the bottom frame, we need to replace the return barrier with the real
1175     // caller's pc.
1176     address last_pc = caller.pc();
1177     assert((last_pc == nullptr) == _cont.tail()->is_empty(), "");
1178     ContinuationHelper::Frame::patch_pc(caller, last_pc);
1179   } else {
1180     assert(!caller.is_empty(), "");
1181   }
1182 
1183   patch_pd(hf, caller);
1184 
1185   if (f.is_interpreted_frame()) {
1186     assert(hf.is_heap_frame(), "should be");
1187     ContinuationHelper::InterpretedFrame::patch_sender_sp(hf, caller);
1188   }
1189 
1190 #ifdef ASSERT
1191   if (hf.is_compiled_frame()) {
1192     if (f.is_deoptimized_frame()) { // TODO DEOPT: long term solution: unroll on freeze and patch pc
1193       log_develop_trace(continuations)("Freezing deoptimized frame");
1194       assert(f.cb()->as_nmethod()->is_deopt_pc(f.raw_pc()), "");
1195       assert(f.cb()->as_nmethod()->is_deopt_pc(ContinuationHelper::Frame::real_pc(f)), "");
1196     }
1197   }
1198 #endif
1199 }
1200 
1201 #ifdef ASSERT
1202 static void verify_frame_top(const frame& f, intptr_t* top) {
1203   ResourceMark rm;

1260 
1261   CONT_JFR_ONLY(_jfr_info.record_interpreted_frame();)
1262   DEBUG_ONLY(after_freeze_java_frame(hf, is_bottom_frame);)
1263   caller = hf;
1264 
1265   // Mark frame_method's GC epoch for class redefinition on_stack calculation.
1266   frame_method->record_gc_epoch();
1267 
1268   return freeze_ok;
1269 }
1270 
1271 // The parameter callee_argsize includes metadata that has to be part of caller/callee overlap.
1272 // See also StackChunkFrameStream<frame_kind>::frame_size()
1273 freeze_result FreezeBase::recurse_freeze_compiled_frame(frame& f, frame& caller,
1274                                                         int callee_argsize /* incl. metadata */,
1275                                                         bool callee_interpreted) {
1276   // The frame's top never includes the stack arguments to the callee
1277   intptr_t* const stack_frame_top = ContinuationHelper::CompiledFrame::frame_top(f, callee_argsize, callee_interpreted);
1278   intptr_t* const stack_frame_bottom = ContinuationHelper::CompiledFrame::frame_bottom(f);
1279   // including metadata between f and its stackargs
1280   const int argsize = ContinuationHelper::CompiledFrame::stack_argsize(f) + frame::metadata_words_at_top;
1281   const int fsize = pointer_delta_as_int(stack_frame_bottom + argsize, stack_frame_top);






















1282 
1283   log_develop_trace(continuations)("recurse_freeze_compiled_frame %s _size: %d fsize: %d argsize: %d",
1284                              ContinuationHelper::Frame::frame_method(f) != nullptr ?
1285                              ContinuationHelper::Frame::frame_method(f)->name_and_sig_as_C_string() : "",
1286                              _freeze_size, fsize, argsize);
1287   // we'd rather not yield inside methods annotated with @JvmtiMountTransition
1288   assert(!ContinuationHelper::Frame::frame_method(f)->jvmti_mount_transition(), "");
1289 
1290   freeze_result result = recurse_freeze_java_frame<ContinuationHelper::CompiledFrame>(f, caller, fsize, argsize);
1291   if (UNLIKELY(result > freeze_ok_bottom)) {
1292     return result;
1293   }
1294 
1295   bool is_bottom_frame = result == freeze_ok_bottom;
1296   assert(!caller.is_empty() || is_bottom_frame, "");

1297 
1298   DEBUG_ONLY(before_freeze_java_frame(f, caller, fsize, argsize, is_bottom_frame);)
1299 
1300   frame hf = new_heap_frame<ContinuationHelper::CompiledFrame>(f, caller);
1301 
1302   intptr_t* heap_frame_top = ContinuationHelper::CompiledFrame::frame_top(hf, callee_argsize, callee_interpreted);
1303 
1304   copy_to_chunk(stack_frame_top, heap_frame_top, fsize);
1305   assert(!is_bottom_frame || !caller.is_compiled_frame() || (heap_frame_top + fsize) == (caller.unextended_sp() + argsize), "");
1306 
1307   if (caller.is_interpreted_frame()) {
1308     // When thawing the frame we might need to add alignment (see Thaw::align)
1309     _total_align_size += frame::align_wiggle;
1310   }
1311 
1312   patch(f, hf, caller, is_bottom_frame);
1313 
1314   assert(is_bottom_frame || Interpreter::contains(ContinuationHelper::CompiledFrame::real_pc(caller)) == caller.is_interpreted_frame(), "");
1315 
1316   DEBUG_ONLY(after_freeze_java_frame(hf, is_bottom_frame);)
1317   caller = hf;
1318   return freeze_ok;
1319 }
1320 

2062 
2063   // Only used for preemption on ObjectLocker
2064   ObjectMonitor* _init_lock;
2065 
2066   StackChunkFrameStream<ChunkFrames::Mixed> _stream;
2067 
2068   NOT_PRODUCT(int _frames;)
2069 
2070 protected:
2071   ThawBase(JavaThread* thread, ContinuationWrapper& cont) :
2072       _thread(thread), _cont(cont),
2073       _fastpath(nullptr) {
2074     DEBUG_ONLY(_top_unextended_sp_before_thaw = nullptr;)
2075     assert (cont.tail() != nullptr, "no last chunk");
2076     DEBUG_ONLY(_top_stack_address = _cont.entrySP() - thaw_size(cont.tail());)
2077   }
2078 
2079   void clear_chunk(stackChunkOop chunk);
2080   template<bool check_stub>
2081   int remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &argsize);

2082   void copy_from_chunk(intptr_t* from, intptr_t* to, int size);
2083 
2084   void thaw_lockstack(stackChunkOop chunk);
2085 
2086   // fast path
2087   inline void prefetch_chunk_pd(void* start, int size_words);
2088   void patch_return(intptr_t* sp, bool is_last);
2089 
2090   intptr_t* handle_preempted_continuation(intptr_t* sp, Continuation::preempt_kind preempt_kind, bool fast_case);
2091   inline intptr_t* push_cleanup_continuation();
2092   inline intptr_t* push_preempt_adapter();
2093   intptr_t* redo_vmcall(JavaThread* current, frame& top);
2094   void throw_interrupted_exception(JavaThread* current, frame& top);
2095 
2096   void recurse_thaw(const frame& heap_frame, frame& caller, int num_frames, bool top_on_preempt_case);
2097   void finish_thaw(frame& f);
2098 
2099 private:
2100   template<typename FKind> bool recurse_thaw_java_frame(frame& caller, int num_frames);
2101   void finalize_thaw(frame& entry, int argsize);
2102 
2103   inline bool seen_by_gc();
2104 
2105   inline void before_thaw_java_frame(const frame& hf, const frame& caller, bool bottom, int num_frame);
2106   inline void after_thaw_java_frame(const frame& f, bool bottom);
2107   inline void patch(frame& f, const frame& caller, bool bottom);
2108   void clear_bitmap_bits(address start, address end);
2109 
2110   NOINLINE void recurse_thaw_interpreted_frame(const frame& hf, frame& caller, int num_frames, bool is_top);
2111   void recurse_thaw_compiled_frame(const frame& hf, frame& caller, int num_frames, bool stub_caller);
2112   void recurse_thaw_stub_frame(const frame& hf, frame& caller, int num_frames);
2113   void recurse_thaw_native_frame(const frame& hf, frame& caller, int num_frames);
2114 
2115   void push_return_frame(const frame& f);
2116   inline frame new_entry_frame();
2117   template<typename FKind> frame new_stack_frame(const frame& hf, frame& caller, bool bottom);
2118   inline void patch_pd(frame& f, const frame& sender);
2119   inline void patch_pd(frame& f, intptr_t* caller_sp);
2120   inline intptr_t* align(const frame& hf, intptr_t* frame_sp, frame& caller, bool bottom);
2121 
2122   void maybe_set_fastpath(intptr_t* sp) { if (sp > _fastpath) _fastpath = sp; }
2123 
2124   static inline void derelativize_interpreted_frame_metadata(const frame& hf, const frame& f);
2125 
2126  public:
2127   CONT_JFR_ONLY(FreezeThawJfrInfo& jfr_info() { return _jfr_info; })
2128 };
2129 
2130 template <typename ConfigT>
2131 class Thaw : public ThawBase {
2132 public:
2133   Thaw(JavaThread* thread, ContinuationWrapper& cont) : ThawBase(thread, cont) {}
2134 
2135   inline bool can_thaw_fast(stackChunkOop chunk) {
2136     return    !_barriers
2137            &&  _thread->cont_fastpath_thread_state()

2174     assert(_base - 1 <= top() + total_size() + frame::metadata_words_at_bottom, "missed entry frame");
2175   }
2176 
2177   int entry_frame_extension() const { return _argsize + (_argsize > 0 ? frame::metadata_words_at_top : 0); }
2178 
2179   // top and bottom stack pointers
2180   intptr_t* sp() const { return ContinuationHelper::frame_align_pointer(_base - _thaw_size); }
2181   intptr_t* bottom_sp() const { return ContinuationHelper::frame_align_pointer(_base - entry_frame_extension()); }
2182 
2183   // several operations operate on the totality of the stack being reconstructed,
2184   // including the metadata words
2185   intptr_t* top() const { return sp() - frame::metadata_words_at_bottom;  }
2186   int total_size() const { return _thaw_size + frame::metadata_words_at_bottom; }
2187 };
2188 
2189 inline void ThawBase::clear_chunk(stackChunkOop chunk) {
2190   chunk->set_sp(chunk->bottom());
2191   chunk->set_max_thawing_size(0);
2192 }
2193 














2194 template<bool check_stub>
2195 int ThawBase::remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &argsize) {
2196   bool empty = false;
2197   StackChunkFrameStream<ChunkFrames::CompiledOnly> f(chunk);
2198   DEBUG_ONLY(intptr_t* const chunk_sp = chunk->start_address() + chunk->sp();)
2199   assert(chunk_sp == f.sp(), "");
2200   assert(chunk_sp == f.unextended_sp(), "");
2201 
2202   int frame_size = f.cb()->frame_size();
2203   argsize = f.stack_argsize();
2204 
2205   assert(!f.is_stub() || check_stub, "");
2206   if (check_stub && f.is_stub()) {
2207     // If we don't thaw the top compiled frame too, after restoring the saved
2208     // registers back in Java, we would hit the return barrier to thaw one more
2209     // frame effectively overwriting the restored registers during that call.
2210     f.next(SmallRegisterMap::instance_no_args(), true /* stop */);
2211     assert(!f.is_done(), "");
2212 
2213     f.get_cb();
2214     assert(f.is_compiled(), "");
2215     frame_size += f.cb()->frame_size();
2216     argsize = f.stack_argsize();
2217 
2218     if (f.cb()->as_nmethod()->is_marked_for_deoptimization()) {
2219       // The caller of the runtime stub when the continuation is preempted is not at a
2220       // Java call instruction, and so cannot rely on nmethod patching for deopt.
2221       log_develop_trace(continuations)("Deoptimizing runtime stub caller");
2222       f.to_frame().deoptimize(nullptr); // the null thread simply avoids the assertion in deoptimize which we're not set up for
2223     }









2224   }
2225 
2226   f.next(SmallRegisterMap::instance_no_args(), true /* stop */);
2227   empty = f.is_done();
2228   assert(!empty || argsize == chunk->argsize(), "");
2229 
2230   if (empty) {
2231     clear_chunk(chunk);
2232   } else {
2233     chunk->set_sp(chunk->sp() + frame_size);
2234     chunk->set_max_thawing_size(chunk->max_thawing_size() - frame_size);
2235     // We set chunk->pc to the return pc into the next frame
2236     chunk->set_pc(f.pc());
2237 #ifdef ASSERT
2238     {
2239       intptr_t* retaddr_slot = (chunk_sp
2240                                 + frame_size
2241                                 - frame::sender_sp_ret_address_offset());
2242       assert(f.pc() == ContinuationHelper::return_address_at(retaddr_slot),
2243              "unexpected pc");

2504   assert(!_cont.is_empty(), "no more frames");
2505   assert(num_frames > 0, "");
2506   assert(!heap_frame.is_empty(), "");
2507 
2508   if (top_on_preempt_case && (heap_frame.is_native_frame() || heap_frame.is_runtime_frame())) {
2509     heap_frame.is_native_frame() ? recurse_thaw_native_frame(heap_frame, caller, 2) : recurse_thaw_stub_frame(heap_frame, caller, 2);
2510   } else if (!heap_frame.is_interpreted_frame()) {
2511     recurse_thaw_compiled_frame(heap_frame, caller, num_frames, false);
2512   } else {
2513     recurse_thaw_interpreted_frame(heap_frame, caller, num_frames, top_on_preempt_case);
2514   }
2515 }
2516 
2517 template<typename FKind>
2518 bool ThawBase::recurse_thaw_java_frame(frame& caller, int num_frames) {
2519   assert(num_frames > 0, "");
2520 
2521   DEBUG_ONLY(_frames++;)
2522 
2523   int argsize = _stream.stack_argsize();

2524 
2525   _stream.next(SmallRegisterMap::instance_no_args());
2526   assert(_stream.to_frame().is_empty() == _stream.is_done(), "");
2527 
2528   // we never leave a compiled caller of an interpreted frame as the top frame in the chunk
2529   // as it makes detecting that situation and adjusting unextended_sp tricky
2530   if (num_frames == 1 && !_stream.is_done() && FKind::interpreted && _stream.is_compiled()) {





2531     log_develop_trace(continuations)("thawing extra compiled frame to not leave a compiled interpreted-caller at top");
2532     num_frames++;
2533   }
2534 
2535   if (num_frames == 1 || _stream.is_done()) { // end recursion
2536     finalize_thaw(caller, FKind::interpreted ? 0 : argsize);
2537     return true; // bottom
2538   } else { // recurse
2539     recurse_thaw(_stream.to_frame(), caller, num_frames - 1, false /* top_on_preempt_case */);
2540     return false;
2541   }
2542 }
2543 
2544 void ThawBase::finalize_thaw(frame& entry, int argsize) {
2545   stackChunkOop chunk = _cont.tail();
2546 
2547   if (!_stream.is_done()) {
2548     assert(_stream.sp() >= chunk->sp_address(), "");
2549     chunk->set_sp(chunk->to_offset(_stream.sp()));
2550     chunk->set_pc(_stream.pc());

2577   }
2578   assert(bottom == _cont.is_entry_frame(caller), "bottom: %d is_entry_frame: %d", bottom, _cont.is_entry_frame(hf));
2579 }
2580 
2581 inline void ThawBase::after_thaw_java_frame(const frame& f, bool bottom) {
2582 #ifdef ASSERT
2583   LogTarget(Trace, continuations) lt;
2584   if (lt.develop_is_enabled()) {
2585     LogStream ls(lt);
2586     ls.print_cr("thawed frame:");
2587     print_frame_layout(f, false, &ls); // f.print_on(&ls);
2588   }
2589 #endif
2590 }
2591 
2592 inline void ThawBase::patch(frame& f, const frame& caller, bool bottom) {
2593   assert(!bottom || caller.fp() == _cont.entryFP(), "");
2594   if (bottom) {
2595     ContinuationHelper::Frame::patch_pc(caller, _cont.is_empty() ? caller.pc()
2596                                                                  : StubRoutines::cont_returnBarrier());
2597   } else if (_should_patch_caller_pc) {
2598     // Caller was deoptimized during thaw but we've overwritten the return address when copying f from the heap.
2599     // Also, on some platforms, if the caller is interpreted but the callee not we also need to patch.
2600     assert(caller.is_deoptimized_frame() PPC64_ONLY(|| caller.is_interpreted_frame()), "");
2601     ContinuationHelper::Frame::patch_pc(caller, caller.raw_pc());
2602     _should_patch_caller_pc = false;
2603   }
2604 
2605   patch_pd(f, caller);
2606 
2607   if (f.is_interpreted_frame()) {
2608     ContinuationHelper::InterpretedFrame::patch_sender_sp(f, caller);
2609   }
2610 
2611   assert(!bottom || !_cont.is_empty() || Continuation::is_continuation_entry_frame(f, nullptr), "");
2612   assert(!bottom || (_cont.is_empty() != Continuation::is_cont_barrier_frame(f)), "");
2613   assert(!caller.is_compiled_frame() || verify_deopt_state(caller), "");
2614 }
2615 
2616 void ThawBase::clear_bitmap_bits(address start, address end) {
2617   assert(is_aligned(start, wordSize), "should be aligned: " PTR_FORMAT, p2i(start));
2618   assert(is_aligned(end, VMRegImpl::stack_slot_size), "should be aligned: " PTR_FORMAT, p2i(end));
2619 
2620   // we need to clear the bits that correspond to arguments as they reside in the caller frame

2820 }
2821 
2822 void ThawBase::recurse_thaw_compiled_frame(const frame& hf, frame& caller, int num_frames, bool stub_caller) {
2823   assert(hf.is_compiled_frame(), "");
2824   assert(_preempted_case || !stub_caller, "stub caller not at preemption");
2825 
2826   if (!stub_caller && UNLIKELY(seen_by_gc())) { // recurse_thaw_stub_frame already invoked our barriers with a full regmap
2827     _cont.tail()->do_barriers<stackChunkOopDesc::BarrierType::Store>(_stream, SmallRegisterMap::instance_no_args());
2828   }
2829 
2830   const bool is_bottom_frame = recurse_thaw_java_frame<ContinuationHelper::CompiledFrame>(caller, num_frames);
2831 
2832   DEBUG_ONLY(before_thaw_java_frame(hf, caller, is_bottom_frame, num_frames);)
2833 
2834   assert(caller.sp() == caller.unextended_sp(), "");
2835 
2836   if ((!is_bottom_frame && caller.is_interpreted_frame()) || (is_bottom_frame && Interpreter::contains(_cont.tail()->pc()))) {
2837     _align_size += frame::align_wiggle; // we add one whether or not we've aligned because we add it in recurse_freeze_compiled_frame
2838   }
2839 









2840   // new_stack_frame must construct the resulting frame using hf.pc() rather than hf.raw_pc() because the frame is not
2841   // yet laid out in the stack, and so the original_pc is not stored in it.
2842   // As a result, f.is_deoptimized_frame() is always false and we must test hf to know if the frame is deoptimized.
2843   frame f = new_stack_frame<ContinuationHelper::CompiledFrame>(hf, caller, is_bottom_frame);


2844   intptr_t* const stack_frame_top = f.sp();
2845   intptr_t* const heap_frame_top = hf.unextended_sp();
2846 
2847   const int added_argsize = (is_bottom_frame || caller.is_interpreted_frame()) ? hf.compiled_frame_stack_argsize() : 0;
2848   int fsize = ContinuationHelper::CompiledFrame::size(hf) + added_argsize;
2849   assert(fsize <= (int)(caller.unextended_sp() - f.unextended_sp()), "");
2850 
2851   intptr_t* from = heap_frame_top - frame::metadata_words_at_bottom;
2852   intptr_t* to   = stack_frame_top - frame::metadata_words_at_bottom;
2853   // copy metadata, except the metadata at the top of the (unextended) entry frame
2854   int sz = fsize + frame::metadata_words_at_bottom + (is_bottom_frame && added_argsize == 0 ? 0 : frame::metadata_words_at_top);
2855 
2856   // If we're the bottom-most thawed frame, we're writing to within one word from entrySP
2857   // (we might have one padding word for alignment)
2858   assert(!is_bottom_frame || (_cont.entrySP() - 1 <= to + sz && to + sz <= _cont.entrySP()), "");
2859   assert(!is_bottom_frame || hf.compiled_frame_stack_argsize() != 0 || (to + sz && to + sz == _cont.entrySP()), "");
2860 
2861   copy_from_chunk(from, to, sz); // copying good oops because we invoked barriers above
2862 
2863   patch(f, caller, is_bottom_frame);
2864 
2865   // f.is_deoptimized_frame() is always false and we must test hf.is_deoptimized_frame() (see comment above)
2866   assert(!f.is_deoptimized_frame(), "");
2867   if (hf.is_deoptimized_frame()) {
2868     maybe_set_fastpath(f.sp());
2869     f.set_deoptimized();
2870   } else if (_thread->is_interp_only_mode()

 451   inline frame freeze_start_frame_yield_stub();
 452   template<typename FKind>
 453   inline freeze_result recurse_freeze_java_frame(const frame& f, frame& caller, int fsize, int argsize);
 454   inline void before_freeze_java_frame(const frame& f, const frame& caller, int fsize, int argsize, bool is_bottom_frame);
 455   inline void after_freeze_java_frame(const frame& hf, bool is_bottom_frame);
 456   freeze_result finalize_freeze(const frame& callee, frame& caller, int argsize);
 457   void patch(const frame& f, frame& hf, const frame& caller, bool is_bottom_frame);
 458   NOINLINE freeze_result recurse_freeze_interpreted_frame(frame& f, frame& caller, int callee_argsize, bool callee_interpreted);
 459   freeze_result recurse_freeze_compiled_frame(frame& f, frame& caller, int callee_argsize, bool callee_interpreted);
 460   NOINLINE freeze_result recurse_freeze_stub_frame(frame& f, frame& caller);
 461   NOINLINE freeze_result recurse_freeze_native_frame(frame& f, frame& caller);
 462   NOINLINE void finish_freeze(const frame& f, const frame& top);
 463 
 464   void freeze_lockstack(stackChunkOop chunk);
 465 
 466   inline bool stack_overflow();
 467 
 468   static frame sender(const frame& f) { return f.is_interpreted_frame() ? sender<ContinuationHelper::InterpretedFrame>(f)
 469                                                                         : sender<ContinuationHelper::NonInterpretedUnknownFrame>(f); }
 470   template<typename FKind> static inline frame sender(const frame& f);
 471   template<typename FKind> frame new_heap_frame(frame& f, frame& caller, int size_adjust = 0);
 472   inline void set_top_frame_metadata_pd(const frame& hf);
 473   inline void patch_pd(frame& callee, const frame& caller, bool is_bottom_frame);
 474   inline void patch_pd_unused(intptr_t* sp);
 475   void adjust_interpreted_frame_unextended_sp(frame& f);
 476   inline void prepare_freeze_interpreted_top_frame(frame& f);
 477   static inline void relativize_interpreted_frame_metadata(const frame& f, const frame& hf);
 478 
 479 protected:
 480   void freeze_fast_copy(stackChunkOop chunk, int chunk_start_sp CONT_JFR_ONLY(COMMA bool chunk_is_allocated));
 481   bool freeze_fast_new_chunk(stackChunkOop chunk);
 482 };
 483 
 484 template <typename ConfigT>
 485 class Freeze : public FreezeBase {
 486 private:
 487   stackChunkOop allocate_chunk(size_t stack_size, int argsize_md);
 488 
 489 public:
 490   inline Freeze(JavaThread* thread, ContinuationWrapper& cont, intptr_t* frame_sp, bool preempt)
 491     : FreezeBase(thread, cont, frame_sp, preempt) {}
 492 
 493   freeze_result try_freeze_fast();

1163 
1164   assert((!empty && Continuation::is_return_barrier_entry(entry.pc())) || (empty && Continuation::is_continuation_enterSpecial(entry)), "");
1165   assert(callee.is_interpreted_frame() || entry.sp() == entry.unextended_sp(), "");
1166 #endif
1167 
1168   return freeze_ok_bottom;
1169 }
1170 
1171 // After freezing a frame we need to possibly adjust some values related to the caller frame.
1172 void FreezeBase::patch(const frame& f, frame& hf, const frame& caller, bool is_bottom_frame) {
1173   if (is_bottom_frame) {
1174     // If we're the bottom frame, we need to replace the return barrier with the real
1175     // caller's pc.
1176     address last_pc = caller.pc();
1177     assert((last_pc == nullptr) == _cont.tail()->is_empty(), "");
1178     ContinuationHelper::Frame::patch_pc(caller, last_pc);
1179   } else {
1180     assert(!caller.is_empty(), "");
1181   }
1182 
1183   patch_pd(hf, caller, is_bottom_frame);
1184 
1185   if (f.is_interpreted_frame()) {
1186     assert(hf.is_heap_frame(), "should be");
1187     ContinuationHelper::InterpretedFrame::patch_sender_sp(hf, caller);
1188   }
1189 
1190 #ifdef ASSERT
1191   if (hf.is_compiled_frame()) {
1192     if (f.is_deoptimized_frame()) { // TODO DEOPT: long term solution: unroll on freeze and patch pc
1193       log_develop_trace(continuations)("Freezing deoptimized frame");
1194       assert(f.cb()->as_nmethod()->is_deopt_pc(f.raw_pc()), "");
1195       assert(f.cb()->as_nmethod()->is_deopt_pc(ContinuationHelper::Frame::real_pc(f)), "");
1196     }
1197   }
1198 #endif
1199 }
1200 
1201 #ifdef ASSERT
1202 static void verify_frame_top(const frame& f, intptr_t* top) {
1203   ResourceMark rm;

1260 
1261   CONT_JFR_ONLY(_jfr_info.record_interpreted_frame();)
1262   DEBUG_ONLY(after_freeze_java_frame(hf, is_bottom_frame);)
1263   caller = hf;
1264 
1265   // Mark frame_method's GC epoch for class redefinition on_stack calculation.
1266   frame_method->record_gc_epoch();
1267 
1268   return freeze_ok;
1269 }
1270 
1271 // The parameter callee_argsize includes metadata that has to be part of caller/callee overlap.
1272 // See also StackChunkFrameStream<frame_kind>::frame_size()
1273 freeze_result FreezeBase::recurse_freeze_compiled_frame(frame& f, frame& caller,
1274                                                         int callee_argsize /* incl. metadata */,
1275                                                         bool callee_interpreted) {
1276   // The frame's top never includes the stack arguments to the callee
1277   intptr_t* const stack_frame_top = ContinuationHelper::CompiledFrame::frame_top(f, callee_argsize, callee_interpreted);
1278   intptr_t* const stack_frame_bottom = ContinuationHelper::CompiledFrame::frame_bottom(f);
1279   // including metadata between f and its stackargs
1280   int argsize = ContinuationHelper::CompiledFrame::stack_argsize(f) + frame::metadata_words_at_top;
1281   int fsize = pointer_delta_as_int(stack_frame_bottom + argsize, stack_frame_top);
1282 
1283   int real_frame_size = 0;
1284   bool augmented = f.was_augmented_on_entry(real_frame_size);
1285   if (augmented) {
1286     // The args reside inside the frame so clear argsize. If the caller is compiled,
1287     // this will cause the stack arguments passed by the caller to be freezed when
1288     // freezing the caller frame itself. If the caller is interpreted this will have
1289     // the effect of discarding the arg area created in the i2c stub.
1290     argsize = 0;
1291     fsize = real_frame_size - (callee_interpreted ? 0 : callee_argsize);
1292 #ifdef ASSERT
1293     nmethod* nm = f.cb()->as_nmethod();
1294     Method* method = nm->method();
1295     address return_pc = ContinuationHelper::CompiledFrame::return_pc(f);
1296     CodeBlob* caller_cb = CodeCache::find_blob_fast(return_pc);
1297     assert(nm->is_compiled_by_c2() || (caller_cb->is_nmethod() && caller_cb->as_nmethod()->is_compiled_by_c2()), "caller or callee should be c2 compiled");
1298     assert((!caller_cb->is_nmethod() && nm->is_compiled_by_c2()) ||
1299            (nm->compiler_type() != caller_cb->as_nmethod()->compiler_type()) ||
1300            (nm->is_compiled_by_c2() && !method->is_static() && method->method_holder()->is_inline_klass()),
1301            "frame should not be extended");
1302 #endif
1303   }
1304 
1305   log_develop_trace(continuations)("recurse_freeze_compiled_frame %s _size: %d fsize: %d argsize: %d augmented: %d",
1306                              ContinuationHelper::Frame::frame_method(f) != nullptr ?
1307                              ContinuationHelper::Frame::frame_method(f)->name_and_sig_as_C_string() : "",
1308                              _freeze_size, fsize, argsize, augmented);
1309   // we'd rather not yield inside methods annotated with @JvmtiMountTransition
1310   assert(!ContinuationHelper::Frame::frame_method(f)->jvmti_mount_transition(), "");
1311 
1312   freeze_result result = recurse_freeze_java_frame<ContinuationHelper::CompiledFrame>(f, caller, fsize, argsize);
1313   if (UNLIKELY(result > freeze_ok_bottom)) {
1314     return result;
1315   }
1316 
1317   bool is_bottom_frame = result == freeze_ok_bottom;
1318   assert(!caller.is_empty() || is_bottom_frame, "");
1319   assert(!is_bottom_frame || !augmented, "thaw extended frame without caller?");
1320 
1321   DEBUG_ONLY(before_freeze_java_frame(f, caller, fsize, argsize, is_bottom_frame);)
1322 
1323   frame hf = new_heap_frame<ContinuationHelper::CompiledFrame>(f, caller, augmented ? real_frame_size - f.cb()->as_nmethod()->frame_size() : 0);
1324 
1325   intptr_t* heap_frame_top = ContinuationHelper::CompiledFrame::frame_top(hf, callee_argsize, callee_interpreted);
1326 
1327   copy_to_chunk(stack_frame_top, heap_frame_top, fsize);
1328   assert(!is_bottom_frame || !caller.is_compiled_frame() || (heap_frame_top + fsize) == (caller.unextended_sp() + argsize), "");
1329 
1330   if (caller.is_interpreted_frame()) {
1331     // When thawing the frame we might need to add alignment (see Thaw::align)
1332     _total_align_size += frame::align_wiggle;
1333   }
1334 
1335   patch(f, hf, caller, is_bottom_frame);
1336 
1337   assert(is_bottom_frame || Interpreter::contains(ContinuationHelper::CompiledFrame::real_pc(caller)) == caller.is_interpreted_frame(), "");
1338 
1339   DEBUG_ONLY(after_freeze_java_frame(hf, is_bottom_frame);)
1340   caller = hf;
1341   return freeze_ok;
1342 }
1343 

2085 
2086   // Only used for preemption on ObjectLocker
2087   ObjectMonitor* _init_lock;
2088 
2089   StackChunkFrameStream<ChunkFrames::Mixed> _stream;
2090 
2091   NOT_PRODUCT(int _frames;)
2092 
2093 protected:
2094   ThawBase(JavaThread* thread, ContinuationWrapper& cont) :
2095       _thread(thread), _cont(cont),
2096       _fastpath(nullptr) {
2097     DEBUG_ONLY(_top_unextended_sp_before_thaw = nullptr;)
2098     assert (cont.tail() != nullptr, "no last chunk");
2099     DEBUG_ONLY(_top_stack_address = _cont.entrySP() - thaw_size(cont.tail());)
2100   }
2101 
2102   void clear_chunk(stackChunkOop chunk);
2103   template<bool check_stub>
2104   int remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &argsize);
2105   int remove_scalarized_frames(StackChunkFrameStream<ChunkFrames::CompiledOnly>& scfs, int &argsize);
2106   void copy_from_chunk(intptr_t* from, intptr_t* to, int size);
2107 
2108   void thaw_lockstack(stackChunkOop chunk);
2109 
2110   // fast path
2111   inline void prefetch_chunk_pd(void* start, int size_words);
2112   void patch_return(intptr_t* sp, bool is_last);
2113 
2114   intptr_t* handle_preempted_continuation(intptr_t* sp, Continuation::preempt_kind preempt_kind, bool fast_case);
2115   inline intptr_t* push_cleanup_continuation();
2116   inline intptr_t* push_preempt_adapter();
2117   intptr_t* redo_vmcall(JavaThread* current, frame& top);
2118   void throw_interrupted_exception(JavaThread* current, frame& top);
2119 
2120   void recurse_thaw(const frame& heap_frame, frame& caller, int num_frames, bool top_on_preempt_case);
2121   void finish_thaw(frame& f);
2122 
2123 private:
2124   template<typename FKind> bool recurse_thaw_java_frame(frame& caller, int num_frames);
2125   void finalize_thaw(frame& entry, int argsize);
2126 
2127   inline bool seen_by_gc();
2128 
2129   inline void before_thaw_java_frame(const frame& hf, const frame& caller, bool bottom, int num_frame);
2130   inline void after_thaw_java_frame(const frame& f, bool bottom);
2131   inline void patch(frame& f, const frame& caller, bool bottom);
2132   void clear_bitmap_bits(address start, address end);
2133 
2134   NOINLINE void recurse_thaw_interpreted_frame(const frame& hf, frame& caller, int num_frames, bool is_top);
2135   void recurse_thaw_compiled_frame(const frame& hf, frame& caller, int num_frames, bool stub_caller);
2136   void recurse_thaw_stub_frame(const frame& hf, frame& caller, int num_frames);
2137   void recurse_thaw_native_frame(const frame& hf, frame& caller, int num_frames);
2138 
2139   void push_return_frame(const frame& f);
2140   inline frame new_entry_frame();
2141   template<typename FKind> frame new_stack_frame(const frame& hf, frame& caller, bool bottom, int size_adjust = 0);
2142   inline void patch_pd(frame& f, const frame& sender);
2143   inline void patch_pd(frame& f, intptr_t* caller_sp);
2144   inline intptr_t* align(const frame& hf, intptr_t* frame_sp, frame& caller, bool bottom);
2145 
2146   void maybe_set_fastpath(intptr_t* sp) { if (sp > _fastpath) _fastpath = sp; }
2147 
2148   static inline void derelativize_interpreted_frame_metadata(const frame& hf, const frame& f);
2149 
2150  public:
2151   CONT_JFR_ONLY(FreezeThawJfrInfo& jfr_info() { return _jfr_info; })
2152 };
2153 
2154 template <typename ConfigT>
2155 class Thaw : public ThawBase {
2156 public:
2157   Thaw(JavaThread* thread, ContinuationWrapper& cont) : ThawBase(thread, cont) {}
2158 
2159   inline bool can_thaw_fast(stackChunkOop chunk) {
2160     return    !_barriers
2161            &&  _thread->cont_fastpath_thread_state()

2198     assert(_base - 1 <= top() + total_size() + frame::metadata_words_at_bottom, "missed entry frame");
2199   }
2200 
2201   int entry_frame_extension() const { return _argsize + (_argsize > 0 ? frame::metadata_words_at_top : 0); }
2202 
2203   // top and bottom stack pointers
2204   intptr_t* sp() const { return ContinuationHelper::frame_align_pointer(_base - _thaw_size); }
2205   intptr_t* bottom_sp() const { return ContinuationHelper::frame_align_pointer(_base - entry_frame_extension()); }
2206 
2207   // several operations operate on the totality of the stack being reconstructed,
2208   // including the metadata words
2209   intptr_t* top() const { return sp() - frame::metadata_words_at_bottom;  }
2210   int total_size() const { return _thaw_size + frame::metadata_words_at_bottom; }
2211 };
2212 
2213 inline void ThawBase::clear_chunk(stackChunkOop chunk) {
2214   chunk->set_sp(chunk->bottom());
2215   chunk->set_max_thawing_size(0);
2216 }
2217 
2218 int ThawBase::remove_scalarized_frames(StackChunkFrameStream<ChunkFrames::CompiledOnly>& f, int &argsize) {
2219   intptr_t* top = f.sp();
2220 
2221   while (f.cb()->as_nmethod()->needs_stack_repair()) {
2222     f.next(SmallRegisterMap::instance_no_args(), false /* stop */);
2223   }
2224   assert(!f.is_done(), "");
2225   assert(f.is_compiled(), "");
2226 
2227   intptr_t* bottom = f.sp() + f.cb()->frame_size();
2228   argsize = f.stack_argsize();
2229   return bottom - top;
2230 }
2231 
2232 template<bool check_stub>
2233 int ThawBase::remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &argsize) {
2234   bool empty = false;
2235   StackChunkFrameStream<ChunkFrames::CompiledOnly> f(chunk);
2236   DEBUG_ONLY(intptr_t* const chunk_sp = chunk->start_address() + chunk->sp();)
2237   assert(chunk_sp == f.sp(), "");
2238   assert(chunk_sp == f.unextended_sp(), "");
2239 
2240   int frame_size = f.cb()->frame_size();
2241   argsize = f.stack_argsize();
2242 
2243   assert(!f.is_stub() || check_stub, "");
2244   if (check_stub && f.is_stub()) {
2245     // If we don't thaw the top compiled frame too, after restoring the saved
2246     // registers back in Java, we would hit the return barrier to thaw one more
2247     // frame effectively overwriting the restored registers during that call.
2248     f.next(SmallRegisterMap::instance_no_args(), true /* stop */);
2249     assert(!f.is_done(), "");
2250 
2251     f.get_cb();
2252     assert(f.is_compiled(), "");


2253 
2254     if (f.cb()->as_nmethod()->is_marked_for_deoptimization()) {
2255       // The caller of the runtime stub when the continuation is preempted is not at a
2256       // Java call instruction, and so cannot rely on nmethod patching for deopt.
2257       log_develop_trace(continuations)("Deoptimizing runtime stub caller");
2258       f.to_frame().deoptimize(nullptr); // the null thread simply avoids the assertion in deoptimize which we're not set up for
2259     }
2260 
2261     if (f.cb()->as_nmethod()->needs_stack_repair()) {
2262       frame_size += remove_scalarized_frames(f, argsize);
2263     } else {
2264       frame_size += f.cb()->frame_size();
2265       argsize = f.stack_argsize();
2266     }
2267   } else if (f.cb()->as_nmethod()->needs_stack_repair()) {
2268     frame_size = remove_scalarized_frames(f, argsize);
2269   }
2270 
2271   f.next(SmallRegisterMap::instance_no_args(), true /* stop */);
2272   empty = f.is_done();
2273   assert(!empty || argsize == chunk->argsize(), "");
2274 
2275   if (empty) {
2276     clear_chunk(chunk);
2277   } else {
2278     chunk->set_sp(chunk->sp() + frame_size);
2279     chunk->set_max_thawing_size(chunk->max_thawing_size() - frame_size);
2280     // We set chunk->pc to the return pc into the next frame
2281     chunk->set_pc(f.pc());
2282 #ifdef ASSERT
2283     {
2284       intptr_t* retaddr_slot = (chunk_sp
2285                                 + frame_size
2286                                 - frame::sender_sp_ret_address_offset());
2287       assert(f.pc() == ContinuationHelper::return_address_at(retaddr_slot),
2288              "unexpected pc");

2549   assert(!_cont.is_empty(), "no more frames");
2550   assert(num_frames > 0, "");
2551   assert(!heap_frame.is_empty(), "");
2552 
2553   if (top_on_preempt_case && (heap_frame.is_native_frame() || heap_frame.is_runtime_frame())) {
2554     heap_frame.is_native_frame() ? recurse_thaw_native_frame(heap_frame, caller, 2) : recurse_thaw_stub_frame(heap_frame, caller, 2);
2555   } else if (!heap_frame.is_interpreted_frame()) {
2556     recurse_thaw_compiled_frame(heap_frame, caller, num_frames, false);
2557   } else {
2558     recurse_thaw_interpreted_frame(heap_frame, caller, num_frames, top_on_preempt_case);
2559   }
2560 }
2561 
2562 template<typename FKind>
2563 bool ThawBase::recurse_thaw_java_frame(frame& caller, int num_frames) {
2564   assert(num_frames > 0, "");
2565 
2566   DEBUG_ONLY(_frames++;)
2567 
2568   int argsize = _stream.stack_argsize();
2569   CodeBlob* cb = _stream.cb();
2570 
2571   _stream.next(SmallRegisterMap::instance_no_args());
2572   assert(_stream.to_frame().is_empty() == _stream.is_done(), "");
2573 
2574   // We never leave a compiled caller of an interpreted frame as the top frame in the chunk
2575   // as it makes detecting that situation and adjusting unextended_sp tricky. We also always
2576   // thaw the caller of a frame that needs_stack_repair, as it would otherwise complicate things:
2577   // - Regardless of whether the frame was extended or not, we would need to copy the right arg
2578   //   size if its greater than the one given by the normal method signature (non-scalarized).
2579   // - If the frame was indeed extended, leaving its caller as the top frame would complicate walking
2580   //   the chunk (we need unextended_sp, but we only have sp).
2581   if (num_frames == 1 && !_stream.is_done() && ((FKind::interpreted && _stream.is_compiled()) || (FKind::compiled && cb->as_nmethod_or_null()->needs_stack_repair()))) {
2582     log_develop_trace(continuations)("thawing extra compiled frame to not leave a compiled interpreted-caller at top");
2583     num_frames++;
2584   }
2585 
2586   if (num_frames == 1 || _stream.is_done()) { // end recursion
2587     finalize_thaw(caller, FKind::interpreted ? 0 : argsize);
2588     return true; // bottom
2589   } else { // recurse
2590     recurse_thaw(_stream.to_frame(), caller, num_frames - 1, false /* top_on_preempt_case */);
2591     return false;
2592   }
2593 }
2594 
2595 void ThawBase::finalize_thaw(frame& entry, int argsize) {
2596   stackChunkOop chunk = _cont.tail();
2597 
2598   if (!_stream.is_done()) {
2599     assert(_stream.sp() >= chunk->sp_address(), "");
2600     chunk->set_sp(chunk->to_offset(_stream.sp()));
2601     chunk->set_pc(_stream.pc());

2628   }
2629   assert(bottom == _cont.is_entry_frame(caller), "bottom: %d is_entry_frame: %d", bottom, _cont.is_entry_frame(hf));
2630 }
2631 
2632 inline void ThawBase::after_thaw_java_frame(const frame& f, bool bottom) {
2633 #ifdef ASSERT
2634   LogTarget(Trace, continuations) lt;
2635   if (lt.develop_is_enabled()) {
2636     LogStream ls(lt);
2637     ls.print_cr("thawed frame:");
2638     print_frame_layout(f, false, &ls); // f.print_on(&ls);
2639   }
2640 #endif
2641 }
2642 
2643 inline void ThawBase::patch(frame& f, const frame& caller, bool bottom) {
2644   assert(!bottom || caller.fp() == _cont.entryFP(), "");
2645   if (bottom) {
2646     ContinuationHelper::Frame::patch_pc(caller, _cont.is_empty() ? caller.pc()
2647                                                                  : StubRoutines::cont_returnBarrier());
2648   } else if (_should_patch_caller_pc || caller.is_compiled_frame()) {
2649     // Caller was deoptimized during thaw but we've overwritten the return address when copying f from the heap.
2650     // Also, on some platforms, if the caller is interpreted but the callee not we also need to patch.
2651     assert(!_should_patch_caller_pc || caller.is_deoptimized_frame() PPC64_ONLY(|| caller.is_interpreted_frame()), "");
2652     ContinuationHelper::Frame::patch_pc(caller, caller.raw_pc());
2653     _should_patch_caller_pc = false;
2654   }
2655 
2656   patch_pd(f, caller);
2657 
2658   if (f.is_interpreted_frame()) {
2659     ContinuationHelper::InterpretedFrame::patch_sender_sp(f, caller);
2660   }
2661 
2662   assert(!bottom || !_cont.is_empty() || Continuation::is_continuation_entry_frame(f, nullptr), "");
2663   assert(!bottom || (_cont.is_empty() != Continuation::is_cont_barrier_frame(f)), "");
2664   assert(!caller.is_compiled_frame() || verify_deopt_state(caller), "");
2665 }
2666 
2667 void ThawBase::clear_bitmap_bits(address start, address end) {
2668   assert(is_aligned(start, wordSize), "should be aligned: " PTR_FORMAT, p2i(start));
2669   assert(is_aligned(end, VMRegImpl::stack_slot_size), "should be aligned: " PTR_FORMAT, p2i(end));
2670 
2671   // we need to clear the bits that correspond to arguments as they reside in the caller frame

2871 }
2872 
2873 void ThawBase::recurse_thaw_compiled_frame(const frame& hf, frame& caller, int num_frames, bool stub_caller) {
2874   assert(hf.is_compiled_frame(), "");
2875   assert(_preempted_case || !stub_caller, "stub caller not at preemption");
2876 
2877   if (!stub_caller && UNLIKELY(seen_by_gc())) { // recurse_thaw_stub_frame already invoked our barriers with a full regmap
2878     _cont.tail()->do_barriers<stackChunkOopDesc::BarrierType::Store>(_stream, SmallRegisterMap::instance_no_args());
2879   }
2880 
2881   const bool is_bottom_frame = recurse_thaw_java_frame<ContinuationHelper::CompiledFrame>(caller, num_frames);
2882 
2883   DEBUG_ONLY(before_thaw_java_frame(hf, caller, is_bottom_frame, num_frames);)
2884 
2885   assert(caller.sp() == caller.unextended_sp(), "");
2886 
2887   if ((!is_bottom_frame && caller.is_interpreted_frame()) || (is_bottom_frame && Interpreter::contains(_cont.tail()->pc()))) {
2888     _align_size += frame::align_wiggle; // we add one whether or not we've aligned because we add it in recurse_freeze_compiled_frame
2889   }
2890 
2891   int fsize = 0;
2892   int added_argsize = 0;
2893   bool augmented = hf.was_augmented_on_entry(fsize);
2894   if (!augmented) {
2895     added_argsize = (is_bottom_frame || caller.is_interpreted_frame()) ? hf.compiled_frame_stack_argsize() : 0;
2896     fsize += added_argsize;
2897   }
2898   assert(!is_bottom_frame || !augmented, "");
2899 
2900   // new_stack_frame must construct the resulting frame using hf.pc() rather than hf.raw_pc() because the frame is not
2901   // yet laid out in the stack, and so the original_pc is not stored in it.
2902   // As a result, f.is_deoptimized_frame() is always false and we must test hf to know if the frame is deoptimized.
2903   frame f = new_stack_frame<ContinuationHelper::CompiledFrame>(hf, caller, is_bottom_frame, augmented ? fsize - hf.cb()->frame_size() : 0);
2904   assert((int)(caller.sp() - f.sp()) == (augmented ? fsize : f.cb()->frame_size()), "");
2905 
2906   intptr_t* const stack_frame_top = f.sp();
2907   intptr_t* const heap_frame_top = hf.unextended_sp();





2908   intptr_t* from = heap_frame_top - frame::metadata_words_at_bottom;
2909   intptr_t* to   = stack_frame_top - frame::metadata_words_at_bottom;
2910   // copy metadata, except the metadata at the top of the (unextended) entry frame
2911   int sz = fsize + frame::metadata_words_at_bottom + (is_bottom_frame && added_argsize == 0 ? 0 : frame::metadata_words_at_top);
2912 
2913   // If we're the bottom-most thawed frame, we're writing to within one word from entrySP
2914   // (we might have one padding word for alignment)
2915   assert(!is_bottom_frame || (_cont.entrySP() - 1 <= to + sz && to + sz <= _cont.entrySP()), "");
2916   assert(!is_bottom_frame || hf.compiled_frame_stack_argsize() != 0 || (to + sz && to + sz == _cont.entrySP()), "");
2917 
2918   copy_from_chunk(from, to, sz); // copying good oops because we invoked barriers above
2919 
2920   patch(f, caller, is_bottom_frame);
2921 
2922   // f.is_deoptimized_frame() is always false and we must test hf.is_deoptimized_frame() (see comment above)
2923   assert(!f.is_deoptimized_frame(), "");
2924   if (hf.is_deoptimized_frame()) {
2925     maybe_set_fastpath(f.sp());
2926     f.set_deoptimized();
2927   } else if (_thread->is_interp_only_mode()
< prev index next >