提交 b496a7ef 编写于 作者: S sspitsyn

8034249: need more workarounds for suspend equivalent condition issue

Summary: Collect data at safepoint, do not rely on thread suspension
Reviewed-by: dcubed, dholmes
上级 2bd585df
/* /*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1000,8 +1000,9 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count ...@@ -1000,8 +1000,9 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count
GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true);
uint32_t debug_bits = 0; // It is only safe to perform the direct operation on the current
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { // thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == calling_thread) {
err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list);
} else { } else {
// JVMTI get monitors info at safepoint. Do not require target thread to // JVMTI get monitors info at safepoint. Do not require target thread to
...@@ -1045,8 +1046,9 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i ...@@ -1045,8 +1046,9 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i
GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list =
new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true);
uint32_t debug_bits = 0; // It is only safe to perform the direct operation on the current
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { // thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == calling_thread) {
err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list);
} else { } else {
// JVMTI get owned monitors info at safepoint. Do not require target thread to // JVMTI get owned monitors info at safepoint. Do not require target thread to
...@@ -1087,9 +1089,11 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i ...@@ -1087,9 +1089,11 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i
jvmtiError jvmtiError
JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) { JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) {
jvmtiError err = JVMTI_ERROR_NONE; jvmtiError err = JVMTI_ERROR_NONE;
uint32_t debug_bits = 0;
JavaThread* calling_thread = JavaThread::current(); JavaThread* calling_thread = JavaThread::current();
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) {
// It is only safe to perform the direct operation on the current
// thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == calling_thread) {
err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr); err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr);
} else { } else {
// get contended monitor information at safepoint. // get contended monitor information at safepoint.
...@@ -1298,8 +1302,10 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth ...@@ -1298,8 +1302,10 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth
jvmtiError jvmtiError
JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) {
jvmtiError err = JVMTI_ERROR_NONE; jvmtiError err = JVMTI_ERROR_NONE;
uint32_t debug_bits = 0;
if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { // It is only safe to perform the direct operation on the current
// thread. All other usage needs to use a vm-safepoint-op for safety.
if (java_thread == JavaThread::current()) {
err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr);
} else { } else {
// JVMTI get stack trace at safepoint. Do not require target thread to // JVMTI get stack trace at safepoint. Do not require target thread to
......
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -356,8 +356,12 @@ public: ...@@ -356,8 +356,12 @@ public:
} }
VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; } VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; }
void doit() { void doit() {
((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread, _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
_owned_monitors_list); if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
&& _java_thread->threadObj() != NULL) {
_result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
_owned_monitors_list);
}
} }
jvmtiError result() { return _result; } jvmtiError result() { return _result; }
}; };
...@@ -439,9 +443,13 @@ public: ...@@ -439,9 +443,13 @@ public:
jvmtiError result() { return _result; } jvmtiError result() { return _result; }
VMOp_Type type() const { return VMOp_GetStackTrace; } VMOp_Type type() const { return VMOp_GetStackTrace; }
void doit() { void doit() {
_result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread, _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
_start_depth, _max_count, if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
_frame_buffer, _count_ptr); && _java_thread->threadObj() != NULL) {
_result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
_start_depth, _max_count,
_frame_buffer, _count_ptr);
}
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册