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