< prev index next >

src/hotspot/cpu/arm/frame_arm.cpp

Print this page

213   }
214 
215   // Will the pc we fetch be non-zero (which we'll find at the oldest frame)
216 
217   if ((address) this->fp()[return_addr_offset] == NULL) return false;
218 
219 
220   // could try and do some more potential verification of native frame if we could think of some...
221 
222   return true;
223 }
224 
225 
226 void frame::patch_pc(Thread* thread, address pc) {
227   assert(_cb == CodeCache::find_blob(pc), "unexpected pc");
228   address* pc_addr = &((address *)sp())[-sender_sp_offset+return_addr_offset];
229   if (TracePcPatching) {
230     tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
231                   p2i(pc_addr), p2i(*pc_addr), p2i(pc));
232   }

233   *pc_addr = pc;

234   address original_pc = CompiledMethod::get_deopt_original_pc(this);
235   if (original_pc != NULL) {
236     assert(original_pc == _pc, "expected original PC to be stored before patching");
237     _deopt_state = is_deoptimized;
238     // leave _pc as is
239   } else {
240     _deopt_state = not_deoptimized;
241     _pc = pc;
242   }
243 }
244 
245 bool frame::is_interpreted_frame() const  {
246   return Interpreter::contains(pc());
247 }
248 
249 int frame::frame_size(RegisterMap* map) const {
250   frame sender = this->sender(map);
251   return sender.sp() - sp();
252 }
253 
254 intptr_t* frame::entry_frame_argument_at(int offset) const {
255   assert(is_entry_frame(), "entry frame expected");
256   // convert offset to index to deal with tsi
257   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
258   // Entry frame's arguments are always in relation to unextended_sp()
259   return &unextended_sp()[index];
260 }
261 
262 // sender_sp
263 intptr_t* frame::interpreter_frame_sender_sp() const {
264   assert(is_interpreted_frame(), "interpreted frame expected");
265   return (intptr_t*) at(interpreter_frame_sender_sp_offset);
266 }
267 
268 void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
269   assert(is_interpreted_frame(), "interpreted frame expected");
270   ptr_at_put(interpreter_frame_sender_sp_offset, (intptr_t) sender_sp);
271 }
272 
273 
274 // monitor elements
275 
276 BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
277   return (BasicObjectLock*) addr_at(interpreter_frame_monitor_block_bottom_offset);
278 }
279 
280 BasicObjectLock* frame::interpreter_frame_monitor_end() const {





281   BasicObjectLock* result = (BasicObjectLock*) *addr_at(interpreter_frame_monitor_block_top_offset);
282   // make sure the pointer points inside the frame
283   assert((intptr_t) fp() >  (intptr_t) result, "result must <  than frame pointer");
284   assert((intptr_t) sp() <= (intptr_t) result, "result must >= than stack pointer");
285   return result;
286 }
287 
288 void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
289   *((BasicObjectLock**)addr_at(interpreter_frame_monitor_block_top_offset)) = value;
290 }
291 
292 
293 // Used by template based interpreter deoptimization
294 void frame::interpreter_frame_set_last_sp(intptr_t* sp) {
295     *((intptr_t**)addr_at(interpreter_frame_last_sp_offset)) = sp;
296 }
297 
298 
299 frame frame::sender_for_entry_frame(RegisterMap* map) const {
300   assert(map != NULL, "map must be set");

380   map->set_location(FP->as_VMReg(), (address) link_addr);
381 }
382 
383 frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
384   // SP is the raw SP from the sender after adapter or interpreter
385   // extension.
386   intptr_t* sender_sp = this->sender_sp();
387 
388   // This is the sp before any possible extension (adapter/locals).
389   intptr_t* unextended_sp = interpreter_frame_sender_sp();
390 
391 #ifdef COMPILER2
392   if (map->update_map()) {
393     update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset));
394   }
395 #endif // COMPILER2
396 
397   return frame(sender_sp, unextended_sp, link(), sender_pc());
398 }
399 

