< prev index next >

src/hotspot/cpu/aarch64/frame_aarch64.cpp

Print this page

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];
138 
139     } else {
140       // must be some sort of compiled/runtime frame
141       // fp does not have to be safe (although it could be check for c1?)
142 
143       // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
144       if (_cb->frame_size() <= 0) {
145         return false;
146       }
147 
148       sender_sp = _unextended_sp + _cb->frame_size();
149       // Is sender_sp safe?
150       if (!thread->is_in_full_stack_checked((address)sender_sp)) {
151         return false;
152       }
153       sender_unextended_sp = sender_sp;
154       sender_pc = (address) *(sender_sp-1);
155       // Note: frame::sender_sp_offset is only valid for compiled frame
156       saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset);
157     }
158 




159 
160     // If the potential sender is the interpreter then we can do some more checking
161     if (Interpreter::contains(sender_pc)) {
162 
163       // fp is always saved in a recognizable place in any code we generate. However
164       // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved fp
165       // is really a frame pointer.
166 
167       if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
168         return false;
169       }
170 
171       // construct the potential sender
172 
173       frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
174 
175       return sender.is_interpreted_frame_valid(thread);
176 
177     }
178 

452   if (map->update_map()) {
453     update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset));
454   }
455 #endif // COMPILER2_OR_JVMCI
456 
457   // Use the raw version of pc - the interpreter should not have signed it.
458 
459   return frame(sender_sp, unextended_sp, link(), sender_pc_maybe_signed());
460 }
461 
462 
463 //------------------------------------------------------------------------------
464 // frame::sender_for_compiled_frame
465 frame frame::sender_for_compiled_frame(RegisterMap* map) const {
466   // we cannot rely upon the last fp having been saved to the thread
467   // in C2 code but it will have been pushed onto the stack. so we
468   // have to find it relative to the unextended sp
469 
470   assert(_cb->frame_size() >= 0, "must have non-zero frame size");
471   intptr_t* l_sender_sp = unextended_sp() + _cb->frame_size();
472   intptr_t* unextended_sp = l_sender_sp;
473 
474   // the return_address is always the word on the stack
475   address sender_pc = (address) *(l_sender_sp-1);

476 
477   intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);
478 
479   // assert (sender_sp() == l_sender_sp, "should be");
480   // assert (*saved_fp_addr == link(), "should be");
481 
















482   if (map->update_map()) {
483     // Tell GC to use argument oopmaps for some runtime stubs that need it.
484     // For C1, the runtime stub might not have oop maps, so set this flag
485     // outside of update_register_map.
486     map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));













487     if (_cb->oop_maps() != NULL) {
488       OopMapSet::update_register_map(this, map);
489     }
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   }

591   Method* method = interpreter_frame_method();
592   BasicType type = method->result_type();
593 
594   intptr_t* tos_addr;
595   if (method->is_native()) {
596     // TODO : ensure AARCH64 does the same as Intel here i.e. push v0 then r0
597     // Prior to calling into the runtime to report the method_exit the possible
598     // return value is pushed to the native stack. If the result is a jfloat/jdouble
599     // then ST0 is saved before EAX/EDX. See the note in generate_native_result
600     tos_addr = (intptr_t*)sp();
601     if (type == T_FLOAT || type == T_DOUBLE) {
602       // This is times two because we do a push(ltos) after pushing XMM0
603       // and that takes two interpreter stack slots.
604       tos_addr += 2 * Interpreter::stackElementWords;
605     }
606   } else {
607     tos_addr = (intptr_t*)interpreter_frame_tos_address();
608   }
609 
610   switch (type) {

611     case T_OBJECT  :
612     case T_ARRAY   : {
613       oop obj;
614       if (method->is_native()) {
615         obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
616       } else {
617         oop* obj_p = (oop*)tos_addr;
618         obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
619       }
620       assert(Universe::is_in_heap_or_null(obj), "sanity check");
621       *oop_result = obj;
622       break;
623     }
624     case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
625     case T_BYTE    : value_result->b = *(jbyte*)tos_addr; break;
626     case T_CHAR    : value_result->c = *(jchar*)tos_addr; break;
627     case T_SHORT   : value_result->s = *(jshort*)tos_addr; break;
628     case T_INT     : value_result->i = *(jint*)tos_addr; break;
629     case T_LONG    : value_result->j = *(jlong*)tos_addr; break;
630     case T_FLOAT   : {

799 }
800 
801 // support for printing out where we are in a Java method
802 // needs to be passed current fp and bcp register values
803 // prints method name, bc index and bytecode name
804 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
805   DESCRIBE_FP_OFFSET(interpreter_frame_method);
806   uintptr_t *p = (uintptr_t *)fp;
807   Method* m = (Method*)p[frame::interpreter_frame_method_offset];
808   printbc(m, bcx);
809 }
810 
811 #ifndef PRODUCT
812 // This is a generic constructor which is only used by pns() in debug.cpp.
813 frame::frame(void* sp, void* fp, void* pc) {
814   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
815 }
816 
817 #endif
818 
















