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

src/cpu/sparc/vm/frame_sparc.cpp

Print this page




 424 }
 425 
 426 #ifndef PRODUCT
 427 // This is a generic constructor which is only used by pns() in debug.cpp.
 428 frame::frame(void* sp, void* fp, void* pc) {
 429   init((intptr_t*)sp, (address)pc, NULL);
 430 }
 431 #endif
 432 
 433 bool frame::is_interpreted_frame() const  {
 434   return Interpreter::contains(pc());
 435 }
 436 
 437 // sender_sp
 438 
 439 intptr_t* frame::interpreter_frame_sender_sp() const {
 440   assert(is_interpreted_frame(), "interpreted frame expected");
 441   return fp();
 442 }
 443 
 444 #ifndef CC_INTERP
 445 void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
 446   assert(is_interpreted_frame(), "interpreted frame expected");
 447   Unimplemented();
 448 }
 449 #endif // CC_INTERP
 450 
 451 frame frame::sender_for_entry_frame(RegisterMap *map) const {
 452   assert(map != NULL, "map must be set");
 453   // Java frame called from C; skip all C frames and return top C
 454   // frame of that chunk as the sender
 455   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
 456   assert(!entry_frame_is_first(), "next Java fp must be non zero");
 457   assert(jfa->last_Java_sp() > _sp, "must be above this frame on stack");
 458   intptr_t* last_Java_sp = jfa->last_Java_sp();
 459   // Since we are walking the stack now this nested anchor is obviously walkable
 460   // even if it wasn't when it was stacked.
 461   if (!jfa->walkable()) {
 462     // Capture _last_Java_pc (if needed) and mark anchor walkable.
 463     jfa->capture_last_Java_pc(_sp);
 464   }
 465   assert(jfa->last_Java_pc() != NULL, "No captured pc!");
 466   map->clear();
 467   map->make_integer_regs_unsaved();
 468   map->shift_window(last_Java_sp, NULL);
 469   assert(map->include_argument_oops(), "should be set by clear");


 583       break;
 584     previous_sp = sp;
 585     sp = (intptr_t*)sp[FP->sp_offset_in_saved_window()];
 586     sp = (intptr_t*)((intptr_t)sp + STACK_BIAS);
 587   }
 588 
 589   return (sp == old_sp ? previous_sp : NULL);
 590 }
 591 
 592 /*
 593   Determine if "sp" is a valid stack pointer. "sp" is assumed to be younger than
 594   "valid_sp". So if "sp" is valid itself then it should be possible to walk frames
 595   from "sp" to "valid_sp". The assumption is that the registers windows for the
 596   thread stack in question are flushed.
 597 */
 598 bool frame::is_valid_stack_pointer(intptr_t* valid_sp, intptr_t* sp) {
 599   return next_younger_sp_or_null(valid_sp, sp) != NULL;
 600 }
 601 
 602 bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
 603 #ifdef CC_INTERP
 604   // Is there anything to do?
 605 #else
 606   assert(is_interpreted_frame(), "Not an interpreted frame");
 607   // These are reasonable sanity checks
 608   if (fp() == 0 || (intptr_t(fp()) & (2*wordSize-1)) != 0) {
 609     return false;
 610   }
 611   if (sp() == 0 || (intptr_t(sp()) & (2*wordSize-1)) != 0) {
 612     return false;
 613   }
 614 
 615   const intptr_t interpreter_frame_initial_sp_offset = interpreter_frame_vm_local_words;
 616   if (fp() + interpreter_frame_initial_sp_offset < sp()) {
 617     return false;
 618   }
 619   // These are hacks to keep us out of trouble.
 620   // The problem with these is that they mask other problems
 621   if (fp() <= sp()) {        // this attempts to deal with unsigned comparison above
 622     return false;
 623   }
 624   // do some validation of frame elements
 625 


 637   }
 638 
 639   // validate bci/bcp
 640 
 641   address bcp = interpreter_frame_bcp();
 642   if (m->validate_bci_from_bcp(bcp) < 0) {
 643     return false;
 644   }
 645 
 646   // validate ConstantPoolCache*
 647   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
 648   if (cp == NULL || !cp->is_metaspace_object()) return false;
 649 
 650   // validate locals
 651 
 652   address locals =  (address) *interpreter_frame_locals_addr();
 653 
 654   if (locals > thread->stack_base() || locals < (address) fp()) return false;
 655 
 656   // We'd have to be pretty unlucky to be mislead at this point
 657 #endif /* CC_INTERP */
 658   return true;
 659 }
 660 
 661 
 662 // Windows have been flushed on entry (but not marked). Capture the pc that
 663 // is the return address to the frame that contains "sp" as its stack pointer.
 664 // This pc resides in the called of the frame corresponding to "sp".
 665 // As a side effect we mark this JavaFrameAnchor as having flushed the windows.
 666 // This side effect lets us mark stacked JavaFrameAnchors (stacked in the
 667 // call_helper) as flushed when we have flushed the windows for the most
 668 // recent (i.e. current) JavaFrameAnchor. This saves useless flushing calls
 669 // and lets us find the pc just once rather than multiple times as it did
 670 // in the bad old _post_Java_state days.
 671 //
 672 void JavaFrameAnchor::capture_last_Java_pc(intptr_t* sp) {
 673   if (last_Java_sp() != NULL && last_Java_pc() == NULL) {
 674     // try and find the sp just younger than _last_Java_sp
 675     intptr_t* _post_Java_sp = frame::next_younger_sp_or_null(last_Java_sp(), sp);
 676     // Really this should never fail otherwise VM call must have non-standard
 677     // frame linkage (bad) or stack is not properly flushed (worse).


 695 }
 696 
 697 intptr_t* frame::entry_frame_argument_at(int offset) const {
 698   // convert offset to index to deal with tsi
 699   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
 700 
 701   intptr_t* LSP = (intptr_t*) sp()[Lentry_args->sp_offset_in_saved_window()];
 702   return &LSP[index+1];
 703 }
 704 
 705 
 706 BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) {
 707   assert(is_interpreted_frame(), "interpreted frame expected");
 708   Method* method = interpreter_frame_method();
 709   BasicType type = method->result_type();
 710 
 711   if (method->is_native()) {
 712     // Prior to notifying the runtime of the method_exit the possible result
 713     // value is saved to l_scratch and d_scratch.
 714 
 715 #ifdef CC_INTERP
 716     interpreterState istate = get_interpreterState();
 717     intptr_t* l_scratch = (intptr_t*) &istate->_native_lresult;
 718     intptr_t* d_scratch = (intptr_t*) &istate->_native_fresult;
 719 #else /* CC_INTERP */
 720     intptr_t* l_scratch = fp() + interpreter_frame_l_scratch_fp_offset;
 721     intptr_t* d_scratch = fp() + interpreter_frame_d_scratch_fp_offset;
 722 #endif /* CC_INTERP */
 723 
 724     address l_addr = (address)l_scratch;
 725 #ifdef _LP64
 726     // On 64-bit the result for 1/8/16/32-bit result types is in the other
 727     // word half
 728     l_addr += wordSize/2;
 729 #endif
 730 
 731     switch (type) {
 732       case T_OBJECT:
 733       case T_ARRAY: {
 734 #ifdef CC_INTERP
 735         *oop_result = istate->_oop_temp;
 736 #else
 737         oop obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
 738         assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
 739         *oop_result = obj;
 740 #endif // CC_INTERP
 741         break;
 742       }
 743 
 744       case T_BOOLEAN : { jint* p = (jint*)l_addr; value_result->z = (jboolean)((*p) & 0x1); break; }
 745       case T_BYTE    : { jint* p = (jint*)l_addr; value_result->b = (jbyte)((*p) & 0xff); break; }
 746       case T_CHAR    : { jint* p = (jint*)l_addr; value_result->c = (jchar)((*p) & 0xffff); break; }
 747       case T_SHORT   : { jint* p = (jint*)l_addr; value_result->s = (jshort)((*p) & 0xffff); break; }
 748       case T_INT     : value_result->i = *(jint*)l_addr; break;
 749       case T_LONG    : value_result->j = *(jlong*)l_scratch; break;
 750       case T_FLOAT   : value_result->f = *(jfloat*)d_scratch; break;
 751       case T_DOUBLE  : value_result->d = *(jdouble*)d_scratch; break;
 752       case T_VOID    : /* Nothing to do */ break;
 753       default        : ShouldNotReachHere();
 754     }
 755   } else {
 756     intptr_t* tos_addr = interpreter_frame_tos_address();
 757 
 758     switch(type) {
 759       case T_OBJECT:
 760       case T_ARRAY: {


 780 }
 781 
 782 // Lesp pointer is one word lower than the top item on the stack.
 783 intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
 784   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize) - 1;
 785   return &interpreter_frame_tos_address()[index];
 786 }
 787 
 788 
 789 #ifndef PRODUCT
 790 
 791 #define DESCRIBE_FP_OFFSET(name) \
 792   values.describe(frame_no, fp() + frame::name##_offset, #name)
 793 
 794 void frame::describe_pd(FrameValues& values, int frame_no) {
 795   for (int w = 0; w < frame::register_save_words; w++) {
 796     values.describe(frame_no, sp() + w, err_msg("register save area word %d", w), 1);
 797   }
 798 
 799   if (is_interpreted_frame()) {
 800 #ifndef CC_INTERP
 801     DESCRIBE_FP_OFFSET(interpreter_frame_d_scratch_fp);
 802     DESCRIBE_FP_OFFSET(interpreter_frame_l_scratch_fp);
 803     DESCRIBE_FP_OFFSET(interpreter_frame_padding);
 804     DESCRIBE_FP_OFFSET(interpreter_frame_oop_temp);
 805 
 806     // esp, according to Lesp (e.g. not depending on bci), if seems valid
 807     intptr_t* esp = *interpreter_frame_esp_addr();
 808     if ((esp >= sp()) && (esp < fp())) {
 809       values.describe(-1, esp, "*Lesp");
 810     }
 811 #endif
 812   }
 813 
 814   if (!is_compiled_frame()) {
 815     if (frame::callee_aggregate_return_pointer_words != 0) {
 816       values.describe(frame_no, sp() + frame::callee_aggregate_return_pointer_sp_offset, "callee_aggregate_return_pointer_word");
 817     }
 818     for (int w = 0; w < frame::callee_register_argument_save_area_words; w++) {
 819       values.describe(frame_no, sp() + frame::callee_register_argument_save_area_sp_offset + w,
 820                       err_msg("callee_register_argument_save_area_words %d", w));
 821     }
 822   }
 823 }
 824 
 825 #endif
 826 
 827 intptr_t *frame::initial_deoptimization_info() {
 828   // unused... but returns fp() to minimize changes introduced by 7087445
 829   return fp();
 830 }


 424 }
 425 
 426 #ifndef PRODUCT
 427 // This is a generic constructor which is only used by pns() in debug.cpp.
 428 frame::frame(void* sp, void* fp, void* pc) {
 429   init((intptr_t*)sp, (address)pc, NULL);
 430 }
 431 #endif
 432 
 433 bool frame::is_interpreted_frame() const  {
 434   return Interpreter::contains(pc());
 435 }
 436 
 437 // sender_sp
 438 
 439 intptr_t* frame::interpreter_frame_sender_sp() const {
 440   assert(is_interpreted_frame(), "interpreted frame expected");
 441   return fp();
 442 }
 443 

 444 void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
 445   assert(is_interpreted_frame(), "interpreted frame expected");
 446   Unimplemented();
 447 }

 448 
 449 frame frame::sender_for_entry_frame(RegisterMap *map) const {
 450   assert(map != NULL, "map must be set");
 451   // Java frame called from C; skip all C frames and return top C
 452   // frame of that chunk as the sender
 453   JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
 454   assert(!entry_frame_is_first(), "next Java fp must be non zero");
 455   assert(jfa->last_Java_sp() > _sp, "must be above this frame on stack");
 456   intptr_t* last_Java_sp = jfa->last_Java_sp();
 457   // Since we are walking the stack now this nested anchor is obviously walkable
 458   // even if it wasn't when it was stacked.
 459   if (!jfa->walkable()) {
 460     // Capture _last_Java_pc (if needed) and mark anchor walkable.
 461     jfa->capture_last_Java_pc(_sp);
 462   }
 463   assert(jfa->last_Java_pc() != NULL, "No captured pc!");
 464   map->clear();
 465   map->make_integer_regs_unsaved();
 466   map->shift_window(last_Java_sp, NULL);
 467   assert(map->include_argument_oops(), "should be set by clear");


 581       break;
 582     previous_sp = sp;
 583     sp = (intptr_t*)sp[FP->sp_offset_in_saved_window()];
 584     sp = (intptr_t*)((intptr_t)sp + STACK_BIAS);
 585   }
 586 
 587   return (sp == old_sp ? previous_sp : NULL);
 588 }
 589 
 590 /*
 591   Determine if "sp" is a valid stack pointer. "sp" is assumed to be younger than
 592   "valid_sp". So if "sp" is valid itself then it should be possible to walk frames
 593   from "sp" to "valid_sp". The assumption is that the registers windows for the
 594   thread stack in question are flushed.
 595 */
 596 bool frame::is_valid_stack_pointer(intptr_t* valid_sp, intptr_t* sp) {
 597   return next_younger_sp_or_null(valid_sp, sp) != NULL;
 598 }
 599 
 600 bool frame::is_interpreted_frame_valid(JavaThread* thread) const {



 601   assert(is_interpreted_frame(), "Not an interpreted frame");
 602   // These are reasonable sanity checks
 603   if (fp() == 0 || (intptr_t(fp()) & (2*wordSize-1)) != 0) {
 604     return false;
 605   }
 606   if (sp() == 0 || (intptr_t(sp()) & (2*wordSize-1)) != 0) {
 607     return false;
 608   }
 609 
 610   const intptr_t interpreter_frame_initial_sp_offset = interpreter_frame_vm_local_words;
 611   if (fp() + interpreter_frame_initial_sp_offset < sp()) {
 612     return false;
 613   }
 614   // These are hacks to keep us out of trouble.
 615   // The problem with these is that they mask other problems
 616   if (fp() <= sp()) {        // this attempts to deal with unsigned comparison above
 617     return false;
 618   }
 619   // do some validation of frame elements
 620 


 632   }
 633 
 634   // validate bci/bcp
 635 
 636   address bcp = interpreter_frame_bcp();
 637   if (m->validate_bci_from_bcp(bcp) < 0) {
 638     return false;
 639   }
 640 
 641   // validate ConstantPoolCache*
 642   ConstantPoolCache* cp = *interpreter_frame_cache_addr();
 643   if (cp == NULL || !cp->is_metaspace_object()) return false;
 644 
 645   // validate locals
 646 
 647   address locals =  (address) *interpreter_frame_locals_addr();
 648 
 649   if (locals > thread->stack_base() || locals < (address) fp()) return false;
 650 
 651   // We'd have to be pretty unlucky to be mislead at this point

 652   return true;
 653 }
 654 
 655 
 656 // Windows have been flushed on entry (but not marked). Capture the pc that
 657 // is the return address to the frame that contains "sp" as its stack pointer.
 658 // This pc resides in the called of the frame corresponding to "sp".
 659 // As a side effect we mark this JavaFrameAnchor as having flushed the windows.
 660 // This side effect lets us mark stacked JavaFrameAnchors (stacked in the
 661 // call_helper) as flushed when we have flushed the windows for the most
 662 // recent (i.e. current) JavaFrameAnchor. This saves useless flushing calls
 663 // and lets us find the pc just once rather than multiple times as it did
 664 // in the bad old _post_Java_state days.
 665 //
 666 void JavaFrameAnchor::capture_last_Java_pc(intptr_t* sp) {
 667   if (last_Java_sp() != NULL && last_Java_pc() == NULL) {
 668     // try and find the sp just younger than _last_Java_sp
 669     intptr_t* _post_Java_sp = frame::next_younger_sp_or_null(last_Java_sp(), sp);
 670     // Really this should never fail otherwise VM call must have non-standard
 671     // frame linkage (bad) or stack is not properly flushed (worse).


 689 }
 690 
 691 intptr_t* frame::entry_frame_argument_at(int offset) const {
 692   // convert offset to index to deal with tsi
 693   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize);
 694 
 695   intptr_t* LSP = (intptr_t*) sp()[Lentry_args->sp_offset_in_saved_window()];
 696   return &LSP[index+1];
 697 }
 698 
 699 
 700 BasicType frame::interpreter_frame_result(oop* oop_result, jvalue* value_result) {
 701   assert(is_interpreted_frame(), "interpreted frame expected");
 702   Method* method = interpreter_frame_method();
 703   BasicType type = method->result_type();
 704 
 705   if (method->is_native()) {
 706     // Prior to notifying the runtime of the method_exit the possible result
 707     // value is saved to l_scratch and d_scratch.
 708 





 709     intptr_t* l_scratch = fp() + interpreter_frame_l_scratch_fp_offset;
 710     intptr_t* d_scratch = fp() + interpreter_frame_d_scratch_fp_offset;

 711 
 712     address l_addr = (address)l_scratch;
 713 #ifdef _LP64
 714     // On 64-bit the result for 1/8/16/32-bit result types is in the other
 715     // word half
 716     l_addr += wordSize/2;
 717 #endif
 718 
 719     switch (type) {
 720       case T_OBJECT:
 721       case T_ARRAY: {



 722         oop obj = cast_to_oop(at(interpreter_frame_oop_temp_offset));
 723         assert(obj == NULL || Universe::heap()->is_in(obj), "sanity check");
 724         *oop_result = obj;

 725         break;
 726       }
 727 
 728       case T_BOOLEAN : { jint* p = (jint*)l_addr; value_result->z = (jboolean)((*p) & 0x1); break; }
 729       case T_BYTE    : { jint* p = (jint*)l_addr; value_result->b = (jbyte)((*p) & 0xff); break; }
 730       case T_CHAR    : { jint* p = (jint*)l_addr; value_result->c = (jchar)((*p) & 0xffff); break; }
 731       case T_SHORT   : { jint* p = (jint*)l_addr; value_result->s = (jshort)((*p) & 0xffff); break; }
 732       case T_INT     : value_result->i = *(jint*)l_addr; break;
 733       case T_LONG    : value_result->j = *(jlong*)l_scratch; break;
 734       case T_FLOAT   : value_result->f = *(jfloat*)d_scratch; break;
 735       case T_DOUBLE  : value_result->d = *(jdouble*)d_scratch; break;
 736       case T_VOID    : /* Nothing to do */ break;
 737       default        : ShouldNotReachHere();
 738     }
 739   } else {
 740     intptr_t* tos_addr = interpreter_frame_tos_address();
 741 
 742     switch(type) {
 743       case T_OBJECT:
 744       case T_ARRAY: {


 764 }
 765 
 766 // Lesp pointer is one word lower than the top item on the stack.
 767 intptr_t* frame::interpreter_frame_tos_at(jint offset) const {
 768   int index = (Interpreter::expr_offset_in_bytes(offset)/wordSize) - 1;
 769   return &interpreter_frame_tos_address()[index];
 770 }
 771 
 772 
 773 #ifndef PRODUCT
 774 
 775 #define DESCRIBE_FP_OFFSET(name) \
 776   values.describe(frame_no, fp() + frame::name##_offset, #name)
 777 
 778 void frame::describe_pd(FrameValues& values, int frame_no) {
 779   for (int w = 0; w < frame::register_save_words; w++) {
 780     values.describe(frame_no, sp() + w, err_msg("register save area word %d", w), 1);
 781   }
 782 
 783   if (is_interpreted_frame()) {

 784     DESCRIBE_FP_OFFSET(interpreter_frame_d_scratch_fp);
 785     DESCRIBE_FP_OFFSET(interpreter_frame_l_scratch_fp);
 786     DESCRIBE_FP_OFFSET(interpreter_frame_padding);
 787     DESCRIBE_FP_OFFSET(interpreter_frame_oop_temp);
 788 
 789     // esp, according to Lesp (e.g. not depending on bci), if seems valid
 790     intptr_t* esp = *interpreter_frame_esp_addr();
 791     if ((esp >= sp()) && (esp < fp())) {
 792       values.describe(-1, esp, "*Lesp");
 793     }

 794   }
 795 
 796   if (!is_compiled_frame()) {
 797     if (frame::callee_aggregate_return_pointer_words != 0) {
 798       values.describe(frame_no, sp() + frame::callee_aggregate_return_pointer_sp_offset, "callee_aggregate_return_pointer_word");
 799     }
 800     for (int w = 0; w < frame::callee_register_argument_save_area_words; w++) {
 801       values.describe(frame_no, sp() + frame::callee_register_argument_save_area_sp_offset + w,
 802                       err_msg("callee_register_argument_save_area_words %d", w));
 803     }
 804   }
 805 }
 806 
 807 #endif
 808 
 809 intptr_t *frame::initial_deoptimization_info() {
 810   // unused... but returns fp() to minimize changes introduced by 7087445
 811   return fp();
 812 }
src/cpu/sparc/vm/frame_sparc.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File