提交 353a41de 编写于 作者: N never

7150390: JFR test crashed on assert(_jni_lock_count == count) failed: must be equal

Reviewed-by: dholmes, minqi, kvn, coleenp
上级 9e433d39
...@@ -219,6 +219,8 @@ void SafepointSynchronize::begin() { ...@@ -219,6 +219,8 @@ void SafepointSynchronize::begin() {
#ifdef ASSERT #ifdef ASSERT
for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) { for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
assert(cur->safepoint_state()->is_running(), "Illegal initial state"); assert(cur->safepoint_state()->is_running(), "Illegal initial state");
// Clear the visited flag to ensure that the critical counts are collected properly.
cur->set_visited_for_critical_count(false);
} }
#endif // ASSERT #endif // ASSERT
...@@ -378,6 +380,13 @@ void SafepointSynchronize::begin() { ...@@ -378,6 +380,13 @@ void SafepointSynchronize::begin() {
OrderAccess::fence(); OrderAccess::fence();
#ifdef ASSERT
for (JavaThread *cur = Threads::first(); cur != NULL; cur = cur->next()) {
// make sure all the threads were visited
assert(cur->was_visited_for_critical_count(), "missed a thread");
}
#endif // ASSERT
// Update the count of active JNI critical regions // Update the count of active JNI critical regions
GC_locker::set_jni_lock_count(_current_jni_active_count); GC_locker::set_jni_lock_count(_current_jni_active_count);
...@@ -626,6 +635,7 @@ void SafepointSynchronize::block(JavaThread *thread) { ...@@ -626,6 +635,7 @@ void SafepointSynchronize::block(JavaThread *thread) {
_waiting_to_block--; _waiting_to_block--;
thread->safepoint_state()->set_has_called_back(true); thread->safepoint_state()->set_has_called_back(true);
DEBUG_ONLY(thread->set_visited_for_critical_count(true));
if (thread->in_critical()) { if (thread->in_critical()) {
// Notice that this thread is in a critical section // Notice that this thread is in a critical section
increment_jni_active_count(); increment_jni_active_count();
...@@ -907,12 +917,8 @@ void ThreadSafepointState::examine_state_of_thread() { ...@@ -907,12 +917,8 @@ void ThreadSafepointState::examine_state_of_thread() {
// running, but are actually at a safepoint. We will happily // running, but are actually at a safepoint. We will happily
// agree and update the safepoint state here. // agree and update the safepoint state here.
if (SafepointSynchronize::safepoint_safe(_thread, state)) { if (SafepointSynchronize::safepoint_safe(_thread, state)) {
roll_forward(_at_safepoint);
SafepointSynchronize::check_for_lazy_critical_native(_thread, state); SafepointSynchronize::check_for_lazy_critical_native(_thread, state);
if (_thread->in_critical()) { roll_forward(_at_safepoint);
// Notice that this thread is in a critical section
SafepointSynchronize::increment_jni_active_count();
}
return; return;
} }
...@@ -937,6 +943,11 @@ void ThreadSafepointState::roll_forward(suspend_type type) { ...@@ -937,6 +943,11 @@ void ThreadSafepointState::roll_forward(suspend_type type) {
switch(_type) { switch(_type) {
case _at_safepoint: case _at_safepoint:
SafepointSynchronize::signal_thread_at_safepoint(); SafepointSynchronize::signal_thread_at_safepoint();
DEBUG_ONLY(_thread->set_visited_for_critical_count(true));
if (_thread->in_critical()) {
// Notice that this thread is in a critical section
SafepointSynchronize::increment_jni_active_count();
}
break; break;
case _call_back: case _call_back:
......
...@@ -247,6 +247,10 @@ Thread::Thread() { ...@@ -247,6 +247,10 @@ Thread::Thread() {
omInUseList = NULL ; omInUseList = NULL ;
omInUseCount = 0 ; omInUseCount = 0 ;
#ifdef ASSERT
_visited_for_critical_count = false;
#endif
_SR_lock = new Monitor(Mutex::suspend_resume, "SR_lock", true); _SR_lock = new Monitor(Mutex::suspend_resume, "SR_lock", true);
_suspend_flags = 0; _suspend_flags = 0;
......
...@@ -268,6 +268,15 @@ class Thread: public ThreadShadow { ...@@ -268,6 +268,15 @@ class Thread: public ThreadShadow {
ObjectMonitor* omInUseList; // SLL to track monitors in circulation ObjectMonitor* omInUseList; // SLL to track monitors in circulation
int omInUseCount; // length of omInUseList int omInUseCount; // length of omInUseList
#ifdef ASSERT
private:
bool _visited_for_critical_count;
public:
void set_visited_for_critical_count(bool z) { _visited_for_critical_count = z; }
bool was_visited_for_critical_count() const { return _visited_for_critical_count; }
#endif
public: public:
enum { enum {
is_definitely_current_thread = true is_definitely_current_thread = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册