< prev index next >

src/hotspot/cpu/aarch64/frame_aarch64.cpp

Print this page

 98     // First check if frame is complete and tester is reliable
 99     // Unfortunately we can only check frame complete for runtime stubs and nmethod
100     // other generic buffer blobs are more problematic so we just assume they are
101     // ok. adapter blobs never have a frame complete and are never ok.
102 
103     if (!_cb->is_frame_complete_at(_pc)) {
104       if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
105         return false;
106       }
107     }
108 
109     // Could just be some random pointer within the codeBlob
110     if (!_cb->code_contains(_pc)) {
111       return false;
112     }
113 
114     // Entry frame checks
115     if (is_entry_frame()) {
116       // an entry frame must have a valid fp.
117       return fp_safe && is_entry_frame_valid(thread);


118     }
119 
120     intptr_t* sender_sp = NULL;
121     intptr_t* sender_unextended_sp = NULL;
122     address   sender_pc = NULL;
123     intptr_t* saved_fp =  NULL;
124 
125     if (is_interpreted_frame()) {
126       // fp must be safe
127       if (!fp_safe) {
128         return false;
129       }
130 
131       sender_pc = (address) this->fp()[return_addr_offset];
132       // for interpreted frames, the value below is the sender "raw" sp,
133       // which can be different from the sender unextended sp (the sp seen
134       // by the sender) because of current frame local variables
135       sender_sp = (intptr_t*) addr_at(sender_sp_offset);
136       sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
137       saved_fp = (intptr_t*) this->fp()[link_offset];

194 
195     // We should never be able to see an adapter if the current frame is something from code cache
196     if (sender_blob->is_adapter_blob()) {
197       return false;
198     }
199 
200     // Could be the call_stub
201     if (StubRoutines::returns_to_call_stub(sender_pc)) {
202       if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
203         return false;
204       }
205 
206       // construct the potential sender
207 
208       frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
209 
210       // Validate the JavaCallWrapper an entry frame must have
211       address jcw = (address)sender.entry_frame_call_wrapper();
212 
213       return thread->is_in_stack_range_excl(jcw, (address)sender.fp());


214     }
215 
216     CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
217     if (nm != NULL) {
218       if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
219           nm->method()->is_method_handle_intrinsic()) {
220         return false;
221       }
222     }
223 
224     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
225     // because the return address counts against the callee's frame.
226 
227     if (sender_blob->frame_size() <= 0) {
228       assert(!sender_blob->is_compiled(), "should count return address at least");
229       return false;
230     }
231 
232     // We should never be able to see anything here except an nmethod. If something in the
233     // code cache (current frame) is called by an entity within the code cache that entity

346   // Java frame called from C; skip all C frames and return top C
347   // frame of that chunk as the sender
348   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
349   assert(!entry_frame_is_first(), "next Java fp must be non zero");
350   assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
351   // Since we are walking the stack now this nested anchor is obviously walkable
352   // even if it wasn't when it was stacked.
353   if (!jfa->walkable()) {
354     // Capture _last_Java_pc (if needed) and mark anchor walkable.
355     jfa->capture_last_Java_pc();
356   }
357   map->clear();
358   assert(map->include_argument_oops(), "should be set by clear");
359   vmassert(jfa->last_Java_pc() != NULL, "not walkable");
360   frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
361 
362   return fr;
363 }
364 
365 OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
366   ShouldNotCallThis();
367   return nullptr;


368 }
369 
370 bool frame::optimized_entry_frame_is_first() const {
371   ShouldNotCallThis();
372   return false;


373 }
374 
375 frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
376   ShouldNotCallThis();
377   return {};

















378 }
379 
380 //------------------------------------------------------------------------------
381 // frame::verify_deopt_original_pc
382 //
383 // Verifies the calculated original PC of a deoptimization PC for the
384 // given unextended SP.
385 #ifdef ASSERT
386 void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) {
387   frame fr;
388 
389   // This is ugly but it's better than to change {get,set}_original_pc
390   // to take an SP value as argument.  And it's only a debugging
391   // method anyway.
392   fr._unextended_sp = unextended_sp;
393 
394   address original_pc = nm->get_original_pc(&fr);
395   assert(nm->insts_contains_inclusive(original_pc),
396          "original PC must be in the main code section of the the compiled method (or must be immediately following it)");
397 }

