src/share/vm/prims/jvmtiTagMap.hpp

Tue, 06 Jan 2009 07:05:05 -0800

author
jmasa
date
Tue, 06 Jan 2009 07:05:05 -0800
changeset 952
e9be0e04635a
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6689653: JMapPerm fails with UseConcMarkSweepIncGC and compressed oops off
Summary: Added safe_object_iterate() for use by JMapPerm.
Reviewed-by: tonyp

     1 /*
     2  * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
     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  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // JvmtiTagMap
    27 #ifndef _JAVA_JVMTI_TAG_MAP_H_
    28 #define _JAVA_JVMTI_TAG_MAP_H_
    30 // forward references
    31 class JvmtiTagHashmap;
    32 class JvmtiTagHashmapEntry;
    33 class JvmtiTagHashmapEntryClosure;
    35 class JvmtiTagMap :  public CHeapObj {
    36  private:
    38   enum{
    39     n_hashmaps = 2,                                 // encapsulates 2 hashmaps
    40     max_free_entries = 4096                         // maximum number of free entries per env
    41   };
    43   // memory region for young generation
    44   static MemRegion _young_gen;
    45   static void get_young_generation();
    47   JvmtiEnv*             _env;                       // the jvmti environment
    48   Mutex                 _lock;                      // lock for this tag map
    49   JvmtiTagHashmap*      _hashmap[n_hashmaps];       // the hashmaps
    51   JvmtiTagHashmapEntry* _free_entries;              // free list for this environment
    52   int _free_entries_count;                          // number of entries on the free list
    54   // create a tag map
    55   JvmtiTagMap(JvmtiEnv* env);
    57   // accessors
    58   inline Mutex* lock()                      { return &_lock; }
    59   inline JvmtiEnv* env() const              { return _env; }
    61   // rehash tags maps for generation start to end
    62   void rehash(int start, int end);
    64   // indicates if the object is in the young generation
    65   static bool is_in_young(oop o);
    67   // iterate over all entries in this tag map
    68   void entry_iterate(JvmtiTagHashmapEntryClosure* closure);
    70  public:
    72   // indicates if this tag map is locked
    73   bool is_locked()                          { return lock()->is_locked(); }
    75   // return the appropriate hashmap for a given object
    76   JvmtiTagHashmap* hashmap_for(oop o);
    78   // create/destroy entries
    79   JvmtiTagHashmapEntry* create_entry(jweak ref, jlong tag);
    80   void destroy_entry(JvmtiTagHashmapEntry* entry);
    82   // returns true if the hashmaps are empty
    83   bool is_empty();
    85   // return tag for the given environment
    86   static JvmtiTagMap* tag_map_for(JvmtiEnv* env);
    88   // destroy tag map
    89   ~JvmtiTagMap();
    91   // set/get tag
    92   void set_tag(jobject obj, jlong tag);
    93   jlong get_tag(jobject obj);
    95   // deprecated heap iteration functions
    96   void iterate_over_heap(jvmtiHeapObjectFilter object_filter,
    97                          KlassHandle klass,
    98                          jvmtiHeapObjectCallback heap_object_callback,
    99                          const void* user_data);
   101   void iterate_over_reachable_objects(jvmtiHeapRootCallback heap_root_callback,
   102                                       jvmtiStackReferenceCallback stack_ref_callback,
   103                                       jvmtiObjectReferenceCallback object_ref_callback,
   104                                       const void* user_data);
   106   void iterate_over_objects_reachable_from_object(jobject object,
   107                                                   jvmtiObjectReferenceCallback object_reference_callback,
   108                                                   const void* user_data);
   111   // advanced (JVMTI 1.1) heap iteration functions
   112   void iterate_through_heap(jint heap_filter,
   113                             KlassHandle klass,
   114                             const jvmtiHeapCallbacks* callbacks,
   115                             const void* user_data);
   117   void follow_references(jint heap_filter,
   118                          KlassHandle klass,
   119                          jobject initial_object,
   120                          const jvmtiHeapCallbacks* callbacks,
   121                          const void* user_data);
   123   // get tagged objects
   124   jvmtiError get_objects_with_tags(const jlong* tags, jint count,
   125                                    jint* count_ptr, jobject** object_result_ptr,
   126                                    jlong** tag_result_ptr);
   128   // call post-GC to rehash the tag maps.
   129   static void gc_epilogue(bool full);
   131   // call after referencing processing has completed (CMS)
   132   static void cms_ref_processing_epilogue();
   133 };
   135 #endif   /* _JAVA_JVMTI_TAG_MAP_H_ */

mercurial