< prev index next >

src/hotspot/cpu/x86/frame_x86.inline.hpp

Print this page

 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_FRAME_X86_INLINE_HPP
 26 #define CPU_X86_FRAME_X86_INLINE_HPP
 27 
 28 #include "code/codeBlob.inline.hpp"
 29 #include "code/codeCache.inline.hpp"
 30 #include "code/vmreg.inline.hpp"
 31 #include "compiler/oopMap.inline.hpp"
 32 #include "interpreter/interpreter.hpp"
 33 #include "interpreter/oopMapCache.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "runtime/registerMap.hpp"



 36 
 37 // Inline functions for Intel frames:
 38 
 39 // Constructors:
 40 
 41 inline frame::frame() {
 42   _pc = NULL;
 43   _sp = NULL;
 44   _unextended_sp = NULL;
 45   _fp = NULL;
 46   _cb = NULL;
 47   _deopt_state = unknown;
 48   _oop_map = NULL;
 49   _on_heap = false;
 50   DEBUG_ONLY(_frame_index = -1;)
 51 }
 52 
 53 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
 54   _sp = sp;
 55   _unextended_sp = sp;

380   if (is_entry_frame())       return sender_for_entry_frame(map);
381   if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
382   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
383 
384   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
385   if (_cb != NULL) return sender_for_compiled_frame(map);
386 
387   // Must be native-compiled frame, i.e. the marshaling code for native
388   // methods that exists in the core system.
389   return frame(sender_sp(), link(), sender_pc());
390 }
391 
392 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
393   assert(map != NULL, "map must be set");
394 
395   // frame owned by optimizing compiler
396   assert(_cb->frame_size() > 0, "must have non-zero frame size");
397   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
398   assert(sender_sp == real_fp(), "");
399 
400   // On Intel the return_address is always the word on the stack
401   address sender_pc = (address) *(sender_sp-1);

402 
403   // This is the saved value of EBP which may or may not really be an FP.
404   // It is only an FP if the sender is an interpreter frame (or C1?).
405   // saved_fp_addr should be correct even for a bottom thawed frame (with a return barrier)
406   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
407 
















408   if (map->update_map()) {
409     // Tell GC to use argument oopmaps for some runtime stubs that need it.
410     // For C1, the runtime stub might not have oop maps, so set this flag
411     // outside of update_register_map.
412     if (!_cb->is_compiled()) { // compiled frames do not use callee-saved registers
413       map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));


















