comparison src/share/vm/runtime/safepoint.cpp @ 4873:0382d2b469b2

7013347: allow crypto functions to be called inline to enhance performance Reviewed-by: kvn
author never
date Wed, 01 Feb 2012 16:57:08 -0800
parents 1a2723f7ad8e
children 0ebca2e35ca5 541c4a5e7b88
comparison
equal deleted inserted replaced
4872:aa3d708d67c4 4873:0382d2b469b2
134 tty->print_cr("Safepoint synchronization initiated. (%d)", nof_threads); 134 tty->print_cr("Safepoint synchronization initiated. (%d)", nof_threads);
135 } 135 }
136 136
137 RuntimeService::record_safepoint_begin(); 137 RuntimeService::record_safepoint_begin();
138 138
139 {
140 MutexLocker mu(Safepoint_lock); 139 MutexLocker mu(Safepoint_lock);
141 140
142 // Reset the count of active JNI critical threads 141 // Reset the count of active JNI critical threads
143 _current_jni_active_count = 0; 142 _current_jni_active_count = 0;
144 143
397 396
398 if (PrintSafepointStatistics) { 397 if (PrintSafepointStatistics) {
399 // Record how much time spend on the above cleanup tasks 398 // Record how much time spend on the above cleanup tasks
400 update_statistics_on_cleanup_end(os::javaTimeNanos()); 399 update_statistics_on_cleanup_end(os::javaTimeNanos());
401 } 400 }
402 }
403 } 401 }
404 402
405 // Wake up all threads, so they are ready to resume execution after the safepoint 403 // Wake up all threads, so they are ready to resume execution after the safepoint
406 // operation has been carried out 404 // operation has been carried out
407 void SafepointSynchronize::end() { 405 void SafepointSynchronize::end() {
542 540
543 default: 541 default:
544 return false; 542 return false;
545 } 543 }
546 } 544 }
545
546
547 // See if the thread is running inside a lazy critical native and
548 // update the thread critical count if so. Also set a suspend flag to
549 // cause the native wrapper to return into the JVM to do the unlock
550 // once the native finishes.
551 void SafepointSynchronize::check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state) {
552 if (state == _thread_in_native &&
553 thread->has_last_Java_frame() &&
554 thread->frame_anchor()->walkable()) {
555 // This thread might be in a critical native nmethod so look at
556 // the top of the stack and increment the critical count if it
557 // is.
558 frame wrapper_frame = thread->last_frame();
559 CodeBlob* stub_cb = wrapper_frame.cb();
560 if (stub_cb != NULL &&
561 stub_cb->is_nmethod() &&
562 stub_cb->as_nmethod_or_null()->is_lazy_critical_native()) {
563 // A thread could potentially be in a critical native across
564 // more than one safepoint, so only update the critical state on
565 // the first one. When it returns it will perform the unlock.
566 if (!thread->do_critical_native_unlock()) {
567 #ifdef ASSERT
568 if (!thread->in_critical()) {
569 GC_locker::increment_debug_jni_lock_count();
570 }
571 #endif
572 thread->enter_critical();
573 // Make sure the native wrapper calls back on return to
574 // perform the needed critical unlock.
575 thread->set_critical_native_unlock();
576 }
577 }
578 }
579 }
580
547 581
548 582
549 // ------------------------------------------------------------------------------------------------------- 583 // -------------------------------------------------------------------------------------------------------
550 // Implementation of Safepoint callback point 584 // Implementation of Safepoint callback point
551 585
872 // Some JavaThread states have an initial safepoint state of 906 // Some JavaThread states have an initial safepoint state of
873 // running, but are actually at a safepoint. We will happily 907 // running, but are actually at a safepoint. We will happily
874 // agree and update the safepoint state here. 908 // agree and update the safepoint state here.
875 if (SafepointSynchronize::safepoint_safe(_thread, state)) { 909 if (SafepointSynchronize::safepoint_safe(_thread, state)) {
876 roll_forward(_at_safepoint); 910 roll_forward(_at_safepoint);
911 SafepointSynchronize::check_for_lazy_critical_native(_thread, state);
877 if (_thread->in_critical()) { 912 if (_thread->in_critical()) {
878 // Notice that this thread is in a critical section 913 // Notice that this thread is in a critical section
879 SafepointSynchronize::increment_jni_active_count(); 914 SafepointSynchronize::increment_jni_active_count();
880 } 915 }
881 return; 916 return;