400 frame frame::sender_for_compiled_frame(RegisterMap* map) const {
401   assert(map != NULL, "map must be set");
402 
403   // frame owned by optimizing compiler
404   assert(_cb->frame_size() >= 0, "must have non-zero frame size");
405   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
406   intptr_t* unextended_sp = sender_sp;
407 
408   address sender_pc = (address) *(sender_sp - sender_sp_offset + return_addr_offset);
409 
410   // This is the saved value of FP which may or may not really be an FP.
411   // It is only an FP if the sender is an interpreter frame (or C1?).
412   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - sender_sp_offset + link_offset);
413 
414   if (map->update_map()) {
415     // Tell GC to use argument oopmaps for some runtime stubs that need it.
416     // For C1, the runtime stub might not have oop maps, so set this flag
417     // outside of update_register_map.
418     map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
419     if (_cb->oop_maps() != NULL) {

423     // Since the prolog does the save and restore of FP there is no oopmap
424     // for it so we must fill in its location as if there was an oopmap entry
425     // since if our caller was compiled code there could be live jvm state in it.
426     update_map_with_saved_link(map, saved_fp_addr);
427   }
428 
429   assert(sender_sp != sp(), "must have changed");
430   return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
431 }
432 
433 frame frame::sender(RegisterMap* map) const {
434   // Default is we done have to follow them. The sender_for_xxx will
435   // update it accordingly
436   map->set_include_argument_oops(false);
437 
438   if (is_entry_frame())       return sender_for_entry_frame(map);
439   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
440   assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
441 
442   if (_cb != NULL) {
443     return sender_for_compiled_frame(map);
444   }
445 
446   assert(false, "should not be called for a C frame");
447   return frame();
448 }
449 
450 bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
451   assert(is_interpreted_frame(), "Not an interpreted frame");
452   // These are reasonable sanity checks
453   if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
454     return false;
455   }
456   if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
457     return false;
458   }
459   if (fp() + interpreter_frame_initial_sp_offset < sp()) {
460     return false;
461   }
462   // These are hacks to keep us out of trouble.
463   // The problem with these is that they mask other problems

528       }
529       assert(Universe::is_in_heap_or_null(obj), "sanity check");
530       *oop_result = obj;
531       break;
532     }
533     case T_BOOLEAN : value_result->z = *(jboolean*)res_addr; break;
534     case T_BYTE    : value_result->b = *(jbyte*)res_addr; break;
535     case T_CHAR    : value_result->c = *(jchar*)res_addr; break;
536     case T_SHORT   : value_result->s = *(jshort*)res_addr; break;
537     case T_INT     : value_result->i = *(jint*)res_addr; break;
538     case T_LONG    : value_result->j = *(jlong*)res_addr; break;
539     case T_FLOAT   : value_result->f = *(jfloat*)res_addr; break;
540     case T_DOUBLE  : value_result->d = *(jdouble*)res_addr; break;
541     case T_VOID    : /* Nothing to do */ break;
542     default        : ShouldNotReachHere();
543   }
544 
545   return type;
546 }
547 


548 
549 intptr_t* frame::interpreter_frame_tos_at(jint offset) const {

550   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
551   return &interpreter_frame_tos_address()[index];
552 }
553 
554 #ifndef PRODUCT
555 
556 #define DESCRIBE_FP_OFFSET(name) \
557   values.describe(frame_no, fp() + frame::name##_offset, #name)
558 
559 void frame::describe_pd(FrameValues& values, int frame_no) {
560   if (is_interpreted_frame()) {
561     DESCRIBE_FP_OFFSET(interpreter_frame_sender_sp);
562     DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
563     DESCRIBE_FP_OFFSET(interpreter_frame_method);
564     DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
565     DESCRIBE_FP_OFFSET(interpreter_frame_cache);
566     DESCRIBE_FP_OFFSET(interpreter_frame_locals);
567     DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
568     DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
569   }
570 }
571 
572 // This is a generic constructor which is only used by pns() in debug.cpp.
573 frame::frame(void* sp, void* fp, void* pc) {
574   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
575 }
576 



577 #endif
578 
579 intptr_t *frame::initial_deoptimization_info() {
580   // used to reset the saved FP
581   return fp();
582 }
583 
584 intptr_t* frame::real_fp() const {
585   if (is_entry_frame()) {
586     // Work-around: FP (currently) does not conform to the ABI for entry
587     // frames (see generate_call_stub). Might be worth fixing as another CR.
588     // Following code assumes (and asserts) this has not yet been fixed.
589     assert(frame::entry_frame_call_wrapper_offset == 0, "adjust this code");
590     intptr_t* new_fp = fp();
591     new_fp += 5; // saved R0,R1,R2,R4,R10
592 #ifndef __SOFTFP__
593     new_fp += 8*2; // saved D8..D15
594 #endif
595     return new_fp;
596   }

213   }
214 
215   // Will the pc we fetch be non-zero (which we'll find at the oldest frame)
216 
217   if ((address) this->fp()[return_addr_offset] == NULL) return false;
218 
219 
220   // could try and do some more potential verification of native frame if we could think of some...
221 
222   return true;
223 }
224 
225 
226 void frame::patch_pc(Thread* thread, address pc) {
227   assert(_cb == CodeCache::find_blob(pc), "unexpected pc");
228   address* pc_addr = &((address *)sp())[-sender_sp_offset+return_addr_offset];
229   if (TracePcPatching) {
230     tty->print_cr("patch_pc at address" INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "] ",
231                   p2i(pc_addr), p2i(*pc_addr), p2i(pc));
232   }
233   DEBUG_ONLY(address old_pc = _pc;)
234   *pc_addr = pc;
235   _pc = pc; // must be set before call to get_deopt_original_pc
236   address original_pc = CompiledMethod::get_deopt_original_pc(this);
237   if (original_pc != NULL) {
238     assert(original_pc == old_pc, "expected original PC to be stored before patching");
239     _deopt_state = is_deoptimized;
240     // leave _pc as is
241   } else {
242     _deopt_state = not_deoptimized;
243     _pc = pc;
244   }
245 }
246 
247 bool frame::is_interpreted_frame() const  {
248   return Interpreter::contains(pc());
249 }
250 





