src/cpu/sparc/vm/frame_sparc.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6930772 Sdiff src/cpu/sparc/vm

src/cpu/sparc/vm/frame_sparc.cpp

Print this page




 319   assert( (((intptr_t)sp & (wordSize-1)) == 0), "frame constructor passed an invalid sp");
 320 #endif
 321   _sp = sp;
 322   _younger_sp = NULL;
 323   _pc = pc;
 324   _cb = cb;
 325   _sp_adjustment_by_callee = 0;
 326   assert(pc == NULL && cb == NULL || pc != NULL, "can't have a cb and no pc!");
 327   if (_cb == NULL && _pc != NULL ) {
 328     _cb = CodeCache::find_blob(_pc);
 329   }
 330   _deopt_state = unknown;
 331 #ifdef ASSERT
 332   if ( _cb != NULL && _cb->is_nmethod()) {
 333     // Without a valid unextended_sp() we can't convert the pc to "original"
 334     assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant broken");
 335   }
 336 #endif // ASSERT
 337 }
 338 
 339 frame::frame(intptr_t* sp, intptr_t* younger_sp, bool younger_frame_adjusted_stack) {
 340   _sp = sp;
 341   _younger_sp = younger_sp;


 342   if (younger_sp == NULL) {
 343     // make a deficient frame which doesn't know where its PC is
 344     _pc = NULL;
 345     _cb = NULL;
 346   } else {
 347     _pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset;
 348     assert( (intptr_t*)younger_sp[FP->sp_offset_in_saved_window()] == (intptr_t*)((intptr_t)sp - STACK_BIAS), "younger_sp must be valid");
 349     // Any frame we ever build should always "safe" therefore we should not have to call
 350     // find_blob_unsafe
 351     // In case of native stubs, the pc retrieved here might be
 352     // wrong.  (the _last_native_pc will have the right value)
 353     // So do not put add any asserts on the _pc here.
 354   }
 355   if (younger_frame_adjusted_stack) {
 356     // compute adjustment to this frame's SP made by its interpreted callee
 357     _sp_adjustment_by_callee = (intptr_t*)((intptr_t)younger_sp[I5_savedSP->sp_offset_in_saved_window()] +
 358                                              STACK_BIAS) - sp;
 359   } else {
 360     _sp_adjustment_by_callee = 0;









 361   }
 362 
 363   _deopt_state = unknown;



 364 
 365   // It is important that frame be fully construct when we do this lookup
 366   // as get_original_pc() needs correct value for unextended_sp()

 367   if (_pc != NULL) {
 368     _cb = CodeCache::find_blob(_pc);
 369     address original_pc = nmethod::get_deopt_original_pc(this);
 370     if (original_pc != NULL) {
 371       _pc = original_pc;
 372       _deopt_state = is_deoptimized;
 373     } else {
 374       _deopt_state = not_deoptimized;
 375     }
 376   }
 377 }
 378 
 379 bool frame::is_interpreted_frame() const  {
 380   return Interpreter::contains(pc());
 381 }
 382 
 383 // sender_sp
 384 
 385 intptr_t* frame::interpreter_frame_sender_sp() const {
 386   assert(is_interpreted_frame(), "interpreted frame expected");
 387   return fp();
 388 }


 447   return sender(map);
 448 }
 449 
 450 frame frame::sender_for_compiled_frame(RegisterMap *map) const {
 451   ShouldNotCallThis();
 452   return sender(map);
 453 }
 454 
 455 frame frame::sender(RegisterMap* map) const {
 456   assert(map != NULL, "map must be set");
 457 
 458   assert(CodeCache::find_blob_unsafe(_pc) == _cb, "inconsistent");
 459 
 460   // Default is not to follow arguments; update it accordingly below
 461   map->set_include_argument_oops(false);
 462 
 463   if (is_entry_frame()) return sender_for_entry_frame(map);
 464 
 465   intptr_t* younger_sp     = sp();
 466   intptr_t* sp             = sender_sp();
 467   bool      adjusted_stack = false;
 468 
 469   // Note:  The version of this operation on any platform with callee-save
 470   //        registers must update the register map (if not null).
 471   //        In order to do this correctly, the various subtypes of
 472   //        of frame (interpreted, compiled, glue, native),
 473   //        must be distinguished.  There is no need on SPARC for
 474   //        such distinctions, because all callee-save registers are
 475   //        preserved for all frames via SPARC-specific mechanisms.
 476   //
 477   //        *** HOWEVER, *** if and when we make any floating-point
 478   //        registers callee-saved, then we will have to copy over
 479   //        the RegisterMap update logic from the Intel code.
 480 
 481   // The constructor of the sender must know whether this frame is interpreted so it can set the
 482   // sender's _sp_adjustment_by_callee field.  An osr adapter frame was originally
 483   // interpreted but its pc is in the code cache (for c1 -> osr_frame_return_id stub), so it must be
 484   // explicitly recognized.
 485 
 486   adjusted_stack = is_interpreted_frame();
 487   if (adjusted_stack) {
 488     map->make_integer_regs_unsaved();
 489     map->shift_window(sp, younger_sp);
 490   } else if (_cb != NULL) {
 491     // Update the locations of implicitly saved registers to be their
 492     // addresses in the register save area.
 493     // For %o registers, the addresses of %i registers in the next younger
 494     // frame are used.
 495     map->shift_window(sp, younger_sp);
 496     if (map->update_map()) {
 497       // Tell GC to use argument oopmaps for some runtime stubs that need it.
 498       // For C1, the runtime stub might not have oop maps, so set this flag
 499       // outside of update_register_map.
 500       map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
 501       if (_cb->oop_maps() != NULL) {
 502         OopMapSet::update_register_map(this, map);
 503       }
 504     }
 505   }
 506   return frame(sp, younger_sp, adjusted_stack);
 507 }
 508 
 509 
 510 void frame::patch_pc(Thread* thread, address pc) {
 511   if(thread == Thread::current()) {
 512    StubRoutines::Sparc::flush_callers_register_windows_func()();
 513   }
 514   if (TracePcPatching) {
 515     // QQQ this assert is invalid (or too strong anyway) sice _pc could
 516     // be original pc and frame could have the deopt pc.
 517     // assert(_pc == *O7_addr() + pc_return_offset, "frame has wrong pc");
 518     tty->print_cr("patch_pc at address  0x%x [0x%x -> 0x%x] ", O7_addr(), _pc, pc);
 519   }
 520   _cb = CodeCache::find_blob(pc);
 521   *O7_addr() = pc - pc_return_offset;
 522   _cb = CodeCache::find_blob(_pc);
 523   address original_pc = nmethod::get_deopt_original_pc(this);
 524   if (original_pc != NULL) {
 525     assert(original_pc == _pc, "expected original to be stored before patching");
 526     _deopt_state = is_deoptimized;




 319   assert( (((intptr_t)sp & (wordSize-1)) == 0), "frame constructor passed an invalid sp");
 320 #endif
 321   _sp = sp;
 322   _younger_sp = NULL;
 323   _pc = pc;
 324   _cb = cb;
 325   _sp_adjustment_by_callee = 0;
 326   assert(pc == NULL && cb == NULL || pc != NULL, "can't have a cb and no pc!");
 327   if (_cb == NULL && _pc != NULL ) {
 328     _cb = CodeCache::find_blob(_pc);
 329   }
 330   _deopt_state = unknown;
 331 #ifdef ASSERT
 332   if ( _cb != NULL && _cb->is_nmethod()) {
 333     // Without a valid unextended_sp() we can't convert the pc to "original"
 334     assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant broken");
 335   }
 336 #endif // ASSERT
 337 }
 338 
 339 frame::frame(intptr_t* sp, intptr_t* younger_sp, bool younger_frame_is_interpreted) :
 340   _sp(sp),
 341   _younger_sp(younger_sp),
 342   _deopt_state(unknown),
 343   _sp_adjustment_by_callee(0) {
 344   if (younger_sp == NULL) {
 345     // make a deficient frame which doesn't know where its PC is
 346     _pc = NULL;
 347     _cb = NULL;
 348   } else {
 349     _pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset;
 350     assert( (intptr_t*)younger_sp[FP->sp_offset_in_saved_window()] == (intptr_t*)((intptr_t)sp - STACK_BIAS), "younger_sp must be valid");
 351     // Any frame we ever build should always "safe" therefore we should not have to call
 352     // find_blob_unsafe
 353     // In case of native stubs, the pc retrieved here might be
 354     // wrong.  (the _last_native_pc will have the right value)
 355     // So do not put add any asserts on the _pc here.
 356   }
 357 
 358   if (_pc != NULL)
 359     _cb = CodeCache::find_blob(_pc);
 360 
 361   // Check for MethodHandle call sites.
 362   if (_cb != NULL) {
 363     nmethod* nm = _cb->as_nmethod_or_null();
 364     if (nm != NULL) {
 365       if (nm->is_deopt_mh_entry(_pc) || nm->is_method_handle_return(_pc)) {
 366         _sp_adjustment_by_callee = (intptr_t*) ((intptr_t) sp[L7_mh_SP_save->sp_offset_in_saved_window()] + STACK_BIAS) - sp;
 367         // The SP is already adjusted by this MH call site, don't
 368         // overwrite this value with the wrong interpreter value.
 369         younger_frame_is_interpreted = false;
 370       }
 371     }
 372   }
 373 
 374   if (younger_frame_is_interpreted) {
 375     // compute adjustment to this frame's SP made by its interpreted callee
 376     _sp_adjustment_by_callee = (intptr_t*) ((intptr_t) younger_sp[I5_savedSP->sp_offset_in_saved_window()] + STACK_BIAS) - sp;
 377   }
 378 
 379   // It is important that the frame is fully constructed when we do
 380   // this lookup as get_deopt_original_pc() needs a correct value for
 381   // unextended_sp() which uses _sp_adjustment_by_callee.
 382   if (_pc != NULL) {

 383     address original_pc = nmethod::get_deopt_original_pc(this);
 384     if (original_pc != NULL) {
 385       _pc = original_pc;
 386       _deopt_state = is_deoptimized;
 387     } else {
 388       _deopt_state = not_deoptimized;
 389     }
 390   }
 391 }
 392 
 393 bool frame::is_interpreted_frame() const  {
 394   return Interpreter::contains(pc());
 395 }
 396 
 397 // sender_sp
 398 
 399 intptr_t* frame::interpreter_frame_sender_sp() const {
 400   assert(is_interpreted_frame(), "interpreted frame expected");
 401   return fp();
 402 }


 461   return sender(map);
 462 }
 463 
 464 frame frame::sender_for_compiled_frame(RegisterMap *map) const {
 465   ShouldNotCallThis();
 466   return sender(map);
 467 }
 468 
 469 frame frame::sender(RegisterMap* map) const {
 470   assert(map != NULL, "map must be set");
 471 
 472   assert(CodeCache::find_blob_unsafe(_pc) == _cb, "inconsistent");
 473 
 474   // Default is not to follow arguments; update it accordingly below
 475   map->set_include_argument_oops(false);
 476 
 477   if (is_entry_frame()) return sender_for_entry_frame(map);
 478 
 479   intptr_t* younger_sp = sp();
 480   intptr_t* sp         = sender_sp();

 481 
 482   // Note:  The version of this operation on any platform with callee-save
 483   //        registers must update the register map (if not null).
 484   //        In order to do this correctly, the various subtypes of
 485   //        of frame (interpreted, compiled, glue, native),
 486   //        must be distinguished.  There is no need on SPARC for
 487   //        such distinctions, because all callee-save registers are
 488   //        preserved for all frames via SPARC-specific mechanisms.
 489   //
 490   //        *** HOWEVER, *** if and when we make any floating-point
 491   //        registers callee-saved, then we will have to copy over
 492   //        the RegisterMap update logic from the Intel code.
 493 
 494   // The constructor of the sender must know whether this frame is interpreted so it can set the
 495   // sender's _sp_adjustment_by_callee field.  An osr adapter frame was originally
 496   // interpreted but its pc is in the code cache (for c1 -> osr_frame_return_id stub), so it must be
 497   // explicitly recognized.
 498 
 499   bool frame_is_interpreted = is_interpreted_frame();
 500   if (frame_is_interpreted) {
 501     map->make_integer_regs_unsaved();
 502     map->shift_window(sp, younger_sp);
 503   } else if (_cb != NULL) {
 504     // Update the locations of implicitly saved registers to be their
 505     // addresses in the register save area.
 506     // For %o registers, the addresses of %i registers in the next younger
 507     // frame are used.
 508     map->shift_window(sp, younger_sp);
 509     if (map->update_map()) {
 510       // Tell GC to use argument oopmaps for some runtime stubs that need it.
 511       // For C1, the runtime stub might not have oop maps, so set this flag
 512       // outside of update_register_map.
 513       map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
 514       if (_cb->oop_maps() != NULL) {
 515         OopMapSet::update_register_map(this, map);
 516       }
 517     }
 518   }
 519   return frame(sp, younger_sp, frame_is_interpreted);
 520 }
 521 
 522 
 523 void frame::patch_pc(Thread* thread, address pc) {
 524   if(thread == Thread::current()) {
 525    StubRoutines::Sparc::flush_callers_register_windows_func()();
 526   }
 527   if (TracePcPatching) {
 528     // QQQ this assert is invalid (or too strong anyway) sice _pc could
 529     // be original pc and frame could have the deopt pc.
 530     // assert(_pc == *O7_addr() + pc_return_offset, "frame has wrong pc");
 531     tty->print_cr("patch_pc at address  0x%x [0x%x -> 0x%x] ", O7_addr(), _pc, pc);
 532   }
 533   _cb = CodeCache::find_blob(pc);
 534   *O7_addr() = pc - pc_return_offset;
 535   _cb = CodeCache::find_blob(_pc);
 536   address original_pc = nmethod::get_deopt_original_pc(this);
 537   if (original_pc != NULL) {
 538     assert(original_pc == _pc, "expected original to be stored before patching");
 539     _deopt_state = is_deoptimized;


src/cpu/sparc/vm/frame_sparc.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File