< prev index next >

src/hotspot/cpu/x86/frame_x86.cpp

Print this page

126       // which can be different from the sender unextended sp (the sp seen
127       // by the sender) because of current frame local variables
128       sender_sp = (intptr_t*) addr_at(sender_sp_offset);
129       sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
130       saved_fp = (intptr_t*) this->fp()[link_offset];
131 
132     } else {
133       // must be some sort of compiled/runtime frame
134       // fp does not have to be safe (although it could be check for c1?)
135 
136       // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
137       if (_cb->frame_size() <= 0) {
138         return false;
139       }
140 
141       sender_sp = _unextended_sp + _cb->frame_size();
142       // Is sender_sp safe?
143       if (!thread->is_in_full_stack_checked((address)sender_sp)) {
144         return false;
145       }
146       sender_unextended_sp = sender_sp;
147       // On Intel the return_address is always the word on the stack
148       sender_pc = (address) *(sender_sp-1);
149       // Note: frame::sender_sp_offset is only valid for compiled frame
150       saved_fp = (intptr_t*) *(sender_sp - frame::sender_sp_offset);
151     }
152 




153     if (Continuation::is_return_barrier_entry(sender_pc)) {
154       // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
155       frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
156       sender_sp = s.sp();
157       sender_pc = s.pc();
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       // ebp 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 ebp
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 

526     // Prior to calling into the runtime to report the method_exit the possible
527     // return value is pushed to the native stack. If the result is a jfloat/jdouble
528     // then ST0 is saved before EAX/EDX. See the note in generate_native_result
529     tos_addr = (intptr_t*)sp();
530     if (type == T_FLOAT || type == T_DOUBLE) {
531     // QQQ seems like this code is equivalent on the two platforms
532 #ifdef AMD64
533       // This is times two because we do a push(ltos) after pushing XMM0
534       // and that takes two interpreter stack slots.
535       tos_addr += 2 * Interpreter::stackElementWords;
536 #else
537       tos_addr += 2;
538 #endif // AMD64
539     }
540   } else {
541     tos_addr = (intptr_t*)interpreter_frame_tos_address();
542   }
543 
544   switch (type) {
545     case T_OBJECT  :

546     case T_ARRAY   : {
547       oop obj;
548       if (method->is_native()) {
549         obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
550       } else {
551         oop* obj_p = (oop*)tos_addr;
552         obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
553       }
554       assert(Universe::is_in_heap_or_null(obj), "sanity check");
555       *oop_result = obj;
556       break;
557     }
558     case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
559     case T_BYTE    : value_result->b = *(jbyte*)tos_addr; break;
560     case T_CHAR    : value_result->c = *(jchar*)tos_addr; break;
561     case T_SHORT   : value_result->s = *(jshort*)tos_addr; break;
562     case T_INT     : value_result->i = *(jint*)tos_addr; break;
563     case T_LONG    : value_result->j = *(jlong*)tos_addr; break;
564     case T_FLOAT   : {
565 #ifdef AMD64

629       Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
630     values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
631   }
632 }
633 
634 #endif // !PRODUCT
635 
636 intptr_t *frame::initial_deoptimization_info() {
637   // used to reset the saved FP
638   return fp();
639 }
640 
641 #ifndef PRODUCT
642 // This is a generic constructor which is only used by pns() in debug.cpp.
643 frame::frame(void* sp, void* fp, void* pc) {
644   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
645 }
646 
647 #endif
648 















649 void JavaFrameAnchor::make_walkable() {
650   // last frame set?
651   if (last_Java_sp() == NULL) return;
652   // already walkable?
653   if (walkable()) return;
654   vmassert(last_Java_pc() == NULL, "already walkable");
655   _last_Java_pc = (address)_last_Java_sp[-1];
656   vmassert(walkable(), "something went wrong");
657 }

