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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
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"
32 #include "runtime/fieldDescriptor.hpp"
33 #include "runtime/frame.hpp"
34 #include "runtime/handles.inline.hpp"
35 #include "runtime/thread.hpp"
36 #include "runtime/vm_operations.hpp"
37 #include "utilities/growableArray.hpp"
38 #include "utilities/macros.hpp"
39
40 //
41 // Forward Declarations
42 //
43
44 class JvmtiEnv;
45 class JvmtiThreadState;
46 class JvmtiRawMonitor; // for jvmtiEnv.hpp
47 class JvmtiEventControllerPrivate;
48 class JvmtiTagMap;
49
50
51
52 // One JvmtiEnv object is created per jvmti attachment;
53 // done via JNI GetEnv() call. Multiple attachments are
54 // allowed in jvmti.
80 static void entering_dying_thread_env_iteration() { ++_dying_thread_env_iteration_count; }
81 static void leaving_dying_thread_env_iteration() { --_dying_thread_env_iteration_count; }
82 static bool is_inside_dying_thread_env_iteration(){ return _dying_thread_env_iteration_count > 0; }
83
84 private:
85
86 enum {
87 JVMTI_MAGIC = 0x71EE,
88 DISPOSED_MAGIC = 0xDEFC,
89 BAD_MAGIC = 0xDEAD
90 };
91
92 jvmtiEnv _jvmti_external;
93 jint _magic;
94 jint _version; // version value passed to JNI GetEnv()
95 JvmtiEnvBase* _next;
96 bool _is_retransformable;
97 const void *_env_local_storage; // per env agent allocated data.
98 jvmtiEventCallbacks _event_callbacks;
99 jvmtiExtEventCallbacks _ext_event_callbacks;
100 JvmtiTagMap* _tag_map;
101 JvmtiEnvEventEnable _env_event_enable;
102 jvmtiCapabilities _current_capabilities;
103 jvmtiCapabilities _prohibited_capabilities;
104 volatile bool _class_file_load_hook_ever_enabled;
105 static volatile bool _needs_clean_up;
106 char** _native_method_prefixes;
107 int _native_method_prefix_count;
108
109 protected:
110 JvmtiEnvBase(jint version);
111 ~JvmtiEnvBase();
112 void dispose();
113 void env_dispose();
114
115 void set_env_local_storage(const void* data) { _env_local_storage = data; }
116 const void* get_env_local_storage() { return _env_local_storage; }
117
118 void record_class_file_load_hook_enabled();
119 void record_first_time_class_file_load_hook_enabled();
120
234 event_type <= JVMTI_MAX_EVENT_TYPE_VAL, "checking");
235 return ((void**)&_event_callbacks)[event_type-JVMTI_MIN_EVENT_TYPE_VAL] != NULL;
236 }
237
238 jvmtiEventCallbacks* callbacks() {
239 return &_event_callbacks;
240 }
241
242 jvmtiExtEventCallbacks* ext_callbacks() {
243 return &_ext_event_callbacks;
244 }
245
246 void set_tag_map(JvmtiTagMap* tag_map) {
247 _tag_map = tag_map;
248 }
249
250 JvmtiTagMap* tag_map() {
251 return _tag_map;
252 }
253
254
255 // return true if event is enabled globally or for any thread
256 // True only if there is a callback for it.
257 bool is_enabled(jvmtiEvent event_type) {
258 return _env_event_enable.is_enabled(event_type);
259 }
260
261 // Random Utilities
262
263 protected:
264 // helper methods for creating arrays of global JNI Handles from local Handles
265 // allocated into environment specific storage
266 jobject * new_jobjectArray(int length, Handle *handles);
267 jthread * new_jthreadArray(int length, Handle *handles);
268 jthreadGroup * new_jthreadGroupArray(int length, Handle *handles);
269
270 // convert from JNIHandle to JavaThread *
271 JavaThread * get_JavaThread(jthread jni_thread);
272
273 // convert to a jni jclass from a non-null Klass*
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
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"
32 #include "runtime/fieldDescriptor.hpp"
33 #include "runtime/frame.hpp"
34 #include "runtime/handles.inline.hpp"
35 #include "runtime/orderAccess.hpp"
36 #include "runtime/thread.hpp"
37 #include "runtime/vm_operations.hpp"
38 #include "utilities/growableArray.hpp"
39 #include "utilities/macros.hpp"
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.
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;
95 jint _version; // version value passed to JNI GetEnv()
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* volatile _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:
111 JvmtiEnvBase(jint version);
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
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 JvmtiTagMap* acquire_tag_map() {
256 return (JvmtiTagMap*)OrderAccess::load_ptr_acquire(&_tag_map);
257 }
258
259 void release_set_tag_map(JvmtiTagMap* tag_map) {
260 OrderAccess::release_store_ptr(&_tag_map, tag_map);
261 }
262
263 // return true if event is enabled globally or for any thread
264 // True only if there is a callback for it.
265 bool is_enabled(jvmtiEvent event_type) {
266 return _env_event_enable.is_enabled(event_type);
267 }
268
269 // Random Utilities
270
271 protected:
272 // helper methods for creating arrays of global JNI Handles from local Handles
273 // allocated into environment specific storage
274 jobject * new_jobjectArray(int length, Handle *handles);
275 jthread * new_jthreadArray(int length, Handle *handles);
276 jthreadGroup * new_jthreadGroupArray(int length, Handle *handles);
277
278 // convert from JNIHandle to JavaThread *
279 JavaThread * get_JavaThread(jthread jni_thread);
280
281 // convert to a jni jclass from a non-null Klass*
|