251 intptr_t* frame::entry_frame_argument_at(int offset) const {
252   assert(is_entry_frame(), "entry frame expected");
253   // convert offset to index to deal with tsi
254   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
255   // Entry frame's arguments are always in relation to unextended_sp()
256   return &unextended_sp()[index];
257 }
258 
259 // sender_sp
260 intptr_t* frame::interpreter_frame_sender_sp() const {
261   assert(is_interpreted_frame(), "interpreted frame expected");
262   return (intptr_t*) at(interpreter_frame_sender_sp_offset);
263 }
264 
265 void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
266   assert(is_interpreted_frame(), "interpreted frame expected");
267   ptr_at_put(interpreter_frame_sender_sp_offset, (intptr_t) sender_sp);
268 }
269 
270 
271 // monitor elements
272 
273 BasicObjectLock* frame::interpreter_frame_monitor_begin() const {
274   return (BasicObjectLock*) addr_at(interpreter_frame_monitor_block_bottom_offset);
275 }
276 
277 // Pointer beyond the "oldest/deepest" BasicObjectLock on stack.
278 template BasicObjectLock* frame::interpreter_frame_monitor_end<true>() const;
279 template BasicObjectLock* frame::interpreter_frame_monitor_end<false>() const;
280 
281 template <bool relative>
282 inline BasicObjectLock* frame::interpreter_frame_monitor_end() const {
283   BasicObjectLock* result = (BasicObjectLock*) *addr_at(interpreter_frame_monitor_block_top_offset);
284   // make sure the pointer points inside the frame
285   assert((intptr_t) fp() >  (intptr_t) result, "result must <  than frame pointer");
286   assert((intptr_t) sp() <= (intptr_t) result, "result must >= than stack pointer");
287   return result;
288 }
289 
290 void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
291   *((BasicObjectLock**)addr_at(interpreter_frame_monitor_block_top_offset)) = value;
292 }
293 
294 
295 // Used by template based interpreter deoptimization
296 void frame::interpreter_frame_set_last_sp(intptr_t* sp) {
297     *((intptr_t**)addr_at(interpreter_frame_last_sp_offset)) = sp;
298 }
299 
300 
301 frame frame::sender_for_entry_frame(RegisterMap* map) const {
302   assert(map != NULL, "map must be set");

382   map->set_location(FP->as_VMReg(), (address) link_addr);
383 }
384 
385 frame frame::sender_for_interpreter_frame(RegisterMap* map) const {
386   // SP is the raw SP from the sender after adapter or interpreter
387   // extension.
388   intptr_t* sender_sp = this->sender_sp();
389 
390   // This is the sp before any possible extension (adapter/locals).
391   intptr_t* unextended_sp = interpreter_frame_sender_sp();
392 
393 #ifdef COMPILER2
394   if (map->update_map()) {
395     update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset));
396   }
397 #endif // COMPILER2
398 
399   return frame(sender_sp, unextended_sp, link(), sender_pc());
400 }
401 
402 template <bool stub>
403 frame frame::sender_for_compiled_frame(RegisterMap* map) const {
404   assert(map != NULL, "map must be set");
405 
406   // frame owned by optimizing compiler
407   assert(_cb->frame_size() >= 0, "must have non-zero frame size");
408   intptr_t* sender_sp = unextended_sp() + _cb->frame_size();
409   intptr_t* unextended_sp = sender_sp;
410 
411   address sender_pc = (address) *(sender_sp - sender_sp_offset + return_addr_offset);
412 
413   // This is the saved value of FP which may or may not really be an FP.
414   // It is only an FP if the sender is an interpreter frame (or C1?).
415   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - sender_sp_offset + link_offset);
416 
417   if (map->update_map()) {
418     // Tell GC to use argument oopmaps for some runtime stubs that need it.
419     // For C1, the runtime stub might not have oop maps, so set this flag
420     // outside of update_register_map.
421     map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
422     if (_cb->oop_maps() != NULL) {

426     // Since the prolog does the save and restore of FP there is no oopmap
427     // for it so we must fill in its location as if there was an oopmap entry
428     // since if our caller was compiled code there could be live jvm state in it.
429     update_map_with_saved_link(map, saved_fp_addr);
430   }
431 
432   assert(sender_sp != sp(), "must have changed");
433   return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc);
434 }
435 
436 frame frame::sender(RegisterMap* map) const {
437   // Default is we done have to follow them. The sender_for_xxx will
438   // update it accordingly
439   map->set_include_argument_oops(false);
440 
441   if (is_entry_frame())       return sender_for_entry_frame(map);
442   if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
443   assert(_cb == CodeCache::find_blob(pc()),"Must be the same");
444 
445   if (_cb != NULL) {
446     return sender_for_compiled_frame<false>(map);
447   }
448 
449   assert(false, "should not be called for a C frame");
450   return frame();
451 }
452 
453 bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
454   assert(is_interpreted_frame(), "Not an interpreted frame");
455   // These are reasonable sanity checks
456   if (fp() == 0 || (intptr_t(fp()) & (wordSize-1)) != 0) {
457     return false;
458   }
459   if (sp() == 0 || (intptr_t(sp()) & (wordSize-1)) != 0) {
460     return false;
461   }
462   if (fp() + interpreter_frame_initial_sp_offset < sp()) {
463     return false;
464   }
465   // These are hacks to keep us out of trouble.
466   // The problem with these is that they mask other problems

