264 // Blocking or yielding incur their own penalties in the form of context switching |
264 // Blocking or yielding incur their own penalties in the form of context switching |
265 // and the resultant loss of $ residency. |
265 // and the resultant loss of $ residency. |
266 // |
266 // |
267 // Further complicating matters is that yield() does not work as naively expected |
267 // Further complicating matters is that yield() does not work as naively expected |
268 // on many platforms -- yield() does not guarantee that any other ready threads |
268 // on many platforms -- yield() does not guarantee that any other ready threads |
269 // will run. As such we revert yield_all() after some number of iterations. |
269 // will run. As such we revert to naked_short_sleep() after some number of iterations. |
270 // Yield_all() is implemented as a short unconditional sleep on some platforms. |
270 // nakes_short_sleep() is implemented as a short unconditional sleep. |
271 // Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping |
271 // Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping |
272 // can actually increase the time it takes the VM thread to detect that a system-wide |
272 // can actually increase the time it takes the VM thread to detect that a system-wide |
273 // stop-the-world safepoint has been reached. In a pathological scenario such as that |
273 // stop-the-world safepoint has been reached. In a pathological scenario such as that |
274 // described in CR6415670 the VMthread may sleep just before the mutator(s) become safe. |
274 // described in CR6415670 the VMthread may sleep just before the mutator(s) become safe. |
275 // In that case the mutators will be stalled waiting for the safepoint to complete and the |
275 // In that case the mutators will be stalled waiting for the safepoint to complete and the |
744 } |
742 } |
745 |
743 |
746 // ------------------------------------------------------------------------------------------------------ |
744 // ------------------------------------------------------------------------------------------------------ |
747 // Exception handlers |
745 // Exception handlers |
748 |
746 |
749 #ifndef PRODUCT |
|
750 |
|
751 #ifdef SPARC |
|
752 |
|
753 #ifdef _LP64 |
|
754 #define PTR_PAD "" |
|
755 #else |
|
756 #define PTR_PAD " " |
|
757 #endif |
|
758 |
|
759 static void print_ptrs(intptr_t oldptr, intptr_t newptr, bool wasoop) { |
|
760 bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false; |
|
761 tty->print_cr(PTR_FORMAT PTR_PAD " %s %c " PTR_FORMAT PTR_PAD " %s %s", |
|
762 oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!', |
|
763 newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" ")); |
|
764 } |
|
765 |
|
766 static void print_longs(jlong oldptr, jlong newptr, bool wasoop) { |
|
767 bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false; |
|
768 tty->print_cr(PTR64_FORMAT " %s %c " PTR64_FORMAT " %s %s", |
|
769 oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!', |
|
770 newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" ")); |
|
771 } |
|
772 |
|
773 static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) { |
|
774 #ifdef _LP64 |
|
775 tty->print_cr("--------+------address-----+------before-----------+-------after----------+"); |
|
776 const int incr = 1; // Increment to skip a long, in units of intptr_t |
|
777 #else |
|
778 tty->print_cr("--------+--address-+------before-----------+-------after----------+"); |
|
779 const int incr = 2; // Increment to skip a long, in units of intptr_t |
|
780 #endif |
|
781 tty->print_cr("---SP---|"); |
|
782 for( int i=0; i<16; i++ ) { |
|
783 tty->print("blob %c%d |"PTR_FORMAT" ","LO"[i>>3],i&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); } |
|
784 tty->print_cr("--------|"); |
|
785 for( int i1=0; i1<frame::memory_parameter_word_sp_offset-16; i1++ ) { |
|
786 tty->print("argv pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); } |
|
787 tty->print(" pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); |
|
788 tty->print_cr("--------|"); |
|
789 tty->print(" G1 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; |
|
790 tty->print(" G3 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; |
|
791 tty->print(" G4 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; |
|
792 tty->print(" G5 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; |
|
793 tty->print_cr(" FSR |"PTR_FORMAT" "PTR64_FORMAT" "PTR64_FORMAT,new_sp,*(jlong*)old_sp,*(jlong*)new_sp); |
|
794 old_sp += incr; new_sp += incr; was_oops += incr; |
|
795 // Skip the floats |
|
796 tty->print_cr("--Float-|"PTR_FORMAT,new_sp); |
|
797 tty->print_cr("---FP---|"); |
|
798 old_sp += incr*32; new_sp += incr*32; was_oops += incr*32; |
|
799 for( int i2=0; i2<16; i2++ ) { |
|
800 tty->print("call %c%d |"PTR_FORMAT" ","LI"[i2>>3],i2&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); } |
|
801 tty->cr(); |
|
802 } |
|
803 #endif // SPARC |
|
804 #endif // PRODUCT |
|
805 |
|
806 |
747 |
807 void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) { |
748 void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) { |
808 assert(thread->is_Java_thread(), "polling reference encountered by VM thread"); |
749 assert(thread->is_Java_thread(), "polling reference encountered by VM thread"); |
809 assert(thread->thread_state() == _thread_in_Java, "should come from Java code"); |
750 assert(thread->thread_state() == _thread_in_Java, "should come from Java code"); |
810 assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization"); |
751 assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization"); |
811 |
752 |
812 // Uncomment this to get some serious before/after printing of the |
|
813 // Sparc safepoint-blob frame structure. |
|
814 /* |
|
815 intptr_t* sp = thread->last_Java_sp(); |
|
816 intptr_t stack_copy[150]; |
|
817 for( int i=0; i<150; i++ ) stack_copy[i] = sp[i]; |
|
818 bool was_oops[150]; |
|
819 for( int i=0; i<150; i++ ) |
|
820 was_oops[i] = stack_copy[i] ? ((oop)stack_copy[i])->is_oop() : false; |
|
821 */ |
|
822 |
|
823 if (ShowSafepointMsgs) { |
753 if (ShowSafepointMsgs) { |
824 tty->print("handle_polling_page_exception: "); |
754 tty->print("handle_polling_page_exception: "); |
825 } |
755 } |
826 |
756 |
827 if (PrintSafepointStatistics) { |
757 if (PrintSafepointStatistics) { |