1 /* |
1 /* |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
997 |
997 |
998 // growable array of jvmti monitors info on the C-heap |
998 // growable array of jvmti monitors info on the C-heap |
999 GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = |
999 GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = |
1000 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); |
1000 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); |
1001 |
1001 |
1002 uint32_t debug_bits = 0; |
1002 // It is only safe to perform the direct operation on the current |
1003 if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { |
1003 // thread. All other usage needs to use a vm-safepoint-op for safety. |
|
1004 if (java_thread == calling_thread) { |
1004 err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); |
1005 err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); |
1005 } else { |
1006 } else { |
1006 // JVMTI get monitors info at safepoint. Do not require target thread to |
1007 // JVMTI get monitors info at safepoint. Do not require target thread to |
1007 // be suspended. |
1008 // be suspended. |
1008 VM_GetOwnedMonitorInfo op(this, calling_thread, java_thread, owned_monitors_list); |
1009 VM_GetOwnedMonitorInfo op(this, calling_thread, java_thread, owned_monitors_list); |
1042 |
1043 |
1043 // growable array of jvmti monitors info on the C-heap |
1044 // growable array of jvmti monitors info on the C-heap |
1044 GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = |
1045 GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list = |
1045 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); |
1046 new (ResourceObj::C_HEAP, mtInternal) GrowableArray<jvmtiMonitorStackDepthInfo*>(1, true); |
1046 |
1047 |
1047 uint32_t debug_bits = 0; |
1048 // It is only safe to perform the direct operation on the current |
1048 if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { |
1049 // thread. All other usage needs to use a vm-safepoint-op for safety. |
|
1050 if (java_thread == calling_thread) { |
1049 err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); |
1051 err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); |
1050 } else { |
1052 } else { |
1051 // JVMTI get owned monitors info at safepoint. Do not require target thread to |
1053 // JVMTI get owned monitors info at safepoint. Do not require target thread to |
1052 // be suspended. |
1054 // be suspended. |
1053 VM_GetOwnedMonitorInfo op(this, calling_thread, java_thread, owned_monitors_list); |
1055 VM_GetOwnedMonitorInfo op(this, calling_thread, java_thread, owned_monitors_list); |
1084 // java_thread - pre-checked |
1086 // java_thread - pre-checked |
1085 // monitor_ptr - pre-checked for NULL |
1087 // monitor_ptr - pre-checked for NULL |
1086 jvmtiError |
1088 jvmtiError |
1087 JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) { |
1089 JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) { |
1088 jvmtiError err = JVMTI_ERROR_NONE; |
1090 jvmtiError err = JVMTI_ERROR_NONE; |
1089 uint32_t debug_bits = 0; |
|
1090 JavaThread* calling_thread = JavaThread::current(); |
1091 JavaThread* calling_thread = JavaThread::current(); |
1091 if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { |
1092 |
|
1093 // It is only safe to perform the direct operation on the current |
|
1094 // thread. All other usage needs to use a vm-safepoint-op for safety. |
|
1095 if (java_thread == calling_thread) { |
1092 err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr); |
1096 err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr); |
1093 } else { |
1097 } else { |
1094 // get contended monitor information at safepoint. |
1098 // get contended monitor information at safepoint. |
1095 VM_GetCurrentContendedMonitor op(this, calling_thread, java_thread, monitor_ptr); |
1099 VM_GetCurrentContendedMonitor op(this, calling_thread, java_thread, monitor_ptr); |
1096 VMThread::execute(&op); |
1100 VMThread::execute(&op); |
1295 // frame_buffer - pre-checked for NULL |
1299 // frame_buffer - pre-checked for NULL |
1296 // count_ptr - pre-checked for NULL |
1300 // count_ptr - pre-checked for NULL |
1297 jvmtiError |
1301 jvmtiError |
1298 JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { |
1302 JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { |
1299 jvmtiError err = JVMTI_ERROR_NONE; |
1303 jvmtiError err = JVMTI_ERROR_NONE; |
1300 uint32_t debug_bits = 0; |
1304 |
1301 if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { |
1305 // It is only safe to perform the direct operation on the current |
|
1306 // thread. All other usage needs to use a vm-safepoint-op for safety. |
|
1307 if (java_thread == JavaThread::current()) { |
1302 err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); |
1308 err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); |
1303 } else { |
1309 } else { |
1304 // JVMTI get stack trace at safepoint. Do not require target thread to |
1310 // JVMTI get stack trace at safepoint. Do not require target thread to |
1305 // be suspended. |
1311 // be suspended. |
1306 VM_GetStackTrace op(this, java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); |
1312 VM_GetStackTrace op(this, java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); |