531       }
532       assert(Universe::is_in_heap_or_null(obj), "sanity check");
533       *oop_result = obj;
534       break;
535     }
536     case T_BOOLEAN : value_result->z = *(jboolean*)res_addr; break;
537     case T_BYTE    : value_result->b = *(jbyte*)res_addr; break;
538     case T_CHAR    : value_result->c = *(jchar*)res_addr; break;
539     case T_SHORT   : value_result->s = *(jshort*)res_addr; break;
540     case T_INT     : value_result->i = *(jint*)res_addr; break;
541     case T_LONG    : value_result->j = *(jlong*)res_addr; break;
542     case T_FLOAT   : value_result->f = *(jfloat*)res_addr; break;
543     case T_DOUBLE  : value_result->d = *(jdouble*)res_addr; break;
544     case T_VOID    : /* Nothing to do */ break;
545     default        : ShouldNotReachHere();
546   }
547 
548   return type;
549 }
550 
551 template intptr_t* frame::interpreter_frame_tos_at<false>(jint offset) const;
552 template intptr_t* frame::interpreter_frame_tos_at<true >(jint offset) const;
553 
554 template <bool relative>
555 inline intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
556   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
557   return &interpreter_frame_tos_address()[index];
558 }
559 
560 #ifndef PRODUCT
561 
562 #define DESCRIBE_FP_OFFSET(name) \
563   values.describe(frame_no, fp() + frame::name##_offset, #name)
564 
565 void frame::describe_pd(FrameValues& values, int frame_no) {
566   if (is_interpreted_frame()) {
567     DESCRIBE_FP_OFFSET(interpreter_frame_sender_sp);
568     DESCRIBE_FP_OFFSET(interpreter_frame_last_sp);
569     DESCRIBE_FP_OFFSET(interpreter_frame_method);
570     DESCRIBE_FP_OFFSET(interpreter_frame_mdp);
571     DESCRIBE_FP_OFFSET(interpreter_frame_cache);
572     DESCRIBE_FP_OFFSET(interpreter_frame_locals);
573     DESCRIBE_FP_OFFSET(interpreter_frame_bcp);
574     DESCRIBE_FP_OFFSET(interpreter_frame_initial_sp);
575   }
576 }
577 
578 // This is a generic constructor which is only used by pns() in debug.cpp.
579 frame::frame(void* sp, void* fp, void* pc) {
580   init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
581 }
582 
583 void frame::describe_top_pd(FrameValues& values) {
584   Unimplemented();
585 }
586 #endif
587 
588 intptr_t *frame::initial_deoptimization_info() {
589   // used to reset the saved FP
590   return fp();
591 }
592 
593 intptr_t* frame::real_fp() const {
594   if (is_entry_frame()) {
595     // Work-around: FP (currently) does not conform to the ABI for entry
596     // frames (see generate_call_stub). Might be worth fixing as another CR.
597     // Following code assumes (and asserts) this has not yet been fixed.
598     assert(frame::entry_frame_call_wrapper_offset == 0, "adjust this code");
599     intptr_t* new_fp = fp();
600     new_fp += 5; // saved R0,R1,R2,R4,R10
601 #ifndef __SOFTFP__
602     new_fp += 8*2; // saved D8..D15
603 #endif
604     return new_fp;
605   }
< prev index next >