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
544 Method* method = interpreter_frame_method();
545 BasicType type = method->result_type();
546
547 intptr_t* tos_addr;
548 if (method->is_native()) {
549 // TODO : ensure AARCH64 does the same as Intel here i.e. push v0 then r0
550 // Prior to calling into the runtime to report the method_exit the possible
551 // return value is pushed to the native stack. If the result is a jfloat/jdouble
552 // then ST0 is saved before EAX/EDX. See the note in generate_native_result
553 tos_addr = (intptr_t*)sp();
554 if (type == T_FLOAT || type == T_DOUBLE) {
555 // This is times two because we do a push(ltos) after pushing XMM0
556 // and that takes two interpreter stack slots.
557 tos_addr += 2 * Interpreter::stackElementWords;
558 }
559 } else {
560 tos_addr = (intptr_t*)interpreter_frame_tos_address();
561 }
562
563 switch (type) {
564 case T_OBJECT :
565 case T_ARRAY : {
566 oop obj;
567 if (method->is_native()) {
568 obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
569 } else {
570 oop* obj_p = (oop*)tos_addr;
571 obj = (obj_p == nullptr) ? (oop)nullptr : *obj_p;
572 }
573 assert(Universe::is_in_heap_or_null(obj), "sanity check");
574 *oop_result = obj;
575 break;
576 }
577 case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
578 case T_BYTE : value_result->b = *(jbyte*)tos_addr; break;
579 case T_CHAR : value_result->c = *(jchar*)tos_addr; break;
580 case T_SHORT : value_result->s = *(jshort*)tos_addr; break;
581 case T_INT : value_result->i = *(jint*)tos_addr; break;
582 case T_LONG : value_result->j = *(jlong*)tos_addr; break;
583 case T_FLOAT : {
763 }
764
765 // support for printing out where we are in a Java method
766 // needs to be passed current fp and bcp register values
767 // prints method name, bc index and bytecode name
768 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
769 DESCRIBE_FP_OFFSET(interpreter_frame_method);
770 uintptr_t *p = (uintptr_t *)fp;
771 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
772 printbc(m, bcx);
773 }
774
775 #ifndef PRODUCT
776 // This is a generic constructor which is only used by pns() in debug.cpp.
777 frame::frame(void* sp, void* fp, void* pc) {
778 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
779 }
780
781 #endif
782
783 void JavaFrameAnchor::make_walkable() {
784 // last frame set?
785 if (last_Java_sp() == nullptr) return;
786 // already walkable?
787 if (walkable()) return;
788 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
789 vmassert(last_Java_pc() == nullptr, "already walkable");
790 _last_Java_pc = (address)_last_Java_sp[-1];
791 vmassert(walkable(), "something went wrong");
792 }
|
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
547 Method* method = interpreter_frame_method();
548 BasicType type = method->result_type();
549
550 intptr_t* tos_addr;
551 if (method->is_native()) {
552 // TODO : ensure AARCH64 does the same as Intel here i.e. push v0 then r0
553 // Prior to calling into the runtime to report the method_exit the possible
554 // return value is pushed to the native stack. If the result is a jfloat/jdouble
555 // then ST0 is saved before EAX/EDX. See the note in generate_native_result
556 tos_addr = (intptr_t*)sp();
557 if (type == T_FLOAT || type == T_DOUBLE) {
558 // This is times two because we do a push(ltos) after pushing XMM0
559 // and that takes two interpreter stack slots.
560 tos_addr += 2 * Interpreter::stackElementWords;
561 }
562 } else {
563 tos_addr = (intptr_t*)interpreter_frame_tos_address();
564 }
565
566 switch (type) {
567 case T_PRIMITIVE_OBJECT :
568 case T_OBJECT :
569 case T_ARRAY : {
570 oop obj;
571 if (method->is_native()) {
572 obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
573 } else {
574 oop* obj_p = (oop*)tos_addr;
575 obj = (obj_p == nullptr) ? (oop)nullptr : *obj_p;
576 }
577 assert(Universe::is_in_heap_or_null(obj), "sanity check");
578 *oop_result = obj;
579 break;
580 }
581 case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
582 case T_BYTE : value_result->b = *(jbyte*)tos_addr; break;
583 case T_CHAR : value_result->c = *(jchar*)tos_addr; break;
584 case T_SHORT : value_result->s = *(jshort*)tos_addr; break;
585 case T_INT : value_result->i = *(jint*)tos_addr; break;
586 case T_LONG : value_result->j = *(jlong*)tos_addr; break;
587 case T_FLOAT : {
767 }
768
769 // support for printing out where we are in a Java method
770 // needs to be passed current fp and bcp register values
771 // prints method name, bc index and bytecode name
772 extern "C" void pm(uintptr_t fp, uintptr_t bcx) {
773 DESCRIBE_FP_OFFSET(interpreter_frame_method);
774 uintptr_t *p = (uintptr_t *)fp;
775 Method* m = (Method*)p[frame::interpreter_frame_method_offset];
776 printbc(m, bcx);
777 }
778
779 #ifndef PRODUCT
780 // This is a generic constructor which is only used by pns() in debug.cpp.
781 frame::frame(void* sp, void* fp, void* pc) {
782 init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
783 }
784
785 #endif
786
787 // Check for a method with scalarized inline type arguments that needs
788 // a stack repair and return the repaired sender stack pointer.
789 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
790 CompiledMethod* cm = _cb->as_compiled_method_or_null();
791 if (cm != nullptr && cm->needs_stack_repair()) {
792 // The stack increment resides just below the saved FP on the stack and
793 // records the total frame size excluding the two words for saving FP and LR.
794 intptr_t* sp_inc_addr = (intptr_t*) (saved_fp_addr - 1);
795 assert(*sp_inc_addr % StackAlignmentInBytes == 0, "sp_inc not aligned");
796 int real_frame_size = (*sp_inc_addr / wordSize) + 2;
797 assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
798 sender_sp = unextended_sp() + real_frame_size;
799 }
800 return sender_sp;
801 }
802
803 void JavaFrameAnchor::make_walkable() {
804 // last frame set?
805 if (last_Java_sp() == nullptr) return;
806 // already walkable?
807 if (walkable()) return;
808 vmassert(last_Java_sp() != nullptr, "not called from Java code?");
809 vmassert(last_Java_pc() == nullptr, "already walkable");
810 _last_Java_pc = (address)_last_Java_sp[-1];
811 vmassert(walkable(), "something went wrong");
812 }
|