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