< prev index next >

src/hotspot/share/memory/metaspaceShared.hpp

Print this page




 108 // written to the shared file.
 109 
 110 class WriteClosure : public SerializeClosure {
 111 private:
 112   DumpRegion* _dump_region;
 113 
 114 public:
 115   WriteClosure(DumpRegion* r) {
 116     _dump_region = r;
 117   }
 118 
 119   void do_ptr(void** p) {
 120     _dump_region->append_intptr_t((intptr_t)*p);
 121   }
 122 
 123   void do_u4(u4* p) {
 124     void* ptr = (void*)(uintx(*p));
 125     do_ptr(&ptr);
 126   }
 127 
 128   void do_bool(bool *p) {
 129     void* ptr = (void*)(uintx(*p));
 130     do_ptr(&ptr);
 131   }
 132 
 133   void do_tag(int tag) {
 134     _dump_region->append_intptr_t((intptr_t)tag);
 135   }
 136 
 137   void do_oop(oop* o);
 138 
 139   void do_region(u_char* start, size_t size);
 140 
 141   bool reading() const { return false; }
 142 };
 143 
 144 // Closure for serializing initialization data in from a data area
 145 // (ptr_array) read from the shared file.
 146 
 147 class ReadClosure : public SerializeClosure {
 148 private:
 149   intptr_t** _ptr_array;
 150 
 151   inline intptr_t nextPtr() {
 152     return *(*_ptr_array)++;
 153   }
 154 
 155 public:
 156   ReadClosure(intptr_t** ptr_array) { _ptr_array = ptr_array; }
 157 
 158   void do_ptr(void** p);
 159 
 160   void do_u4(u4* p);
 161 
 162   void do_bool(bool *p);
 163 
 164   void do_tag(int tag);
 165 
 166   void do_oop(oop *p);
 167 
 168   void do_region(u_char* start, size_t size);
 169 
 170   bool reading() const { return true; }
 171 };
 172 
 173 #endif
 174 
 175 // Class Data Sharing Support
 176 class MetaspaceShared : AllStatic {
 177 
 178   // CDS support
 179   static ReservedSpace _shared_rs;
 180   static VirtualSpace _shared_vs;
 181   static int _max_alignment;
 182   static MetaspaceSharedStats _stats;
 183   static bool _has_error_classes;


 287   // JVM/TI RedefineClasses() support:
 288   // Remap the shared readonly space to shared readwrite, private if
 289   // sharing is enabled. Simply returns true if sharing is not enabled
 290   // or if the remapping has already been done by a prior call.
 291   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 292   static bool remapped_readwrite() {
 293     CDS_ONLY(return _remapped_readwrite);
 294     NOT_CDS(return false);
 295   }
 296 
 297   static bool try_link_class(InstanceKlass* ik, TRAPS);
 298   static void link_and_cleanup_shared_classes(TRAPS);
 299 
 300 #if INCLUDE_CDS
 301   static ReservedSpace* reserve_shared_rs(size_t size, size_t alignment,
 302                                           bool large, char* requested_address);
 303   static void init_shared_dump_space(DumpRegion* first_space, address first_space_bottom = NULL);
 304   static DumpRegion* misc_code_dump_space();
 305   static DumpRegion* read_write_dump_space();
 306   static DumpRegion* read_only_dump_space();

 307   static void pack_dump_space(DumpRegion* current, DumpRegion* next,
 308                               ReservedSpace* rs);
 309 
 310   static void rewrite_nofast_bytecodes_and_calculate_fingerprints(InstanceKlass* ik);
 311 #endif
 312 
 313   // Allocate a block of memory from the "mc", "ro", or "rw" regions.
 314   static char* misc_code_space_alloc(size_t num_bytes);
 315   static char* read_only_space_alloc(size_t num_bytes);
 316 
 317   template <typename T>
 318   static Array<T>* new_ro_array(int length) {
 319 #if INCLUDE_CDS
 320     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 321     Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size);
 322     array->initialize(length);
 323     return array;
 324 #else
 325     return NULL;
 326 #endif




 108 // written to the shared file.
 109 
 110 class WriteClosure : public SerializeClosure {
 111 private:
 112   DumpRegion* _dump_region;
 113 
 114 public:
 115   WriteClosure(DumpRegion* r) {
 116     _dump_region = r;
 117   }
 118 
 119   void do_ptr(void** p) {
 120     _dump_region->append_intptr_t((intptr_t)*p);
 121   }
 122 
 123   void do_u4(u4* p) {
 124     void* ptr = (void*)(uintx(*p));
 125     do_ptr(&ptr);
 126   }
 127 





 128   void do_tag(int tag) {
 129     _dump_region->append_intptr_t((intptr_t)tag);
 130   }
 131 
 132   void do_oop(oop* o);
 133 
 134   void do_region(u_char* start, size_t size);
 135 
 136   bool reading() const { return false; }
 137 };
 138 
 139 // Closure for serializing initialization data in from a data area
 140 // (ptr_array) read from the shared file.
 141 
 142 class ReadClosure : public SerializeClosure {
 143 private:
 144   intptr_t** _ptr_array;
 145 
 146   inline intptr_t nextPtr() {
 147     return *(*_ptr_array)++;
 148   }
 149 
 150 public:
 151   ReadClosure(intptr_t** ptr_array) { _ptr_array = ptr_array; }
 152 
 153   void do_ptr(void** p);
 154 
 155   void do_u4(u4* p);
 156 


 157   void do_tag(int tag);
 158 
 159   void do_oop(oop *p);
 160 
 161   void do_region(u_char* start, size_t size);
 162 
 163   bool reading() const { return true; }
 164 };
 165 
 166 #endif
 167 
 168 // Class Data Sharing Support
 169 class MetaspaceShared : AllStatic {
 170 
 171   // CDS support
 172   static ReservedSpace _shared_rs;
 173   static VirtualSpace _shared_vs;
 174   static int _max_alignment;
 175   static MetaspaceSharedStats _stats;
 176   static bool _has_error_classes;


 280   // JVM/TI RedefineClasses() support:
 281   // Remap the shared readonly space to shared readwrite, private if
 282   // sharing is enabled. Simply returns true if sharing is not enabled
 283   // or if the remapping has already been done by a prior call.
 284   static bool remap_shared_readonly_as_readwrite() NOT_CDS_RETURN_(true);
 285   static bool remapped_readwrite() {
 286     CDS_ONLY(return _remapped_readwrite);
 287     NOT_CDS(return false);
 288   }
 289 
 290   static bool try_link_class(InstanceKlass* ik, TRAPS);
 291   static void link_and_cleanup_shared_classes(TRAPS);
 292 
 293 #if INCLUDE_CDS
 294   static ReservedSpace* reserve_shared_rs(size_t size, size_t alignment,
 295                                           bool large, char* requested_address);
 296   static void init_shared_dump_space(DumpRegion* first_space, address first_space_bottom = NULL);
 297   static DumpRegion* misc_code_dump_space();
 298   static DumpRegion* read_write_dump_space();
 299   static DumpRegion* read_only_dump_space();
 300   static DumpRegion* optional_data_dump_space();
 301   static void pack_dump_space(DumpRegion* current, DumpRegion* next,
 302                               ReservedSpace* rs);
 303 
 304   static void rewrite_nofast_bytecodes_and_calculate_fingerprints(InstanceKlass* ik);
 305 #endif
 306 
 307   // Allocate a block of memory from the "mc", "ro", or "rw" regions.
 308   static char* misc_code_space_alloc(size_t num_bytes);
 309   static char* read_only_space_alloc(size_t num_bytes);
 310 
 311   template <typename T>
 312   static Array<T>* new_ro_array(int length) {
 313 #if INCLUDE_CDS
 314     size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
 315     Array<T>* array = (Array<T>*)read_only_space_alloc(byte_size);
 316     array->initialize(length);
 317     return array;
 318 #else
 319     return NULL;
 320 #endif


< prev index next >