138 // by the sender) because of current frame local variables
139 sender_sp = (intptr_t*) addr_at(sender_sp_offset);
140 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
141 saved_fp = (intptr_t*) this->fp()[link_offset];
142 sender_pc = pauth_strip_verifiable((address) this->fp()[return_addr_offset], (address)saved_fp);
143
144 } else {
145 // must be some sort of compiled/runtime frame
146 // fp does not have to be safe (although it could be check for c1?)
147
148 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
149 if (_cb->frame_size() <= 0) {
150 return false;
151 }
152
153 sender_sp = _unextended_sp + _cb->frame_size();
154 // Is sender_sp safe?
155 if (!thread->is_in_full_stack_checked((address)sender_sp)) {
156 return false;
157 }
158 sender_unextended_sp = sender_sp;
159 // Note: frame::sender_sp_offset is only valid for compiled frame
160 saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset);
161 sender_pc = pauth_strip_verifiable((address) *(sender_sp-1), (address)saved_fp);
162 }
163
164 if (Continuation::is_return_barrier_entry(sender_pc)) {
165 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
166 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
167 sender_sp = s.sp();
168 sender_pc = s.pc();
169 }
170
171 // If the potential sender is the interpreter then we can do some more checking
172 if (Interpreter::contains(sender_pc)) {
173
174 // fp is always saved in a recognizable place in any code we generate. However
175 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved fp
176 // is really a frame pointer.
177
178 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
179 return false;
180 }
181
182 // construct the potential sender
183
535 Method* method = interpreter_frame_method();
536 BasicType type = method->result_type();
537
538 intptr_t* tos_addr;
539 if (method->is_native()) {
540 // TODO : ensure AARCH64 does the same as Intel here i.e. push v0 then r0
541 // Prior to calling into the runtime to report the method_exit the possible
542 // return value is pushed to the native stack. If the result is a jfloat/jdouble
543 // then ST0 is saved before EAX/EDX. See the note in generate_native_result
544 tos_addr = (intptr_t*)sp();
545 if (type == T_FLOAT || type == T_DOUBLE) {
546 // This is times two because we do a push(ltos) after pushing XMM0
547 // and that takes two interpreter stack slots.
548 tos_addr += 2 * Interpreter::stackElementWords;
549 }
550 } else {
551 tos_addr = (intptr_t*)interpreter_frame_tos_address();
552 }
553
554 switch (type) {
555 case T_OBJECT :
556 case T_ARRAY : {
557 oop obj;
558 if (method->is_native()) {
559 obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
560 } else {
561 oop* obj_p = (oop*)tos_addr;
562 obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
563 }
564 assert(Universe::is_in_heap_or_null(obj), "sanity check");
565 *oop_result = obj;
566 break;
567 }
568 case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
569 case T_BYTE : value_result->b = *(jbyte*)tos_addr; break;
570 case T_CHAR : value_result->c = *(jchar*)tos_addr; break;
571 case T_SHORT : value_result->s = *(jshort*)tos_addr; break;
572 case T_INT : value_result->i = *(jint*)tos_addr; break;
573 case T_LONG : value_result->j = *(jlong*)tos_addr; break;
574 case T_FLOAT : {
754 }
755
756 // support for printing out where we are in a Java method
757 // needs to be passed current fp and bcp register values
758 // prints method name, bc index and bytecode name
759 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
760 DESCRIBE_FP_OFFSET(interpreter_frame_method);
761 uintptr_t *p = (uintptr_t *)fp;
762 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
763 printbc(m, bcx);
764 }
765
766 #ifndef PRODUCT
767 // This is a generic constructor which is only used by pns() in debug.cpp.
768 frame::frame(void* sp, void* fp, void* pc) {
769 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
770 }
771
772 #endif
773
774 void JavaFrameAnchor::make_walkable() {
775 // last frame set?
776 if (last_Java_sp() == NULL) return;
777 // already walkable?
778 if (walkable()) return;
779 vmassert(last_Java_sp() != NULL, "not called from Java code?");
780 vmassert(last_Java_pc() == NULL, "already walkable");
781 _last_Java_pc = (address)_last_Java_sp[-1];
782 vmassert(walkable(), "something went wrong");
783 }
|
138 // by the sender) because of current frame local variables
139 sender_sp = (intptr_t*) addr_at(sender_sp_offset);
140 sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
141 saved_fp = (intptr_t*) this->fp()[link_offset];
142 sender_pc = pauth_strip_verifiable((address) this->fp()[return_addr_offset], (address)saved_fp);
143
144 } else {
145 // must be some sort of compiled/runtime frame
146 // fp does not have to be safe (although it could be check for c1?)
147
148 // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
149 if (_cb->frame_size() <= 0) {
150 return false;
151 }
152
153 sender_sp = _unextended_sp + _cb->frame_size();
154 // Is sender_sp safe?
155 if (!thread->is_in_full_stack_checked((address)sender_sp)) {
156 return false;
157 }
158 // Note: frame::sender_sp_offset is only valid for compiled frame
159 intptr_t **saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
160 saved_fp = *saved_fp_addr;
161 sender_pc = pauth_strip_verifiable((address) *(sender_sp-1), (address)saved_fp);
162
163 // Repair the sender sp if this is a method with scalarized inline type args
164 sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
165 sender_unextended_sp = sender_sp;
166 }
167 if (Continuation::is_return_barrier_entry(sender_pc)) {
168 // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
169 frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
170 sender_sp = s.sp();
171 sender_pc = s.pc();
172 }
173
174 // If the potential sender is the interpreter then we can do some more checking
175 if (Interpreter::contains(sender_pc)) {
176
177 // fp is always saved in a recognizable place in any code we generate. However
178 // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved fp
179 // is really a frame pointer.
180
181 if (!thread->is_in_stack_range_excl((address)saved_fp, (address)sender_sp)) {
182 return false;
183 }
184
185 // construct the potential sender
186
538 Method* method = interpreter_frame_method();
539 BasicType type = method->result_type();
540
541 intptr_t* tos_addr;
542 if (method->is_native()) {
543 // TODO : ensure AARCH64 does the same as Intel here i.e. push v0 then r0
544 // Prior to calling into the runtime to report the method_exit the possible
545 // return value is pushed to the native stack. If the result is a jfloat/jdouble
546 // then ST0 is saved before EAX/EDX. See the note in generate_native_result
547 tos_addr = (intptr_t*)sp();
548 if (type == T_FLOAT || type == T_DOUBLE) {
549 // This is times two because we do a push(ltos) after pushing XMM0
550 // and that takes two interpreter stack slots.
551 tos_addr += 2 * Interpreter::stackElementWords;
552 }
553 } else {
554 tos_addr = (intptr_t*)interpreter_frame_tos_address();
555 }
556
557 switch (type) {
558 case T_PRIMITIVE_OBJECT :
559 case T_OBJECT :
560 case T_ARRAY : {
561 oop obj;
562 if (method->is_native()) {
563 obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
564 } else {
565 oop* obj_p = (oop*)tos_addr;
566 obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
567 }
568 assert(Universe::is_in_heap_or_null(obj), "sanity check");
569 *oop_result = obj;
570 break;
571 }
572 case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
573 case T_BYTE : value_result->b = *(jbyte*)tos_addr; break;
574 case T_CHAR : value_result->c = *(jchar*)tos_addr; break;
575 case T_SHORT : value_result->s = *(jshort*)tos_addr; break;
576 case T_INT : value_result->i = *(jint*)tos_addr; break;
577 case T_LONG : value_result->j = *(jlong*)tos_addr; break;
578 case T_FLOAT : {
758 }
759
760 // support for printing out where we are in a Java method
761 // needs to be passed current fp and bcp register values
762 // prints method name, bc index and bytecode name
763 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
764 DESCRIBE_FP_OFFSET(interpreter_frame_method);
765 uintptr_t *p = (uintptr_t *)fp;
766 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
767 printbc(m, bcx);
768 }
769
770 #ifndef PRODUCT
771 // This is a generic constructor which is only used by pns() in debug.cpp.
772 frame::frame(void* sp, void* fp, void* pc) {
773 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
774 }
775
776 #endif
777
778 // Check for a method with scalarized inline type arguments that needs
779 // a stack repair and return the repaired sender stack pointer.
780 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
781 CompiledMethod* cm = _cb->as_compiled_method_or_null();
782 if (cm != NULL && cm->needs_stack_repair()) {
783 // The stack increment resides just below the saved FP on the stack and
784 // records the total frame size excluding the two words for saving FP and LR.
785 intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
786 assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
787 int real_frame_size = (*sp_inc_addr / wordSize) + 2;
788 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
789 sender_sp = unextended_sp() + real_frame_size;
790 }
791 return sender_sp;
792 }
793
794 void JavaFrameAnchor::make_walkable() {
795 // last frame set?
796 if (last_Java_sp() == NULL) return;
797 // already walkable?
798 if (walkable()) return;
799 vmassert(last_Java_sp() != NULL, "not called from Java code?");
800 vmassert(last_Java_pc() == NULL, "already walkable");
801 _last_Java_pc = (address)_last_Java_sp[-1];
802 vmassert(walkable(), "something went wrong");
803 }
|