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 // JvmtiTagMap
26
27 #ifndef SHARE_PRIMS_JVMTITAGMAP_HPP
28 #define SHARE_PRIMS_JVMTITAGMAP_HPP
29
30 #include "jvmtifiles/jvmti.h"
31 #include "memory/allocation.hpp"
32
33 class JvmtiEnv;
34 class JvmtiTagMapTable;
35 class JvmtiTagMapKeyClosure;
36
37 class JvmtiTagMap : public CHeapObj<mtServiceability> {
38 private:
39
40 JvmtiEnv* _env; // the jvmti environment
41 Monitor _lock; // lock for this tag map
42 JvmtiTagMapTable* _hashmap; // the hashmap for tags
43 bool _needs_cleaning;
44 bool _posting_events;
45
46 static bool _has_object_free_events;
47
48 // create a tag map
49 JvmtiTagMap(JvmtiEnv* env);
50
51 // accessors
52 inline JvmtiEnv* env() const { return _env; }
53
54 void check_hashmap(GrowableArray<jlong>* objects);
55
56 void entry_iterate(JvmtiTagMapKeyClosure* closure);
57
58 public:
59 // indicates if this tag map is locked
60 bool is_locked() { return lock()->is_locked(); }
61 inline Monitor* lock() { return &_lock; }
62
63 JvmtiTagMapTable* hashmap() { return _hashmap; }
64
65 // returns true if the hashmaps are empty
66 bool is_empty();
67
68 // return tag for the given environment
69 static JvmtiTagMap* tag_map_for(JvmtiEnv* env);
70
71 // destroy tag map
72 ~JvmtiTagMap();
73
74 // set/get tag
75 void set_tag(jobject obj, jlong tag);
76 jlong get_tag(jobject obj);
77
78 // deprecated heap iteration functions
79 void iterate_over_heap(jvmtiHeapObjectFilter object_filter,
80 Klass* klass,
81 jvmtiHeapObjectCallback heap_object_callback,
82 const void* user_data);
83
84 void iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
85 jvmtiStackReferenceCallback stack_ref_callback,
86 jvmtiObjectReferenceCallback object_ref_callback,
87 const void* user_data);
88
101 Klass* klass,
102 jobject initial_object,
103 const jvmtiHeapCallbacks* callbacks,
104 const void* user_data);
105
106 // get tagged objects
107 jvmtiError get_objects_with_tags(const jlong* tags, jint count,
108 jint* count_ptr, jobject** object_result_ptr,
109 jlong** tag_result_ptr);
110
111 void remove_and_post_dead_objects();
112 void remove_dead_entries(GrowableArray<jlong>* objects);
113 void remove_dead_entries_locked(GrowableArray<jlong>* objects);
114 void post_dead_objects(GrowableArray<jlong>* const objects);
115
116 static void check_hashmaps_for_heapwalk(GrowableArray<jlong>* objects);
117 static void set_needs_cleaning() NOT_JVMTI_RETURN;
118 static void gc_notification(size_t num_dead_entries) NOT_JVMTI_RETURN;
119
120 void flush_object_free_events();
121 void clear(); // Clear tagmap table after the env is disposed.
122
123 // For ServiceThread
124 static void flush_all_object_free_events() NOT_JVMTI_RETURN;
125 static bool has_object_free_events_and_reset() NOT_JVMTI_RETURN_(false);
126 };
127
128 #endif // SHARE_PRIMS_JVMTITAGMAP_HPP
|
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 // JvmtiTagMap
26
27 #ifndef SHARE_PRIMS_JVMTITAGMAP_HPP
28 #define SHARE_PRIMS_JVMTITAGMAP_HPP
29
30 #include "jvmtifiles/jvmti.h"
31 #include "memory/allocation.hpp"
32
33 class JvmtiEnv;
34 class JvmtiTagMapTable;
35 class JvmtiFlatTagMapTable;
36 class JvmtiTagMapKeyClosure;
37 class JvmtiHeapwalkObject;
38
39 class JvmtiTagMap : public CHeapObj<mtServiceability> {
40 private:
41
42 JvmtiEnv* _env; // the jvmti environment
43 Monitor _lock; // lock for this tag map
44 JvmtiTagMapTable* _hashmap; // the hashmap for tags
45 JvmtiFlatTagMapTable* _flat_hashmap;
46
47 bool _needs_cleaning;
48 bool _posting_events;
49
50 static bool _has_object_free_events;
51
52 bool _converting_flat_object;
53
54 // create a tag map
55 JvmtiTagMap(JvmtiEnv* env);
56
57 // accessors
58 inline JvmtiEnv* env() const { return _env; }
59
60 void check_hashmap(GrowableArray<jlong>* objects);
61
62 // moves entries from _flat_hashmap to _hashmap
63 void convert_flat_object_entries();
64
65 public:
66 // for inernal use
67 jlong find(const JvmtiHeapwalkObject& obj) const;
68 void add(const JvmtiHeapwalkObject& obj, jlong tag);
69 void remove(const JvmtiHeapwalkObject& obj);
70
71 public:
72 // indicates if this tag map is locked
73 bool is_locked() const { return lock()->is_locked(); }
74 inline const Monitor* lock() const { return &_lock; }
75 inline Monitor* lock() { return &_lock; }
76
77 // returns true if the hashmaps are empty
78 bool is_empty() const;
79
80 // return tag map for the given environment
81 static JvmtiTagMap* tag_map_for(JvmtiEnv* env);
82
83 // destroy tag map
84 ~JvmtiTagMap();
85
86 // set/get tag
87 void set_tag(jobject obj, jlong tag);
88 jlong get_tag(jobject obj);
89
90 // deprecated heap iteration functions
91 void iterate_over_heap(jvmtiHeapObjectFilter object_filter,
92 Klass* klass,
93 jvmtiHeapObjectCallback heap_object_callback,
94 const void* user_data);
95
96 void iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
97 jvmtiStackReferenceCallback stack_ref_callback,
98 jvmtiObjectReferenceCallback object_ref_callback,
99 const void* user_data);
100
113 Klass* klass,
114 jobject initial_object,
115 const jvmtiHeapCallbacks* callbacks,
116 const void* user_data);
117
118 // get tagged objects
119 jvmtiError get_objects_with_tags(const jlong* tags, jint count,
120 jint* count_ptr, jobject** object_result_ptr,
121 jlong** tag_result_ptr);
122
123 void remove_and_post_dead_objects();
124 void remove_dead_entries(GrowableArray<jlong>* objects);
125 void remove_dead_entries_locked(GrowableArray<jlong>* objects);
126 void post_dead_objects(GrowableArray<jlong>* const objects);
127
128 static void check_hashmaps_for_heapwalk(GrowableArray<jlong>* objects);
129 static void set_needs_cleaning() NOT_JVMTI_RETURN;
130 static void gc_notification(size_t num_dead_entries) NOT_JVMTI_RETURN;
131
132 void flush_object_free_events();
133 void clear(); // Clear hash tables after the env is disposed.
134
135 // For ServiceThread
136 static void flush_all_object_free_events() NOT_JVMTI_RETURN;
137 static bool has_object_free_events_and_reset() NOT_JVMTI_RETURN_(false);
138 };
139
140 #endif // SHARE_PRIMS_JVMTITAGMAP_HPP
|