171 };
172
173 #endif // INCLUDE_CDS
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;
184 static bool _archive_loading_failed;
185 static bool _remapped_readwrite;
186 static address _i2i_entry_code_buffers;
187 static size_t _i2i_entry_code_buffers_size;
188 static size_t _core_spaces_size;
189 static void* _shared_metaspace_static_top;
190 static intx _relocation_delta;
191 public:
192 enum {
193 // core archive spaces
194 mc = 0, // miscellaneous code for method trampolines
195 rw = 1, // read-write shared space in the heap
196 ro = 2, // read-only shared space in the heap
197 bm = 3, // relocation bitmaps (freed after file mapping is finished)
198 num_core_region = 3,
199 num_non_heap_spaces = 4,
200
201 // mapped java heap regions
202 first_closed_archive_heap_region = bm + 1,
203 max_closed_archive_heap_region = 2,
204 last_closed_archive_heap_region = first_closed_archive_heap_region + max_closed_archive_heap_region - 1,
205 first_open_archive_heap_region = last_closed_archive_heap_region + 1,
206 max_open_archive_heap_region = 2,
207 last_open_archive_heap_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
208
209 last_valid_region = last_open_archive_heap_region,
210 n_regions = last_valid_region + 1 // total number of regions
332 static size_t ro_array_bytesize(int length) {
333 size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
334 return align_up(byte_size, BytesPerWord);
335 }
336
337 static address i2i_entry_code_buffers(size_t total_size);
338
339 static address i2i_entry_code_buffers() {
340 return _i2i_entry_code_buffers;
341 }
342 static size_t i2i_entry_code_buffers_size() {
343 return _i2i_entry_code_buffers_size;
344 }
345 static void relocate_klass_ptr(oop o);
346
347 static Klass* get_relocated_klass(Klass *k, bool is_final=false);
348
349 static void allocate_cloned_cpp_vtptrs();
350 static intptr_t* fix_cpp_vtable_for_dynamic_archive(MetaspaceObj::Type msotype, address obj);
351 static void initialize_ptr_marker(CHeapBitMap* ptrmap);
352
353 // Non-zero if the archive(s) need to be mapped a non-default location due to ASLR.
354 static intx relocation_delta() { return _relocation_delta; }
355 static intx final_delta();
356 static bool use_windows_memory_mapping() {
357 const bool is_windows = (NOT_WINDOWS(false) WINDOWS_ONLY(true));
358 //const bool is_windows = true; // enable this to allow testing the windows mmap semantics on Linux, etc.
359 return is_windows;
360 }
361
362 static void write_core_archive_regions(FileMapInfo* mapinfo,
363 GrowableArray<ArchiveHeapOopmapInfo>* closed_oopmaps,
364 GrowableArray<ArchiveHeapOopmapInfo>* open_oopmaps);
365 private:
366 #if INCLUDE_CDS
367 static void write_region(FileMapInfo* mapinfo, int region_idx, DumpRegion* dump_region,
368 bool read_only, bool allow_exec);
369 #endif
370 static void read_extra_data(const char* filename, TRAPS) NOT_CDS_RETURN;
371 static FileMapInfo* open_static_archive();
|
171 };
172
173 #endif // INCLUDE_CDS
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;
184 static bool _archive_loading_failed;
185 static bool _remapped_readwrite;
186 static address _i2i_entry_code_buffers;
187 static size_t _i2i_entry_code_buffers_size;
188 static size_t _core_spaces_size;
189 static void* _shared_metaspace_static_top;
190 static intx _relocation_delta;
191 static char* _default_base_address;
192 public:
193 enum {
194 // core archive spaces
195 mc = 0, // miscellaneous code for method trampolines
196 rw = 1, // read-write shared space in the heap
197 ro = 2, // read-only shared space in the heap
198 bm = 3, // relocation bitmaps (freed after file mapping is finished)
199 num_core_region = 3,
200 num_non_heap_spaces = 4,
201
202 // mapped java heap regions
203 first_closed_archive_heap_region = bm + 1,
204 max_closed_archive_heap_region = 2,
205 last_closed_archive_heap_region = first_closed_archive_heap_region + max_closed_archive_heap_region - 1,
206 first_open_archive_heap_region = last_closed_archive_heap_region + 1,
207 max_open_archive_heap_region = 2,
208 last_open_archive_heap_region = first_open_archive_heap_region + max_open_archive_heap_region - 1,
209
210 last_valid_region = last_open_archive_heap_region,
211 n_regions = last_valid_region + 1 // total number of regions
333 static size_t ro_array_bytesize(int length) {
334 size_t byte_size = Array<T>::byte_sizeof(length, sizeof(T));
335 return align_up(byte_size, BytesPerWord);
336 }
337
338 static address i2i_entry_code_buffers(size_t total_size);
339
340 static address i2i_entry_code_buffers() {
341 return _i2i_entry_code_buffers;
342 }
343 static size_t i2i_entry_code_buffers_size() {
344 return _i2i_entry_code_buffers_size;
345 }
346 static void relocate_klass_ptr(oop o);
347
348 static Klass* get_relocated_klass(Klass *k, bool is_final=false);
349
350 static void allocate_cloned_cpp_vtptrs();
351 static intptr_t* fix_cpp_vtable_for_dynamic_archive(MetaspaceObj::Type msotype, address obj);
352 static void initialize_ptr_marker(CHeapBitMap* ptrmap);
353
354 // This is the base address as specified by -XX:SharedBaseAddress during -Xshare:dump.
355 // Both the base/top archives are written using this as their base address.
356 static char* default_base_address() {
357 return _default_base_address;
358 }
359
360 // Non-zero if the archive(s) need to be mapped a non-default location due to ASLR.
361 static intx relocation_delta() { return _relocation_delta; }
362 static intx final_delta();
363 static bool use_windows_memory_mapping() {
364 const bool is_windows = (NOT_WINDOWS(false) WINDOWS_ONLY(true));
365 //const bool is_windows = true; // enable this to allow testing the windows mmap semantics on Linux, etc.
366 return is_windows;
367 }
368
369 static void write_core_archive_regions(FileMapInfo* mapinfo,
370 GrowableArray<ArchiveHeapOopmapInfo>* closed_oopmaps,
371 GrowableArray<ArchiveHeapOopmapInfo>* open_oopmaps);
372 private:
373 #if INCLUDE_CDS
374 static void write_region(FileMapInfo* mapinfo, int region_idx, DumpRegion* dump_region,
375 bool read_only, bool allow_exec);
376 #endif
377 static void read_extra_data(const char* filename, TRAPS) NOT_CDS_RETURN;
378 static FileMapInfo* open_static_archive();
|