490 
491     // Since the prolog does the save and restore of FP there is no
492     // oopmap for it so we must fill in its location as if there was
493     // an oopmap entry since if our caller was compiled code there
494     // could be live jvm state in it.
495     update_map_with_saved_link(map, saved_fp_addr);
496   }
497 
498   return frame(l_sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
499 }
500 
501 //------------------------------------------------------------------------------
502 // frame::sender_raw
503 frame frame::sender_raw(RegisterMap* map) const {
504   // Default is we done have to follow them. The sender_for_xxx will
505   // update it accordingly
506    map->set_include_argument_oops(false);
507 
508   if (is_entry_frame())
509     return sender_for_entry_frame(map);


510   if (is_interpreted_frame())
511     return sender_for_interpreter_frame(map);
512   assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
513 
514   // This test looks odd: why is it not is_compiled_frame() ?  That's
515   // because stubs also have OOP maps.
516   if (_cb != NULL) {
517     return sender_for_compiled_frame(map);
518   }
519 
520   // Must be native-compiled frame, i.e. the marshaling code for native
521   // methods that exists in the core system.
522 
523   return frame(sender_sp(), link(), sender_pc());
524 }
525 
526 frame frame::sender(RegisterMap* map) const {
527   frame result = sender_raw(map);
528 
529   if (map->process_frames()) {

 98     // First check if frame is complete and tester is reliable
 99     // Unfortunately we can only check frame complete for runtime stubs and nmethod
100     // other generic buffer blobs are more problematic so we just assume they are
101     // ok. adapter blobs never have a frame complete and are never ok.
102 
103     if (!_cb->is_frame_complete_at(_pc)) {
104       if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) {
105         return false;
106       }
107     }
108 
109     // Could just be some random pointer within the codeBlob
110     if (!_cb->code_contains(_pc)) {
111       return false;
112     }
113 
114     // Entry frame checks
115     if (is_entry_frame()) {
116       // an entry frame must have a valid fp.
117       return fp_safe && is_entry_frame_valid(thread);
118     } else if (is_optimized_entry_frame()) {
119       return fp_safe;
120     }
121 
122     intptr_t* sender_sp = NULL;
123     intptr_t* sender_unextended_sp = NULL;
124     address   sender_pc = NULL;
125     intptr_t* saved_fp =  NULL;
126 
127     if (is_interpreted_frame()) {
128       // fp must be safe
129       if (!fp_safe) {
130         return false;
131       }
132 
133       sender_pc = (address) this->fp()[return_addr_offset];
134       // for interpreted frames, the value below is the sender "raw" sp,
135       // which can be different from the sender unextended sp (the sp seen
136       // by the sender) because of current frame local variables
137       sender_sp = (intptr_t*) addr_at(sender_sp_offset);
138       sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
139       saved_fp = (intptr_t*) this->fp()[link_offset];

196 
197     // We should never be able to see an adapter if the current frame is something from code cache
198     if (sender_blob->is_adapter_blob()) {
199       return false;
200     }
201 
202     // Could be the call_stub
203     if (StubRoutines::returns_to_call_stub(sender_pc)) {
204       if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
205         return false;
206       }
207 
208       // construct the potential sender
209 
210       frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
211 
212       // Validate the JavaCallWrapper an entry frame must have
213       address jcw = (address)sender.entry_frame_call_wrapper();
214 
215       return thread->is_in_stack_range_excl(jcw, (address)sender.fp());
216     } else if (sender_blob->is_optimized_entry_blob()) {
217       return false;
218     }
219 
220     CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
221     if (nm != NULL) {
222       if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
223           nm->method()->is_method_handle_intrinsic()) {
224         return false;
225       }
226     }
227 
228     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
229     // because the return address counts against the callee's frame.
230 
231     if (sender_blob->frame_size() <= 0) {
232       assert(!sender_blob->is_compiled(), "should count return address at least");
233       return false;
234     }
235 
236     // We should never be able to see anything here except an nmethod. If something in the
237     // code cache (current frame) is called by an entity within the code cache that entity

