15 * You should have received a copy of the GNU General Public License version
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 "runtime/sharedRuntime.hpp"
34 #include "runtime/registerMap.hpp"
35
36 // Inline functions for Intel frames:
37
38 #if INCLUDE_JFR
39
40 // Static helper routines
41
42 inline address frame::interpreter_bcp(const intptr_t* fp) {
43 assert(fp != nullptr, "invariant");
44 return reinterpret_cast<address>(fp[frame::interpreter_frame_bcp_offset]);
45 }
46
47 inline address frame::interpreter_return_address(const intptr_t* fp) {
48 assert(fp != nullptr, "invariant");
49 return reinterpret_cast<address>(fp[frame::return_addr_offset]);
50 }
51
52 inline intptr_t* frame::interpreter_sender_sp(const intptr_t* fp) {
53 assert(fp != nullptr, "invariant");
54 return reinterpret_cast<intptr_t*>(fp[frame::interpreter_frame_sender_sp_offset]);
406 map->set_include_argument_oops(false);
407
408 if (map->in_cont()) { // already in an h-stack
409 return map->stack_chunk()->sender(*this, map);
410 }
411
412 if (is_entry_frame()) return sender_for_entry_frame(map);
413 if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
414 if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
415
416 assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
417 if (_cb != nullptr) return sender_for_compiled_frame(map);
418
419 // Must be native-compiled frame, i.e. the marshaling code for native
420 // methods that exists in the core system.
421 return frame(sender_sp(), link(), sender_pc());
422 }
423
424 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
425 assert(map != nullptr, "map must be set");
426
427 // frame owned by optimizing compiler
428 assert(_cb->frame_size() > 0, "must have non-zero frame size");
429 intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
430 assert(sender_sp == real_fp(), "");
431
432 // On Intel the return_address is always the word on the stack
433 address sender_pc = (address) *(sender_sp-1);
434
435 // This is the saved value of EBP which may or may not really be an FP.
436 // It is only an FP if the sender is an interpreter frame (or C1?).
437 // saved_fp_addr should be correct even for a bottom thawed frame (with a return barrier)
438 intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
439
440 if (map->update_map()) {
441 // Tell GC to use argument oopmaps for some runtime stubs that need it.
442 // For C1, the runtime stub might not have oop maps, so set this flag
443 // outside of update_register_map.
444 if (!_cb->is_nmethod()) { // compiled frames do not use callee-saved registers
445 map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
446 if (oop_map() != nullptr) {
447 _oop_map->update_register_map(this, map);
448 }
449 } else {
450 assert(!_cb->caller_must_gc_arguments(map->thread()), "");
451 assert(!map->include_argument_oops(), "");
452 assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
453 }
454
455 // Since the prolog does the save and restore of EBP there is no oopmap
456 // for it so we must fill in its location as if there was an oopmap entry
457 // since if our caller was compiled code there could be live jvm state in it.
458 update_map_with_saved_link(map, saved_fp_addr);
459 }
460
461 assert(sender_sp != sp(), "must have changed");
462
463 if (Continuation::is_return_barrier_entry(sender_pc)) {
464 if (map->walk_cont()) { // about to walk into an h-stack
465 return Continuation::top_frame(*this, map);
466 } else {
467 return Continuation::continuation_bottom_sender(map->thread(), *this, sender_sp);
468 }
469 }
470
471 intptr_t* unextended_sp = sender_sp;
472 return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
473 }
474
475 template <typename RegisterMapT>
476 void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
477 // The interpreter and compiler(s) always save EBP/RBP in a known
478 // location on entry. We must record where that location is
479 // so this if EBP/RBP was live on callout from c2 we can find
480 // the saved copy no matter what it called.
481
482 // Since the interpreter always saves EBP/RBP if we record where it is then
483 // we don't have to always save EBP/RBP on entry and exit to c2 compiled
484 // code, on entry will be enough.
485 map->set_location(rbp->as_VMReg(), (address) link_addr);
486 // this is weird "H" ought to be at a higher address however the
487 // oopMaps seems to have the "H" regs at the same address and the
488 // vanilla register.
489 // XXXX make this go away
490 if (true) {
491 map->set_location(rbp->as_VMReg()->next(), (address) link_addr);
492 }
|
15 * You should have received a copy of the GNU General Public License version
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 "runtime/sharedRuntime.hpp"
34 #include "runtime/registerMap.hpp"
35 #ifdef COMPILER1
36 #include "c1/c1_Runtime1.hpp"
37 #endif
38
39 // Inline functions for Intel frames:
40
41 #if INCLUDE_JFR
42
43 // Static helper routines
44
45 inline address frame::interpreter_bcp(const intptr_t* fp) {
46 assert(fp != nullptr, "invariant");
47 return reinterpret_cast<address>(fp[frame::interpreter_frame_bcp_offset]);
48 }
49
50 inline address frame::interpreter_return_address(const intptr_t* fp) {
51 assert(fp != nullptr, "invariant");
52 return reinterpret_cast<address>(fp[frame::return_addr_offset]);
53 }
54
55 inline intptr_t* frame::interpreter_sender_sp(const intptr_t* fp) {
56 assert(fp != nullptr, "invariant");
57 return reinterpret_cast<intptr_t*>(fp[frame::interpreter_frame_sender_sp_offset]);
409 map->set_include_argument_oops(false);
410
411 if (map->in_cont()) { // already in an h-stack
412 return map->stack_chunk()->sender(*this, map);
413 }
414
415 if (is_entry_frame()) return sender_for_entry_frame(map);
416 if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
417 if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
418
419 assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
420 if (_cb != nullptr) return sender_for_compiled_frame(map);
421
422 // Must be native-compiled frame, i.e. the marshaling code for native
423 // methods that exists in the core system.
424 return frame(sender_sp(), link(), sender_pc());
425 }
426
427 inline frame frame::sender_for_compiled_frame(RegisterMap* map) const {
428 assert(map != nullptr, "map must be set");
429 CompiledFramePointers cfp = compiled_frame_details();
430
431 if (map->update_map()) {
432 // Tell GC to use argument oopmaps for some runtime stubs that need it.
433 // For C1, the runtime stub might not have oop maps, so set this flag
434 // outside of update_register_map.
435 bool c1_buffering = false;
436 #ifdef COMPILER1
437 nmethod* nm = _cb->as_nmethod_or_null();
438 if (nm != nullptr && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
439 pc() < nm->verified_inline_entry_point()) {
440 // TODO 8284443 Can't we do that by not passing 'dont_gc_arguments' in case 'StubId::c1_buffer_inline_args_id' in 'Runtime1::generate_code_for'?
441 // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
442 // before doing any argument shuffling, so we need to scan the oops
443 // as the caller passes them.
444 c1_buffering = true;
445 #ifdef ASSERT
446 NativeCall* call = nativeCall_before(pc());
447 address dest = call->destination();
448 assert(dest == Runtime1::entry_for(StubId::c1_buffer_inline_args_no_receiver_id) ||
449 dest == Runtime1::entry_for(StubId::c1_buffer_inline_args_id), "unexpected safepoint in entry point");
450 #endif
451 }
452 #endif
453 if (!_cb->is_nmethod() || c1_buffering) { // compiled frames do not use callee-saved registers
454 bool caller_args = _cb->caller_must_gc_arguments(map->thread()) || c1_buffering;
455 map->set_include_argument_oops(caller_args);
456 if (oop_map() != nullptr) {
457 _oop_map->update_register_map(this, map);
458 }
459 } else {
460 assert(!_cb->caller_must_gc_arguments(map->thread()), "");
461 assert(!map->include_argument_oops(), "");
462 assert(oop_map() == nullptr || !oop_map()->has_any(OopMapValue::callee_saved_value), "callee-saved value in compiled frame");
463 }
464
465 // Since the prolog does the save and restore of EBP there is no oopmap
466 // for it so we must fill in its location as if there was an oopmap entry
467 // since if our caller was compiled code there could be live jvm state in it.
468 update_map_with_saved_link(map, cfp.saved_fp_addr);
469 }
470
471 assert(cfp.sender_sp != sp(), "must have changed");
472
473 if (Continuation::is_return_barrier_entry(*cfp.sender_pc_addr)) {
474 if (map->walk_cont()) { // about to walk into an h-stack
475 return Continuation::top_frame(*this, map);
476 } else {
477 return Continuation::continuation_bottom_sender(map->thread(), *this, cfp.sender_sp);
478 }
479 }
480
481 intptr_t* unextended_sp = cfp.sender_sp;
482 return frame(cfp.sender_sp, unextended_sp, *cfp.saved_fp_addr, *cfp.sender_pc_addr);
483 }
484
485 template <typename RegisterMapT>
486 void frame::update_map_with_saved_link(RegisterMapT* map, intptr_t** link_addr) {
487 // The interpreter and compiler(s) always save EBP/RBP in a known
488 // location on entry. We must record where that location is
489 // so this if EBP/RBP was live on callout from c2 we can find
490 // the saved copy no matter what it called.
491
492 // Since the interpreter always saves EBP/RBP if we record where it is then
493 // we don't have to always save EBP/RBP on entry and exit to c2 compiled
494 // code, on entry will be enough.
495 map->set_location(rbp->as_VMReg(), (address) link_addr);
496 // this is weird "H" ought to be at a higher address however the
497 // oopMaps seems to have the "H" regs at the same address and the
498 // vanilla register.
499 // XXXX make this go away
500 if (true) {
501 map->set_location(rbp->as_VMReg()->next(), (address) link_addr);
502 }
|