author | iklam |
Tue, 14 Aug 2018 09:59:37 -0700 | |
changeset 51491 | 187c84a5efe1 |
parent 51480 | 2e928420389d |
child 51720 | b7bfd64e43a6 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
2 |
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2131
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2131
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2131
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47599
diff
changeset
|
26 |
#include "jvm.h" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48962
diff
changeset
|
27 |
#include "classfile/classLoader.inline.hpp" |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
28 |
#include "classfile/classLoaderExt.hpp" |
34659
3a7071043457
8143615: compactHashtable.hpp includes .inline.hpp file
iklam
parents:
33628
diff
changeset
|
29 |
#include "classfile/compactHashtable.inline.hpp" |
46742 | 30 |
#include "classfile/stringTable.hpp" |
7397 | 31 |
#include "classfile/symbolTable.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
32 |
#include "classfile/systemDictionaryShared.hpp" |
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
33 |
#include "classfile/altHashing.hpp" |
46522
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
34 |
#include "logging/log.hpp" |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
35 |
#include "logging/logStream.hpp" |
46522
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
36 |
#include "logging/logMessage.hpp" |
7397 | 37 |
#include "memory/filemap.hpp" |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
38 |
#include "memory/heapShared.inline.hpp" |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
39 |
#include "memory/iterator.inline.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
40 |
#include "memory/metadataFactory.hpp" |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
41 |
#include "memory/metaspaceClosure.hpp" |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
42 |
#include "memory/metaspaceShared.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
43 |
#include "memory/oopFactory.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
44 |
#include "oops/compressedOops.inline.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
45 |
#include "oops/objArrayOop.hpp" |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
46 |
#include "oops/oop.inline.hpp" |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
47 |
#include "prims/jvmtiExport.hpp" |
7397 | 48 |
#include "runtime/arguments.hpp" |
49 |
#include "runtime/java.hpp" |
|
51480
2e928420389d
8209826: Undefined reference to os::write after JDK-8209657 (filemap.hpp cleanup)
iklam
parents:
51477
diff
changeset
|
50 |
#include "runtime/os.inline.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24424
diff
changeset
|
51 |
#include "runtime/vm_version.hpp" |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13728
diff
changeset
|
52 |
#include "services/memTracker.hpp" |
46625 | 53 |
#include "utilities/align.hpp" |
7397 | 54 |
#include "utilities/defaultStream.hpp" |
49982 | 55 |
#if INCLUDE_G1GC |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
56 |
#include "gc/g1/g1CollectedHeap.hpp" |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
57 |
#include "gc/g1/heapRegion.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
58 |
#endif |
7397 | 59 |
|
1 | 60 |
# include <sys/stat.h> |
61 |
# include <errno.h> |
|
62 |
||
63 |
#ifndef O_BINARY // if defined (Win32) use binary files. |
|
64 |
#define O_BINARY 0 // otherwise do nothing. |
|
65 |
#endif |
|
66 |
||
67 |
extern address JVM_FunctionAtStart(); |
|
68 |
extern address JVM_FunctionAtEnd(); |
|
69 |
||
2131 | 70 |
// Complain and stop. All error conditions occurring during the writing of |
1 | 71 |
// an archive file should stop the process. Unrecoverable errors during |
72 |
// the reading of the archive file should stop the process. |
|
73 |
||
74 |
static void fail(const char *msg, va_list ap) { |
|
75 |
// This occurs very early during initialization: tty is not initialized. |
|
76 |
jio_fprintf(defaultStream::error_stream(), |
|
2131 | 77 |
"An error has occurred while processing the" |
1 | 78 |
" shared archive file.\n"); |
79 |
jio_vfprintf(defaultStream::error_stream(), msg, ap); |
|
80 |
jio_fprintf(defaultStream::error_stream(), "\n"); |
|
19707
fecaabc8e462
8023381: VM fails to initialize in runtime/CDSCompressedKPtrs/XShareAuto.java runtime/SharedArchiveFile/CdsSameObjectAlignment.java
hseigel
parents:
19319
diff
changeset
|
81 |
// Do not change the text of the below message because some tests check for it. |
1 | 82 |
vm_exit_during_initialization("Unable to use shared archive.", NULL); |
83 |
} |
|
84 |
||
85 |
||
86 |
void FileMapInfo::fail_stop(const char *msg, ...) { |
|
87 |
va_list ap; |
|
88 |
va_start(ap, msg); |
|
89 |
fail(msg, ap); // Never returns. |
|
90 |
va_end(ap); // for completeness. |
|
91 |
} |
|
92 |
||
93 |
||
94 |
// Complain and continue. Recoverable errors during the reading of the |
|
95 |
// archive file may continue (with sharing disabled). |
|
96 |
// |
|
97 |
// If we continue, then disable shared spaces and close the file. |
|
98 |
||
99 |
void FileMapInfo::fail_continue(const char *msg, ...) { |
|
100 |
va_list ap; |
|
101 |
va_start(ap, msg); |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
102 |
MetaspaceShared::set_archive_loading_failed(); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
103 |
if (PrintSharedArchiveAndExit && _validating_shared_path_table) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
104 |
// If we are doing PrintSharedArchiveAndExit and some of the classpath entries |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
105 |
// do not validate, we can still continue "limping" to validate the remaining |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
106 |
// entries. No need to quit. |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
107 |
tty->print("["); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
108 |
tty->vprint(msg, ap); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
109 |
tty->print_cr("]"); |
23186
9396c6fb571b
8033990: Add message to verbose output to indicate when JVM was unable to use shared archive (with -Xshare:auto)
mseledtsov
parents:
19707
diff
changeset
|
110 |
} else { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
111 |
if (RequireSharedSpaces) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
112 |
fail(msg, ap); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
113 |
} else { |
46522
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
114 |
if (log_is_enabled(Info, cds)) { |
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
115 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
116 |
LogStream ls(Log(cds)::info()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
117 |
ls.print("UseSharedSpaces: "); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
118 |
ls.vprint_cr(msg, ap); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
119 |
} |
23186
9396c6fb571b
8033990: Add message to verbose output to indicate when JVM was unable to use shared archive (with -Xshare:auto)
mseledtsov
parents:
19707
diff
changeset
|
120 |
} |
28017
84009002b566
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
27880
diff
changeset
|
121 |
UseSharedSpaces = false; |
84009002b566
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
27880
diff
changeset
|
122 |
assert(current_info() != NULL, "singleton must be registered"); |
84009002b566
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
27880
diff
changeset
|
123 |
current_info()->close(); |
1 | 124 |
} |
125 |
va_end(ap); |
|
126 |
} |
|
127 |
||
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
128 |
// Fill in the fileMapInfo structure with data about this VM instance. |
1 | 129 |
|
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
130 |
// This method copies the vm version info into header_version. If the version is too |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
131 |
// long then a truncated version, which has a hash code appended to it, is copied. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
132 |
// |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
133 |
// Using a template enables this method to verify that header_version is an array of |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
134 |
// length JVM_IDENT_MAX. This ensures that the code that writes to the CDS file and |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
135 |
// the code that reads the CDS file will both use the same size buffer. Hence, will |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
136 |
// use identical truncation. This is necessary for matching of truncated versions. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
137 |
template <int N> static void get_header_version(char (&header_version) [N]) { |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
138 |
assert(N == JVM_IDENT_MAX, "Bad header_version size"); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
139 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
140 |
const char *vm_version = VM_Version::internal_vm_info_string(); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
141 |
const int version_len = (int)strlen(vm_version); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
142 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
143 |
if (version_len < (JVM_IDENT_MAX-1)) { |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
144 |
strcpy(header_version, vm_version); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
145 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
146 |
} else { |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
147 |
// Get the hash value. Use a static seed because the hash needs to return the same |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
148 |
// value over multiple jvm invocations. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
149 |
unsigned int hash = AltHashing::murmur3_32(8191, (const jbyte*)vm_version, version_len); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
150 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
151 |
// Truncate the ident, saving room for the 8 hex character hash value. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
152 |
strncpy(header_version, vm_version, JVM_IDENT_MAX-9); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
153 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
154 |
// Append the hash code as eight hex digits. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
155 |
sprintf(&header_version[JVM_IDENT_MAX-9], "%08x", hash); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
156 |
header_version[JVM_IDENT_MAX-1] = 0; // Null terminate. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
157 |
} |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
158 |
} |
1 | 159 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
160 |
FileMapInfo::FileMapInfo() { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
161 |
assert(_current_info == NULL, "must be singleton"); // not thread safe |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
162 |
_current_info = this; |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
163 |
memset((void*)this, 0, sizeof(FileMapInfo)); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
164 |
_file_offset = 0; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
165 |
_file_open = false; |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
166 |
_header = (FileMapHeader*)os::malloc(sizeof(FileMapHeader), mtInternal); |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
167 |
_header->_version = INVALID_CDS_ARCHIVE_VERSION; |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
168 |
_header->_has_platform_or_app_classes = true; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
169 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
170 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
171 |
FileMapInfo::~FileMapInfo() { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
172 |
assert(_current_info == this, "must be singleton"); // not thread safe |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
173 |
_current_info = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
174 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
175 |
|
1 | 176 |
void FileMapInfo::populate_header(size_t alignment) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
177 |
_header->populate(this, alignment); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
178 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
179 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
180 |
void FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) { |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
181 |
_magic = CDS_ARCHIVE_MAGIC; |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
182 |
_version = CURRENT_CDS_ARCHIVE_VERSION; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
183 |
_alignment = alignment; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
184 |
_obj_alignment = ObjectAlignmentInBytes; |
33628 | 185 |
_compact_strings = CompactStrings; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
186 |
_narrow_oop_mode = Universe::narrow_oop_mode(); |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47216
diff
changeset
|
187 |
_narrow_oop_base = Universe::narrow_oop_base(); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
188 |
_narrow_oop_shift = Universe::narrow_oop_shift(); |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
189 |
_max_heap_size = MaxHeapSize; |
31362
8957ccbb5821
8098821: Crash in system dictionary initialization with shared strings
coleenp
parents:
31345
diff
changeset
|
190 |
_narrow_klass_base = Universe::narrow_klass_base(); |
8957ccbb5821
8098821: Crash in system dictionary initialization with shared strings
coleenp
parents:
31345
diff
changeset
|
191 |
_narrow_klass_shift = Universe::narrow_klass_shift(); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
192 |
_shared_path_table_size = mapinfo->_shared_path_table_size; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
193 |
_shared_path_table = mapinfo->_shared_path_table; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
194 |
_shared_path_entry_size = mapinfo->_shared_path_entry_size; |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
195 |
if (MetaspaceShared::is_heap_object_archiving_allowed()) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
196 |
_heap_reserved = Universe::heap()->reserved_region(); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
197 |
} |
1 | 198 |
|
199 |
// The following fields are for sanity checks for whether this archive |
|
200 |
// will function correctly with this JVM and the bootclasspath it's |
|
201 |
// invoked with. |
|
202 |
||
203 |
// JVM version string ... changes on each build. |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
204 |
get_header_version(_jvm_ident); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
205 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
206 |
ClassLoaderExt::finalize_shared_paths_misc_info(); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
207 |
_app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index(); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
208 |
_app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index(); |
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
209 |
_max_used_path_index = ClassLoaderExt::max_used_path_index(); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
210 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
211 |
_verify_local = BytecodeVerificationLocal; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
212 |
_verify_remote = BytecodeVerificationRemote; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
213 |
_has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes(); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
214 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
215 |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
216 |
void SharedClassPathEntry::init(const char* name, bool is_modules_image, TRAPS) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
217 |
assert(DumpSharedSpaces, "dump time only"); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
218 |
_timestamp = 0; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
219 |
_filesize = 0; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
220 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
221 |
struct stat st; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
222 |
if (os::stat(name, &st) == 0) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
223 |
if ((st.st_mode & S_IFMT) == S_IFDIR) { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
224 |
_type = dir_entry; |
40013 | 225 |
} else { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
226 |
// The timestamp of the modules_image is not checked at runtime. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
227 |
if (is_modules_image) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
228 |
_type = modules_image_entry; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
229 |
} else { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
230 |
_type = jar_entry; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
231 |
_timestamp = st.st_mtime; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
232 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
233 |
_filesize = st.st_size; |
40013 | 234 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
235 |
} else { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
236 |
// The file/dir must exist, or it would not have been added |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
237 |
// into ClassLoader::classpath_entry(). |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
238 |
// |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
239 |
// If we can't access a jar file in the boot path, then we can't |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
240 |
// make assumptions about where classes get loaded from. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
241 |
FileMapInfo::fail_stop("Unable to open file %s.", name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
242 |
} |
40013 | 243 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
244 |
size_t len = strlen(name) + 1; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
245 |
_name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
246 |
strcpy(_name->data(), name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
247 |
} |
1 | 248 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
249 |
bool SharedClassPathEntry::validate(bool is_class_path) { |
49931 | 250 |
assert(UseSharedSpaces, "runtime only"); |
251 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
252 |
struct stat st; |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
253 |
const char* name; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
254 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
255 |
// In order to validate the runtime modules image file size against the archived |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
256 |
// size information, we need to obtain the runtime modules image path. The recorded |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
257 |
// dump time modules image path in the archive may be different from the runtime path |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
258 |
// if the JDK image has beed moved after generating the archive. |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
259 |
if (is_modules_image()) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
260 |
name = ClassLoader::get_jrt_entry()->name(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
261 |
} else { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
262 |
name = this->name(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
263 |
} |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
264 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
265 |
bool ok = true; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
266 |
log_info(class, path)("checking shared classpath entry: %s", name); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
267 |
if (os::stat(name, &st) != 0 && is_class_path) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
268 |
// If the archived module path entry does not exist at runtime, it is not fatal |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
269 |
// (no need to invalid the shared archive) because the shared runtime visibility check |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
270 |
// filters out any archived module classes that do not have a matching runtime |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
271 |
// module path location. |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
272 |
FileMapInfo::fail_continue("Required classpath entry does not exist: %s", name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
273 |
ok = false; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
274 |
} else if (is_dir()) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
275 |
if (!os::dir_is_empty(name)) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
276 |
FileMapInfo::fail_continue("directory is not empty: %s", name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
277 |
ok = false; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
278 |
} |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
279 |
} else if ((has_timestamp() && _timestamp != st.st_mtime) || |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
280 |
_filesize != st.st_size) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
281 |
ok = false; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
282 |
if (PrintSharedArchiveAndExit) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
283 |
FileMapInfo::fail_continue(_timestamp != st.st_mtime ? |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
284 |
"Timestamp mismatch" : |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
285 |
"File size mismatch"); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
286 |
} else { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
287 |
FileMapInfo::fail_continue("A jar file is not the one used while building" |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
288 |
" the shared archive file: %s", name); |
1 | 289 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
290 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
291 |
return ok; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
292 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
293 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
294 |
void SharedClassPathEntry::metaspace_pointers_do(MetaspaceClosure* it) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
295 |
it->push(&_name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
296 |
it->push(&_manifest); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
297 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
298 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
299 |
void FileMapInfo::allocate_shared_path_table() { |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
300 |
assert(DumpSharedSpaces, "Sanity"); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
301 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
302 |
Thread* THREAD = Thread::current(); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
303 |
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
304 |
ClassPathEntry* jrt = ClassLoader::get_jrt_entry(); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
305 |
|
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
306 |
assert(jrt != NULL, |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
307 |
"No modular java runtime image present when allocating the CDS classpath entry table"); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
308 |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
309 |
size_t entry_size = sizeof(SharedClassPathEntry); // assert ( should be 8 byte aligned??) |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
310 |
int num_boot_classpath_entries = ClassLoader::num_boot_classpath_entries(); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
311 |
int num_app_classpath_entries = ClassLoader::num_app_classpath_entries(); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
312 |
int num_module_path_entries = ClassLoader::num_module_path_entries(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
313 |
int num_entries = num_boot_classpath_entries + num_app_classpath_entries + num_module_path_entries; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
314 |
size_t bytes = entry_size * num_entries; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
315 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
316 |
_shared_path_table = MetadataFactory::new_array<u8>(loader_data, (int)(bytes + 7 / 8), THREAD); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
317 |
_shared_path_table_size = num_entries; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
318 |
_shared_path_entry_size = entry_size; |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
319 |
|
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
320 |
// 1. boot class path |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
321 |
int i = 0; |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
322 |
ClassPathEntry* cpe = jrt; |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
323 |
while (cpe != NULL) { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
324 |
bool is_jrt = (cpe == jrt); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
325 |
const char* type = (is_jrt ? "jrt" : (cpe->is_jar_file() ? "jar" : "dir")); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
326 |
log_info(class, path)("add main shared path (%s) %s", type, cpe->name()); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
327 |
SharedClassPathEntry* ent = shared_path(i); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
328 |
ent->init(cpe->name(), is_jrt, THREAD); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
329 |
if (!is_jrt) { // No need to do the modules image. |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
330 |
EXCEPTION_MARK; // The following call should never throw, but would exit VM on error. |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
331 |
update_shared_classpath(cpe, ent, THREAD); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
332 |
} |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
333 |
cpe = ClassLoader::get_next_boot_classpath_entry(cpe); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
334 |
i++; |
1 | 335 |
} |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
336 |
assert(i == num_boot_classpath_entries, |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
337 |
"number of boot class path entry mismatch"); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
338 |
|
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
339 |
// 2. app class path |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
340 |
ClassPathEntry *acpe = ClassLoader::app_classpath_entries(); |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
341 |
while (acpe != NULL) { |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
342 |
log_info(class, path)("add app shared path %s", acpe->name()); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
343 |
SharedClassPathEntry* ent = shared_path(i); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
344 |
ent->init(acpe->name(), false, THREAD); |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
345 |
EXCEPTION_MARK; |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
346 |
update_shared_classpath(acpe, ent, THREAD); |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
347 |
acpe = acpe->next(); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
348 |
i++; |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
349 |
} |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
350 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
351 |
// 3. module path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
352 |
ClassPathEntry *mpe = ClassLoader::module_path_entries(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
353 |
while (mpe != NULL) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
354 |
log_info(class, path)("add module path %s",mpe->name()); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
355 |
SharedClassPathEntry* ent = shared_path(i); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
356 |
ent->init(mpe->name(), false, THREAD); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
357 |
EXCEPTION_MARK; |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
358 |
update_shared_classpath(mpe, ent, THREAD); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
359 |
mpe = mpe->next(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
360 |
i++; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
361 |
} |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
362 |
assert(i == num_entries, "number of shared path entry mismatch"); |
1 | 363 |
} |
364 |
||
49931 | 365 |
void FileMapInfo::check_nonempty_dir_in_shared_path_table() { |
366 |
assert(DumpSharedSpaces, "dump time only"); |
|
367 |
||
368 |
bool has_nonempty_dir = false; |
|
369 |
||
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
370 |
int last = _shared_path_table_size - 1; |
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
371 |
if (last > ClassLoaderExt::max_used_path_index()) { |
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
372 |
// no need to check any path beyond max_used_path_index |
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
373 |
last = ClassLoaderExt::max_used_path_index(); |
49931 | 374 |
} |
375 |
||
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
376 |
for (int i = 0; i <= last; i++) { |
49931 | 377 |
SharedClassPathEntry *e = shared_path(i); |
378 |
if (e->is_dir()) { |
|
379 |
const char* path = e->name(); |
|
380 |
if (!os::dir_is_empty(path)) { |
|
381 |
tty->print_cr("Error: non-empty directory '%s'", path); |
|
382 |
has_nonempty_dir = true; |
|
383 |
} |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
if (has_nonempty_dir) { |
|
388 |
ClassLoader::exit_with_path_failure("Cannot have non-empty directory in paths", NULL); |
|
389 |
} |
|
390 |
} |
|
391 |
||
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
392 |
class ManifestStream: public ResourceObj { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
393 |
private: |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
394 |
u1* _buffer_start; // Buffer bottom |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
395 |
u1* _buffer_end; // Buffer top (one past last element) |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
396 |
u1* _current; // Current buffer position |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
397 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
398 |
public: |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
399 |
// Constructor |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
400 |
ManifestStream(u1* buffer, int length) : _buffer_start(buffer), |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
401 |
_current(buffer) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
402 |
_buffer_end = buffer + length; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
403 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
404 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
405 |
static bool is_attr(u1* attr, const char* name) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
406 |
return strncmp((const char*)attr, name, strlen(name)) == 0; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
407 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
408 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
409 |
static char* copy_attr(u1* value, size_t len) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
410 |
char* buf = NEW_RESOURCE_ARRAY(char, len + 1); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
411 |
strncpy(buf, (char*)value, len); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
412 |
buf[len] = 0; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
413 |
return buf; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
414 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
415 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
416 |
// The return value indicates if the JAR is signed or not |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
417 |
bool check_is_signed() { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
418 |
u1* attr = _current; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
419 |
bool isSigned = false; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
420 |
while (_current < _buffer_end) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
421 |
if (*_current == '\n') { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
422 |
*_current = '\0'; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
423 |
u1* value = (u1*)strchr((char*)attr, ':'); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
424 |
if (value != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
425 |
assert(*(value+1) == ' ', "Unrecognized format" ); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
426 |
if (strstr((char*)attr, "-Digest") != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
427 |
isSigned = true; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
428 |
break; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
429 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
430 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
431 |
*_current = '\n'; // restore |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
432 |
attr = _current + 1; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
433 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
434 |
_current ++; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
435 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
436 |
return isSigned; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
437 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
438 |
}; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
439 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
440 |
void FileMapInfo::update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
441 |
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
442 |
ResourceMark rm(THREAD); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
443 |
jint manifest_size; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
444 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
445 |
if (cpe->is_jar_file()) { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
446 |
assert(ent->is_jar(), "the shared class path entry is not a JAR file"); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
447 |
char* manifest = ClassLoaderExt::read_manifest(cpe, &manifest_size, CHECK); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
448 |
if (manifest != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
449 |
ManifestStream* stream = new ManifestStream((u1*)manifest, |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
450 |
manifest_size); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
451 |
if (stream->check_is_signed()) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
452 |
ent->set_is_signed(); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
453 |
} else { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
454 |
// Copy the manifest into the shared archive |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
455 |
manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
456 |
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data, |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
457 |
manifest_size, |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
458 |
THREAD); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
459 |
char* p = (char*)(buf->data()); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
460 |
memcpy(p, manifest, manifest_size); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
461 |
ent->set_manifest(buf); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
462 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
463 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
464 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
465 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
466 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
467 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
468 |
bool FileMapInfo::validate_shared_path_table() { |
49931 | 469 |
assert(UseSharedSpaces, "runtime only"); |
470 |
||
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
471 |
_validating_shared_path_table = true; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
472 |
_shared_path_table = _header->_shared_path_table; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
473 |
_shared_path_entry_size = _header->_shared_path_entry_size; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
474 |
_shared_path_table_size = _header->_shared_path_table_size; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
475 |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
476 |
int module_paths_start_index = _header->_app_module_paths_start_index; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
477 |
|
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
478 |
// validate the path entries up to the _max_used_path_index |
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
479 |
for (int i=0; i < _header->_max_used_path_index + 1; i++) { |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
480 |
if (i < module_paths_start_index) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
481 |
if (shared_path(i)->validate()) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
482 |
log_info(class, path)("ok"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
483 |
} |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
484 |
} else if (i >= module_paths_start_index) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
485 |
if (shared_path(i)->validate(false /* not a class path entry */)) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
486 |
log_info(class, path)("ok"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
487 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
488 |
} else if (!PrintSharedArchiveAndExit) { |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
489 |
_validating_shared_path_table = false; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
490 |
_shared_path_table = NULL; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
491 |
_shared_path_table_size = 0; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
492 |
return false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
493 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
494 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
495 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
496 |
_validating_shared_path_table = false; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
497 |
return true; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
498 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
499 |
|
1 | 500 |
// Read the FileMapInfo information from the file. |
501 |
||
502 |
bool FileMapInfo::init_from_file(int fd) { |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
503 |
size_t sz = sizeof(FileMapHeader); |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
504 |
size_t n = os::read(fd, _header, (unsigned int)sz); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
505 |
if (n != sz) { |
1 | 506 |
fail_continue("Unable to read the file header."); |
507 |
return false; |
|
508 |
} |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
509 |
if (_header->_version != CURRENT_CDS_ARCHIVE_VERSION) { |
1 | 510 |
fail_continue("The shared archive file has the wrong version."); |
511 |
return false; |
|
512 |
} |
|
513 |
_file_offset = (long)n; |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
514 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
515 |
size_t info_size = _header->_paths_misc_info_size; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
516 |
_paths_misc_info = NEW_C_HEAP_ARRAY_RETURN_NULL(char, info_size, mtClass); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
517 |
if (_paths_misc_info == NULL) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
518 |
fail_continue("Unable to read the file header."); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
519 |
return false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
520 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
521 |
n = os::read(fd, _paths_misc_info, (unsigned int)info_size); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
522 |
if (n != info_size) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
523 |
fail_continue("Unable to read the shared path info header."); |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27025
diff
changeset
|
524 |
FREE_C_HEAP_ARRAY(char, _paths_misc_info); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
525 |
_paths_misc_info = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
526 |
return false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
527 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
528 |
|
27025 | 529 |
size_t len = lseek(fd, 0, SEEK_END); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
530 |
CDSFileMapRegion* si = space_at(MetaspaceShared::last_valid_region); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
531 |
// The last space might be empty |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
532 |
if (si->_file_offset > len || len - si->_file_offset < si->_used) { |
27025 | 533 |
fail_continue("The shared archive file has been truncated."); |
534 |
return false; |
|
535 |
} |
|
536 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
537 |
_file_offset += (long)n; |
1 | 538 |
return true; |
539 |
} |
|
540 |
||
541 |
||
542 |
// Read the FileMapInfo information from the file. |
|
543 |
bool FileMapInfo::open_for_read() { |
|
544 |
_full_path = Arguments::GetSharedArchivePath(); |
|
545 |
int fd = open(_full_path, O_RDONLY | O_BINARY, 0); |
|
546 |
if (fd < 0) { |
|
547 |
if (errno == ENOENT) { |
|
548 |
// Not locating the shared archive is ok. |
|
549 |
fail_continue("Specified shared archive not found."); |
|
550 |
} else { |
|
551 |
fail_continue("Failed to open shared archive file (%s).", |
|
37113 | 552 |
os::strerror(errno)); |
1 | 553 |
} |
554 |
return false; |
|
555 |
} |
|
556 |
||
557 |
_fd = fd; |
|
558 |
_file_open = true; |
|
559 |
return true; |
|
560 |
} |
|
561 |
||
562 |
||
563 |
// Write the FileMapInfo information to the file. |
|
564 |
||
565 |
void FileMapInfo::open_for_write() { |
|
48962
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
566 |
_full_path = Arguments::GetSharedArchivePath(); |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
567 |
LogMessage(cds) msg; |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
568 |
if (msg.is_info()) { |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
569 |
msg.info("Dumping shared data to file: "); |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
570 |
msg.info(" %s", _full_path); |
1 | 571 |
} |
572 |
||
15461
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
573 |
#ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. |
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
574 |
chmod(_full_path, _S_IREAD | _S_IWRITE); |
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
575 |
#endif |
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
576 |
|
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
577 |
// Use remove() to delete the existing file because, on Unix, this will |
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
578 |
// allow processes that have it open continued access to the file. |
1 | 579 |
remove(_full_path); |
580 |
int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); |
|
581 |
if (fd < 0) { |
|
28950
693ae3d5e1ff
8072694: Need errno info when CDS archive creation fails
hseigel
parents:
28023
diff
changeset
|
582 |
fail_stop("Unable to create shared archive file %s: (%s).", _full_path, |
37113 | 583 |
os::strerror(errno)); |
1 | 584 |
} |
585 |
_fd = fd; |
|
586 |
_file_offset = 0; |
|
587 |
_file_open = true; |
|
588 |
} |
|
589 |
||
590 |
||
591 |
// Write the header to the file, seek to the next allocation boundary. |
|
592 |
||
593 |
void FileMapInfo::write_header() { |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
594 |
int info_size = ClassLoader::get_shared_paths_misc_info_size(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
595 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
596 |
_header->_paths_misc_info_size = info_size; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
597 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
598 |
align_file_position(); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
599 |
write_bytes(_header, sizeof(FileMapHeader)); |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
600 |
write_bytes(ClassLoader::get_shared_paths_misc_info(), (size_t)info_size); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
601 |
align_file_position(); |
1 | 602 |
} |
603 |
||
604 |
||
605 |
// Dump region to file. |
|
606 |
||
607 |
void FileMapInfo::write_region(int region, char* base, size_t size, |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
608 |
bool read_only, bool allow_exec) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
609 |
CDSFileMapRegion* si = space_at(region); |
1 | 610 |
|
611 |
if (_file_open) { |
|
612 |
guarantee(si->_file_offset == _file_offset, "file offset mismatch."); |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
613 |
log_info(cds)("Shared file region %d: " SIZE_FORMAT_HEX_W(08) |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
614 |
" bytes, addr " INTPTR_FORMAT " file offset " SIZE_FORMAT_HEX_W(08), |
46522
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
615 |
region, size, p2i(base), _file_offset); |
1 | 616 |
} else { |
617 |
si->_file_offset = _file_offset; |
|
618 |
} |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
619 |
if (MetaspaceShared::is_heap_region(region)) { |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
620 |
assert((base - (char*)Universe::narrow_oop_base()) % HeapWordSize == 0, "Sanity"); |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
621 |
if (base != NULL) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
622 |
si->_addr._offset = (intx)CompressedOops::encode_not_null((oop)base); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
623 |
} else { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
624 |
si->_addr._offset = 0; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
625 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
626 |
} else { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
627 |
si->_addr._base = base; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
628 |
} |
1 | 629 |
si->_used = size; |
630 |
si->_read_only = read_only; |
|
631 |
si->_allow_exec = allow_exec; |
|
27025 | 632 |
si->_crc = ClassLoader::crc32(0, base, (jint)size); |
51070 | 633 |
if (base != NULL) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
634 |
write_bytes_aligned(base, size); |
51070 | 635 |
} |
1 | 636 |
} |
637 |
||
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
638 |
// Write out the given archive heap memory regions. GC code combines multiple |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
639 |
// consecutive archive GC regions into one MemRegion whenever possible and |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
640 |
// produces the 'heap_mem' array. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
641 |
// |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
642 |
// If the archive heap memory size is smaller than a single dump time GC region |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
643 |
// size, there is only one MemRegion in the array. |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
644 |
// |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
645 |
// If the archive heap memory size is bigger than one dump time GC region size, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
646 |
// the 'heap_mem' array may contain more than one consolidated MemRegions. When |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
647 |
// the first/bottom archive GC region is a partial GC region (with the empty |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
648 |
// portion at the higher address within the region), one MemRegion is used for |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
649 |
// the bottom partial archive GC region. The rest of the consecutive archive |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
650 |
// GC regions are combined into another MemRegion. |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
651 |
// |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
652 |
// Here's the mapping from (archive heap GC regions) -> (GrowableArray<MemRegion> *regions). |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
653 |
// + We have 1 or more archive heap regions: ah0, ah1, ah2 ..... ahn |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
654 |
// + We have 1 or 2 consolidated heap memory regions: r0 and r1 |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
655 |
// |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
656 |
// If there's a single archive GC region (ah0), then r0 == ah0, and r1 is empty. |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
657 |
// Otherwise: |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
658 |
// |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
659 |
// "X" represented space that's occupied by heap objects. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
660 |
// "_" represented unused spaced in the heap region. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
661 |
// |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
662 |
// |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
663 |
// |ah0 | ah1 | ah2| ...... | ahn| |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
664 |
// |XXXXXX|__ |XXXXX|XXXX|XXXXXXXX|XXXX| |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
665 |
// |<-r0->| |<- r1 ----------------->| |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
666 |
// ^^^ |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
667 |
// | |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
668 |
// +-- gap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
669 |
size_t FileMapInfo::write_archive_heap_regions(GrowableArray<MemRegion> *heap_mem, |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
670 |
GrowableArray<ArchiveHeapOopmapInfo> *oopmaps, |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
671 |
int first_region_id, int max_num_regions) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
672 |
assert(max_num_regions <= 2, "Only support maximum 2 memory regions"); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
673 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
674 |
int arr_len = heap_mem == NULL ? 0 : heap_mem->length(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
675 |
if(arr_len > max_num_regions) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
676 |
fail_stop("Unable to write archive heap memory regions: " |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
677 |
"number of memory regions exceeds maximum due to fragmentation"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
678 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
679 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
680 |
size_t total_size = 0; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
681 |
for (int i = first_region_id, arr_idx = 0; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
682 |
i < first_region_id + max_num_regions; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
683 |
i++, arr_idx++) { |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
684 |
char* start = NULL; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
685 |
size_t size = 0; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
686 |
if (arr_idx < arr_len) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
687 |
start = (char*)heap_mem->at(arr_idx).start(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
688 |
size = heap_mem->at(arr_idx).byte_size(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
689 |
total_size += size; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
690 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
691 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
692 |
log_info(cds)("Archive heap region %d " INTPTR_FORMAT " - " INTPTR_FORMAT " = " SIZE_FORMAT_W(8) " bytes", |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
693 |
i, p2i(start), p2i(start + size), size); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
694 |
write_region(i, start, size, false, false); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
695 |
if (size > 0) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
696 |
space_at(i)->_oopmap = oopmaps->at(arr_idx)._oopmap; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
697 |
space_at(i)->_oopmap_size_in_bits = oopmaps->at(arr_idx)._oopmap_size_in_bits; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
698 |
} |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
699 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
700 |
return total_size; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
701 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
702 |
|
1 | 703 |
// Dump bytes to file -- at the current file position. |
704 |
||
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
705 |
void FileMapInfo::write_bytes(const void* buffer, size_t nbytes) { |
1 | 706 |
if (_file_open) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
707 |
size_t n = os::write(_fd, buffer, (unsigned int)nbytes); |
1 | 708 |
if (n != nbytes) { |
709 |
// It is dangerous to leave the corrupted shared archive file around, |
|
710 |
// close and remove the file. See bug 6372906. |
|
711 |
close(); |
|
712 |
remove(_full_path); |
|
26296 | 713 |
fail_stop("Unable to write to shared archive file."); |
1 | 714 |
} |
715 |
} |
|
716 |
_file_offset += nbytes; |
|
717 |
} |
|
718 |
||
719 |
||
720 |
// Align file position to an allocation unit boundary. |
|
721 |
||
722 |
void FileMapInfo::align_file_position() { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
723 |
size_t new_file_offset = align_up(_file_offset, |
27025 | 724 |
os::vm_allocation_granularity()); |
1 | 725 |
if (new_file_offset != _file_offset) { |
726 |
_file_offset = new_file_offset; |
|
727 |
if (_file_open) { |
|
728 |
// Seek one byte back from the target and write a byte to insure |
|
729 |
// that the written file is the correct length. |
|
730 |
_file_offset -= 1; |
|
27025 | 731 |
if (lseek(_fd, (long)_file_offset, SEEK_SET) < 0) { |
26296 | 732 |
fail_stop("Unable to seek."); |
1 | 733 |
} |
734 |
char zero = 0; |
|
735 |
write_bytes(&zero, 1); |
|
736 |
} |
|
737 |
} |
|
738 |
} |
|
739 |
||
740 |
||
741 |
// Dump bytes to file -- at the current file position. |
|
742 |
||
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
743 |
void FileMapInfo::write_bytes_aligned(const void* buffer, size_t nbytes) { |
1 | 744 |
align_file_position(); |
745 |
write_bytes(buffer, nbytes); |
|
746 |
align_file_position(); |
|
747 |
} |
|
748 |
||
749 |
||
750 |
// Close the shared archive file. This does NOT unmap mapped regions. |
|
751 |
||
752 |
void FileMapInfo::close() { |
|
753 |
if (_file_open) { |
|
754 |
if (::close(_fd) < 0) { |
|
755 |
fail_stop("Unable to close the shared archive file."); |
|
756 |
} |
|
757 |
_file_open = false; |
|
758 |
_fd = -1; |
|
759 |
} |
|
760 |
} |
|
761 |
||
762 |
||
763 |
// JVM/TI RedefineClasses() support: |
|
764 |
// Remap the shared readonly space to shared readwrite, private. |
|
765 |
bool FileMapInfo::remap_shared_readonly_as_readwrite() { |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
766 |
int idx = MetaspaceShared::ro; |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
767 |
CDSFileMapRegion* si = space_at(idx); |
1 | 768 |
if (!si->_read_only) { |
769 |
// the space is already readwrite so we are done |
|
770 |
return true; |
|
771 |
} |
|
772 |
size_t used = si->_used; |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
773 |
size_t size = align_up(used, os::vm_allocation_granularity()); |
1 | 774 |
if (!open_for_read()) { |
775 |
return false; |
|
776 |
} |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
777 |
char *addr = region_addr(idx); |
1 | 778 |
char *base = os::remap_memory(_fd, _full_path, si->_file_offset, |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
779 |
addr, size, false /* !read_only */, |
1 | 780 |
si->_allow_exec); |
781 |
close(); |
|
782 |
if (base == NULL) { |
|
783 |
fail_continue("Unable to remap shared readonly space (errno=%d).", errno); |
|
784 |
return false; |
|
785 |
} |
|
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
786 |
if (base != addr) { |
1 | 787 |
fail_continue("Unable to remap shared readonly space at required address."); |
788 |
return false; |
|
789 |
} |
|
790 |
si->_read_only = false; |
|
791 |
return true; |
|
792 |
} |
|
793 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
794 |
// Map the whole region at once, assumed to be allocated contiguously. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
795 |
ReservedSpace FileMapInfo::reserve_shared_memory() { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
796 |
char* requested_addr = region_addr(0); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
797 |
size_t size = FileMapInfo::core_spaces_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
798 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
799 |
// Reserve the space first, then map otherwise map will go right over some |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
800 |
// other reserved memory (like the code cache). |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
801 |
ReservedSpace rs(size, os::vm_allocation_granularity(), false, requested_addr); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
802 |
if (!rs.is_reserved()) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32589
diff
changeset
|
803 |
fail_continue("Unable to reserve shared space at required address " |
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32589
diff
changeset
|
804 |
INTPTR_FORMAT, p2i(requested_addr)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
805 |
return rs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
806 |
} |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13728
diff
changeset
|
807 |
// the reserved virtual memory is for mapping class data sharing archive |
15100
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
808 |
MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared); |
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
809 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
810 |
return rs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
811 |
} |
1 | 812 |
|
813 |
// Memory map a region in the address space. |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
814 |
static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData", |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
815 |
"String1", "String2", "OpenArchive1", "OpenArchive2" }; |
1 | 816 |
|
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
817 |
char* FileMapInfo::map_region(int i, char** top_ret) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
818 |
assert(!MetaspaceShared::is_heap_region(i), "sanity"); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
819 |
CDSFileMapRegion* si = space_at(i); |
1 | 820 |
size_t used = si->_used; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
821 |
size_t alignment = os::vm_allocation_granularity(); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
822 |
size_t size = align_up(used, alignment); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
823 |
char *requested_addr = region_addr(i); |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
824 |
|
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
825 |
// If a tool agent is in use (debugging enabled), we must map the address space RW |
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
826 |
if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) { |
31375
aa5ecd9a5716
8087153: EXCEPTION_ACCESS_VIOLATION when CDS RO section vanished on win32
cjplummer
parents:
31364
diff
changeset
|
827 |
si->_read_only = false; |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
828 |
} |
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
829 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
830 |
// map the contents of the CDS archive in this memory |
1 | 831 |
char *base = os::map_memory(_fd, _full_path, si->_file_offset, |
31375
aa5ecd9a5716
8087153: EXCEPTION_ACCESS_VIOLATION when CDS RO section vanished on win32
cjplummer
parents:
31364
diff
changeset
|
832 |
requested_addr, size, si->_read_only, |
1 | 833 |
si->_allow_exec); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
834 |
if (base == NULL || base != requested_addr) { |
26296 | 835 |
fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]); |
1 | 836 |
return NULL; |
837 |
} |
|
15100
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
838 |
#ifdef _WINDOWS |
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
839 |
// This call is Windows-only because the memory_type gets recorded for the other platforms |
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
840 |
// in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. |
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
841 |
MemTracker::record_virtual_memory_type((address)base, mtClassShared); |
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
842 |
#endif |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
843 |
|
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
844 |
|
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
845 |
if (!verify_region_checksum(i)) { |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
846 |
return NULL; |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
847 |
} |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
848 |
|
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
849 |
*top_ret = base + size; |
1 | 850 |
return base; |
851 |
} |
|
852 |
||
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
853 |
address FileMapInfo::decode_start_address(CDSFileMapRegion* spc, bool with_current_oop_encoding_mode) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
854 |
if (with_current_oop_encoding_mode) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
855 |
return (address)CompressedOops::decode_not_null(offset_of_space(spc)); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
856 |
} else { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
857 |
return (address)HeapShared::decode_with_archived_oop_encoding_mode(offset_of_space(spc)); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
858 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
859 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
860 |
|
31360
87d3a62c7e35
8098815: Assertion failure in CDS shared string archive support on Windows
iklam
parents:
31345
diff
changeset
|
861 |
static MemRegion *string_ranges = NULL; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
862 |
static MemRegion *open_archive_heap_ranges = NULL; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
863 |
static int num_string_ranges = 0; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
864 |
static int num_open_archive_heap_ranges = 0; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
865 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
866 |
#if INCLUDE_CDS_JAVA_HEAP |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
867 |
bool FileMapInfo::has_heap_regions() { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
868 |
return (_header->_space[MetaspaceShared::first_string]._used > 0); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
869 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
870 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
871 |
// Returns the address range of the archived heap regions computed using the |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
872 |
// current oop encoding mode. This range may be different than the one seen at |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
873 |
// dump time due to encoding mode differences. The result is used in determining |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
874 |
// if/how these regions should be relocated at run time. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
875 |
MemRegion FileMapInfo::get_heap_regions_range_with_current_oop_encoding_mode() { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
876 |
address start = (address) max_uintx; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
877 |
address end = NULL; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
878 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
879 |
for (int i = MetaspaceShared::first_string; i <= MetaspaceShared::last_valid_region; i++) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
880 |
CDSFileMapRegion* si = space_at(i); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
881 |
size_t size = si->_used; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
882 |
if (size > 0) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
883 |
address s = start_address_with_current_oop_encoding_mode(si); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
884 |
address e = s + size; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
885 |
if (start > s) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
886 |
start = s; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
887 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
888 |
if (end < e) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
889 |
end = e; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
890 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
891 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
892 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
893 |
assert(end != NULL, "must have at least one used heap region"); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
894 |
return MemRegion((HeapWord*)start, (HeapWord*)end); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
895 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
896 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
897 |
// |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
898 |
// Map the shared string objects and open archive heap objects to the runtime |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
899 |
// java heap. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
900 |
// |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
901 |
// The shared strings are mapped close to the end of the java heap top in |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
902 |
// closed archive regions. The mapped strings contain no out-going references |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
903 |
// to any other java heap regions. GC does not write into the mapped shared strings. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
904 |
// |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
905 |
// The open archive heap objects are mapped below the shared strings in |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
906 |
// the runtime java heap. The mapped open archive heap data only contain |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
907 |
// references to the shared strings and open archive objects initially. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
908 |
// During runtime execution, out-going references to any other java heap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
909 |
// regions may be added. GC may mark and update references in the mapped |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
910 |
// open archive objects. |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
911 |
void FileMapInfo::map_heap_regions_impl() { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
912 |
if (!MetaspaceShared::is_heap_object_archiving_allowed()) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
913 |
log_info(cds)("CDS heap data is being ignored. UseG1GC, " |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
914 |
"UseCompressedOops and UseCompressedClassPointers are required."); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
915 |
return; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
916 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
917 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
918 |
MemRegion heap_reserved = Universe::heap()->reserved_region(); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
919 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
920 |
log_info(cds)("CDS archive was created with max heap size = " SIZE_FORMAT "M, and the following configuration:", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
921 |
max_heap_size()/M); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
922 |
log_info(cds)(" narrow_klass_base = " PTR_FORMAT ", narrow_klass_shift = %d", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
923 |
p2i(narrow_klass_base()), narrow_klass_shift()); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
924 |
log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
925 |
narrow_oop_mode(), p2i(narrow_oop_base()), narrow_oop_shift()); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
926 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
927 |
log_info(cds)("The current max heap size = " SIZE_FORMAT "M, HeapRegion::GrainBytes = " SIZE_FORMAT, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
928 |
heap_reserved.byte_size()/M, HeapRegion::GrainBytes); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
929 |
log_info(cds)(" narrow_klass_base = " PTR_FORMAT ", narrow_klass_shift = %d", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
930 |
p2i(Universe::narrow_klass_base()), Universe::narrow_klass_shift()); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
931 |
log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
932 |
Universe::narrow_oop_mode(), p2i(Universe::narrow_oop_base()), Universe::narrow_oop_shift()); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
933 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
934 |
if (narrow_klass_base() != Universe::narrow_klass_base() || |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
935 |
narrow_klass_shift() != Universe::narrow_klass_shift()) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
936 |
log_info(cds)("CDS heap data cannot be used because the archive was created with an incompatible narrow klass encoding mode."); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
937 |
return; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
938 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
939 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
940 |
if (narrow_oop_mode() != Universe::narrow_oop_mode() || |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
941 |
narrow_oop_base() != Universe::narrow_oop_base() || |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
942 |
narrow_oop_shift() != Universe::narrow_oop_shift()) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
943 |
log_info(cds)("CDS heap data need to be relocated because the archive was created with an incompatible oop encoding mode."); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
944 |
_heap_pointers_need_patching = true; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
945 |
} else { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
946 |
MemRegion range = get_heap_regions_range_with_current_oop_encoding_mode(); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
947 |
if (!heap_reserved.contains(range)) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
948 |
log_info(cds)("CDS heap data need to be relocated because"); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
949 |
log_info(cds)("the desired range " PTR_FORMAT " - " PTR_FORMAT, p2i(range.start()), p2i(range.end())); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
950 |
log_info(cds)("is outside of the heap " PTR_FORMAT " - " PTR_FORMAT, p2i(heap_reserved.start()), p2i(heap_reserved.end())); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
951 |
_heap_pointers_need_patching = true; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
952 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
953 |
} |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47216
diff
changeset
|
954 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
955 |
ptrdiff_t delta = 0; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
956 |
if (_heap_pointers_need_patching) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
957 |
// dumptime heap end ------------v |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
958 |
// [ |archived heap regions| ] runtime heap end ------v |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
959 |
// [ |archived heap regions| ] |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
960 |
// |<-----delta-------------------->| |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
961 |
// |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
962 |
// At dump time, the archived heap regions were near the top of the heap. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
963 |
// At run time, they may not be inside the heap, so we move them so |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
964 |
// that they are now near the top of the runtime time. This can be done by |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
965 |
// the simple math of adding the delta as shown above. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
966 |
address dumptime_heap_end = (address)_header->_heap_reserved.end(); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
967 |
address runtime_heap_end = (address)heap_reserved.end(); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
968 |
delta = runtime_heap_end - dumptime_heap_end; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
969 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
970 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
971 |
log_info(cds)("CDS heap data relocation delta = " INTX_FORMAT " bytes", delta); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
972 |
HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift()); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
973 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
974 |
CDSFileMapRegion* si = space_at(MetaspaceShared::first_string); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
975 |
address relocated_strings_bottom = start_address_with_archived_oop_encoding_mode(si); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
976 |
if (!is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes)) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
977 |
// Align the bottom of the string regions at G1 region boundary. This will avoid |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
978 |
// the situation where the highest open region and the lowest string region sharing |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
979 |
// the same G1 region. Otherwise we will fail to map the open regions. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
980 |
size_t align = size_t(relocated_strings_bottom) % HeapRegion::GrainBytes; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
981 |
delta -= align; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
982 |
assert(is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes), "must be"); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
983 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
984 |
log_info(cds)("CDS heap data need to be relocated lower by a further " SIZE_FORMAT |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
985 |
" bytes to be aligned with HeapRegion::GrainBytes", align); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
986 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
987 |
HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift()); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
988 |
_heap_pointers_need_patching = true; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
989 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
990 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
991 |
// First, map string regions as closed archive heap regions. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
992 |
// GC does not write into the regions. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
993 |
if (map_heap_data(&string_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
994 |
MetaspaceShared::first_string, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
995 |
MetaspaceShared::max_strings, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
996 |
&num_string_ranges)) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
997 |
StringTable::set_shared_string_mapped(); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
998 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
999 |
// Now, map open_archive heap regions, GC can write into the regions. |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1000 |
if (map_heap_data(&open_archive_heap_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1001 |
MetaspaceShared::first_open_archive_heap_region, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1002 |
MetaspaceShared::max_open_archive_heap_region, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1003 |
&num_open_archive_heap_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1004 |
true /* open */)) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1005 |
MetaspaceShared::set_open_archive_heap_region_mapped(); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1006 |
} |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1007 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1008 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1009 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1010 |
void FileMapInfo::map_heap_regions() { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1011 |
if (has_heap_regions()) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1012 |
map_heap_regions_impl(); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1013 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1014 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1015 |
if (!StringTable::shared_string_mapped()) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1016 |
assert(string_ranges == NULL && num_string_ranges == 0, "sanity"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1017 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1018 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1019 |
if (!MetaspaceShared::open_archive_heap_region_mapped()) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1020 |
assert(open_archive_heap_ranges == NULL && num_open_archive_heap_ranges == 0, "sanity"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1021 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1022 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1023 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1024 |
bool FileMapInfo::map_heap_data(MemRegion **heap_mem, int first, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1025 |
int max, int* num, bool is_open_archive) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1026 |
MemRegion * regions = new MemRegion[max]; |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1027 |
CDSFileMapRegion* si; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1028 |
int region_num = 0; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1029 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1030 |
for (int i = first; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1031 |
i < first + max; i++) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1032 |
si = space_at(i); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1033 |
size_t size = si->_used; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1034 |
if (size > 0) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1035 |
HeapWord* start = (HeapWord*)start_address_with_archived_oop_encoding_mode(si); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1036 |
regions[region_num] = MemRegion(start, size / HeapWordSize); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1037 |
region_num ++; |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1038 |
log_info(cds)("Trying to map heap data: region[%d] at " INTPTR_FORMAT ", size = " SIZE_FORMAT_W(8) " bytes", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1039 |
i, p2i(start), size); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1040 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1041 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1042 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1043 |
if (region_num == 0) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1044 |
return false; // no archived java heap data |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1045 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1046 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1047 |
// Check that ranges are within the java heap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1048 |
if (!G1CollectedHeap::heap()->check_archive_addresses(regions, region_num)) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1049 |
log_info(cds)("UseSharedSpaces: Unable to allocate region, range is not within java heap."); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1050 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1051 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1052 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1053 |
// allocate from java heap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1054 |
if (!G1CollectedHeap::heap()->alloc_archive_regions( |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1055 |
regions, region_num, is_open_archive)) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1056 |
log_info(cds)("UseSharedSpaces: Unable to allocate region, java heap range is already in use."); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1057 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1058 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1059 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1060 |
// Map the archived heap data. No need to call MemTracker::record_virtual_memory_type() |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1061 |
// for mapped regions as they are part of the reserved java heap, which is |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1062 |
// already recorded. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1063 |
for (int i = 0; i < region_num; i++) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1064 |
si = space_at(first + i); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1065 |
char* addr = (char*)regions[i].start(); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1066 |
char* base = os::map_memory(_fd, _full_path, si->_file_offset, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1067 |
addr, regions[i].byte_size(), si->_read_only, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1068 |
si->_allow_exec); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1069 |
if (base == NULL || base != addr) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1070 |
// dealloc the regions from java heap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1071 |
dealloc_archive_heap_regions(regions, region_num); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1072 |
log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. " |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1073 |
INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes", |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1074 |
p2i(addr), regions[i].byte_size()); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1075 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1076 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1077 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1078 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1079 |
if (!verify_mapped_heap_regions(first, region_num)) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1080 |
// dealloc the regions from java heap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1081 |
dealloc_archive_heap_regions(regions, region_num); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1082 |
log_info(cds)("UseSharedSpaces: mapped heap regions are corrupt"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1083 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1084 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1085 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1086 |
// the shared heap data is mapped successfully |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1087 |
*heap_mem = regions; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1088 |
*num = region_num; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1089 |
return true; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1090 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1091 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1092 |
bool FileMapInfo::verify_mapped_heap_regions(int first, int num) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1093 |
for (int i = first; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1094 |
i <= first + num; i++) { |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1095 |
if (!verify_region_checksum(i)) { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1096 |
return false; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1097 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1098 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1099 |
return true; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1100 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1101 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1102 |
void FileMapInfo::patch_archived_heap_embedded_pointers() { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1103 |
if (!_heap_pointers_need_patching) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1104 |
return; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1105 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1106 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1107 |
patch_archived_heap_embedded_pointers(string_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1108 |
num_string_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1109 |
MetaspaceShared::first_string); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1110 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1111 |
patch_archived_heap_embedded_pointers(open_archive_heap_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1112 |
num_open_archive_heap_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1113 |
MetaspaceShared::first_open_archive_heap_region); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1114 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1115 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1116 |
void FileMapInfo::patch_archived_heap_embedded_pointers(MemRegion* ranges, int num_ranges, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1117 |
int first_region_idx) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1118 |
for (int i=0; i<num_ranges; i++) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1119 |
CDSFileMapRegion* si = space_at(i + first_region_idx); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1120 |
HeapShared::patch_archived_heap_embedded_pointers(ranges[i], (address)si->_oopmap, |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1121 |
si->_oopmap_size_in_bits); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1122 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1123 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1124 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1125 |
// This internally allocates objects using SystemDictionary::Object_klass(), so it |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1126 |
// must be called after the well-known classes are resolved. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1127 |
void FileMapInfo::fixup_mapped_heap_regions() { |
31360
87d3a62c7e35
8098815: Assertion failure in CDS shared string archive support on Windows
iklam
parents:
31345
diff
changeset
|
1128 |
// If any string regions were found, call the fill routine to make them parseable. |
87d3a62c7e35
8098815: Assertion failure in CDS shared string archive support on Windows
iklam
parents:
31345
diff
changeset
|
1129 |
// Note that string_ranges may be non-NULL even if no ranges were found. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1130 |
if (num_string_ranges != 0) { |
31360
87d3a62c7e35
8098815: Assertion failure in CDS shared string archive support on Windows
iklam
parents:
31345
diff
changeset
|
1131 |
assert(string_ranges != NULL, "Null string_ranges array with non-zero count"); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1132 |
G1CollectedHeap::heap()->fill_archive_regions(string_ranges, num_string_ranges); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1133 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1134 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1135 |
// do the same for mapped open archive heap regions |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1136 |
if (num_open_archive_heap_ranges != 0) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1137 |
assert(open_archive_heap_ranges != NULL, "NULL open_archive_heap_ranges array with non-zero count"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1138 |
G1CollectedHeap::heap()->fill_archive_regions(open_archive_heap_ranges, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1139 |
num_open_archive_heap_ranges); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1140 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1141 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1142 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1143 |
// dealloc the archive regions from java heap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1144 |
void FileMapInfo::dealloc_archive_heap_regions(MemRegion* regions, int num) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1145 |
if (num > 0) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1146 |
assert(regions != NULL, "Null archive ranges array with non-zero count"); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1147 |
G1CollectedHeap::heap()->dealloc_archive_regions(regions, num); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1148 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1149 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1150 |
#endif // INCLUDE_CDS_JAVA_HEAP |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1151 |
|
27025 | 1152 |
bool FileMapInfo::verify_region_checksum(int i) { |
1153 |
if (!VerifySharedSpaces) { |
|
1154 |
return true; |
|
1155 |
} |
|
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1156 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1157 |
size_t sz = space_at(i)->_used; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1158 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1159 |
if (sz == 0) { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1160 |
return true; // no data |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1161 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1162 |
if ((MetaspaceShared::is_string_region(i) && |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1163 |
!StringTable::shared_string_mapped()) || |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1164 |
(MetaspaceShared::is_open_archive_heap_region(i) && |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1165 |
!MetaspaceShared::open_archive_heap_region_mapped())) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1166 |
return true; // archived heap data is not mapped |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1167 |
} |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1168 |
const char* buf = region_addr(i); |
27025 | 1169 |
int crc = ClassLoader::crc32(0, buf, (jint)sz); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1170 |
if (crc != space_at(i)->_crc) { |
27025 | 1171 |
fail_continue("Checksum verification failed."); |
1172 |
return false; |
|
1173 |
} |
|
1174 |
return true; |
|
1175 |
} |
|
1 | 1176 |
|
1177 |
// Unmap a memory region in the address space. |
|
1178 |
||
1179 |
void FileMapInfo::unmap_region(int i) { |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1180 |
assert(!MetaspaceShared::is_heap_region(i), "sanity"); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1181 |
CDSFileMapRegion* si = space_at(i); |
1 | 1182 |
size_t used = si->_used; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
1183 |
size_t size = align_up(used, os::vm_allocation_granularity()); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1184 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1185 |
if (used == 0) { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1186 |
return; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1187 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1188 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1189 |
char* addr = region_addr(i); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1190 |
if (!os::unmap_memory(addr, size)) { |
1 | 1191 |
fail_stop("Unable to unmap shared space."); |
1192 |
} |
|
1193 |
} |
|
1194 |
||
1195 |
void FileMapInfo::assert_mark(bool check) { |
|
1196 |
if (!check) { |
|
26296 | 1197 |
fail_stop("Mark mismatch while restoring from shared file."); |
1 | 1198 |
} |
1199 |
} |
|
1200 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1201 |
void FileMapInfo::metaspace_pointers_do(MetaspaceClosure* it) { |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1202 |
it->push(&_shared_path_table); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1203 |
for (int i=0; i<_shared_path_table_size; i++) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1204 |
shared_path(i)->metaspace_pointers_do(it); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1205 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1206 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1207 |
|
1 | 1208 |
|
1209 |
FileMapInfo* FileMapInfo::_current_info = NULL; |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1210 |
bool FileMapInfo::_heap_pointers_need_patching = false; |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1211 |
Array<u8>* FileMapInfo::_shared_path_table = NULL; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1212 |
int FileMapInfo::_shared_path_table_size = 0; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1213 |
size_t FileMapInfo::_shared_path_entry_size = 0x1234baad; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1214 |
bool FileMapInfo::_validating_shared_path_table = false; |
1 | 1215 |
|
1216 |
// Open the shared archive file, read and validate the header |
|
1217 |
// information (version, boot classpath, etc.). If initialization |
|
1218 |
// fails, shared spaces are disabled and the file is closed. [See |
|
1219 |
// fail_continue.] |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1220 |
// |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1221 |
// Validation of the archive is done in two steps: |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1222 |
// |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1223 |
// [1] validate_header() - done here. This checks the header, including _paths_misc_info. |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1224 |
// [2] validate_shared_path_table - this is done later, because the table is in the RW |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1225 |
// region of the archive, which is not mapped yet. |
1 | 1226 |
bool FileMapInfo::initialize() { |
1227 |
assert(UseSharedSpaces, "UseSharedSpaces expected."); |
|
1228 |
||
1229 |
if (!open_for_read()) { |
|
1230 |
return false; |
|
1231 |
} |
|
1232 |
||
1233 |
init_from_file(_fd); |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1234 |
if (!validate_header()) { |
1 | 1235 |
return false; |
1236 |
} |
|
1237 |
return true; |
|
1238 |
} |
|
1239 |
||
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1240 |
char* FileMapInfo::region_addr(int idx) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1241 |
CDSFileMapRegion* si = space_at(idx); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1242 |
if (MetaspaceShared::is_heap_region(idx)) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1243 |
assert(DumpSharedSpaces, "The following doesn't work at runtime"); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1244 |
return si->_used > 0 ? |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1245 |
(char*)start_address_with_current_oop_encoding_mode(si) : NULL; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1246 |
} else { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1247 |
return si->_addr._base; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1248 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1249 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1250 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1251 |
int FileMapHeader::compute_crc() { |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1252 |
char* start = (char*)this; |
27025 | 1253 |
// start computing from the field after _crc |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1254 |
char* buf = (char*)&_crc + sizeof(_crc); |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1255 |
size_t sz = sizeof(FileMapHeader) - (buf - start); |
27025 | 1256 |
int crc = ClassLoader::crc32(0, buf, (jint)sz); |
1257 |
return crc; |
|
1258 |
} |
|
1259 |
||
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1260 |
// This function should only be called during run time with UseSharedSpaces enabled. |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1261 |
bool FileMapHeader::validate() { |
27025 | 1262 |
if (VerifySharedSpaces && compute_crc() != _crc) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1263 |
FileMapInfo::fail_continue("Header checksum verification failed."); |
27025 | 1264 |
return false; |
1265 |
} |
|
1266 |
||
40013 | 1267 |
if (!Arguments::has_jimage()) { |
1268 |
FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build."); |
|
1269 |
return false; |
|
1270 |
} |
|
1271 |
||
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1272 |
if (_version != CURRENT_CDS_ARCHIVE_VERSION) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1273 |
FileMapInfo::fail_continue("The shared archive file is the wrong version."); |
1 | 1274 |
return false; |
1275 |
} |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1276 |
if (_magic != CDS_ARCHIVE_MAGIC) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1277 |
FileMapInfo::fail_continue("The shared archive file has a bad magic number."); |
1 | 1278 |
return false; |
1279 |
} |
|
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
1280 |
char header_version[JVM_IDENT_MAX]; |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
1281 |
get_header_version(header_version); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1282 |
if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
38108
diff
changeset
|
1283 |
log_info(class, path)("expected: %s", header_version); |
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
38108
diff
changeset
|
1284 |
log_info(class, path)("actual: %s", _jvm_ident); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1285 |
FileMapInfo::fail_continue("The shared archive file was created by a different" |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1286 |
" version or build of HotSpot"); |
1 | 1287 |
return false; |
1288 |
} |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1289 |
if (_obj_alignment != ObjectAlignmentInBytes) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1290 |
FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d" |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
32589
diff
changeset
|
1291 |
" does not equal the current ObjectAlignmentInBytes of " INTX_FORMAT ".", |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1292 |
_obj_alignment, ObjectAlignmentInBytes); |
1 | 1293 |
return false; |
1294 |
} |
|
33628 | 1295 |
if (_compact_strings != CompactStrings) { |
1296 |
FileMapInfo::fail_continue("The shared archive file's CompactStrings setting (%s)" |
|
1297 |
" does not equal the current CompactStrings setting (%s).", |
|
1298 |
_compact_strings ? "enabled" : "disabled", |
|
1299 |
CompactStrings ? "enabled" : "disabled"); |
|
1300 |
return false; |
|
1301 |
} |
|
1 | 1302 |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1303 |
// This must be done after header validation because it might change the |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1304 |
// header data |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1305 |
const char* prop = Arguments::get_property("java.system.class.loader"); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1306 |
if (prop != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1307 |
warning("Archived non-system classes are disabled because the " |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1308 |
"java.system.class.loader property is specified (value = \"%s\"). " |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1309 |
"To use archived non-system classes, this property must be not be set", prop); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1310 |
_has_platform_or_app_classes = false; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1311 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1312 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1313 |
// For backwards compatibility, we don't check the verification setting |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1314 |
// if the archive only contains system classes. |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1315 |
if (_has_platform_or_app_classes && |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1316 |
((!_verify_local && BytecodeVerificationLocal) || |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1317 |
(!_verify_remote && BytecodeVerificationRemote))) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1318 |
FileMapInfo::fail_continue("The shared archive file was created with less restrictive " |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1319 |
"verification setting than the current setting."); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1320 |
return false; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1321 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1322 |
|
1 | 1323 |
return true; |
1324 |
} |
|
1325 |
||
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1326 |
bool FileMapInfo::validate_header() { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1327 |
bool status = _header->validate(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1328 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1329 |
if (status) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1330 |
if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1331 |
if (!PrintSharedArchiveAndExit) { |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
38108
diff
changeset
|
1332 |
fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)"); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1333 |
status = false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1334 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1335 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1336 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1337 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1338 |
if (_paths_misc_info != NULL) { |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27025
diff
changeset
|
1339 |
FREE_C_HEAP_ARRAY(char, _paths_misc_info); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1340 |
_paths_misc_info = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1341 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1342 |
return status; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1343 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1344 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1345 |
// Check if a given address is within one of the shared regions |
37439
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1346 |
bool FileMapInfo::is_in_shared_region(const void* p, int idx) { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1347 |
assert(idx == MetaspaceShared::ro || |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1348 |
idx == MetaspaceShared::rw || |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1349 |
idx == MetaspaceShared::mc || |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1350 |
idx == MetaspaceShared::md, "invalid region index"); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1351 |
char* base = region_addr(idx); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1352 |
if (p >= base && p < base + space_at(idx)->_used) { |
37439
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1353 |
return true; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1354 |
} |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1355 |
return false; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1356 |
} |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1357 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1358 |
// Unmap mapped regions of shared space. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1359 |
void FileMapInfo::stop_sharing_and_unmap(const char* msg) { |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1360 |
FileMapInfo *map_info = FileMapInfo::current_info(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1361 |
if (map_info) { |
26296 | 1362 |
map_info->fail_continue("%s", msg); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1363 |
for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1364 |
if (!MetaspaceShared::is_heap_region(i)) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1365 |
char *addr = map_info->region_addr(i); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1366 |
if (addr != NULL) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1367 |
map_info->unmap_region(i); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1368 |
map_info->space_at(i)->_addr._base = NULL; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1369 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1370 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1371 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1372 |
// Dealloc the archive heap regions only without unmapping. The regions are part |
32589
f86fb16fcab0
8131734: assert(!is_null(v)) failed: narrow klass value can never be zero with -Xshared:auto
jiangli
parents:
31375
diff
changeset
|
1373 |
// of the java heap. Unmapping of the heap regions are managed by GC. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1374 |
map_info->dealloc_archive_heap_regions(open_archive_heap_ranges, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1375 |
num_open_archive_heap_ranges); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1376 |
map_info->dealloc_archive_heap_regions(string_ranges, num_string_ranges); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1377 |
} else if (DumpSharedSpaces) { |
26296 | 1378 |
fail_stop("%s", msg); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1379 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1380 |
} |