350   // Java frame called from C; skip all C frames and return top C
351   // frame of that chunk as the sender
352   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
353   assert(!entry_frame_is_first(), "next Java fp must be non zero");
354   assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
355   // Since we are walking the stack now this nested anchor is obviously walkable
356   // even if it wasn't when it was stacked.
357   if (!jfa->walkable()) {
358     // Capture _last_Java_pc (if needed) and mark anchor walkable.
359     jfa->capture_last_Java_pc();
360   }
361   map->clear();
362   assert(map->include_argument_oops(), "should be set by clear");
363   vmassert(jfa->last_Java_pc() != NULL, "not walkable");
364   frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
365 
366   return fr;
367 }
368 
369 OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
370   assert(frame.is_optimized_entry_frame(), "wrong frame");
371   // need unextended_sp here, since normal sp is wrong for interpreter callees
372   return reinterpret_cast<OptimizedEntryBlob::FrameData*>(
373     reinterpret_cast<char*>(frame.unextended_sp()) + in_bytes(_frame_data_offset));
374 }
375 
376 bool frame::optimized_entry_frame_is_first() const {
377   assert(is_optimized_entry_frame(), "must be optimzed entry frame");
378   OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
379   JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
380   return jfa->last_Java_sp() == NULL;
381 }
382 
383 frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
384   assert(map != NULL, "map must be set");
385   OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
386   // Java frame called from C; skip all C frames and return top C
387   // frame of that chunk as the sender
388   JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
389   assert(!optimized_entry_frame_is_first(), "must have a frame anchor to go back to");
390   assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
391   // Since we are walking the stack now this nested anchor is obviously walkable
392   // even if it wasn't when it was stacked.
393   if (!jfa->walkable()) {
394     // Capture _last_Java_pc (if needed) and mark anchor walkable.
395     jfa->capture_last_Java_pc();
396   }
397   map->clear();
398   assert(map->include_argument_oops(), "should be set by clear");
399   vmassert(jfa->last_Java_pc() != NULL, "not walkable");
400   frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
401 
402   return fr;
403 }
404 
405 //------------------------------------------------------------------------------
406 // frame::verify_deopt_original_pc
407 //
408 // Verifies the calculated original PC of a deoptimization PC for the
409 // given unextended SP.
410 #ifdef ASSERT
411 void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) {
412   frame fr;
413 
414   // This is ugly but it's better than to change {get,set}_original_pc
415   // to take an SP value as argument.  And it's only a debugging
416   // method anyway.
417   fr._unextended_sp = unextended_sp;
418 
419   address original_pc = nm->get_original_pc(&fr);
420   assert(nm->insts_contains_inclusive(original_pc),
421          "original PC must be in the main code section of the the compiled method (or must be immediately following it)");
422 }

515 
516     // Since the prolog does the save and restore of FP there is no
517     // oopmap for it so we must fill in its location as if there was
518     // an oopmap entry since if our caller was compiled code there
519     // could be live jvm state in it.
520     update_map_with_saved_link(map, saved_fp_addr);
521   }
522 
523   return frame(l_sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
524 }
525 
526 //------------------------------------------------------------------------------
527 // frame::sender_raw
528 frame frame::sender_raw(RegisterMap* map) const {
529   // Default is we done have to follow them. The sender_for_xxx will
530   // update it accordingly
531    map->set_include_argument_oops(false);
532 
533   if (is_entry_frame())
534     return sender_for_entry_frame(map);
535   if (is_optimized_entry_frame())
536     return sender_for_optimized_entry_frame(map);
537   if (is_interpreted_frame())
538     return sender_for_interpreter_frame(map);
539   assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
540 
541   // This test looks odd: why is it not is_compiled_frame() ?  That's
542   // because stubs also have OOP maps.
543   if (_cb != NULL) {
544     return sender_for_compiled_frame(map);
545   }
546 
547   // Must be native-compiled frame, i.e. the marshaling code for native
548   // methods that exists in the core system.
549 
550   return frame(sender_sp(), link(), sender_pc());
551 }
552 
553 frame frame::sender(RegisterMap* map) const {
554   frame result = sender_raw(map);
555 
556   if (map->process_frames()) {
< prev index next >