< prev index next >

src/hotspot/cpu/s390/continuationFreezeThaw_s390.inline.hpp

Print this page

 56 }
 57 
 58 template<typename FKind>
 59 inline frame FreezeBase::sender(const frame& f) {
 60   assert(FKind::is_instance(f), "");
 61 
 62   if (FKind::interpreted) {
 63     return frame(f.sender_sp(), f.sender_pc(), f.interpreter_frame_sender_sp());
 64   }
 65 
 66   intptr_t* sender_sp = f.sender_sp();
 67   address sender_pc = f.sender_pc();
 68   assert(sender_sp != f.sp(), "must have changed");
 69   int slot = 0;
 70   CodeBlob* sender_cb = CodeCache::find_blob_and_oopmap(sender_pc, slot);
 71   return sender_cb != nullptr
 72          ? frame(sender_sp, sender_sp, nullptr, sender_pc, sender_cb, slot == -1 ? nullptr : sender_cb->oop_map_for_slot(slot, sender_pc))
 73          : frame(sender_sp, sender_pc, sender_sp);
 74 }
 75 
 76 template<typename FKind> frame FreezeBase::new_heap_frame(frame& f, frame& caller) {
 77   assert(FKind::is_instance(f), "");
 78   intptr_t *sp, *fp;
 79   if (FKind::interpreted) {
 80     intptr_t locals_offset = *f.addr_at(_z_ijava_idx(locals));
 81 
 82     // If the caller.is_empty(), i.e. we're freezing into an empty chunk, then we set
 83     // the chunk's argsize in finalize_freeze and make room for it above the unextended_sp
 84     // See also comment on StackChunkFrameStream<frame_kind>::interpreter_frame_size()
 85 
 86     int overlap =
 87       (caller.is_interpreted_frame() || caller.is_empty())
 88       ? ContinuationHelper::InterpretedFrame::stack_argsize(f) + frame::metadata_words_at_top
 89       : 0;
 90 
 91     // Calculate the new frame's FP in the heap chunk.
 92     // Starting from caller's unextended_sp, we:
 93     // - subtract 1 for the z_parent_ijava_frame_abi (which sits just below the locals)
 94     // - subtract locals_offset (distance from FP to locals in the original frame)
 95     // - add overlap (to account for shared stack args when caller is interpreted or empty)
 96     // This positions FP such that locals are correctly placed relative to the caller's frame.

154   intptr_t* vfp = f.fp();
155   intptr_t* hfp = hf.fp();
156   assert(f.fp() > (intptr_t*)f.interpreter_frame_esp(), "");
157 
158   // There is alignment padding between vfp and f's locals array in the original
159   // frame, because we freeze the padding (see recurse_freeze_interpreted_frame)
160   // in order to keep the same relativized locals pointer, we don't need to change it here.
161 
162   // Make sure that monitors is already relativized.
163   assert(hf.at_absolute(_z_ijava_idx(monitors)) <= -(frame::z_ijava_state_size / wordSize), "");
164   // Make sure that esp is already relativized.
165   assert(hf.at_absolute(_z_ijava_idx(esp)) <= hf.at_absolute(_z_ijava_idx(monitors)), "");
166   // top_frame_sp is already relativized
167 
168   // hfp == hf.sp() + (f.fp() - f.sp()) is not true on ppc because the stack frame has room for
169   // the maximal expression stack and the expression stack in the heap frame is trimmed.
170   assert(hf.fp() == hf.interpreter_frame_esp() + (f.fp() - f.interpreter_frame_esp()), "");
171   assert(hf.fp()                 <= (intptr_t*)hf.at(_z_ijava_idx(locals)), "");
172 }
173 
174 inline void FreezeBase::patch_pd(frame& hf, const frame& caller) {
175   if (caller.is_interpreted_frame()) {
176     assert(!caller.is_empty(), "");
177     patch_callee_link_relative(caller, caller.fp());
178   }
179 #ifdef ASSERT
180   else {
181     // For compiled frames the back link is actually redundant. It gets computed
182     // as unextended_sp + frame_size.
183 
184     // Note a difference from x86_64: the link is not made relative if the caller
185     // is a compiled frame because there rbp is used as a non-volatile register by
186     // c1/c2 so it could be a computed value local to the caller.
187 
188     // See also:
189     // - FreezeBase::set_top_frame_metadata_pd
190     // - StackChunkFrameStream<frame_kind>::fp()
191     // - UseContinuationFastPath: compiled frames are copied in a batch w/o patching the back link.
192     //   The backlinks are restored when thawing (see Thaw<ConfigT>::patch_caller_links())
193     patch_callee_link(hf, (intptr_t*)badAddress);
194   }

200 
201 inline void FreezeBase::patch_stack_pd(intptr_t* frame_sp, intptr_t* heap_sp) {
202   // Nothing to do. The backchain is reconstructed when thawing (see Thaw<ConfigT>::patch_caller_links())
203 }
204 
205 inline intptr_t* AnchorMark::anchor_mark_set_pd() {
206   // Nothing to do on s390 because the interpreter does not use SP as expression stack pointer.
207   // Instead there is a dedicated register Z_esp which is not affected by VM calls.
208   return _top_frame.sp();
209 }
210 
211 inline void AnchorMark::anchor_mark_clear_pd() {
212   // Nothing to do. See anchor_mark_set_pd().
213 }
214 
215 inline frame ThawBase::new_entry_frame() {
216   intptr_t* sp = _cont.entrySP();
217   return frame(sp, _cont.entryPC(), sp, _cont.entryFP());
218 }
219 
220 template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame& caller, bool bottom) {
221   assert(FKind::is_instance(hf), "");
222 
223   assert(is_aligned(caller.fp(), frame::frame_alignment), PTR_FORMAT, p2i(caller.fp()));
224   // caller.sp() can be unaligned. This is fixed below.
225   if (FKind::interpreted) {
226     // Note: we have to overlap with the caller, at least if it is interpreted, to match the
227     // max_thawing_size calculation during freeze. See also comment above.
228     intptr_t* heap_sp = hf.unextended_sp();
229     const int fsize = ContinuationHelper::InterpretedFrame::frame_bottom(hf) - hf.unextended_sp();
230     const int overlap = !caller.is_interpreted_frame() ? 0
231                         : ContinuationHelper::InterpretedFrame::stack_argsize(hf) + frame::metadata_words_at_top;
232     intptr_t* frame_sp = caller.unextended_sp() + overlap - fsize;
233     intptr_t* fp = frame_sp + (hf.fp() - heap_sp);
234     // align fp
235     int padding = fp - align_down(fp, frame::frame_alignment);
236     fp -= padding;
237     // alignment of sp is done by callee or in finish_thaw()
238     frame_sp -= padding;
239 
240     // On s390 esp points to the first free slot on the expression stack (see frame_s390.hpp).

 56 }
 57 
 58 template<typename FKind>
 59 inline frame FreezeBase::sender(const frame& f) {
 60   assert(FKind::is_instance(f), "");
 61 
 62   if (FKind::interpreted) {
 63     return frame(f.sender_sp(), f.sender_pc(), f.interpreter_frame_sender_sp());
 64   }
 65 
 66   intptr_t* sender_sp = f.sender_sp();
 67   address sender_pc = f.sender_pc();
 68   assert(sender_sp != f.sp(), "must have changed");
 69   int slot = 0;
 70   CodeBlob* sender_cb = CodeCache::find_blob_and_oopmap(sender_pc, slot);
 71   return sender_cb != nullptr
 72          ? frame(sender_sp, sender_sp, nullptr, sender_pc, sender_cb, slot == -1 ? nullptr : sender_cb->oop_map_for_slot(slot, sender_pc))
 73          : frame(sender_sp, sender_pc, sender_sp);
 74 }
 75 
 76 template<typename FKind> frame FreezeBase::new_heap_frame(frame& f, frame& caller, int size_adjust) {
 77   assert(FKind::is_instance(f), "");
 78   intptr_t *sp, *fp;
 79   if (FKind::interpreted) {
 80     intptr_t locals_offset = *f.addr_at(_z_ijava_idx(locals));
 81 
 82     // If the caller.is_empty(), i.e. we're freezing into an empty chunk, then we set
 83     // the chunk's argsize in finalize_freeze and make room for it above the unextended_sp
 84     // See also comment on StackChunkFrameStream<frame_kind>::interpreter_frame_size()
 85 
 86     int overlap =
 87       (caller.is_interpreted_frame() || caller.is_empty())
 88       ? ContinuationHelper::InterpretedFrame::stack_argsize(f) + frame::metadata_words_at_top
 89       : 0;
 90 
 91     // Calculate the new frame's FP in the heap chunk.
 92     // Starting from caller's unextended_sp, we:
 93     // - subtract 1 for the z_parent_ijava_frame_abi (which sits just below the locals)
 94     // - subtract locals_offset (distance from FP to locals in the original frame)
 95     // - add overlap (to account for shared stack args when caller is interpreted or empty)
 96     // This positions FP such that locals are correctly placed relative to the caller's frame.

154   intptr_t* vfp = f.fp();
155   intptr_t* hfp = hf.fp();
156   assert(f.fp() > (intptr_t*)f.interpreter_frame_esp(), "");
157 
158   // There is alignment padding between vfp and f's locals array in the original
159   // frame, because we freeze the padding (see recurse_freeze_interpreted_frame)
160   // in order to keep the same relativized locals pointer, we don't need to change it here.
161 
162   // Make sure that monitors is already relativized.
163   assert(hf.at_absolute(_z_ijava_idx(monitors)) <= -(frame::z_ijava_state_size / wordSize), "");
164   // Make sure that esp is already relativized.
165   assert(hf.at_absolute(_z_ijava_idx(esp)) <= hf.at_absolute(_z_ijava_idx(monitors)), "");
166   // top_frame_sp is already relativized
167 
168   // hfp == hf.sp() + (f.fp() - f.sp()) is not true on ppc because the stack frame has room for
169   // the maximal expression stack and the expression stack in the heap frame is trimmed.
170   assert(hf.fp() == hf.interpreter_frame_esp() + (f.fp() - f.interpreter_frame_esp()), "");
171   assert(hf.fp()                 <= (intptr_t*)hf.at(_z_ijava_idx(locals)), "");
172 }
173 
174 inline void FreezeBase::patch_pd(frame& hf, const frame& caller, bool is_bottom_frame) {
175   if (caller.is_interpreted_frame()) {
176     assert(!caller.is_empty(), "");
177     patch_callee_link_relative(caller, caller.fp());
178   }
179 #ifdef ASSERT
180   else {
181     // For compiled frames the back link is actually redundant. It gets computed
182     // as unextended_sp + frame_size.
183 
184     // Note a difference from x86_64: the link is not made relative if the caller
185     // is a compiled frame because there rbp is used as a non-volatile register by
186     // c1/c2 so it could be a computed value local to the caller.
187 
188     // See also:
189     // - FreezeBase::set_top_frame_metadata_pd
190     // - StackChunkFrameStream<frame_kind>::fp()
191     // - UseContinuationFastPath: compiled frames are copied in a batch w/o patching the back link.
192     //   The backlinks are restored when thawing (see Thaw<ConfigT>::patch_caller_links())
193     patch_callee_link(hf, (intptr_t*)badAddress);
194   }

200 
201 inline void FreezeBase::patch_stack_pd(intptr_t* frame_sp, intptr_t* heap_sp) {
202   // Nothing to do. The backchain is reconstructed when thawing (see Thaw<ConfigT>::patch_caller_links())
203 }
204 
205 inline intptr_t* AnchorMark::anchor_mark_set_pd() {
206   // Nothing to do on s390 because the interpreter does not use SP as expression stack pointer.
207   // Instead there is a dedicated register Z_esp which is not affected by VM calls.
208   return _top_frame.sp();
209 }
210 
211 inline void AnchorMark::anchor_mark_clear_pd() {
212   // Nothing to do. See anchor_mark_set_pd().
213 }
214 
215 inline frame ThawBase::new_entry_frame() {
216   intptr_t* sp = _cont.entrySP();
217   return frame(sp, _cont.entryPC(), sp, _cont.entryFP());
218 }
219 
220 template<typename FKind> frame ThawBase::new_stack_frame(const frame& hf, frame& caller, bool bottom, int size_adjust) {
221   assert(FKind::is_instance(hf), "");
222 
223   assert(is_aligned(caller.fp(), frame::frame_alignment), PTR_FORMAT, p2i(caller.fp()));
224   // caller.sp() can be unaligned. This is fixed below.
225   if (FKind::interpreted) {
226     // Note: we have to overlap with the caller, at least if it is interpreted, to match the
227     // max_thawing_size calculation during freeze. See also comment above.
228     intptr_t* heap_sp = hf.unextended_sp();
229     const int fsize = ContinuationHelper::InterpretedFrame::frame_bottom(hf) - hf.unextended_sp();
230     const int overlap = !caller.is_interpreted_frame() ? 0
231                         : ContinuationHelper::InterpretedFrame::stack_argsize(hf) + frame::metadata_words_at_top;
232     intptr_t* frame_sp = caller.unextended_sp() + overlap - fsize;
233     intptr_t* fp = frame_sp + (hf.fp() - heap_sp);
234     // align fp
235     int padding = fp - align_down(fp, frame::frame_alignment);
236     fp -= padding;
237     // alignment of sp is done by callee or in finish_thaw()
238     frame_sp -= padding;
239 
240     // On s390 esp points to the first free slot on the expression stack (see frame_s390.hpp).
< prev index next >