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