equal
deleted
inserted
replaced
29 |
29 |
30 volatile jint GC_locker::_jni_lock_count = 0; |
30 volatile jint GC_locker::_jni_lock_count = 0; |
31 volatile jint GC_locker::_lock_count = 0; |
31 volatile jint GC_locker::_lock_count = 0; |
32 volatile bool GC_locker::_needs_gc = false; |
32 volatile bool GC_locker::_needs_gc = false; |
33 volatile bool GC_locker::_doing_gc = false; |
33 volatile bool GC_locker::_doing_gc = false; |
34 jlong GC_locker::_wait_begin = 0; |
|
35 |
34 |
36 #ifdef ASSERT |
35 #ifdef ASSERT |
37 volatile jint GC_locker::_debug_jni_lock_count = 0; |
36 volatile jint GC_locker::_debug_jni_lock_count = 0; |
38 #endif |
37 #endif |
39 |
38 |
67 if (is_active() && !_needs_gc) { |
66 if (is_active() && !_needs_gc) { |
68 verify_critical_count(); |
67 verify_critical_count(); |
69 _needs_gc = true; |
68 _needs_gc = true; |
70 if (PrintJNIGCStalls && PrintGCDetails) { |
69 if (PrintJNIGCStalls && PrintGCDetails) { |
71 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
70 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
72 _wait_begin = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; |
71 gclog_or_tty->print_cr("%.3f: Setting _needs_gc. Thread \"%s\" %d locked.", |
73 gclog_or_tty->print_cr(INT64_FORMAT ": Setting _needs_gc. Thread \"%s\" %d locked.", |
72 gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); |
74 _wait_begin, Thread::current()->name(), _jni_lock_count); |
|
75 } |
73 } |
76 |
74 |
77 } |
75 } |
78 return is_active(); |
76 return is_active(); |
79 } |
77 } |
83 MutexLocker ml(JNICritical_lock); |
81 MutexLocker ml(JNICritical_lock); |
84 |
82 |
85 if (needs_gc()) { |
83 if (needs_gc()) { |
86 if (PrintJNIGCStalls && PrintGCDetails) { |
84 if (PrintJNIGCStalls && PrintGCDetails) { |
87 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
85 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
88 gclog_or_tty->print_cr(INT64_FORMAT ": Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.", |
86 gclog_or_tty->print_cr("%.3f: Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.", |
89 (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count); |
87 gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); |
90 } |
88 } |
91 } |
89 } |
92 |
90 |
93 // Wait for _needs_gc to be cleared |
91 // Wait for _needs_gc to be cleared |
94 while (needs_gc()) { |
92 while (needs_gc()) { |
129 { |
127 { |
130 // Must give up the lock while at a safepoint |
128 // Must give up the lock while at a safepoint |
131 MutexUnlocker munlock(JNICritical_lock); |
129 MutexUnlocker munlock(JNICritical_lock); |
132 if (PrintJNIGCStalls && PrintGCDetails) { |
130 if (PrintJNIGCStalls && PrintGCDetails) { |
133 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
131 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
134 gclog_or_tty->print_cr(INT64_FORMAT ": Thread \"%s\" is performing GC after exiting critical section, %d locked", |
132 gclog_or_tty->print_cr("%.3f: Thread \"%s\" is performing GC after exiting critical section, %d locked", |
135 (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count); |
133 gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); |
136 } |
134 } |
137 Universe::heap()->collect(GCCause::_gc_locker); |
135 Universe::heap()->collect(GCCause::_gc_locker); |
138 } |
136 } |
139 _doing_gc = false; |
137 _doing_gc = false; |
140 } |
138 } |