67 if (is_active() && !_needs_gc) { |
67 if (is_active() && !_needs_gc) { |
68 verify_critical_count(); |
68 verify_critical_count(); |
69 _needs_gc = true; |
69 _needs_gc = true; |
70 if (PrintJNIGCStalls && PrintGCDetails) { |
70 if (PrintJNIGCStalls && PrintGCDetails) { |
71 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
71 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
72 _wait_begin = tty->time_stamp().milliseconds(); |
72 _wait_begin = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; |
73 gclog_or_tty->print_cr(INT64_FORMAT ": Setting _needs_gc. Thread \"%s\" %d locked.", |
73 gclog_or_tty->print_cr(INT64_FORMAT ": Setting _needs_gc. Thread \"%s\" %d locked.", |
74 _wait_begin, Thread::current()->name(), _jni_lock_count); |
74 _wait_begin, Thread::current()->name(), _jni_lock_count); |
75 } |
75 } |
76 |
76 |
77 } |
77 } |
84 |
84 |
85 if (needs_gc()) { |
85 if (needs_gc()) { |
86 if (PrintJNIGCStalls && PrintGCDetails) { |
86 if (PrintJNIGCStalls && PrintGCDetails) { |
87 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
87 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.", |
88 gclog_or_tty->print_cr(INT64_FORMAT ": Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.", |
89 tty->time_stamp().milliseconds() - _wait_begin, Thread::current()->name(), _jni_lock_count); |
89 (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count); |
90 } |
90 } |
91 } |
91 } |
92 |
92 |
93 // Wait for _needs_gc to be cleared |
93 // Wait for _needs_gc to be cleared |
94 while (needs_gc()) { |
94 while (needs_gc()) { |
130 // Must give up the lock while at a safepoint |
130 // Must give up the lock while at a safepoint |
131 MutexUnlocker munlock(JNICritical_lock); |
131 MutexUnlocker munlock(JNICritical_lock); |
132 if (PrintJNIGCStalls && PrintGCDetails) { |
132 if (PrintJNIGCStalls && PrintGCDetails) { |
133 ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
133 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", |
134 gclog_or_tty->print_cr(INT64_FORMAT ": Thread \"%s\" is performing GC after exiting critical section, %d locked", |
135 tty->time_stamp().milliseconds() - _wait_begin, Thread::current()->name(), _jni_lock_count); |
135 (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count); |
136 } |
136 } |
137 Universe::heap()->collect(GCCause::_gc_locker); |
137 Universe::heap()->collect(GCCause::_gc_locker); |
138 } |
138 } |
139 _doing_gc = false; |
139 _doing_gc = false; |
140 } |
140 } |