< prev index next >

src/hotspot/share/memory/metaspaceShared.hpp

Print this page




  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 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_MEMORY_METASPACESHARED_HPP
  26 #define SHARE_VM_MEMORY_METASPACESHARED_HPP
  27 
  28 #include "classfile/compactHashtable.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "memory/virtualspace.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "utilities/exceptions.hpp"
  34 #include "utilities/macros.hpp"
  35 #include "utilities/resourceHash.hpp"
  36 
  37 #define MAX_SHARED_DELTA                (0x7FFFFFFF)
  38 
  39 class FileMapInfo;
  40 
  41 class MetaspaceSharedStats {
  42 public:
  43   MetaspaceSharedStats() {
  44     memset(this, 0, sizeof(*this));
  45   }
  46   CompactHashtableStats symbol;
  47   CompactHashtableStats string;
  48 };
  49 
  50 // Class Data Sharing Support
  51 class MetaspaceShared : AllStatic {
  52 


  79     // mapped java heap regions
  80     first_string = od + 1, // index of first string region
  81     max_strings = 2, // max number of string regions in string space
  82     first_open_archive_heap_region = first_string + max_strings,
  83     max_open_archive_heap_region = 2,
  84 
  85     last_valid_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
  86     n_regions =  last_valid_region + 1 // total number of regions
  87   };
  88 
  89   static void prepare_for_dumping() NOT_CDS_RETURN;
  90   static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
  91   static int preload_classes(const char * class_list_path,
  92                              TRAPS) NOT_CDS_RETURN_(0);
  93 
  94 #if INCLUDE_CDS_JAVA_HEAP
  95  private:
  96   static bool obj_equals(oop const& p1, oop const& p2) {
  97     return p1 == p2;
  98   }
  99   static unsigned obj_hash(oop const& p) {
 100     assert(!p->mark()->has_bias_pattern(),
 101            "this object should never have been locked");  // so identity_hash won't safepoin
 102     unsigned hash = (unsigned)p->identity_hash();
 103     return hash;
 104   }
 105   typedef ResourceHashtable<oop, oop,
 106       MetaspaceShared::obj_hash,
 107       MetaspaceShared::obj_equals,
 108       15889, // prime number
 109       ResourceObj::C_HEAP> ArchivedObjectCache;
 110   static ArchivedObjectCache* _archive_object_cache;
 111 
 112  public:
 113   static ArchivedObjectCache* archive_object_cache() {
 114     return _archive_object_cache;
 115   }
 116   static oop find_archived_heap_object(oop obj);
 117   static oop archive_heap_object(oop obj, Thread* THREAD);
 118   static void archive_klass_objects(Thread* THREAD);
 119 #endif
 120   static bool is_heap_object_archiving_allowed() {
 121     CDS_JAVA_HEAP_ONLY(return (UseG1GC && UseCompressedOops && UseCompressedClassPointers);)
 122     NOT_CDS_JAVA_HEAP(return false;)
 123   }
 124   static void create_archive_object_cache() {




  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 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_MEMORY_METASPACESHARED_HPP
  26 #define SHARE_VM_MEMORY_METASPACESHARED_HPP
  27 
  28 #include "classfile/compactHashtable.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "memory/virtualspace.hpp"
  32 #include "oops/oop.hpp"
  33 #include "utilities/exceptions.hpp"
  34 #include "utilities/macros.hpp"
  35 #include "utilities/resourceHash.hpp"
  36 
  37 #define MAX_SHARED_DELTA                (0x7FFFFFFF)
  38 
  39 class FileMapInfo;
  40 
  41 class MetaspaceSharedStats {
  42 public:
  43   MetaspaceSharedStats() {
  44     memset(this, 0, sizeof(*this));
  45   }
  46   CompactHashtableStats symbol;
  47   CompactHashtableStats string;
  48 };
  49 
  50 // Class Data Sharing Support
  51 class MetaspaceShared : AllStatic {
  52 


  79     // mapped java heap regions
  80     first_string = od + 1, // index of first string region
  81     max_strings = 2, // max number of string regions in string space
  82     first_open_archive_heap_region = first_string + max_strings,
  83     max_open_archive_heap_region = 2,
  84 
  85     last_valid_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
  86     n_regions =  last_valid_region + 1 // total number of regions
  87   };
  88 
  89   static void prepare_for_dumping() NOT_CDS_RETURN;
  90   static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
  91   static int preload_classes(const char * class_list_path,
  92                              TRAPS) NOT_CDS_RETURN_(0);
  93 
  94 #if INCLUDE_CDS_JAVA_HEAP
  95  private:
  96   static bool obj_equals(oop const& p1, oop const& p2) {
  97     return p1 == p2;
  98   }
  99   static unsigned obj_hash(oop const& p);
 100 




 101   typedef ResourceHashtable<oop, oop,
 102       MetaspaceShared::obj_hash,
 103       MetaspaceShared::obj_equals,
 104       15889, // prime number
 105       ResourceObj::C_HEAP> ArchivedObjectCache;
 106   static ArchivedObjectCache* _archive_object_cache;
 107 
 108  public:
 109   static ArchivedObjectCache* archive_object_cache() {
 110     return _archive_object_cache;
 111   }
 112   static oop find_archived_heap_object(oop obj);
 113   static oop archive_heap_object(oop obj, Thread* THREAD);
 114   static void archive_klass_objects(Thread* THREAD);
 115 #endif
 116   static bool is_heap_object_archiving_allowed() {
 117     CDS_JAVA_HEAP_ONLY(return (UseG1GC && UseCompressedOops && UseCompressedClassPointers);)
 118     NOT_CDS_JAVA_HEAP(return false;)
 119   }
 120   static void create_archive_object_cache() {


< prev index next >