< prev index next >

src/hotspot/share/memory/metaspaceShared.hpp

Print this page




  62   static address _cds_i2i_entry_code_buffers;
  63   static size_t  _cds_i2i_entry_code_buffers_size;
  64   static size_t  _core_spaces_size;
  65  public:
  66   enum {
  67     // core archive spaces
  68     mc = 0,  // miscellaneous code for method trampolines
  69     rw = 1,  // read-write shared space in the heap
  70     ro = 2,  // read-only shared space in the heap
  71     md = 3,  // miscellaneous data for initializing tables, etc.
  72     num_core_spaces = 4, // number of non-string regions
  73 
  74     // optional mapped spaces
  75     // Currently it only contains class file data.
  76     od = num_core_spaces,
  77     num_non_heap_spaces = od + 1,
  78 
  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 oop materialize_archived_object(oop obj);
 115   static void archive_klass_objects(Thread* THREAD);
 116 #endif
 117 
 118   static bool is_archive_object(oop p) NOT_CDS_JAVA_HEAP_RETURN_(false);
 119 
 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() {
 125     CDS_JAVA_HEAP_ONLY(_archive_object_cache = new (ResourceObj::C_HEAP, mtClass)ArchivedObjectCache(););
 126   }
 127   static void destroy_archive_object_cache() {
 128     CDS_JAVA_HEAP_ONLY(delete _archive_object_cache; _archive_object_cache = NULL;);
 129   }
 130   static void fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
 131 
 132   static void dump_closed_archive_heap_objects(GrowableArray<MemRegion> * closed_archive) NOT_CDS_JAVA_HEAP_RETURN;
 133 
 134   static void dump_open_archive_heap_objects(GrowableArray<MemRegion> * open_archive) NOT_CDS_JAVA_HEAP_RETURN;


 203   static void zero_cpp_vtable_clones_for_writing();
 204   static void patch_cpp_vtable_pointers();
 205   static bool is_valid_shared_method(const Method* m) NOT_CDS_RETURN_(false);
 206   static void serialize(SerializeClosure* sc) NOT_CDS_RETURN;
 207 
 208   static MetaspaceSharedStats* stats() {
 209     return &_stats;
 210   }
 211 
 212   static void report_out_of_space(const char* name, size_t needed_bytes);
 213 
 214   // JVM/TI RedefineClasses() support:
 215   // Remap the shared readonly space to shared readwrite, private if
 216   // sharing is enabled. Simply returns true if sharing is not enabled
 217   // or if the remapping has already been done by a prior call.
 218   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 219   static bool remapped_readwrite() {
 220     CDS_ONLY(return _remapped_readwrite);
 221     NOT_CDS(return false);
 222   }
 223 
 224   static void print_shared_spaces();
 225 
 226   static bool try_link_class(InstanceKlass* ik, TRAPS);
 227   static void link_and_cleanup_shared_classes(TRAPS);
 228   static void check_shared_class_loader_type(InstanceKlass* ik);
 229 
 230   // Allocate a block of memory from the "mc", "ro", or "rw" regions.
 231   static char* misc_code_space_alloc(size_t num_bytes);
 232   static char* read_only_space_alloc(size_t num_bytes);
 233 
 234   static char* read_only_space_top();
 235 
 236   template <typename T>
 237   static Array<T>* new_ro_array(int length) {
 238 #if INCLUDE_CDS
 239     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 240     Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size);
 241     array->initialize(length);
 242     return array;
 243 #else
 244     return NULL;


  62   static address _cds_i2i_entry_code_buffers;
  63   static size_t  _cds_i2i_entry_code_buffers_size;
  64   static size_t  _core_spaces_size;
  65  public:
  66   enum {
  67     // core archive spaces
  68     mc = 0,  // miscellaneous code for method trampolines
  69     rw = 1,  // read-write shared space in the heap
  70     ro = 2,  // read-only shared space in the heap
  71     md = 3,  // miscellaneous data for initializing tables, etc.
  72     num_core_spaces = 4, // number of non-string regions
  73 
  74     // optional mapped spaces
  75     // Currently it only contains class file data.
  76     od = num_core_spaces,
  77     num_non_heap_spaces = od + 1,
  78 
  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     last_string = first_string + max_strings - 1,
  83     first_open_archive_heap_region = first_string + max_strings,
  84     max_open_archive_heap_region = 2,
  85 
  86     last_valid_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
  87     n_regions =  last_valid_region + 1 // total number of regions
  88   };
  89 
  90   static void prepare_for_dumping() NOT_CDS_RETURN;
  91   static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
  92   static int preload_classes(const char * class_list_path,
  93                              TRAPS) NOT_CDS_RETURN_(0);
  94 
  95 #if INCLUDE_CDS_JAVA_HEAP
  96  private:
  97   static bool obj_equals(oop const& p1, oop const& p2) {
  98     return p1 == p2;
  99   }
 100   static unsigned obj_hash(oop const& p);
 101 
 102   typedef ResourceHashtable<oop, oop,
 103       MetaspaceShared::obj_hash,
 104       MetaspaceShared::obj_equals,
 105       15889, // prime number
 106       ResourceObj::C_HEAP> ArchivedObjectCache;
 107   static ArchivedObjectCache* _archive_object_cache;
 108 
 109  public:
 110   static ArchivedObjectCache* archive_object_cache() {
 111     return _archive_object_cache;
 112   }
 113   static oop find_archived_heap_object(oop obj);
 114   static oop archive_heap_object(oop obj, Thread* THREAD);
 115   static oop materialize_archived_object(narrowOop v);
 116   static void archive_klass_objects(Thread* THREAD);
 117 #endif
 118 
 119   static bool is_archive_object(oop p) NOT_CDS_JAVA_HEAP_RETURN_(false);
 120 
 121   static bool is_heap_object_archiving_allowed() {
 122     CDS_JAVA_HEAP_ONLY(return (UseG1GC && UseCompressedOops && UseCompressedClassPointers);)
 123     NOT_CDS_JAVA_HEAP(return false;)
 124   }
 125   static void create_archive_object_cache() {
 126     CDS_JAVA_HEAP_ONLY(_archive_object_cache = new (ResourceObj::C_HEAP, mtClass)ArchivedObjectCache(););
 127   }
 128   static void destroy_archive_object_cache() {
 129     CDS_JAVA_HEAP_ONLY(delete _archive_object_cache; _archive_object_cache = NULL;);
 130   }
 131   static void fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
 132 
 133   static void dump_closed_archive_heap_objects(GrowableArray<MemRegion> * closed_archive) NOT_CDS_JAVA_HEAP_RETURN;
 134 
 135   static void dump_open_archive_heap_objects(GrowableArray<MemRegion> * open_archive) NOT_CDS_JAVA_HEAP_RETURN;


 204   static void zero_cpp_vtable_clones_for_writing();
 205   static void patch_cpp_vtable_pointers();
 206   static bool is_valid_shared_method(const Method* m) NOT_CDS_RETURN_(false);
 207   static void serialize(SerializeClosure* sc) NOT_CDS_RETURN;
 208 
 209   static MetaspaceSharedStats* stats() {
 210     return &_stats;
 211   }
 212 
 213   static void report_out_of_space(const char* name, size_t needed_bytes);
 214 
 215   // JVM/TI RedefineClasses() support:
 216   // Remap the shared readonly space to shared readwrite, private if
 217   // sharing is enabled. Simply returns true if sharing is not enabled
 218   // or if the remapping has already been done by a prior call.
 219   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 220   static bool remapped_readwrite() {
 221     CDS_ONLY(return _remapped_readwrite);
 222     NOT_CDS(return false);
 223   }


 224 
 225   static bool try_link_class(InstanceKlass* ik, TRAPS);
 226   static void link_and_cleanup_shared_classes(TRAPS);
 227   static void check_shared_class_loader_type(InstanceKlass* ik);
 228 
 229   // Allocate a block of memory from the "mc", "ro", or "rw" regions.
 230   static char* misc_code_space_alloc(size_t num_bytes);
 231   static char* read_only_space_alloc(size_t num_bytes);
 232 
 233   static char* read_only_space_top();
 234 
 235   template <typename T>
 236   static Array<T>* new_ro_array(int length) {
 237 #if INCLUDE_CDS
 238     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 239     Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size);
 240     array->initialize(length);
 241     return array;
 242 #else
 243     return NULL;
< prev index next >