819 void JavaFrameAnchor::make_walkable(JavaThread* thread) {
820   // last frame set?
821   if (last_Java_sp() == NULL) return;
822   // already walkable?
823   if (walkable()) return;
824   vmassert(Thread::current() == (Thread*)thread, "not current thread");
825   vmassert(last_Java_sp() != NULL, "not called from Java code?");
826   vmassert(last_Java_pc() == NULL, "already walkable");
827   capture_last_Java_pc();
828   vmassert(walkable(), "something went wrong");
829 }
830 
831 void JavaFrameAnchor::capture_last_Java_pc() {
832   vmassert(_last_Java_sp != NULL, "no last frame set");
833   vmassert(_last_Java_pc == NULL, "already walkable");
834   _last_Java_pc = (address)_last_Java_sp[-1];
835 }

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];
138 
139     } else {
140       // must be some sort of compiled/runtime frame
141       // fp does not have to be safe (although it could be check for c1?)
142 
143       // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
144       if (_cb->frame_size() <= 0) {
145         return false;
146       }
147 
148       sender_sp = _unextended_sp + _cb->frame_size();
149       // Is sender_sp safe?
150       if (!thread->is_in_full_stack_checked((address)sender_sp)) {
151         return false;
152       }

153       sender_pc = (address) *(sender_sp-1);
154       // Note: frame::sender_sp_offset is only valid for compiled frame
155       intptr_t **saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
156       saved_fp = *saved_fp_addr;
157 
158       // Repair the sender sp if this is a method with scalarized inline type args
159       sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
160       sender_unextended_sp = sender_sp;
161     }
162 
163     // If the potential sender is the interpreter then we can do some more checking
164     if (Interpreter::contains(sender_pc)) {
165 
166       // fp is always saved in a recognizable place in any code we generate. However
167       // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved fp
168       // is really a frame pointer.
169 
170       if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
171         return false;
172       }
173 
174       // construct the potential sender
175 
176       frame sender(sender_sp, sender_unextended_sp, saved_fp, sender_pc);
177 
178       return sender.is_interpreted_frame_valid(thread);
179 
180     }
181 

