< prev index next >

src/hotspot/share/prims/jvmtiTagMap.hpp

Print this page

 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 entry_iterate(JvmtiTagMapKeyClosure* closure);







 55 
 56  public:
 57   // indicates if this tag map is locked
 58   bool is_locked()                          { return lock()->is_locked(); }

 59   inline Monitor* lock()                    { return &_lock; }
 60 
 61   JvmtiTagMapTable* hashmap() { return _hashmap; }
 62 
 63   // returns true if the hashmaps are empty
 64   bool is_empty();
 65 
 66   // return tag for the given environment
 67   static JvmtiTagMap* tag_map_for(JvmtiEnv* env);
 68 
 69   // destroy tag map
 70   ~JvmtiTagMap();
 71 
 72   // set/get tag
 73   void set_tag(jobject obj, jlong tag);
 74   jlong get_tag(jobject obj);
 75 
 76   // deprecated heap iteration functions
 77   void iterate_over_heap(jvmtiHeapObjectFilter object_filter,
 78                          Klass* klass,
 79                          jvmtiHeapObjectCallback heap_object_callback,
 80                          const void* user_data);
 81 
 82   void iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
 83                                       jvmtiStackReferenceCallback stack_ref_callback,
 84                                       jvmtiObjectReferenceCallback object_ref_callback,
 85                                       const void* user_data);
 86 

 99                          Klass* klass,
100                          jobject initial_object,
101                          const jvmtiHeapCallbacks* callbacks,
102                          const void* user_data);
103 
104   // get tagged objects
105   jvmtiError get_objects_with_tags(const jlong* tags, jint count,
106                                    jint* count_ptr, jobject** object_result_ptr,
107                                    jlong** tag_result_ptr);
108 
109   void remove_and_post_dead_objects();
110   void remove_dead_entries(GrowableArray<jlong>* objects);
111   void remove_dead_entries_locked(GrowableArray<jlong>* objects);
112   void post_dead_objects(GrowableArray<jlong>* const objects);
113 
114   static void check_hashmaps_for_heapwalk(GrowableArray<jlong>* objects);
115   static void set_needs_cleaning() NOT_JVMTI_RETURN;
116   static void gc_notification(size_t num_dead_entries) NOT_JVMTI_RETURN;
117 
118   void flush_object_free_events();
119   void clear();  // Clear tagmap table after the env is disposed.
120 
121   // For ServiceThread
122   static void flush_all_object_free_events() NOT_JVMTI_RETURN;
123   static bool has_object_free_events_and_reset() NOT_JVMTI_RETURN_(false);
124 };
125 
126 #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   // moves entries from _flat_hashmap to _hashmap
 61   void convert_flat_object_entries();
 62 
 63  public:
 64   // for inernal use
 65   jlong find(const JvmtiHeapwalkObject& obj) const;
 66   void add(const JvmtiHeapwalkObject& obj, jlong tag);
 67   void remove(const JvmtiHeapwalkObject& obj);
 68 
 69  public:
 70   // indicates if this tag map is locked
 71   bool is_locked() const                    { return lock()->is_locked(); }
 72   inline const Monitor* lock() const        { return &_lock; }
 73   inline Monitor* lock()                    { return &_lock; }
 74 


 75   // returns true if the hashmaps are empty
 76   bool is_empty() const;
 77 
 78   // return tag map for the given environment
 79   static JvmtiTagMap* tag_map_for(JvmtiEnv* env);
 80 
 81   // destroy tag map
 82   ~JvmtiTagMap();
 83 
 84   // set/get tag
 85   void set_tag(jobject obj, jlong tag);
 86   jlong get_tag(jobject obj);
 87 
 88   // deprecated heap iteration functions
 89   void iterate_over_heap(jvmtiHeapObjectFilter object_filter,
 90                          Klass* klass,
 91                          jvmtiHeapObjectCallback heap_object_callback,
 92                          const void* user_data);
 93 
 94   void iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
 95                                       jvmtiStackReferenceCallback stack_ref_callback,
 96                                       jvmtiObjectReferenceCallback object_ref_callback,
 97                                       const void* user_data);
 98 

111                          Klass* klass,
112                          jobject initial_object,
113                          const jvmtiHeapCallbacks* callbacks,
114                          const void* user_data);
115 
116   // get tagged objects
117   jvmtiError get_objects_with_tags(const jlong* tags, jint count,
118                                    jint* count_ptr, jobject** object_result_ptr,
119                                    jlong** tag_result_ptr);
120 
121   void remove_and_post_dead_objects();
122   void remove_dead_entries(GrowableArray<jlong>* objects);
123   void remove_dead_entries_locked(GrowableArray<jlong>* objects);
124   void post_dead_objects(GrowableArray<jlong>* const objects);
125 
126   static void check_hashmaps_for_heapwalk(GrowableArray<jlong>* objects);
127   static void set_needs_cleaning() NOT_JVMTI_RETURN;
128   static void gc_notification(size_t num_dead_entries) NOT_JVMTI_RETURN;
129 
130   void flush_object_free_events();
131   void clear();  // Clear hash tables after the env is disposed.
132 
133   // For ServiceThread
134   static void flush_all_object_free_events() NOT_JVMTI_RETURN;
135   static bool has_object_free_events_and_reset() NOT_JVMTI_RETURN_(false);
136 };
137 
138 #endif // SHARE_PRIMS_JVMTITAGMAP_HPP
< prev index next >