annotate src/share/vm/prims/jvmtiEnvBase.hpp @ 14653:0d8d78c0329a

6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync") Summary: It is more safe to get/update data for suspended threads at a safepoint Reviewed-by: dcubed, twisti, dholmes Contributed-by: serguei.spitsyn@oracle.com
author sspitsyn
date Sat, 01 Mar 2014 08:05:55 -0800
parents 402677ca28ed
children 92aa6797d639
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
14381
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1122
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1122
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1122
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_PRIMS_JVMTIENVBASE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_PRIMS_JVMTIENVBASE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/classLoader.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "prims/jvmtiEnvThreadState.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "prims/jvmtiEventController.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "prims/jvmtiThreadState.hpp"
14653
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
32 #include "prims/jvmtiThreadState.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/fieldDescriptor.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/frame.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "runtime/thread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #include "runtime/vm_operations.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #include "utilities/growableArray.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 6919
diff changeset
39 #include "utilities/macros.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 //
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // Forward Declarations
a61af66fc99e Initial load
duke
parents:
diff changeset
43 //
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class JvmtiEnv;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class JvmtiThreadState;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 class JvmtiRawMonitor; // for jvmtiEnv.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
48 class JvmtiEventControllerPrivate;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class JvmtiTagMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // One JvmtiEnv object is created per jvmti attachment;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // done via JNI GetEnv() call. Multiple attachments are
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // allowed in jvmti.
a61af66fc99e Initial load
duke
parents:
diff changeset
56
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3938
diff changeset
57 class JvmtiEnvBase : public CHeapObj<mtInternal> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
60
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
61 #if INCLUDE_JVMTI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 static JvmtiEnvBase* _head_environment; // head of environment list
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
63 #endif // INCLUDE_JVMTI
0
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 static bool _globally_initialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static jvmtiPhase _phase;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static volatile int _dying_thread_env_iteration_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 JDK15_JVMTI_VERSION = JVMTI_VERSION_1_0 + 33, /* version: 1.0.33 */
1988
684faacebf20 7003782: Update JVMTI version to 1.2 for jdk7
kamg
parents: 1972
diff changeset
73 JDK16_JVMTI_VERSION = JVMTI_VERSION_1_1 + 102, /* version: 1.1.102 */
6919
39556eae08af 6533010: SPEC: A few broken links in jvmti.html
sspitsyn
parents: 6854
diff changeset
74 JDK17_JVMTI_VERSION = JVMTI_VERSION_1_2 + 2 /* version: 1.2.2 */
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75 };
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 static jvmtiPhase get_phase() { return _phase; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 static void set_phase(jvmtiPhase phase) { _phase = phase; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static bool is_vm_live() { return _phase == JVMTI_PHASE_LIVE; }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 static void entering_dying_thread_env_iteration() { ++_dying_thread_env_iteration_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 static void leaving_dying_thread_env_iteration() { --_dying_thread_env_iteration_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static bool is_inside_dying_thread_env_iteration(){ return _dying_thread_env_iteration_count > 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 JVMTI_MAGIC = 0x71EE,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 DISPOSED_MAGIC = 0xDEFC,
a61af66fc99e Initial load
duke
parents:
diff changeset
90 BAD_MAGIC = 0xDEAD
a61af66fc99e Initial load
duke
parents:
diff changeset
91 };
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 jvmtiEnv _jvmti_external;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 jint _magic;
1121
98cd9901c161 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 0
diff changeset
95 jint _version; // version value passed to JNI GetEnv()
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96 JvmtiEnvBase* _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 bool _is_retransformable;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 const void *_env_local_storage; // per env agent allocated data.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 jvmtiEventCallbacks _event_callbacks;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 jvmtiExtEventCallbacks _ext_event_callbacks;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 JvmtiTagMap* _tag_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 JvmtiEnvEventEnable _env_event_enable;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 jvmtiCapabilities _current_capabilities;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 jvmtiCapabilities _prohibited_capabilities;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 volatile bool _class_file_load_hook_ever_enabled;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static volatile bool _needs_clean_up;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 char** _native_method_prefixes;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 int _native_method_prefix_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 protected:
1121
98cd9901c161 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 0
diff changeset
111 JvmtiEnvBase(jint version);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ~JvmtiEnvBase();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void dispose();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void env_dispose();
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void set_env_local_storage(const void* data) { _env_local_storage = data; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 const void* get_env_local_storage() { return _env_local_storage; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void record_class_file_load_hook_enabled();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void record_first_time_class_file_load_hook_enabled();
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 char** get_native_method_prefixes() { return _native_method_prefixes; }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int get_native_method_prefix_count() { return _native_method_prefix_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 jvmtiError set_native_method_prefixes(jint prefix_count, char** prefixes);
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 friend class JvmtiEventControllerPrivate;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void set_event_callbacks(const jvmtiEventCallbacks* callbacks, jint size_of_callbacks);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 static void globally_initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static void periodic_clean_up();
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 friend class JvmtiEnvIterator;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 JvmtiEnv* next_environment() { return (JvmtiEnv*)_next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void set_next_environment(JvmtiEnvBase* env) { _next = env; }
6854
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
136 static JvmtiEnv* head_environment() {
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
137 JVMTI_ONLY(return (JvmtiEnv*)_head_environment);
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
138 NOT_JVMTI(return NULL);
fb19af007ffc 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 6725
diff changeset
139 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
142
611
2f716c0acb64 6567360: 3/4 SIGBUS in jvmti RawMonitor magic check for unaligned bad monitor pointer
dcubed
parents: 0
diff changeset
143 bool is_valid();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144
1121
98cd9901c161 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 0
diff changeset
145 bool use_version_1_0_semantics(); // agent asked for version 1.0
98cd9901c161 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 0
diff changeset
146 bool use_version_1_1_semantics(); // agent asked for version 1.1
1988
684faacebf20 7003782: Update JVMTI version to 1.2 for jdk7
kamg
parents: 1972
diff changeset
147 bool use_version_1_2_semantics(); // agent asked for version 1.2
1121
98cd9901c161 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 0
diff changeset
148
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 bool is_retransformable() { return _is_retransformable; }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 static ByteSize jvmti_external_offset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return byte_offset_of(JvmtiEnvBase, _jvmti_external);
a61af66fc99e Initial load
duke
parents:
diff changeset
153 };
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 static JvmtiEnv* JvmtiEnv_from_jvmti_env(jvmtiEnv *env) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return (JvmtiEnv*)((intptr_t)env - in_bytes(jvmti_external_offset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
157 };
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 jvmtiCapabilities *get_capabilities() { return &_current_capabilities; }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 jvmtiCapabilities *get_prohibited_capabilities() { return &_prohibited_capabilities; }
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 static char** get_all_native_method_prefixes(int* count_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // This test will answer true when all environments have been disposed and some have
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // not yet been deallocated. As a result, this test should only be used as an
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // optimization for the no environment case.
a61af66fc99e Initial load
duke
parents:
diff changeset
168 static bool environments_might_exist() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return head_environment() != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 static void check_for_periodic_clean_up();
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 JvmtiEnvEventEnable *env_event_enable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 return &_env_event_enable;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 jvmtiError allocate(jlong size, unsigned char** mem_ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if (size < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (size == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 *mem_ptr = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 } else {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3938
diff changeset
185 *mem_ptr = (unsigned char *)os::malloc((size_t)size, mtInternal);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (*mem_ptr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 return JVMTI_ERROR_OUT_OF_MEMORY;
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 jvmtiError deallocate(unsigned char* mem) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 if (mem != NULL) {
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3938
diff changeset
195 os::free(mem, mtInternal);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Memory functions
a61af66fc99e Initial load
duke
parents:
diff changeset
202 unsigned char* jvmtiMalloc(jlong size); // don't use this - call allocate
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // method to create a local handle
a61af66fc99e Initial load
duke
parents:
diff changeset
205 jobject jni_reference(Handle hndl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return JNIHandles::make_local(hndl());
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // method to create a local handle.
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // This function allows caller to specify which
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // threads local handle table to use.
a61af66fc99e Initial load
duke
parents:
diff changeset
212 jobject jni_reference(JavaThread *thread, Handle hndl) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 return JNIHandles::make_local(thread, hndl());
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // method to destroy a local handle
a61af66fc99e Initial load
duke
parents:
diff changeset
217 void destroy_jni_reference(jobject jobj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 JNIHandles::destroy_local(jobj);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // method to destroy a local handle.
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // This function allows caller to specify which
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // threads local handle table to use although currently it is
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // not used.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void destroy_jni_reference(JavaThread *thread, jobject jobj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 destroy_jni_reference(jobj);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 jvmtiEnv* jvmti_external() { return &_jvmti_external; };
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Event Dispatch
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 bool has_callback(jvmtiEvent event_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 assert(event_type >= JVMTI_MIN_EVENT_TYPE_VAL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
235 event_type <= JVMTI_MAX_EVENT_TYPE_VAL, "checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
236 return ((void**)&_event_callbacks)[event_type-JVMTI_MIN_EVENT_TYPE_VAL] != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 jvmtiEventCallbacks* callbacks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return &_event_callbacks;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 jvmtiExtEventCallbacks* ext_callbacks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
244 return &_ext_event_callbacks;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void set_tag_map(JvmtiTagMap* tag_map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 _tag_map = tag_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 JvmtiTagMap* tag_map() {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return _tag_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // return true if event is enabled globally or for any thread
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // True only if there is a callback for it.
a61af66fc99e Initial load
duke
parents:
diff changeset
258 bool is_enabled(jvmtiEvent event_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return _env_event_enable.is_enabled(event_type);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Random Utilities
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // helper methods for creating arrays of global JNI Handles from local Handles
a61af66fc99e Initial load
duke
parents:
diff changeset
266 // allocated into environment specific storage
a61af66fc99e Initial load
duke
parents:
diff changeset
267 jobject * new_jobjectArray(int length, Handle *handles);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 jthread * new_jthreadArray(int length, Handle *handles);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 jthreadGroup * new_jthreadGroupArray(int length, Handle *handles);
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // convert from JNIHandle to JavaThread *
a61af66fc99e Initial load
duke
parents:
diff changeset
272 JavaThread * get_JavaThread(jthread jni_thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
273
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
274 // convert to a jni jclass from a non-null Klass*
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
275 jclass get_jni_class_non_null(Klass* k);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 jint count_locked_objects(JavaThread *java_thread, Handle hobj);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 jvmtiError get_locked_objects_in_frame(JavaThread *calling_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
279 JavaThread* java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
280 javaVFrame *jvf,
a61af66fc99e Initial load
duke
parents:
diff changeset
281 GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list,
a61af66fc99e Initial load
duke
parents:
diff changeset
282 jint depth);
a61af66fc99e Initial load
duke
parents:
diff changeset
283 vframe* vframeFor(JavaThread* java_thread, jint depth);
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // get a field descriptor for the specified class and field
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
287 static bool get_field_descriptor(Klass* k, jfieldID field, fieldDescriptor* fd);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // test for suspend - most (all?) of these should go away
a61af66fc99e Initial load
duke
parents:
diff changeset
289 static bool is_thread_fully_suspended(JavaThread *thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
290 bool wait_for_suspend,
a61af66fc99e Initial load
duke
parents:
diff changeset
291 uint32_t *bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // JVMTI API helper functions which are called at safepoint or thread is suspended.
a61af66fc99e Initial load
duke
parents:
diff changeset
295 jvmtiError get_frame_count(JvmtiThreadState *state, jint *count_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 jvmtiError get_frame_location(JavaThread* java_thread, jint depth,
a61af66fc99e Initial load
duke
parents:
diff changeset
297 jmethodID* method_ptr, jlocation* location_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
298 jvmtiError get_object_monitor_usage(JavaThread *calling_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
299 jobject object, jvmtiMonitorUsage* info_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 jvmtiError get_stack_trace(JavaThread *java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
301 jint stack_depth, jint max_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
302 jvmtiFrameInfo* frame_buffer, jint* count_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
303 jvmtiError get_current_contended_monitor(JavaThread *calling_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
304 JavaThread *java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
305 jobject *monitor_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 jvmtiError get_owned_monitors(JavaThread *calling_thread, JavaThread* java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
307 GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 jvmtiError check_top_frame(JavaThread* current_thread, JavaThread* java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
309 jvalue value, TosState tos, Handle* ret_ob_h);
a61af66fc99e Initial load
duke
parents:
diff changeset
310 jvmtiError force_early_return(JavaThread* java_thread, jvalue value, TosState tos);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 };
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // This class is the only safe means of iterating through environments.
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // Note that this iteratation includes invalid environments pending
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // deallocation -- in fact, some uses depend on this behavior.
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 class JvmtiEnvIterator : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
319 bool _entry_was_marked;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
321 JvmtiEnvIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if (Threads::number_of_threads() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 _entry_was_marked = false; // we are single-threaded, no need
a61af66fc99e Initial load
duke
parents:
diff changeset
324 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 Thread::current()->entering_jvmti_env_iteration();
a61af66fc99e Initial load
duke
parents:
diff changeset
326 _entry_was_marked = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 ~JvmtiEnvIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (_entry_was_marked) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 Thread::current()->leaving_jvmti_env_iteration();
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334 JvmtiEnv* first() { return JvmtiEnvBase::head_environment(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 JvmtiEnv* next(JvmtiEnvBase* env) { return env->next_environment(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 };
a61af66fc99e Initial load
duke
parents:
diff changeset
337
14653
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
338 // VM operation to update for pop top frame.
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
339 class VM_UpdateForPopTopFrame : public VM_Operation {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
340 private:
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
341 JvmtiThreadState* _state;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
342 jvmtiError _result;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
343
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
344 public:
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
345 VM_UpdateForPopTopFrame(JvmtiThreadState* state) {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
346 _state = state;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
347 _result = JVMTI_ERROR_NONE;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
348 }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
349 VMOp_Type type() const { return VMOp_UpdateForPopTopFrame; }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
350 jvmtiError result() { return _result; }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
351 void doit() {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
352 JavaThread* jt = _state->get_thread();
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
353 if (Threads::includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
354 _state->update_for_pop_top_frame();
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
355 } else {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
356 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
357 }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
358 }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
359 };
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
360
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
361 // VM operation to set frame pop.
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
362 class VM_SetFramePop : public VM_Operation {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
363 private:
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
364 JvmtiEnv *_env;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
365 JvmtiThreadState* _state;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
366 jint _depth;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
367 jvmtiError _result;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
368
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
369 public:
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
370 VM_SetFramePop(JvmtiEnv *env, JvmtiThreadState* state, jint depth) {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
371 _env = env;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
372 _state = state;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
373 _depth = depth;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
374 _result = JVMTI_ERROR_NONE;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
375 }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
376 // Nested operation must be allowed for the VM_EnterInterpOnlyMode that is
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
377 // called from the JvmtiEventControllerPrivate::recompute_thread_enabled.
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
378 bool allow_nested_vm_operations() const { return true; }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
379 VMOp_Type type() const { return VMOp_SetFramePop; }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
380 jvmtiError result() { return _result; }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
381 void doit() {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
382 JavaThread* jt = _state->get_thread();
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
383 if (Threads::includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
384 int frame_number = _state->count_frames() - _depth;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
385 _state->env_thread_state((JvmtiEnvBase*)_env)->set_frame_pop(frame_number);
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
386 } else {
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
387 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
388 }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
389 }
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
390 };
0d8d78c0329a 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 14381
diff changeset
391
0
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 // VM operation to get monitor information with stack depth.
a61af66fc99e Initial load
duke
parents:
diff changeset
394 class VM_GetOwnedMonitorInfo : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
396 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
397 JavaThread* _calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
398 JavaThread *_java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
399 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
400 GrowableArray<jvmtiMonitorStackDepthInfo*> *_owned_monitors_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
403 VM_GetOwnedMonitorInfo(JvmtiEnv* env, JavaThread* calling_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
404 JavaThread* java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
405 GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitor_list) {
a61af66fc99e Initial load
duke
parents:
diff changeset
406 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 _calling_thread = calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
408 _java_thread = java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
409 _owned_monitors_list = owned_monitor_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
410 _result = JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412 VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; }
a61af66fc99e Initial load
duke
parents:
diff changeset
413 void doit() {
14381
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
414 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
415 if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
416 && _java_thread->threadObj() != NULL) {
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
417 _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread,
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
418 _owned_monitors_list);
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
419 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
421 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
422 };
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 // VM operation to get object monitor usage.
a61af66fc99e Initial load
duke
parents:
diff changeset
426 class VM_GetObjectMonitorUsage : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
428 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 jobject _object;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 JavaThread* _calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
431 jvmtiMonitorUsage* _info_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
432 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
435 VM_GetObjectMonitorUsage(JvmtiEnv *env, JavaThread* calling_thread, jobject object, jvmtiMonitorUsage* info_ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
436 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
437 _object = object;
a61af66fc99e Initial load
duke
parents:
diff changeset
438 _calling_thread = calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
439 _info_ptr = info_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
441 VMOp_Type type() const { return VMOp_GetObjectMonitorUsage; }
a61af66fc99e Initial load
duke
parents:
diff changeset
442 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
443 void doit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
444 _result = ((JvmtiEnvBase*) _env)->get_object_monitor_usage(_calling_thread, _object, _info_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
445 }
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 };
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // VM operation to get current contended monitor.
a61af66fc99e Initial load
duke
parents:
diff changeset
450 class VM_GetCurrentContendedMonitor : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
451 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
452 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 JavaThread *_calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 JavaThread *_java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 jobject *_owned_monitor_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
456 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
459 VM_GetCurrentContendedMonitor(JvmtiEnv *env, JavaThread *calling_thread, JavaThread *java_thread, jobject *mon_ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
460 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
461 _calling_thread = calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
462 _java_thread = java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
463 _owned_monitor_ptr = mon_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
465 VMOp_Type type() const { return VMOp_GetCurrentContendedMonitor; }
a61af66fc99e Initial load
duke
parents:
diff changeset
466 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
467 void doit() {
12277
c1d7040a1183 8022836: JVM crashes in JVMTIENVBASE::GET_CURRENT_CONTENDED_MONITOR and GET_OWNED_MONITOR
sgabdura
parents: 8001
diff changeset
468 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
c1d7040a1183 8022836: JVM crashes in JVMTIENVBASE::GET_CURRENT_CONTENDED_MONITOR and GET_OWNED_MONITOR
sgabdura
parents: 8001
diff changeset
469 if (Threads::includes(_java_thread) && !_java_thread->is_exiting() &&
c1d7040a1183 8022836: JVM crashes in JVMTIENVBASE::GET_CURRENT_CONTENDED_MONITOR and GET_OWNED_MONITOR
sgabdura
parents: 8001
diff changeset
470 _java_thread->threadObj() != NULL) {
c1d7040a1183 8022836: JVM crashes in JVMTIENVBASE::GET_CURRENT_CONTENDED_MONITOR and GET_OWNED_MONITOR
sgabdura
parents: 8001
diff changeset
471 _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,_java_thread,_owned_monitor_ptr);
c1d7040a1183 8022836: JVM crashes in JVMTIENVBASE::GET_CURRENT_CONTENDED_MONITOR and GET_OWNED_MONITOR
sgabdura
parents: 8001
diff changeset
472 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
473 }
a61af66fc99e Initial load
duke
parents:
diff changeset
474 };
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // VM operation to get stack trace at safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
477 class VM_GetStackTrace : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
479 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
480 JavaThread *_java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
481 jint _start_depth;
a61af66fc99e Initial load
duke
parents:
diff changeset
482 jint _max_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
483 jvmtiFrameInfo *_frame_buffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
484 jint *_count_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
485 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
488 VM_GetStackTrace(JvmtiEnv *env, JavaThread *java_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
489 jint start_depth, jint max_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
490 jvmtiFrameInfo* frame_buffer, jint* count_ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
492 _java_thread = java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
493 _start_depth = start_depth;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 _max_count = max_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
495 _frame_buffer = frame_buffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
496 _count_ptr = count_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 VMOp_Type type() const { return VMOp_GetStackTrace; }
a61af66fc99e Initial load
duke
parents:
diff changeset
500 void doit() {
14381
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
501 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
502 if (Threads::includes(_java_thread) && !_java_thread->is_exiting()
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
503 && _java_thread->threadObj() != NULL) {
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
504 _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread,
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
505 _start_depth, _max_count,
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
506 _frame_buffer, _count_ptr);
402677ca28ed 8034249: need more workarounds for suspend equivalent condition issue
sspitsyn
parents: 14321
diff changeset
507 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
509 };
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // forward declaration
a61af66fc99e Initial load
duke
parents:
diff changeset
512 struct StackInfoNode;
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // VM operation to get stack trace at safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
515 class VM_GetMultipleStackTraces : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
516 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
517 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
518 jint _max_frame_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
519 jvmtiStackInfo *_stack_info;
a61af66fc99e Initial load
duke
parents:
diff changeset
520 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
521 int _frame_count_total;
a61af66fc99e Initial load
duke
parents:
diff changeset
522 struct StackInfoNode *_head;
a61af66fc99e Initial load
duke
parents:
diff changeset
523
a61af66fc99e Initial load
duke
parents:
diff changeset
524 JvmtiEnvBase *env() { return (JvmtiEnvBase *)_env; }
a61af66fc99e Initial load
duke
parents:
diff changeset
525 jint max_frame_count() { return _max_frame_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
526 struct StackInfoNode *head() { return _head; }
a61af66fc99e Initial load
duke
parents:
diff changeset
527 void set_head(StackInfoNode *head) { _head = head; }
a61af66fc99e Initial load
duke
parents:
diff changeset
528
a61af66fc99e Initial load
duke
parents:
diff changeset
529 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
530 void set_result(jvmtiError result) { _result = result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
531 void fill_frames(jthread jt, JavaThread *thr, oop thread_oop);
a61af66fc99e Initial load
duke
parents:
diff changeset
532 void allocate_and_fill_stacks(jint thread_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
533
a61af66fc99e Initial load
duke
parents:
diff changeset
534 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
535 VM_GetMultipleStackTraces(JvmtiEnv *env, jint max_frame_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
536 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
537 _max_frame_count = max_frame_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
538 _frame_count_total = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
539 _head = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 _result = JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
541 }
a61af66fc99e Initial load
duke
parents:
diff changeset
542 VMOp_Type type() const { return VMOp_GetMultipleStackTraces; }
a61af66fc99e Initial load
duke
parents:
diff changeset
543 jvmtiStackInfo *stack_info() { return _stack_info; }
a61af66fc99e Initial load
duke
parents:
diff changeset
544 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 };
a61af66fc99e Initial load
duke
parents:
diff changeset
546
a61af66fc99e Initial load
duke
parents:
diff changeset
547
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // VM operation to get stack trace at safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
549 class VM_GetAllStackTraces : public VM_GetMultipleStackTraces {
a61af66fc99e Initial load
duke
parents:
diff changeset
550 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
551 JavaThread *_calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
552 jint _final_thread_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
555 VM_GetAllStackTraces(JvmtiEnv *env, JavaThread *calling_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
556 jint max_frame_count)
a61af66fc99e Initial load
duke
parents:
diff changeset
557 : VM_GetMultipleStackTraces(env, max_frame_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
558 _calling_thread = calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
559 }
a61af66fc99e Initial load
duke
parents:
diff changeset
560 VMOp_Type type() const { return VMOp_GetAllStackTraces; }
a61af66fc99e Initial load
duke
parents:
diff changeset
561 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
562 jint final_thread_count() { return _final_thread_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
563 };
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 // VM operation to get stack trace at safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
566 class VM_GetThreadListStackTraces : public VM_GetMultipleStackTraces {
a61af66fc99e Initial load
duke
parents:
diff changeset
567 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
568 jint _thread_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
569 const jthread* _thread_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
572 VM_GetThreadListStackTraces(JvmtiEnv *env, jint thread_count, const jthread* thread_list, jint max_frame_count)
a61af66fc99e Initial load
duke
parents:
diff changeset
573 : VM_GetMultipleStackTraces(env, max_frame_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
574 _thread_count = thread_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
575 _thread_list = thread_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
577 VMOp_Type type() const { return VMOp_GetThreadListStackTraces; }
a61af66fc99e Initial load
duke
parents:
diff changeset
578 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
579 };
a61af66fc99e Initial load
duke
parents:
diff changeset
580
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 // VM operation to count stack frames at safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
583 class VM_GetFrameCount : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
584 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
585 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
586 JvmtiThreadState *_state;
a61af66fc99e Initial load
duke
parents:
diff changeset
587 jint *_count_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
588 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
589
a61af66fc99e Initial load
duke
parents:
diff changeset
590 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
591 VM_GetFrameCount(JvmtiEnv *env, JvmtiThreadState *state, jint *count_ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
592 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
593 _state = state;
a61af66fc99e Initial load
duke
parents:
diff changeset
594 _count_ptr = count_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
596 VMOp_Type type() const { return VMOp_GetFrameCount; }
a61af66fc99e Initial load
duke
parents:
diff changeset
597 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
598 void doit() {
14321
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
599 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
600 JavaThread* jt = _state->get_thread();
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
601 if (Threads::includes(jt) && !jt->is_exiting() && jt->threadObj() != NULL) {
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
602 _result = ((JvmtiEnvBase*)_env)->get_frame_count(_state, _count_ptr);
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
603 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
604 }
a61af66fc99e Initial load
duke
parents:
diff changeset
605 };
a61af66fc99e Initial load
duke
parents:
diff changeset
606
a61af66fc99e Initial load
duke
parents:
diff changeset
607 // VM operation to frame location at safepoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
608 class VM_GetFrameLocation : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
609 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
610 JvmtiEnv *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
611 JavaThread* _java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 jint _depth;
a61af66fc99e Initial load
duke
parents:
diff changeset
613 jmethodID* _method_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
614 jlocation* _location_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
615 jvmtiError _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
616
a61af66fc99e Initial load
duke
parents:
diff changeset
617 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
618 VM_GetFrameLocation(JvmtiEnv *env, JavaThread* java_thread, jint depth,
a61af66fc99e Initial load
duke
parents:
diff changeset
619 jmethodID* method_ptr, jlocation* location_ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
620 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
621 _java_thread = java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
622 _depth = depth;
a61af66fc99e Initial load
duke
parents:
diff changeset
623 _method_ptr = method_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
624 _location_ptr = location_ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626 VMOp_Type type() const { return VMOp_GetFrameLocation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
627 jvmtiError result() { return _result; }
a61af66fc99e Initial load
duke
parents:
diff changeset
628 void doit() {
14321
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
629 _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
630 if (Threads::includes(_java_thread) && !_java_thread->is_exiting() &&
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
631 _java_thread->threadObj() != NULL) {
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
632 _result = ((JvmtiEnvBase*)_env)->get_frame_location(_java_thread, _depth,
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
633 _method_ptr, _location_ptr);
e4062d6c5f22 8032223: nsk/regression/b4663146 gets assert(SafepointSynchronize::is_at_safepoint() || JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits))
sspitsyn
parents: 14223
diff changeset
634 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
635 }
a61af66fc99e Initial load
duke
parents:
diff changeset
636 };
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // ResourceTracker
a61af66fc99e Initial load
duke
parents:
diff changeset
640 //
a61af66fc99e Initial load
duke
parents:
diff changeset
641 // ResourceTracker works a little like a ResourceMark. All allocates
a61af66fc99e Initial load
duke
parents:
diff changeset
642 // using the resource tracker are recorded. If an allocate using the
a61af66fc99e Initial load
duke
parents:
diff changeset
643 // resource tracker fails the destructor will free any resources
a61af66fc99e Initial load
duke
parents:
diff changeset
644 // that were allocated using the tracker.
a61af66fc99e Initial load
duke
parents:
diff changeset
645 // The motive for this class is to avoid messy error recovery code
a61af66fc99e Initial load
duke
parents:
diff changeset
646 // in situations where multiple allocations are done in sequence. If
a61af66fc99e Initial load
duke
parents:
diff changeset
647 // the second or subsequent allocation fails it avoids any code to
a61af66fc99e Initial load
duke
parents:
diff changeset
648 // release memory allocated in the previous calls.
a61af66fc99e Initial load
duke
parents:
diff changeset
649 //
a61af66fc99e Initial load
duke
parents:
diff changeset
650 // Usage :-
a61af66fc99e Initial load
duke
parents:
diff changeset
651 // ResourceTracker rt(env);
a61af66fc99e Initial load
duke
parents:
diff changeset
652 // :
a61af66fc99e Initial load
duke
parents:
diff changeset
653 // err = rt.allocate(1024, &ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
654
a61af66fc99e Initial load
duke
parents:
diff changeset
655 class ResourceTracker : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
657 JvmtiEnv* _env;
a61af66fc99e Initial load
duke
parents:
diff changeset
658 GrowableArray<unsigned char*> *_allocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
659 bool _failed;
a61af66fc99e Initial load
duke
parents:
diff changeset
660 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
661 ResourceTracker(JvmtiEnv* env);
a61af66fc99e Initial load
duke
parents:
diff changeset
662 ~ResourceTracker();
a61af66fc99e Initial load
duke
parents:
diff changeset
663 jvmtiError allocate(jlong size, unsigned char** mem_ptr);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 unsigned char* allocate(jlong size);
a61af66fc99e Initial load
duke
parents:
diff changeset
665 char* strdup(const char* str);
a61af66fc99e Initial load
duke
parents:
diff changeset
666 };
a61af66fc99e Initial load
duke
parents:
diff changeset
667
a61af66fc99e Initial load
duke
parents:
diff changeset
668
a61af66fc99e Initial load
duke
parents:
diff changeset
669 // Jvmti monitor closure to collect off stack monitors.
a61af66fc99e Initial load
duke
parents:
diff changeset
670 class JvmtiMonitorClosure: public MonitorClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
671 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
672 JavaThread *_java_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
673 JavaThread *_calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
674 GrowableArray<jvmtiMonitorStackDepthInfo*> *_owned_monitors_list;
a61af66fc99e Initial load
duke
parents:
diff changeset
675 jvmtiError _error;
a61af66fc99e Initial load
duke
parents:
diff changeset
676 JvmtiEnvBase *_env;
a61af66fc99e Initial load
duke
parents:
diff changeset
677
a61af66fc99e Initial load
duke
parents:
diff changeset
678 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
679 JvmtiMonitorClosure(JavaThread* thread, JavaThread *calling_thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
680 GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors,
a61af66fc99e Initial load
duke
parents:
diff changeset
681 JvmtiEnvBase *env) {
a61af66fc99e Initial load
duke
parents:
diff changeset
682 _java_thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
683 _calling_thread = calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 _owned_monitors_list = owned_monitors;
a61af66fc99e Initial load
duke
parents:
diff changeset
685 _error = JVMTI_ERROR_NONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
686 _env = env;
a61af66fc99e Initial load
duke
parents:
diff changeset
687 }
a61af66fc99e Initial load
duke
parents:
diff changeset
688 void do_monitor(ObjectMonitor* mon);
a61af66fc99e Initial load
duke
parents:
diff changeset
689 jvmtiError error() { return _error;}
a61af66fc99e Initial load
duke
parents:
diff changeset
690 };
a61af66fc99e Initial load
duke
parents:
diff changeset
691
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
692 #endif // SHARE_VM_PRIMS_JVMTIENVBASE_HPP