455   if (map->update_map()) {
456     update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset));
457   }
458 #endif // COMPILER2_OR_JVMCI
459 
460   // Use the raw version of pc - the interpreter should not have signed it.
461 
462   return frame(sender_sp, unextended_sp, link(), sender_pc_maybe_signed());
463 }
464 
465 
466 //------------------------------------------------------------------------------
467 // frame::sender_for_compiled_frame
468 frame frame::sender_for_compiled_frame(RegisterMap* map) const {
469   // we cannot rely upon the last fp having been saved to the thread
470   // in C2 code but it will have been pushed onto the stack. so we
471   // have to find it relative to the unextended sp
472 
473   assert(_cb->frame_size() >= 0, "must have non-zero frame size");
474   intptr_t* l_sender_sp = unextended_sp() + _cb->frame_size();

475 
476 #ifdef ASSERT
477   address sender_pc_copy = (address) *(l_sender_sp-1);
478 #endif
479 
480   intptr_t** saved_fp_addr = (intptr_t**) (l_sender_sp - frame::sender_sp_offset);
481 
482   // assert (sender_sp() == l_sender_sp, "should be");
483   // assert (*saved_fp_addr == link(), "should be");
484 
485   // Repair the sender sp if the frame has been extended
486   l_sender_sp = repair_sender_sp(l_sender_sp, saved_fp_addr);
487 
488   // The return address is always the first word on the stack
489   address sender_pc = (address) *(l_sender_sp-1);
490 
491 #ifdef ASSERT
492   if (sender_pc != sender_pc_copy) {
493     // When extending the stack in the callee method entry to make room for unpacking of value
494     // type args, we keep a copy of the sender pc at the expected location in the callee frame.
495     // If the sender pc is patched due to deoptimization, the copy is not consistent anymore.
496     nmethod* nm = CodeCache::find_blob(sender_pc)->as_nmethod();
497     assert(sender_pc == nm->deopt_mh_handler_begin() || sender_pc == nm->deopt_handler_begin(), "unexpected sender pc");
498   }
499 #endif
500 
501   if (map->update_map()) {
502     // Tell GC to use argument oopmaps for some runtime stubs that need it.
503     // For C1, the runtime stub might not have oop maps, so set this flag
504     // outside of update_register_map.
505     bool caller_args = _cb->caller_must_gc_arguments(map->thread());
506 #ifdef COMPILER1
507     if (!caller_args) {
508       nmethod* nm = _cb->as_nmethod_or_null();
509       if (nm != NULL && nm->is_compiled_by_c1() && nm->method()->has_scalarized_args() &&
510           pc() < nm->verified_inline_entry_point()) {
511         // The VEP and VIEP(RO) of C1-compiled methods call buffer_inline_args_xxx
512         // before doing any argument shuffling, so we need to scan the oops
513         // as the caller passes them.
514         caller_args = true;
515       }
516     }
517 #endif
518     map->set_include_argument_oops(caller_args);
519     if (_cb->oop_maps() != NULL) {
520       OopMapSet::update_register_map(this, map);
521     }
522 
523     // Since the prolog does the save and restore of FP there is no
524     // oopmap for it so we must fill in its location as if there was
525     // an oopmap entry since if our caller was compiled code there
526     // could be live jvm state in it.
527     update_map_with_saved_link(map, saved_fp_addr);
528   }
529 
530   return frame(l_sender_sp, l_sender_sp, *saved_fp_addr, sender_pc);
531 }
532 
533 //------------------------------------------------------------------------------
534 // frame::sender_raw
535 frame frame::sender_raw(RegisterMap* map) const {
536   // Default is we done have to follow them. The sender_for_xxx will
537   // update it accordingly
538    map->set_include_argument_oops(false);
539 
540   if (is_entry_frame())
541     return sender_for_entry_frame(map);
542   if (is_interpreted_frame())
543     return sender_for_interpreter_frame(map);
544   assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
545 
546   // This test looks odd: why is it not is_compiled_frame() ?  That's
547   // because stubs also have OOP maps.
548   if (_cb != NULL) {
549     return sender_for_compiled_frame(map);
550   }

623   Method* method = interpreter_frame_method();
624   BasicType type = method->result_type();
625 
626   intptr_t* tos_addr;
627   if (method->is_native()) {
628     // TODO : ensure AARCH64 does the same as Intel here i.e. push v0 then r0
629     // Prior to calling into the runtime to report the method_exit the possible
630     // return value is pushed to the native stack. If the result is a jfloat/jdouble
631     // then ST0 is saved before EAX/EDX. See the note in generate_native_result
632     tos_addr = (intptr_t*)sp();
633     if (type == T_FLOAT || type == T_DOUBLE) {
634       // This is times two because we do a push(ltos) after pushing XMM0
635       // and that takes two interpreter stack slots.
636       tos_addr += 2 * Interpreter::stackElementWords;
637     }
638   } else {
639     tos_addr = (intptr_t*)interpreter_frame_tos_address();
640   }
641 
642   switch (type) {
643     case T_INLINE_TYPE :
644     case T_OBJECT  :
645     case T_ARRAY   : {
646       oop obj;
647       if (method->is_native()) {
648         obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
649       } else {
650         oop* obj_p = (oop*)tos_addr;
651         obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
652       }
653       assert(Universe::is_in_heap_or_null(obj), "sanity check");
654       *oop_result = obj;
655       break;
656     }
657     case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
658     case T_BYTE    : value_result->b = *(jbyte*)tos_addr; break;
659     case T_CHAR    : value_result->c = *(jchar*)tos_addr; break;
660     case T_SHORT   : value_result->s = *(jshort*)tos_addr; break;
661     case T_INT     : value_result->i = *(jint*)tos_addr; break;
662     case T_LONG    : value_result->j = *(jlong*)tos_addr; break;
663     case T_FLOAT   : {

832 }
833 
834 // support for printing out where we are in a Java method
835 // needs to be passed current fp and bcp register values
836 // prints method name, bc index and bytecode name
837 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
838   DESCRIBE_FP_OFFSET(interpreter_frame_method);
839   uintptr_t *p = (uintptr_t *)fp;
840   Method* m = (Method*)p[frame::interpreter_frame_method_offset];
841   printbc(m, bcx);
842 }
843 
844 #ifndef PRODUCT
845 // This is a generic constructor which is only used by pns() in debug.cpp.
846 frame::frame(void* sp, void* fp, void* pc) {
847   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
848 }
849 
850 #endif
851 
852 // Check for a method with scalarized inline type arguments that needs
853 // a stack repair and return the repaired sender stack pointer.
854 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
855   CompiledMethod* cm = _cb->as_compiled_method_or_null();
856   if (cm != NULL && cm->needs_stack_repair()) {
857     // The stack increment resides just below the saved FP on the stack and
858     // records the total frame size exluding the two words for saving FP and LR.
859     intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
860     assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
861     int real_frame_size = (*sp_inc_addr / wordSize) + 2;
862     assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
863     sender_sp = unextended_sp() + real_frame_size;
864   }
865   return sender_sp;
866 }
867 
868 void JavaFrameAnchor::make_walkable(JavaThread* thread) {
869   // last frame set?
870   if (last_Java_sp() == NULL) return;
871   // already walkable?
872   if (walkable()) return;
873   vmassert(Thread::current() == (Thread*)thread, "not current thread");
874   vmassert(last_Java_sp() != NULL, "not called from Java code?");
875   vmassert(last_Java_pc() == NULL, "already walkable");
876   capture_last_Java_pc();
877   vmassert(walkable(), "something went wrong");
878 }
879 
880 void JavaFrameAnchor::capture_last_Java_pc() {
881   vmassert(_last_Java_sp != NULL, "no last frame set");
882   vmassert(_last_Java_pc == NULL, "already walkable");
883   _last_Java_pc = (address)_last_Java_sp[-1];
884 }
< prev index next >