1 /*
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. 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 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 *
231 size_t core_spaces_size() { return _header->_core_spaces_size; }
232
233 static FileMapInfo* current_info() {
234 CDS_ONLY(return _current_info;)
235 NOT_CDS(return NULL;)
236 }
237
238 static void assert_mark(bool check);
239
240 // File manipulation.
241 bool initialize() NOT_CDS_RETURN_(false);
242 bool open_for_read();
243 void open_for_write();
244 void write_header();
245 void write_region(int region, char* base, size_t size,
246 bool read_only, bool allow_exec);
247 size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
248 int first_region_id, int max_num_regions);
249 void write_bytes(const void* buffer, int count);
250 void write_bytes_aligned(const void* buffer, int count);
251 char* map_region(int i);
252 void map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
253 void fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
254 void unmap_region(int i);
255 bool verify_region_checksum(int i);
256 void close();
257 bool is_open() { return _file_open; }
258 ReservedSpace reserve_shared_memory();
259
260 // JVM/TI RedefineClasses() support:
261 // Remap the shared readonly space to shared readwrite, private.
262 bool remap_shared_readonly_as_readwrite();
263
264 // Errors.
265 static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
266 static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
267
268 // Return true if given address is in the mapped shared space.
269 bool is_in_shared_space(const void* p) NOT_CDS_RETURN_(false);
270 bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
271 void print_shared_spaces() NOT_CDS_RETURN;
272
273 // Stop CDS sharing and unmap CDS regions.
274 static void stop_sharing_and_unmap(const char* msg);
275
276 static void allocate_classpath_entry_table();
277 bool validate_classpath_entry_table();
278
279 static SharedClassPathEntry* shared_classpath(int index) {
280 if (index < 0) {
281 return NULL;
282 }
283 assert(index < _classpath_entry_table_size, "sanity");
284 char* p = (char*)_classpath_entry_table->data();
285 p += _classpath_entry_size * index;
286 return (SharedClassPathEntry*)p;
287 }
288 static const char* shared_classpath_name(int index) {
289 assert(index >= 0, "Sanity");
|
1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. 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 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 *
231 size_t core_spaces_size() { return _header->_core_spaces_size; }
232
233 static FileMapInfo* current_info() {
234 CDS_ONLY(return _current_info;)
235 NOT_CDS(return NULL;)
236 }
237
238 static void assert_mark(bool check);
239
240 // File manipulation.
241 bool initialize() NOT_CDS_RETURN_(false);
242 bool open_for_read();
243 void open_for_write();
244 void write_header();
245 void write_region(int region, char* base, size_t size,
246 bool read_only, bool allow_exec);
247 size_t write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem,
248 int first_region_id, int max_num_regions);
249 void write_bytes(const void* buffer, int count);
250 void write_bytes_aligned(const void* buffer, int count);
251 char* map_region(int i, char** top_ret);
252 void map_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
253 void fixup_mapped_heap_regions() NOT_CDS_JAVA_HEAP_RETURN;
254 void unmap_region(int i);
255 bool verify_region_checksum(int i);
256 void close();
257 bool is_open() { return _file_open; }
258 ReservedSpace reserve_shared_memory();
259
260 // JVM/TI RedefineClasses() support:
261 // Remap the shared readonly space to shared readwrite, private.
262 bool remap_shared_readonly_as_readwrite();
263
264 // Errors.
265 static void fail_stop(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
266 static void fail_continue(const char *msg, ...) ATTRIBUTE_PRINTF(1, 2);
267
268 bool is_in_shared_region(const void* p, int idx) NOT_CDS_RETURN_(false);
269 void print_shared_spaces() NOT_CDS_RETURN;
270
271 // Stop CDS sharing and unmap CDS regions.
272 static void stop_sharing_and_unmap(const char* msg);
273
274 static void allocate_classpath_entry_table();
275 bool validate_classpath_entry_table();
276
277 static SharedClassPathEntry* shared_classpath(int index) {
278 if (index < 0) {
279 return NULL;
280 }
281 assert(index < _classpath_entry_table_size, "sanity");
282 char* p = (char*)_classpath_entry_table->data();
283 p += _classpath_entry_size * index;
284 return (SharedClassPathEntry*)p;
285 }
286 static const char* shared_classpath_name(int index) {
287 assert(index >= 0, "Sanity");
|