190 // If we're the bottom-most frame frozen in this freeze, the caller might have stayed frozen in the chunk,
191 // and its oop-containing fp fixed. We've now just overwritten it, so we must patch it back to its value
192 // as read from the chunk.
193 patch_callee_link(caller, caller.fp());
194 }
195 }
196
197 inline void FreezeBase::patch_pd_unused(intptr_t* sp) {
198 }
199
200 //////// Thaw
201
202 // Fast path
203
204 inline void ThawBase::prefetch_chunk_pd(void* start, int size) {
205 size <<= LogBytesPerWord;
206 Prefetch::read(start, size);
207 Prefetch::read(start, size - 64);
208 }
209
210 template <typename ConfigT>
211 inline void Thaw<ConfigT>::patch_caller_links(intptr_t* sp, intptr_t* bottom) {
212 // Fast path depends on !PreserveFramePointer. See can_thaw_fast().
213 assert(!PreserveFramePointer, "Frame pointers need to be fixed");
214 }
215
216 // Slow path
217
218 inline frame ThawBase::new_entry_frame() {
219 intptr_t* sp = _cont.entrySP();
220 // TODO PERF: This finds code blob and computes deopt state
221 return frame(sp, sp, _cont.entryFP(), _cont.entryPC());
222 }
223
224 template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame& caller, bool bottom) {
225 assert(FKind::is_instance(hf), "");
226 // The values in the returned frame object will be written into the callee's stack in patch.
227
228 if (FKind::interpreted) {
229 intptr_t* heap_sp = hf.unextended_sp();
290 #endif
291
292 return frame_sp;
293 }
294
295 inline void ThawBase::patch_pd(frame& f, const frame& caller) {
296 patch_callee_link(caller, caller.fp());
297 }
298
299 inline void ThawBase::patch_pd(frame& f, intptr_t* caller_sp) {
300 intptr_t* fp = caller_sp - frame::sender_sp_offset;
301 patch_callee_link(f, fp);
302 }
303
304 inline intptr_t* ThawBase::push_cleanup_continuation() {
305 frame enterSpecial = new_entry_frame();
306 intptr_t* sp = enterSpecial.sp();
307
308 sp[-1] = (intptr_t)ContinuationEntry::cleanup_pc();
309 sp[-2] = (intptr_t)enterSpecial.fp();
310
311 log_develop_trace(continuations, preempt)("push_cleanup_continuation initial sp: " INTPTR_FORMAT " final sp: " INTPTR_FORMAT, p2i(sp + 2 * frame::metadata_words), p2i(sp));
312 return sp;
313 }
314
315 inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, const frame& f) {
316 // Make sure that last_sp is kept relativized.
317 assert((intptr_t*)f.at_relative(frame::interpreter_frame_last_sp_offset) == f.unextended_sp(), "");
318
319 // Make sure that monitor_block_top is still relativized.
320 assert(f.at_absolute(frame::interpreter_frame_monitor_block_top_offset) <= frame::interpreter_frame_initial_sp_offset, "");
321
322 DEBUG_ONLY(Method* m = hf.interpreter_frame_method();)
323 DEBUG_ONLY(int extra_space = m->is_object_wait0() ? m->size_of_parameters() : 0;) // see comment in relativize_interpreted_frame_metadata()
324
325 // Make sure that extended_sp is kept relativized.
326 assert((intptr_t*)f.at_relative(frame::interpreter_frame_extended_sp_offset) < f.unextended_sp() + extra_space, "");
327 }
328
329 #endif // CPU_RISCV_CONTINUATIONFREEZETHAW_RISCV_INLINE_HPP
|
190 // If we're the bottom-most frame frozen in this freeze, the caller might have stayed frozen in the chunk,
191 // and its oop-containing fp fixed. We've now just overwritten it, so we must patch it back to its value
192 // as read from the chunk.
193 patch_callee_link(caller, caller.fp());
194 }
195 }
196
197 inline void FreezeBase::patch_pd_unused(intptr_t* sp) {
198 }
199
200 //////// Thaw
201
202 // Fast path
203
204 inline void ThawBase::prefetch_chunk_pd(void* start, int size) {
205 size <<= LogBytesPerWord;
206 Prefetch::read(start, size);
207 Prefetch::read(start, size - 64);
208 }
209
210 inline intptr_t* AnchorMark::anchor_mark_set_pd() {
211 intptr_t* sp = _top_frame.sp();
212 if (_top_frame.is_interpreted_frame()) {
213 // In case the top frame is interpreted we need to set up the anchor using
214 // the last_sp saved in the frame (remove possible alignment added while
215 // thawing, see ThawBase::finish_thaw()). We also need to clear the last_sp
216 // saved in the frame as it is not expected to be set in case we preempt again.
217 _last_sp_from_frame = _top_frame.interpreter_frame_last_sp();
218 assert(_last_sp_from_frame != nullptr, "");
219 _top_frame.interpreter_frame_set_last_sp(nullptr);
220 if (sp != _last_sp_from_frame) {
221 _last_sp_from_frame[-1] = (intptr_t)_top_frame.pc();
222 _last_sp_from_frame[-2] = (intptr_t)_top_frame.fp();
223 }
224 _is_interpreted = true;
225 sp = _last_sp_from_frame;
226 }
227 return sp;
228 }
229
230 inline void AnchorMark::anchor_mark_clear_pd() {
231 if (_is_interpreted) {
232 // Restore last_sp_from_frame and possibly overwritten pc.
233 _top_frame.interpreter_frame_set_last_sp(_last_sp_from_frame);
234 intptr_t* sp = _top_frame.sp();
235 if (sp != _last_sp_from_frame) {
236 sp[-1] = (intptr_t)_top_frame.pc();
237 }
238 }
239 }
240
241 template <typename ConfigT>
242 inline void Thaw<ConfigT>::patch_caller_links(intptr_t* sp, intptr_t* bottom) {
243 // Fast path depends on !PreserveFramePointer. See can_thaw_fast().
244 assert(!PreserveFramePointer, "Frame pointers need to be fixed");
245 }
246
247 // Slow path
248
249 inline frame ThawBase::new_entry_frame() {
250 intptr_t* sp = _cont.entrySP();
251 // TODO PERF: This finds code blob and computes deopt state
252 return frame(sp, sp, _cont.entryFP(), _cont.entryPC());
253 }
254
255 template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame& caller, bool bottom) {
256 assert(FKind::is_instance(hf), "");
257 // The values in the returned frame object will be written into the callee's stack in patch.
258
259 if (FKind::interpreted) {
260 intptr_t* heap_sp = hf.unextended_sp();
321 #endif
322
323 return frame_sp;
324 }
325
326 inline void ThawBase::patch_pd(frame& f, const frame& caller) {
327 patch_callee_link(caller, caller.fp());
328 }
329
330 inline void ThawBase::patch_pd(frame& f, intptr_t* caller_sp) {
331 intptr_t* fp = caller_sp - frame::sender_sp_offset;
332 patch_callee_link(f, fp);
333 }
334
335 inline intptr_t* ThawBase::push_cleanup_continuation() {
336 frame enterSpecial = new_entry_frame();
337 intptr_t* sp = enterSpecial.sp();
338
339 sp[-1] = (intptr_t)ContinuationEntry::cleanup_pc();
340 sp[-2] = (intptr_t)enterSpecial.fp();
341 return sp;
342 }
343
344 inline intptr_t* ThawBase::push_preempt_adapter() {
345 frame enterSpecial = new_entry_frame();
346 intptr_t* sp = enterSpecial.sp();
347
348 sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
349 return sp;
350 }
351
352 inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, const frame& f) {
353 // Make sure that last_sp is kept relativized.
354 assert((intptr_t*)f.at_relative(frame::interpreter_frame_last_sp_offset) == f.unextended_sp(), "");
355
356 // Make sure that monitor_block_top is still relativized.
357 assert(f.at_absolute(frame::interpreter_frame_monitor_block_top_offset) <= frame::interpreter_frame_initial_sp_offset, "");
358
359 DEBUG_ONLY(Method* m = hf.interpreter_frame_method();)
360 DEBUG_ONLY(int extra_space = m->is_object_wait0() ? m->size_of_parameters() : 0;) // see comment in relativize_interpreted_frame_metadata()
361
362 // Make sure that extended_sp is kept relativized.
363 assert((intptr_t*)f.at_relative(frame::interpreter_frame_extended_sp_offset) < f.unextended_sp() + extra_space, "");
364 }
365
366 #endif // CPU_RISCV_CONTINUATIONFREEZETHAW_RISCV_INLINE_HPP
|