Mercurial > hg > graal-jvmci-8
annotate src/share/vm/prims/jvmtiExport.hpp @ 2125:7246a374a9f2
6458402: 3 jvmti tests fail with CMS and +ExplicitGCInvokesConcurrent
Summary: Make JvmtiGCMark safe to run non-safepoint and instrument CMS
Reviewed-by: ysr, dcubed
author | kamg |
---|---|
date | Mon, 10 Jan 2011 17:14:53 -0500 |
parents | c760f78e0a53 |
children | 9afee0b9fc1d |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
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:
1397
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_PRIMS_JVMTIEXPORT_HPP |
26 #define SHARE_VM_PRIMS_JVMTIEXPORT_HPP | |
27 | |
28 #include "jvmtifiles/jvmti.h" | |
29 #include "memory/allocation.hpp" | |
30 #include "memory/iterator.hpp" | |
31 #include "oops/oop.hpp" | |
32 #include "oops/oopsHierarchy.hpp" | |
33 #include "runtime/frame.hpp" | |
34 #include "runtime/handles.hpp" | |
35 #include "utilities/globalDefinitions.hpp" | |
36 #include "utilities/growableArray.hpp" | |
0 | 37 |
1983
c760f78e0a53
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
1972
diff
changeset
|
38 // Must be included after jvmti.h. |
c760f78e0a53
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
1972
diff
changeset
|
39 #include "code/jvmticmlr.h" |
c760f78e0a53
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
1972
diff
changeset
|
40 |
0 | 41 // Forward declarations |
42 | |
43 class JvmtiEventControllerPrivate; | |
44 class JvmtiManageCapabilities; | |
45 class JvmtiEnv; | |
46 class JvmtiThreadState; | |
47 class AttachOperation; | |
48 | |
49 #ifndef JVMTI_KERNEL | |
50 #define JVMTI_SUPPORT_FLAG(key) \ | |
51 private: \ | |
52 static bool _##key; \ | |
53 public: \ | |
54 inline static void set_##key(bool on) { _##key = (on != 0); } \ | |
55 inline static bool key() { return _##key; } | |
56 #else // JVMTI_KERNEL | |
57 #define JVMTI_SUPPORT_FLAG(key) \ | |
58 private: \ | |
59 const static bool _##key = false; \ | |
60 public: \ | |
61 inline static void set_##key(bool on) { report_unsupported(on); } \ | |
62 inline static bool key() { return _##key; } | |
63 #endif // JVMTI_KERNEL | |
64 | |
65 | |
66 // This class contains the JVMTI interface for the rest of hotspot. | |
67 // | |
68 class JvmtiExport : public AllStatic { | |
69 private: | |
70 static int _field_access_count; | |
71 static int _field_modification_count; | |
72 | |
73 static bool _can_access_local_variables; | |
74 static bool _can_hotswap_or_post_breakpoint; | |
75 static bool _can_modify_any_class; | |
76 static bool _can_walk_any_space; | |
77 | |
78 JVMTI_SUPPORT_FLAG(can_get_source_debug_extension) | |
79 JVMTI_SUPPORT_FLAG(can_maintain_original_method_order) | |
80 JVMTI_SUPPORT_FLAG(can_post_interpreter_events) | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1121
diff
changeset
|
81 JVMTI_SUPPORT_FLAG(can_post_on_exceptions) |
0 | 82 JVMTI_SUPPORT_FLAG(can_post_breakpoint) |
83 JVMTI_SUPPORT_FLAG(can_post_field_access) | |
84 JVMTI_SUPPORT_FLAG(can_post_field_modification) | |
85 JVMTI_SUPPORT_FLAG(can_post_method_entry) | |
86 JVMTI_SUPPORT_FLAG(can_post_method_exit) | |
87 JVMTI_SUPPORT_FLAG(can_pop_frame) | |
88 JVMTI_SUPPORT_FLAG(can_force_early_return) | |
89 | |
90 friend class JvmtiEventControllerPrivate; // should only modify these flags | |
91 JVMTI_SUPPORT_FLAG(should_post_single_step) | |
92 JVMTI_SUPPORT_FLAG(should_post_field_access) | |
93 JVMTI_SUPPORT_FLAG(should_post_field_modification) | |
94 JVMTI_SUPPORT_FLAG(should_post_class_load) | |
95 JVMTI_SUPPORT_FLAG(should_post_class_prepare) | |
96 JVMTI_SUPPORT_FLAG(should_post_class_unload) | |
97 JVMTI_SUPPORT_FLAG(should_post_native_method_bind) | |
98 JVMTI_SUPPORT_FLAG(should_post_compiled_method_load) | |
99 JVMTI_SUPPORT_FLAG(should_post_compiled_method_unload) | |
100 JVMTI_SUPPORT_FLAG(should_post_dynamic_code_generated) | |
101 JVMTI_SUPPORT_FLAG(should_post_monitor_contended_enter) | |
102 JVMTI_SUPPORT_FLAG(should_post_monitor_contended_entered) | |
103 JVMTI_SUPPORT_FLAG(should_post_monitor_wait) | |
104 JVMTI_SUPPORT_FLAG(should_post_monitor_waited) | |
105 JVMTI_SUPPORT_FLAG(should_post_data_dump) | |
106 JVMTI_SUPPORT_FLAG(should_post_garbage_collection_start) | |
107 JVMTI_SUPPORT_FLAG(should_post_garbage_collection_finish) | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1121
diff
changeset
|
108 JVMTI_SUPPORT_FLAG(should_post_on_exceptions) |
0 | 109 |
110 // ------ the below maybe don't have to be (but are for now) | |
111 // fixed conditions here ------------ | |
112 // any events can be enabled | |
113 JVMTI_SUPPORT_FLAG(should_post_thread_life) | |
114 JVMTI_SUPPORT_FLAG(should_post_object_free) | |
115 JVMTI_SUPPORT_FLAG(should_post_resource_exhausted) | |
116 | |
117 // we are holding objects on the heap - need to talk to GC - e.g. | |
118 // breakpoint info | |
119 JVMTI_SUPPORT_FLAG(should_clean_up_heap_objects) | |
120 JVMTI_SUPPORT_FLAG(should_post_vm_object_alloc) | |
121 | |
122 // If flag cannot be implemented, give an error if on=true | |
123 static void report_unsupported(bool on); | |
124 | |
125 // these should only be called by the friend class | |
126 friend class JvmtiManageCapabilities; | |
127 inline static void set_can_modify_any_class(bool on) { _can_modify_any_class = (on != 0); } | |
128 inline static void set_can_access_local_variables(bool on) { _can_access_local_variables = (on != 0); } | |
129 inline static void set_can_hotswap_or_post_breakpoint(bool on) { _can_hotswap_or_post_breakpoint = (on != 0); } | |
130 inline static void set_can_walk_any_space(bool on) { _can_walk_any_space = (on != 0); } | |
131 | |
132 enum { | |
133 JVMTI_VERSION_MASK = 0x70000000, | |
134 JVMTI_VERSION_VALUE = 0x30000000, | |
135 JVMDI_VERSION_VALUE = 0x20000000 | |
136 }; | |
137 | |
138 static void post_field_modification(JavaThread *thread, methodOop method, address location, | |
139 KlassHandle field_klass, Handle object, jfieldID field, | |
140 char sig_type, jvalue *value); | |
141 | |
142 | |
143 private: | |
144 // CompiledMethodUnload events are reported from the VM thread so they | |
145 // are collected in lists (of jmethodID/addresses) and the events are posted later | |
146 // from threads posting CompieldMethodLoad or DynamicCodeGenerated events. | |
147 static bool _have_pending_compiled_method_unload_events; | |
148 static GrowableArray<jmethodID>* _pending_compiled_method_unload_method_ids; | |
149 static GrowableArray<const void *>* _pending_compiled_method_unload_code_begins; | |
150 static JavaThread* _current_poster; | |
151 | |
152 // tests if there are CompiledMethodUnload events pending | |
153 inline static bool have_pending_compiled_method_unload_events() { | |
154 return _have_pending_compiled_method_unload_events; | |
155 } | |
156 | |
157 // posts any pending CompiledMethodUnload events. | |
158 static void post_pending_compiled_method_unload_events(); | |
159 | |
1577
852d0157c696
6956931: assert(SafepointSynchronize::is_at_safepoint()) failed: must be executed at a safepoint
never
parents:
1397
diff
changeset
|
160 // Perform the actual notification to interested JvmtiEnvs. |
852d0157c696
6956931: assert(SafepointSynchronize::is_at_safepoint()) failed: must be executed at a safepoint
never
parents:
1397
diff
changeset
|
161 static void post_compiled_method_unload_internal(JavaThread* self, jmethodID mid, const void* code_begin); |
852d0157c696
6956931: assert(SafepointSynchronize::is_at_safepoint()) failed: must be executed at a safepoint
never
parents:
1397
diff
changeset
|
162 |
0 | 163 // posts a DynamicCodeGenerated event (internal/private implementation). |
164 // The public post_dynamic_code_generated* functions make use of the | |
165 // internal implementation. | |
166 static void post_dynamic_code_generated_internal(const char *name, const void *code_begin, const void *code_end) KERNEL_RETURN; | |
167 | |
168 | |
169 // GenerateEvents support to allow posting of CompiledMethodLoad and | |
170 // DynamicCodeGenerated events for a given environment. | |
171 friend class JvmtiCodeBlobEvents; | |
172 | |
173 static void post_compiled_method_load(JvmtiEnv* env, const jmethodID method, const jint length, | |
174 const void *code_begin, const jint map_length, | |
175 const jvmtiAddrLocationMap* map) KERNEL_RETURN; | |
176 static void post_dynamic_code_generated(JvmtiEnv* env, const char *name, const void *code_begin, | |
177 const void *code_end) KERNEL_RETURN; | |
178 | |
179 // The RedefineClasses() API breaks some invariants in the "regular" | |
180 // system. For example, there are sanity checks when GC'ing nmethods | |
181 // that require the containing class to be unloading. However, when a | |
182 // method is redefined, the old method and nmethod can become GC'able | |
183 // without the containing class unloading. The state of becoming | |
184 // GC'able can be asynchronous to the RedefineClasses() call since | |
185 // the old method may still be running and cannot be GC'ed until | |
186 // after all old invocations have finished. Additionally, a method | |
187 // that has not been redefined may have an nmethod that depends on | |
188 // the redefined method. The dependent nmethod will get deopted in | |
189 // this case and may also be GC'able without the containing class | |
190 // being unloaded. | |
191 // | |
192 // This flag indicates whether RedefineClasses() has ever redefined | |
193 // one or more classes during the lifetime of the VM. The flag should | |
194 // only be set by the friend class and can be queried by other sub | |
195 // systems as needed to relax invariant checks. | |
196 static bool _has_redefined_a_class; | |
197 friend class VM_RedefineClasses; | |
198 inline static void set_has_redefined_a_class() { | |
199 _has_redefined_a_class = true; | |
200 } | |
201 | |
202 // Flag to indicate if the compiler has recorded all dependencies. When the | |
203 // can_redefine_classes capability is enabled in the OnLoad phase then the compiler | |
204 // records all dependencies from startup. However if the capability is first | |
205 // enabled some time later then the dependencies recorded by the compiler | |
206 // are incomplete. This flag is used by RedefineClasses to know if the | |
207 // dependency information is complete or not. | |
208 static bool _all_dependencies_are_recorded; | |
209 | |
210 public: | |
211 inline static bool has_redefined_a_class() { | |
212 return _has_redefined_a_class; | |
213 } | |
214 | |
215 inline static bool all_dependencies_are_recorded() { | |
216 return _all_dependencies_are_recorded; | |
217 } | |
218 | |
219 inline static void set_all_dependencies_are_recorded(bool on) { | |
220 _all_dependencies_are_recorded = (on != 0); | |
221 } | |
222 | |
223 | |
224 // let JVMTI know that the JVM_OnLoad code is running | |
225 static void enter_onload_phase(); | |
226 | |
227 // let JVMTI know that the VM isn't up yet (and JVM_OnLoad code isn't running) | |
228 static void enter_primordial_phase(); | |
229 | |
230 // let JVMTI know that the VM isn't up yet but JNI is live | |
231 static void enter_start_phase(); | |
232 | |
233 // let JVMTI know that the VM is fully up and running now | |
234 static void enter_live_phase(); | |
235 | |
236 // ------ can_* conditions (below) are set at OnLoad and never changed ------------ | |
237 inline static bool can_modify_any_class() { return _can_modify_any_class; } | |
238 inline static bool can_access_local_variables() { return _can_access_local_variables; } | |
239 inline static bool can_hotswap_or_post_breakpoint() { return _can_hotswap_or_post_breakpoint; } | |
240 inline static bool can_walk_any_space() { return _can_walk_any_space; } | |
241 | |
242 // field access management | |
243 static address get_field_access_count_addr(); | |
244 | |
245 // field modification management | |
246 static address get_field_modification_count_addr(); | |
247 | |
248 // ----------------- | |
249 | |
250 static bool is_jvmti_version(jint version) { return (version & JVMTI_VERSION_MASK) == JVMTI_VERSION_VALUE; } | |
251 static bool is_jvmdi_version(jint version) { return (version & JVMTI_VERSION_MASK) == JVMDI_VERSION_VALUE; } | |
252 static jint get_jvmti_interface(JavaVM *jvm, void **penv, jint version); | |
1121 | 253 static void decode_version_values(jint version, int * major, int * minor, |
254 int * micro); | |
0 | 255 |
256 // single stepping management methods | |
257 static void at_single_stepping_point(JavaThread *thread, methodOop method, address location) KERNEL_RETURN; | |
258 static void expose_single_stepping(JavaThread *thread) KERNEL_RETURN; | |
259 static bool hide_single_stepping(JavaThread *thread) KERNEL_RETURN_(return false;); | |
260 | |
261 // Methods that notify the debugger that something interesting has happened in the VM. | |
262 static void post_vm_start (); | |
263 static void post_vm_initialized (); | |
264 static void post_vm_death (); | |
265 | |
266 static void post_single_step (JavaThread *thread, methodOop method, address location) KERNEL_RETURN; | |
267 static void post_raw_breakpoint (JavaThread *thread, methodOop method, address location) KERNEL_RETURN; | |
268 | |
269 static void post_exception_throw (JavaThread *thread, methodOop method, address location, oop exception) KERNEL_RETURN; | |
270 static void notice_unwind_due_to_exception (JavaThread *thread, methodOop method, address location, oop exception, bool in_handler_frame) KERNEL_RETURN; | |
271 | |
272 static oop jni_GetField_probe (JavaThread *thread, jobject jobj, | |
273 oop obj, klassOop klass, jfieldID fieldID, bool is_static) | |
274 KERNEL_RETURN_(return NULL;); | |
275 static oop jni_GetField_probe_nh (JavaThread *thread, jobject jobj, | |
276 oop obj, klassOop klass, jfieldID fieldID, bool is_static) | |
277 KERNEL_RETURN_(return NULL;); | |
278 static void post_field_access_by_jni (JavaThread *thread, oop obj, | |
279 klassOop klass, jfieldID fieldID, bool is_static) KERNEL_RETURN; | |
280 static void post_field_access (JavaThread *thread, methodOop method, | |
281 address location, KlassHandle field_klass, Handle object, jfieldID field) KERNEL_RETURN; | |
282 static oop jni_SetField_probe (JavaThread *thread, jobject jobj, | |
283 oop obj, klassOop klass, jfieldID fieldID, bool is_static, char sig_type, | |
284 jvalue *value) KERNEL_RETURN_(return NULL;); | |
285 static oop jni_SetField_probe_nh (JavaThread *thread, jobject jobj, | |
286 oop obj, klassOop klass, jfieldID fieldID, bool is_static, char sig_type, | |
287 jvalue *value) KERNEL_RETURN_(return NULL;); | |
288 static void post_field_modification_by_jni(JavaThread *thread, oop obj, | |
289 klassOop klass, jfieldID fieldID, bool is_static, char sig_type, | |
290 jvalue *value); | |
291 static void post_raw_field_modification(JavaThread *thread, methodOop method, | |
292 address location, KlassHandle field_klass, Handle object, jfieldID field, | |
293 char sig_type, jvalue *value) KERNEL_RETURN; | |
294 | |
295 static void post_method_entry (JavaThread *thread, methodOop method, frame current_frame) KERNEL_RETURN; | |
296 static void post_method_exit (JavaThread *thread, methodOop method, frame current_frame) KERNEL_RETURN; | |
297 | |
298 static void post_class_load (JavaThread *thread, klassOop klass) KERNEL_RETURN; | |
299 static void post_class_unload (klassOop klass) KERNEL_RETURN; | |
300 static void post_class_prepare (JavaThread *thread, klassOop klass) KERNEL_RETURN; | |
301 | |
302 static void post_thread_start (JavaThread *thread) KERNEL_RETURN; | |
303 static void post_thread_end (JavaThread *thread) KERNEL_RETURN; | |
304 | |
305 // Support for java.lang.instrument agent loading. | |
306 static bool _should_post_class_file_load_hook; | |
307 inline static void set_should_post_class_file_load_hook(bool on) { _should_post_class_file_load_hook = on; } | |
308 inline static bool should_post_class_file_load_hook() { return _should_post_class_file_load_hook; } | |
309 static void post_class_file_load_hook(symbolHandle h_name, Handle class_loader, | |
310 Handle h_protection_domain, | |
311 unsigned char **data_ptr, unsigned char **end_ptr, | |
312 unsigned char **cached_data_ptr, | |
313 jint *cached_length_ptr); | |
314 static void post_native_method_bind(methodOop method, address* function_ptr) KERNEL_RETURN; | |
315 static void post_compiled_method_load(nmethod *nm) KERNEL_RETURN; | |
316 static void post_dynamic_code_generated(const char *name, const void *code_begin, const void *code_end) KERNEL_RETURN; | |
317 | |
1577
852d0157c696
6956931: assert(SafepointSynchronize::is_at_safepoint()) failed: must be executed at a safepoint
never
parents:
1397
diff
changeset
|
318 // used to post a CompiledMethodUnload event |
852d0157c696
6956931: assert(SafepointSynchronize::is_at_safepoint()) failed: must be executed at a safepoint
never
parents:
1397
diff
changeset
|
319 static void post_compiled_method_unload(jmethodID mid, const void *code_begin) KERNEL_RETURN; |
0 | 320 |
321 // similiar to post_dynamic_code_generated except that it can be used to | |
322 // post a DynamicCodeGenerated event while holding locks in the VM. Any event | |
323 // posted using this function is recorded by the enclosing event collector | |
324 // -- JvmtiDynamicCodeEventCollector. | |
325 static void post_dynamic_code_generated_while_holding_locks(const char* name, address code_begin, address code_end) KERNEL_RETURN; | |
326 | |
327 static void post_garbage_collection_finish() KERNEL_RETURN; | |
328 static void post_garbage_collection_start() KERNEL_RETURN; | |
329 static void post_data_dump() KERNEL_RETURN; | |
330 static void post_monitor_contended_enter(JavaThread *thread, ObjectMonitor *obj_mntr) KERNEL_RETURN; | |
331 static void post_monitor_contended_entered(JavaThread *thread, ObjectMonitor *obj_mntr) KERNEL_RETURN; | |
332 static void post_monitor_wait(JavaThread *thread, oop obj, jlong timeout) KERNEL_RETURN; | |
333 static void post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mntr, jboolean timed_out) KERNEL_RETURN; | |
334 static void post_object_free(JvmtiEnv* env, jlong tag) KERNEL_RETURN; | |
335 static void post_resource_exhausted(jint resource_exhausted_flags, const char* detail) KERNEL_RETURN; | |
336 static void record_vm_internal_object_allocation(oop object) KERNEL_RETURN; | |
337 // Post objects collected by vm_object_alloc_event_collector. | |
338 static void post_vm_object_alloc(JavaThread *thread, oop object) KERNEL_RETURN; | |
339 // Collects vm internal objects for later event posting. | |
340 inline static void vm_object_alloc_event_collector(oop object) { | |
341 if (should_post_vm_object_alloc()) { | |
342 record_vm_internal_object_allocation(object); | |
343 } | |
344 } | |
345 | |
346 static void cleanup_thread (JavaThread* thread) KERNEL_RETURN; | |
347 | |
348 static void oops_do(OopClosure* f) KERNEL_RETURN; | |
349 | |
350 static void transition_pending_onload_raw_monitors() KERNEL_RETURN; | |
351 | |
352 #ifndef SERVICES_KERNEL | |
353 // attach support | |
354 static jint load_agent_library(AttachOperation* op, outputStream* out); | |
355 #endif // SERVICES_KERNEL | |
356 | |
357 // SetNativeMethodPrefix support | |
358 static char** get_all_native_method_prefixes(int* count_ptr); | |
359 }; | |
360 | |
361 // Support class used by JvmtiDynamicCodeEventCollector and others. It | |
362 // describes a single code blob by name and address range. | |
363 class JvmtiCodeBlobDesc : public CHeapObj { | |
364 private: | |
365 char _name[64]; | |
366 address _code_begin; | |
367 address _code_end; | |
368 | |
369 public: | |
370 JvmtiCodeBlobDesc(const char *name, address code_begin, address code_end) { | |
371 assert(name != NULL, "all code blobs must be named"); | |
372 strncpy(_name, name, sizeof(_name)); | |
373 _name[sizeof(_name)-1] = '\0'; | |
374 _code_begin = code_begin; | |
375 _code_end = code_end; | |
376 } | |
377 char* name() { return _name; } | |
378 address code_begin() { return _code_begin; } | |
379 address code_end() { return _code_end; } | |
380 }; | |
381 | |
382 // JvmtiEventCollector is a helper class to setup thread for | |
383 // event collection. | |
384 class JvmtiEventCollector : public StackObj { | |
385 private: | |
386 JvmtiEventCollector* _prev; // Save previous one to support nested event collector. | |
387 | |
388 public: | |
389 void setup_jvmti_thread_state(); // Set this collector in current thread. | |
390 void unset_jvmti_thread_state(); // Reset previous collector in current thread. | |
391 virtual bool is_dynamic_code_event() { return false; } | |
392 virtual bool is_vm_object_alloc_event(){ return false; } | |
393 JvmtiEventCollector *get_prev() { return _prev; } | |
394 }; | |
395 | |
396 // A JvmtiDynamicCodeEventCollector is a helper class for the JvmtiExport | |
397 // interface. It collects "dynamic code generated" events that are posted | |
398 // while holding locks. When the event collector goes out of scope the | |
399 // events will be posted. | |
400 // | |
401 // Usage :- | |
402 // | |
403 // { | |
404 // JvmtiDynamicCodeEventCollector event_collector; | |
405 // : | |
406 // { MutexLocker ml(...) | |
407 // : | |
408 // JvmtiExport::post_dynamic_code_generated_while_holding_locks(...) | |
409 // } | |
410 // // event collector goes out of scope => post events to profiler. | |
411 // } | |
412 | |
413 class JvmtiDynamicCodeEventCollector : public JvmtiEventCollector { | |
414 private: | |
415 GrowableArray<JvmtiCodeBlobDesc*>* _code_blobs; // collected code blob events | |
416 | |
417 friend class JvmtiExport; | |
418 void register_stub(const char* name, address start, address end); | |
419 | |
420 public: | |
421 JvmtiDynamicCodeEventCollector() KERNEL_RETURN; | |
422 ~JvmtiDynamicCodeEventCollector() KERNEL_RETURN; | |
423 bool is_dynamic_code_event() { return true; } | |
424 | |
425 }; | |
426 | |
427 // Used to record vm internally allocated object oops and post | |
428 // vm object alloc event for objects visible to java world. | |
429 // Constructor enables JvmtiThreadState flag and all vm allocated | |
430 // objects are recorded in a growable array. When destructor is | |
431 // called the vm object alloc event is posted for each objects | |
432 // visible to java world. | |
433 // See jvm.cpp file for its usage. | |
434 // | |
435 class JvmtiVMObjectAllocEventCollector : public JvmtiEventCollector { | |
436 private: | |
437 GrowableArray<oop>* _allocated; // field to record vm internally allocated object oop. | |
438 bool _enable; // This flag is enabled in constructor and disabled | |
439 // in destructor before posting event. To avoid | |
440 // collection of objects allocated while running java code inside | |
441 // agent post_vm_object_alloc() event handler. | |
442 | |
443 //GC support | |
444 void oops_do(OopClosure* f); | |
445 | |
446 friend class JvmtiExport; | |
447 // Record vm allocated object oop. | |
448 inline void record_allocation(oop obj); | |
449 | |
450 //GC support | |
451 static void oops_do_for_all_threads(OopClosure* f); | |
452 | |
453 public: | |
454 JvmtiVMObjectAllocEventCollector() KERNEL_RETURN; | |
455 ~JvmtiVMObjectAllocEventCollector() KERNEL_RETURN; | |
456 bool is_vm_object_alloc_event() { return true; } | |
457 | |
458 bool is_enabled() { return _enable; } | |
459 void set_enabled(bool on) { _enable = on; } | |
460 }; | |
461 | |
462 | |
463 | |
464 // Marker class to disable the posting of VMObjectAlloc events | |
465 // within its scope. | |
466 // | |
467 // Usage :- | |
468 // | |
469 // { | |
470 // NoJvmtiVMObjectAllocMark njm; | |
471 // : | |
472 // // VMObjAlloc event will not be posted | |
473 // JvmtiExport::vm_object_alloc_event_collector(obj); | |
474 // : | |
475 // } | |
476 | |
477 class NoJvmtiVMObjectAllocMark : public StackObj { | |
478 private: | |
479 // enclosing collector if enabled, NULL otherwise | |
480 JvmtiVMObjectAllocEventCollector *_collector; | |
481 | |
482 bool was_enabled() { return _collector != NULL; } | |
483 | |
484 public: | |
485 NoJvmtiVMObjectAllocMark() KERNEL_RETURN; | |
486 ~NoJvmtiVMObjectAllocMark() KERNEL_RETURN; | |
487 }; | |
488 | |
489 | |
490 // Base class for reporting GC events to JVMTI. | |
491 class JvmtiGCMarker : public StackObj { | |
2125
7246a374a9f2
6458402: 3 jvmti tests fail with CMS and +ExplicitGCInvokesConcurrent
kamg
parents:
1983
diff
changeset
|
492 public: |
7246a374a9f2
6458402: 3 jvmti tests fail with CMS and +ExplicitGCInvokesConcurrent
kamg
parents:
1983
diff
changeset
|
493 JvmtiGCMarker() KERNEL_RETURN; |
7246a374a9f2
6458402: 3 jvmti tests fail with CMS and +ExplicitGCInvokesConcurrent
kamg
parents:
1983
diff
changeset
|
494 ~JvmtiGCMarker() KERNEL_RETURN; |
0 | 495 }; |
496 | |
497 // JvmtiHideSingleStepping is a helper class for hiding | |
498 // internal single step events. | |
499 class JvmtiHideSingleStepping : public StackObj { | |
500 private: | |
501 bool _single_step_hidden; | |
502 JavaThread * _thread; | |
503 | |
504 public: | |
505 JvmtiHideSingleStepping(JavaThread * thread) { | |
506 assert(thread != NULL, "sanity check"); | |
507 | |
508 _single_step_hidden = false; | |
509 _thread = thread; | |
510 if (JvmtiExport::should_post_single_step()) { | |
511 _single_step_hidden = JvmtiExport::hide_single_stepping(_thread); | |
512 } | |
513 } | |
514 | |
515 ~JvmtiHideSingleStepping() { | |
516 if (_single_step_hidden) { | |
517 JvmtiExport::expose_single_stepping(_thread); | |
518 } | |
519 } | |
520 }; | |
521 | |
1972 | 522 #endif // SHARE_VM_PRIMS_JVMTIEXPORT_HPP |