414       if (oop_map() != NULL) {
415         _oop_map->update_register_map(this, map);
416       }
417     } else {
418       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
419       assert(!map->include_argument_oops(), "");
420       assert(oop_map() == NULL || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
421     }
422 
423     // Since the prolog does the save and restore of EBP there is no oopmap
424     // for it so we must fill in its location as if there was an oopmap entry
425     // since if our caller was compiled code there could be live jvm state in it.
426     update_map_with_saved_link(map, saved_fp_addr);
427   }
428 
429   assert(sender_sp != sp(), "must have changed");
430 
431   if (Continuation::is_return_barrier_entry(sender_pc)) {
432     if (map->walk_cont()) { // about to walk into an h-stack
433       return Continuation::top_frame(*this, map);

 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_FRAME_X86_INLINE_HPP
 26 #define CPU_X86_FRAME_X86_INLINE_HPP
 27 
 28 #include "code/codeBlob.inline.hpp"
 29 #include "code/codeCache.inline.hpp"
 30 #include "code/vmreg.inline.hpp"
 31 #include "compiler/oopMap.inline.hpp"
 32 #include "interpreter/interpreter.hpp"
 33 #include "interpreter/oopMapCache.hpp"
 34 #include "runtime/sharedRuntime.hpp"
 35 #include "runtime/registerMap.hpp"
 36 #ifdef COMPILER1
 37 #include "c1/c1_Runtime1.hpp"
 38 #endif
 39 
 40 // Inline functions for Intel frames:
 41 
 42 // Constructors:
 43 
 44 inline frame::frame() {
 45   _pc = NULL;
 46   _sp = NULL;
 47   _unextended_sp = NULL;
 48   _fp = NULL;
 49   _cb = NULL;
 50   _deopt_state = unknown;
 51   _oop_map = NULL;
 52   _on_heap = false;
 53   DEBUG_ONLY(_frame_index = -1;)
 54 }
 55 
 56 inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) {
 57   _sp = sp;
 58   _unextended_sp = sp;

383   if (is_entry_frame())       return sender_for_entry_frame(map);
384   if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
385   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
386 
387   assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
388   if (_cb != NULL) return sender_for_compiled_frame(map);
389 
390   // Must be native-compiled frame, i.e. the marshaling code for native
391   // methods that exists in the core system.
392   return frame(sender_sp(), link(), sender_pc());
393 }
394 
395 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
396   assert(map != NULL, "map must be set");
397 
398   // frame owned by optimizing compiler
399   assert(_cb->frame_size() > 0, "must have non-zero frame size");
400   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
401   assert(sender_sp == real_fp(), "");
402 
403 #ifdef ASSERT
404   address sender_pc_copy = (address) *(sender_sp-1);
405 #endif
406 
407   // This is the saved value of EBP which may or may not really be an FP.
408   // It is only an FP if the sender is an interpreter frame (or C1?).
409   // saved_fp_addr should be correct even for a bottom thawed frame (with a return barrier)
410   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
411 
412   // Repair the sender sp if the frame has been extended
413   sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
414 
415   // On Intel the return_address is always the word on the stack
416   address sender_pc = (address) *(sender_sp-1);
417 
418 #ifdef ASSERT
419   if (sender_pc != sender_pc_copy) {
420     // When extending the stack in the callee method entry to make room for unpacking of value
421     // type args, we keep a copy of the sender pc at the expected location in the callee frame.
422     // If the sender pc is patched due to deoptimization, the copy is not consistent anymore.
423     nmethod* nm = CodeCache::find_blob(sender_pc)->as_nmethod();
424     assert(sender_pc == nm->deopt_mh_handler_begin() || sender_pc == nm->deopt_handler_begin(), "unexpected sender pc");
425   }
426 #endif
427 
428   if (map->update_map()) {
429     // Tell GC to use argument oopmaps for some runtime stubs that need it.
430     // For C1, the runtime stub might not have oop maps, so set this flag
431     // outside of update_register_map.
432     bool c1_buffering = false;
433 #ifdef COMPILER1
434     nmethod* nm = _cb->as_nmethod_or_null();
435     if (nm != NULL && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
436         pc() < nm->verified_inline_entry_point()) {
437       // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
438       // before doing any argument shuffling, so we need to scan the oops
439       // as the caller passes them.
440       c1_buffering = true;
441 #ifdef ASSERT
442       NativeCall* call = nativeCall_before(pc());
443       address dest = call->destination();
444       assert(dest == Runtime1::entry_for(Runtime1::buffer_inline_args_no_receiver_id) ||
445              dest == Runtime1::entry_for(Runtime1::buffer_inline_args_id), "unexpected safepoint in entry point");
446 #endif
447     }
448 #endif
449     if (!_cb->is_compiled() || c1_buffering) { // compiled frames do not use callee-saved registers
450       bool caller_args = _cb->caller_must_gc_arguments(map->thread()) || c1_buffering;
451       map->set_include_argument_oops(caller_args);
452       if (oop_map() != NULL) {
453         _oop_map->update_register_map(this, map);
454       }
455     } else {
456       assert(!_cb->caller_must_gc_arguments(map->thread()), "");
457       assert(!map->include_argument_oops(), "");
458       assert(oop_map() == NULL || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
459     }
460 
461     // Since the prolog does the save and restore of EBP there is no oopmap
462     // for it so we must fill in its location as if there was an oopmap entry
463     // since if our caller was compiled code there could be live jvm state in it.
464     update_map_with_saved_link(map, saved_fp_addr);
465   }
466 
467   assert(sender_sp != sp(), "must have changed");
468 
469   if (Continuation::is_return_barrier_entry(sender_pc)) {
470     if (map->walk_cont()) { // about to walk into an h-stack
471       return Continuation::top_frame(*this, map);
< prev index next >