126       // which can be different from the sender unextended sp (the sp seen
127       // by the sender) because of current frame local variables
128       sender_sp = (intptr_t*) addr_at(sender_sp_offset);
129       sender_unextended_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
130       saved_fp = (intptr_t*) this->fp()[link_offset];
131 
132     } else {
133       // must be some sort of compiled/runtime frame
134       // fp does not have to be safe (although it could be check for c1?)
135 
136       // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
137       if (_cb->frame_size() <= 0) {
138         return false;
139       }
140 
141       sender_sp = _unextended_sp + _cb->frame_size();
142       // Is sender_sp safe?
143       if (!thread->is_in_full_stack_checked((address)sender_sp)) {
144         return false;
145       }

146       // On Intel the return_address is always the word on the stack
147       sender_pc = (address) *(sender_sp-1);
148       // Note: frame::sender_sp_offset is only valid for compiled frame
149       intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
150       saved_fp = *saved_fp_addr;
151 
152       // Repair the sender sp if this is a method with scalarized inline type args
153       sender_sp = repair_sender_sp(sender_sp, saved_fp_addr);
154       sender_unextended_sp = sender_sp;
155     }
156     if (Continuation::is_return_barrier_entry(sender_pc)) {
157       // If our sender_pc is the return barrier, then our "real" sender is the continuation entry
158       frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp);
159       sender_sp = s.sp();
160       sender_pc = s.pc();
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       // ebp 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 ebp
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 

529     // Prior to calling into the runtime to report the method_exit the possible
530     // return value is pushed to the native stack. If the result is a jfloat/jdouble
531     // then ST0 is saved before EAX/EDX. See the note in generate_native_result
532     tos_addr = (intptr_t*)sp();
533     if (type == T_FLOAT || type == T_DOUBLE) {
534     // QQQ seems like this code is equivalent on the two platforms
535 #ifdef AMD64
536       // This is times two because we do a push(ltos) after pushing XMM0
537       // and that takes two interpreter stack slots.
538       tos_addr += 2 * Interpreter::stackElementWords;
539 #else
540       tos_addr += 2;
541 #endif // AMD64
542     }
543   } else {
544     tos_addr = (intptr_t*)interpreter_frame_tos_address();
545   }
546 
547   switch (type) {
548     case T_OBJECT  :
549     case T_PRIMITIVE_OBJECT:
550     case T_ARRAY   : {
551       oop obj;
552       if (method->is_native()) {
553         obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
554       } else {
555         oop* obj_p = (oop*)tos_addr;
556         obj = (obj_p == NULL) ? (oop)NULL : *obj_p;
557       }
558       assert(Universe::is_in_heap_or_null(obj), "sanity check");
559       *oop_result = obj;
560       break;
561     }
562     case T_BOOLEAN : value_result->z = *(jboolean*)tos_addr; break;
563     case T_BYTE    : value_result->b = *(jbyte*)tos_addr; break;
564     case T_CHAR    : value_result->c = *(jchar*)tos_addr; break;
565     case T_SHORT   : value_result->s = *(jshort*)tos_addr; break;
566     case T_INT     : value_result->i = *(jint*)tos_addr; break;
567     case T_LONG    : value_result->j = *(jlong*)tos_addr; break;
568     case T_FLOAT   : {
569 #ifdef AMD64

633       Continuation::is_return_barrier_entry(ret_pc) ? "return address (return barrier)" : "return address");
634     values.describe(-1, fp_loc, "saved fp", 0); // "unowned" as value belongs to sender
635   }
636 }
637 
638 #endif // !PRODUCT
639 
640 intptr_t *frame::initial_deoptimization_info() {
641   // used to reset the saved FP
642   return fp();
643 }
644 
645 #ifndef PRODUCT
646 // This is a generic constructor which is only used by pns() in debug.cpp.
647 frame::frame(void* sp, void* fp, void* pc) {
648   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
649 }
650 
651 #endif
652 
653 // Check for a method with scalarized inline type arguments that needs
654 // a stack repair and return the repaired sender stack pointer.
655 intptr_t* frame::repair_sender_sp(intptr_t* sender_sp, intptr_t** saved_fp_addr) const {
656   CompiledMethod* cm = _cb->as_compiled_method_or_null();
657   if (cm != NULL && cm->needs_stack_repair()) {
658     // The stack increment resides just below the saved rbp on the stack
659     // and does not account for the return address.
660     intptr_t* real_frame_size_addr = (intptr_t*) (saved_fp_addr - 1);
661     int real_frame_size = ((*real_frame_size_addr) + wordSize) / wordSize;
662     assert(real_frame_size >= _cb->frame_size() && real_frame_size <= 1000000, "invalid frame size");
663     sender_sp = unextended_sp() + real_frame_size;
664   }
665   return sender_sp;
666 }
667 
668 void JavaFrameAnchor::make_walkable() {
669   // last frame set?
670   if (last_Java_sp() == NULL) return;
671   // already walkable?
672   if (walkable()) return;
673   vmassert(last_Java_pc() == NULL, "already walkable");
674   _last_Java_pc = (address)_last_Java_sp[-1];
675   vmassert(walkable(), "something went wrong");
676 }
< prev index next >