author | ccheung |
Fri, 12 Jul 2019 08:40:37 -0700 | |
changeset 55694 | 7b7df2be6219 |
parent 55296 | 357c9dcb6eb9 |
child 55717 | 2b4e14968afd |
child 57579 | 1edf6cc224fb |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, 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" |
54340
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
27 |
#include "classfile/classFileStream.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
48962
diff
changeset
|
28 |
#include "classfile/classLoader.inline.hpp" |
54340
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
29 |
#include "classfile/classLoaderData.inline.hpp" |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
30 |
#include "classfile/classLoaderExt.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" |
54927 | 37 |
#include "memory/dynamicArchive.hpp" |
7397 | 38 |
#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
|
39 |
#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
|
40 |
#include "memory/iterator.inline.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
41 |
#include "memory/metadataFactory.hpp" |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
42 |
#include "memory/metaspaceClosure.hpp" |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
43 |
#include "memory/metaspaceShared.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
44 |
#include "memory/oopFactory.hpp" |
54825 | 45 |
#include "memory/universe.hpp" |
54927 | 46 |
#include "oops/compressedOops.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
47 |
#include "oops/compressedOops.inline.hpp" |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
48 |
#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
|
49 |
#include "oops/oop.inline.hpp" |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
50 |
#include "prims/jvmtiExport.hpp" |
7397 | 51 |
#include "runtime/arguments.hpp" |
52 |
#include "runtime/java.hpp" |
|
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
53 |
#include "runtime/mutexLocker.hpp" |
51480
2e928420389d
8209826: Undefined reference to os::write after JDK-8209657 (filemap.hpp cleanup)
iklam
parents:
51477
diff
changeset
|
54 |
#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
|
55 |
#include "runtime/vm_version.hpp" |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13728
diff
changeset
|
56 |
#include "services/memTracker.hpp" |
46625 | 57 |
#include "utilities/align.hpp" |
7397 | 58 |
#include "utilities/defaultStream.hpp" |
49982 | 59 |
#if INCLUDE_G1GC |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
60 |
#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
|
61 |
#include "gc/g1/heapRegion.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49340
diff
changeset
|
62 |
#endif |
7397 | 63 |
|
1 | 64 |
# include <sys/stat.h> |
65 |
# include <errno.h> |
|
66 |
||
67 |
#ifndef O_BINARY // if defined (Win32) use binary files. |
|
68 |
#define O_BINARY 0 // otherwise do nothing. |
|
69 |
#endif |
|
70 |
||
71 |
extern address JVM_FunctionAtStart(); |
|
72 |
extern address JVM_FunctionAtEnd(); |
|
73 |
||
2131 | 74 |
// Complain and stop. All error conditions occurring during the writing of |
1 | 75 |
// an archive file should stop the process. Unrecoverable errors during |
76 |
// the reading of the archive file should stop the process. |
|
77 |
||
78 |
static void fail(const char *msg, va_list ap) { |
|
79 |
// This occurs very early during initialization: tty is not initialized. |
|
80 |
jio_fprintf(defaultStream::error_stream(), |
|
2131 | 81 |
"An error has occurred while processing the" |
1 | 82 |
" shared archive file.\n"); |
83 |
jio_vfprintf(defaultStream::error_stream(), msg, ap); |
|
84 |
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
|
85 |
// Do not change the text of the below message because some tests check for it. |
1 | 86 |
vm_exit_during_initialization("Unable to use shared archive.", NULL); |
87 |
} |
|
88 |
||
89 |
||
90 |
void FileMapInfo::fail_stop(const char *msg, ...) { |
|
91 |
va_list ap; |
|
92 |
va_start(ap, msg); |
|
93 |
fail(msg, ap); // Never returns. |
|
94 |
va_end(ap); // for completeness. |
|
95 |
} |
|
96 |
||
97 |
||
98 |
// Complain and continue. Recoverable errors during the reading of the |
|
99 |
// archive file may continue (with sharing disabled). |
|
100 |
// |
|
101 |
// If we continue, then disable shared spaces and close the file. |
|
102 |
||
103 |
void FileMapInfo::fail_continue(const char *msg, ...) { |
|
104 |
va_list ap; |
|
105 |
va_start(ap, msg); |
|
54927 | 106 |
if (_dynamic_archive_info == NULL) { |
107 |
MetaspaceShared::set_archive_loading_failed(); |
|
108 |
} else { |
|
109 |
// _dynamic_archive_info has been setup after mapping the base archive |
|
110 |
DynamicArchive::disable(); |
|
111 |
} |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
112 |
if (PrintSharedArchiveAndExit && _validating_shared_path_table) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
113 |
// 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
|
114 |
// 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
|
115 |
// entries. No need to quit. |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
116 |
tty->print("["); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
117 |
tty->vprint(msg, ap); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
118 |
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
|
119 |
} else { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
120 |
if (RequireSharedSpaces) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
121 |
fail(msg, ap); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
122 |
} else { |
46522
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
123 |
if (log_is_enabled(Info, cds)) { |
86b13b03a053
8176132: -XX:+PrintSharedSpaces should be converted to use Unified Logging.
rprotacio
parents:
42876
diff
changeset
|
124 |
ResourceMark rm; |
46701
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
125 |
LogStream ls(Log(cds)::info()); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
126 |
ls.print("UseSharedSpaces: "); |
f559541c0daa
8181917: Refactor UL LogStreams to avoid using resource area
stuefe
parents:
46630
diff
changeset
|
127 |
ls.vprint_cr(msg, ap); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
128 |
} |
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
|
129 |
} |
54927 | 130 |
if (_dynamic_archive_info == NULL) { |
131 |
UseSharedSpaces = false; |
|
132 |
assert(current_info() != NULL, "singleton must be registered"); |
|
133 |
current_info()->close(); |
|
134 |
} else { |
|
135 |
// We are failing when loading the top archive, but the base archive should |
|
136 |
// continue to work. |
|
137 |
log_warning(cds, dynamic)("Unable to use shared archive. The top archive failed to load: %s", _dynamic_archive_info->_full_path); |
|
138 |
} |
|
1 | 139 |
} |
140 |
va_end(ap); |
|
141 |
} |
|
142 |
||
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
143 |
// Fill in the fileMapInfo structure with data about this VM instance. |
1 | 144 |
|
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
145 |
// 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
|
146 |
// 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
|
147 |
// |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
148 |
// 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
|
149 |
// 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
|
150 |
// 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
|
151 |
// 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
|
152 |
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
|
153 |
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
|
154 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
|
55694
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
158 |
memset(header_version, 0, JVM_IDENT_MAX); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
159 |
|
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
160 |
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
|
161 |
strcpy(header_version, vm_version); |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
162 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
163 |
} else { |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
164 |
// 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
|
165 |
// value over multiple jvm invocations. |
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
166 |
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
|
167 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
168 |
// 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
|
169 |
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
|
170 |
|
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
171 |
// 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
|
172 |
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
|
173 |
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
|
174 |
} |
55694
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
175 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
176 |
assert(header_version[JVM_IDENT_MAX-1] == 0, "must be"); |
14577
fd68d810d86b
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
14120
diff
changeset
|
177 |
} |
1 | 178 |
|
54927 | 179 |
FileMapInfo::FileMapInfo(bool is_static) { |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46625
diff
changeset
|
180 |
memset((void*)this, 0, sizeof(FileMapInfo)); |
54927 | 181 |
_is_static = is_static; |
182 |
size_t header_size; |
|
183 |
if (is_static) { |
|
184 |
assert(_current_info == NULL, "must be singleton"); // not thread safe |
|
185 |
_current_info = this; |
|
186 |
header_size = sizeof(FileMapHeader); |
|
187 |
} else { |
|
188 |
assert(_dynamic_archive_info == NULL, "must be singleton"); // not thread safe |
|
189 |
_dynamic_archive_info = this; |
|
190 |
header_size = sizeof(DynamicArchiveHeader); |
|
191 |
} |
|
192 |
_header = (FileMapHeader*)os::malloc(header_size, mtInternal); |
|
193 |
memset((void*)_header, 0, header_size); |
|
194 |
_header->_header_size = header_size; |
|
195 |
_header->_version = INVALID_CDS_ARCHIVE_VERSION; |
|
196 |
_header->_has_platform_or_app_classes = true; |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
197 |
_file_offset = 0; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
198 |
_file_open = false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
199 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
200 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
201 |
FileMapInfo::~FileMapInfo() { |
54927 | 202 |
if (_is_static) { |
203 |
assert(_current_info == this, "must be singleton"); // not thread safe |
|
204 |
_current_info = NULL; |
|
205 |
} else { |
|
206 |
assert(_dynamic_archive_info == this, "must be singleton"); // not thread safe |
|
207 |
_dynamic_archive_info = NULL; |
|
208 |
} |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
209 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
210 |
|
1 | 211 |
void FileMapInfo::populate_header(size_t alignment) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
212 |
_header->populate(this, alignment); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
213 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
214 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
215 |
void FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) { |
54927 | 216 |
if (DynamicDumpSharedSpaces) { |
217 |
_magic = CDS_DYNAMIC_ARCHIVE_MAGIC; |
|
218 |
} else { |
|
219 |
_magic = CDS_ARCHIVE_MAGIC; |
|
220 |
} |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
221 |
_version = CURRENT_CDS_ARCHIVE_VERSION; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
222 |
_alignment = alignment; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
223 |
_obj_alignment = ObjectAlignmentInBytes; |
33628 | 224 |
_compact_strings = CompactStrings; |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
225 |
_narrow_oop_mode = CompressedOops::mode(); |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
226 |
_narrow_oop_base = CompressedOops::base(); |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
227 |
_narrow_oop_shift = CompressedOops::shift(); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
228 |
_max_heap_size = MaxHeapSize; |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
229 |
_narrow_klass_base = CompressedKlassPointers::base(); |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
230 |
_narrow_klass_shift = CompressedKlassPointers::shift(); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
231 |
_shared_path_table = mapinfo->_shared_path_table; |
52062
8dbf1a13af49
8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents:
51823
diff
changeset
|
232 |
if (HeapShared::is_heap_object_archiving_allowed()) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
233 |
_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
|
234 |
} |
1 | 235 |
|
236 |
// The following fields are for sanity checks for whether this archive |
|
237 |
// will function correctly with this JVM and the bootclasspath it's |
|
238 |
// invoked with. |
|
239 |
||
240 |
// JVM version string ... changes on each build. |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
241 |
get_header_version(_jvm_ident); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
242 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
243 |
ClassLoaderExt::finalize_shared_paths_misc_info(); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
244 |
_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
|
245 |
_app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index(); |
54927 | 246 |
_num_module_paths = ClassLoader::num_module_path_entries(); |
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
247 |
_max_used_path_index = ClassLoaderExt::max_used_path_index(); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
248 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
249 |
_verify_local = BytecodeVerificationLocal; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
250 |
_verify_remote = BytecodeVerificationRemote; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
251 |
_has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes(); |
52514
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
252 |
_shared_base_address = SharedBaseAddress; |
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
253 |
_allow_archiving_with_java_agent = AllowArchivingWithJavaAgent; |
54927 | 254 |
// the following 2 fields will be set in write_header for dynamic archive header |
255 |
_base_archive_name_size = 0; |
|
256 |
_base_archive_is_default = false; |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
257 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
258 |
|
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
259 |
void SharedClassPathEntry::init(const char* name, bool is_modules_image, TRAPS) { |
54927 | 260 |
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump time only"); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
261 |
_timestamp = 0; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
262 |
_filesize = 0; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
263 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
264 |
struct stat st; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
265 |
if (os::stat(name, &st) == 0) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
266 |
if ((st.st_mode & S_IFMT) == S_IFDIR) { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
267 |
_type = dir_entry; |
40013 | 268 |
} else { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
269 |
// 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
|
270 |
if (is_modules_image) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
271 |
_type = modules_image_entry; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
272 |
} else { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
273 |
_type = jar_entry; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
274 |
_timestamp = st.st_mtime; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
275 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
276 |
_filesize = st.st_size; |
40013 | 277 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
278 |
} else { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
279 |
// 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
|
280 |
// into ClassLoader::classpath_entry(). |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
281 |
// |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
282 |
// 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
|
283 |
// make assumptions about where classes get loaded from. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
284 |
FileMapInfo::fail_stop("Unable to open file %s.", name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
285 |
} |
40013 | 286 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
287 |
size_t len = strlen(name) + 1; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
288 |
_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
|
289 |
strcpy(_name->data(), name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
290 |
} |
1 | 291 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
292 |
bool SharedClassPathEntry::validate(bool is_class_path) { |
49931 | 293 |
assert(UseSharedSpaces, "runtime only"); |
294 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
295 |
struct stat st; |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
296 |
const char* name; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
297 |
|
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
298 |
// 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
|
299 |
// 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
|
300 |
// 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
|
301 |
// 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
|
302 |
if (is_modules_image()) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
303 |
name = ClassLoader::get_jrt_entry()->name(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
304 |
} else { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
305 |
name = this->name(); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
306 |
} |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
307 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
308 |
bool ok = true; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
309 |
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
|
310 |
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
|
311 |
// 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
|
312 |
// (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
|
313 |
// 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
|
314 |
// module path location. |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
315 |
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
|
316 |
ok = false; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
317 |
} else if (is_dir()) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
318 |
if (!os::dir_is_empty(name)) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
319 |
FileMapInfo::fail_continue("directory is not empty: %s", name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
320 |
ok = false; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
321 |
} |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
322 |
} else if ((has_timestamp() && _timestamp != st.st_mtime) || |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
323 |
_filesize != st.st_size) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
324 |
ok = false; |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
325 |
if (PrintSharedArchiveAndExit) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
326 |
FileMapInfo::fail_continue(_timestamp != st.st_mtime ? |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
327 |
"Timestamp mismatch" : |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
328 |
"File size mismatch"); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
329 |
} else { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
330 |
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
|
331 |
" the shared archive file: %s", name); |
1 | 332 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
333 |
} |
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
334 |
|
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
335 |
if (PrintSharedArchiveAndExit && !ok) { |
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
336 |
// If PrintSharedArchiveAndExit is enabled, don't report failure to the |
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
337 |
// caller. Please see above comments for more details. |
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
338 |
ok = true; |
54927 | 339 |
MetaspaceShared::set_archive_loading_failed(); |
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
340 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
341 |
return ok; |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
342 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
343 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
344 |
void SharedClassPathEntry::metaspace_pointers_do(MetaspaceClosure* it) { |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
345 |
it->push(&_name); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
346 |
it->push(&_manifest); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
347 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
348 |
|
54927 | 349 |
void SharedPathTable::metaspace_pointers_do(MetaspaceClosure* it) { |
350 |
it->push(&_table); |
|
351 |
for (int i=0; i<_size; i++) { |
|
352 |
path_at(i)->metaspace_pointers_do(it); |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
void SharedPathTable::dumptime_init(ClassLoaderData* loader_data, Thread* THREAD) { |
|
357 |
size_t entry_size = sizeof(SharedClassPathEntry); |
|
358 |
int num_boot_classpath_entries = ClassLoader::num_boot_classpath_entries(); |
|
359 |
int num_app_classpath_entries = ClassLoader::num_app_classpath_entries(); |
|
360 |
int num_module_path_entries = ClassLoader::num_module_path_entries(); |
|
361 |
int num_entries = num_boot_classpath_entries + num_app_classpath_entries + num_module_path_entries; |
|
362 |
size_t bytes = entry_size * num_entries; |
|
363 |
||
364 |
_table = MetadataFactory::new_array<u8>(loader_data, (int)(bytes + 7 / 8), THREAD); |
|
365 |
_size = num_entries; |
|
366 |
} |
|
367 |
||
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
368 |
void FileMapInfo::allocate_shared_path_table() { |
54927 | 369 |
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Sanity"); |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
370 |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
371 |
Thread* THREAD = Thread::current(); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
372 |
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
|
373 |
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
|
374 |
|
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
375 |
assert(jrt != NULL, |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
376 |
"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
|
377 |
|
54927 | 378 |
_shared_path_table.dumptime_init(loader_data, THREAD); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
379 |
|
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
380 |
// 1. boot class path |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
381 |
int i = 0; |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
382 |
ClassPathEntry* cpe = jrt; |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
383 |
while (cpe != NULL) { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
384 |
bool is_jrt = (cpe == jrt); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
385 |
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
|
386 |
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
|
387 |
SharedClassPathEntry* ent = shared_path(i); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
388 |
ent->init(cpe->name(), is_jrt, THREAD); |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
389 |
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
|
390 |
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
|
391 |
update_shared_classpath(cpe, ent, THREAD); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
392 |
} |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
393 |
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
|
394 |
i++; |
1 | 395 |
} |
54927 | 396 |
assert(i == ClassLoader::num_boot_classpath_entries(), |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
397 |
"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
|
398 |
|
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
399 |
// 2. app class path |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
400 |
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
|
401 |
while (acpe != NULL) { |
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
402 |
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
|
403 |
SharedClassPathEntry* ent = shared_path(i); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
404 |
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
|
405 |
EXCEPTION_MARK; |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
406 |
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
|
407 |
acpe = acpe->next(); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
408 |
i++; |
47991
a474466c4fdb
8187118: Remove appending -cp path to the boot class path at AppCDS dump time
jiangli
parents:
47765
diff
changeset
|
409 |
} |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
410 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
411 |
// 3. module path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
412 |
ClassPathEntry *mpe = ClassLoader::module_path_entries(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
413 |
while (mpe != NULL) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
414 |
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
|
415 |
SharedClassPathEntry* ent = shared_path(i); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
416 |
ent->init(mpe->name(), false, THREAD); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
417 |
EXCEPTION_MARK; |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
418 |
update_shared_classpath(mpe, ent, THREAD); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
419 |
mpe = mpe->next(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
420 |
i++; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
421 |
} |
54927 | 422 |
assert(i == _shared_path_table.size(), "number of shared path entry mismatch"); |
1 | 423 |
} |
424 |
||
49931 | 425 |
void FileMapInfo::check_nonempty_dir_in_shared_path_table() { |
54927 | 426 |
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump time only"); |
49931 | 427 |
|
428 |
bool has_nonempty_dir = false; |
|
429 |
||
54927 | 430 |
int last = _shared_path_table.size() - 1; |
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
431 |
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
|
432 |
// 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
|
433 |
last = ClassLoaderExt::max_used_path_index(); |
49931 | 434 |
} |
435 |
||
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
436 |
for (int i = 0; i <= last; i++) { |
49931 | 437 |
SharedClassPathEntry *e = shared_path(i); |
438 |
if (e->is_dir()) { |
|
439 |
const char* path = e->name(); |
|
440 |
if (!os::dir_is_empty(path)) { |
|
441 |
tty->print_cr("Error: non-empty directory '%s'", path); |
|
442 |
has_nonempty_dir = true; |
|
443 |
} |
|
444 |
} |
|
445 |
} |
|
446 |
||
447 |
if (has_nonempty_dir) { |
|
448 |
ClassLoader::exit_with_path_failure("Cannot have non-empty directory in paths", NULL); |
|
449 |
} |
|
450 |
} |
|
451 |
||
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
452 |
class ManifestStream: public ResourceObj { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
453 |
private: |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
454 |
u1* _buffer_start; // Buffer bottom |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
455 |
u1* _buffer_end; // Buffer top (one past last element) |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
456 |
u1* _current; // Current buffer position |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
457 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
458 |
public: |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
459 |
// Constructor |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
460 |
ManifestStream(u1* buffer, int length) : _buffer_start(buffer), |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
461 |
_current(buffer) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
462 |
_buffer_end = buffer + length; |
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 |
static bool is_attr(u1* attr, const char* name) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
466 |
return strncmp((const char*)attr, name, strlen(name)) == 0; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
467 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
468 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
469 |
static char* copy_attr(u1* value, size_t len) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
470 |
char* buf = NEW_RESOURCE_ARRAY(char, len + 1); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
471 |
strncpy(buf, (char*)value, len); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
472 |
buf[len] = 0; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
473 |
return buf; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
474 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
475 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
476 |
// 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
|
477 |
bool check_is_signed() { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
478 |
u1* attr = _current; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
479 |
bool isSigned = false; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
480 |
while (_current < _buffer_end) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
481 |
if (*_current == '\n') { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
482 |
*_current = '\0'; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
483 |
u1* value = (u1*)strchr((char*)attr, ':'); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
484 |
if (value != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
485 |
assert(*(value+1) == ' ', "Unrecognized format" ); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
486 |
if (strstr((char*)attr, "-Digest") != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
487 |
isSigned = true; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
488 |
break; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
489 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
490 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
491 |
*_current = '\n'; // restore |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
492 |
attr = _current + 1; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
493 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
494 |
_current ++; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
495 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
496 |
return isSigned; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
497 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
498 |
}; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
499 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
500 |
void FileMapInfo::update_shared_classpath(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
501 |
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
502 |
ResourceMark rm(THREAD); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
503 |
jint manifest_size; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
504 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
505 |
if (cpe->is_jar_file()) { |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
506 |
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
|
507 |
char* manifest = ClassLoaderExt::read_manifest(cpe, &manifest_size, CHECK); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
508 |
if (manifest != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
509 |
ManifestStream* stream = new ManifestStream((u1*)manifest, |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
510 |
manifest_size); |
50199
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
511 |
if (stream->check_is_signed()) { |
83d8b3a25f25
8199807: AppCDS performs overly restrictive path matching check.
jiangli
parents:
50039
diff
changeset
|
512 |
ent->set_is_signed(); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
513 |
} else { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
514 |
// Copy the manifest into the shared archive |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
515 |
manifest = ClassLoaderExt::read_raw_manifest(cpe, &manifest_size, CHECK); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
516 |
Array<u1>* buf = MetadataFactory::new_array<u1>(loader_data, |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
517 |
manifest_size, |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
518 |
THREAD); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
519 |
char* p = (char*)(buf->data()); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
520 |
memcpy(p, manifest, manifest_size); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
521 |
ent->set_manifest(buf); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
522 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
523 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
524 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
525 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
526 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
527 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
528 |
bool FileMapInfo::validate_shared_path_table() { |
49931 | 529 |
assert(UseSharedSpaces, "runtime only"); |
530 |
||
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
531 |
_validating_shared_path_table = true; |
54927 | 532 |
|
533 |
// Load the shared path table info from the archive header |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
534 |
_shared_path_table = _header->_shared_path_table; |
54927 | 535 |
if (DynamicDumpSharedSpaces) { |
536 |
// Only support dynamic dumping with the usage of the default CDS archive |
|
537 |
// or a simple base archive. |
|
538 |
// If the base layer archive contains additional path component besides |
|
539 |
// the runtime image and the -cp, dynamic dumping is disabled. |
|
540 |
// |
|
541 |
// When dynamic archiving is enabled, the _shared_path_table is overwritten |
|
542 |
// to include the application path and stored in the top layer archive. |
|
543 |
assert(shared_path(0)->is_modules_image(), "first shared_path must be the modules image"); |
|
544 |
if (_header->_app_class_paths_start_index > 1) { |
|
545 |
DynamicDumpSharedSpaces = false; |
|
546 |
warning( |
|
547 |
"Dynamic archiving is disabled because base layer archive has appended boot classpath"); |
|
548 |
} |
|
549 |
if (_header->_num_module_paths > 0) { |
|
550 |
DynamicDumpSharedSpaces = false; |
|
551 |
warning( |
|
552 |
"Dynamic archiving is disabled because base layer archive has module path"); |
|
553 |
} |
|
554 |
} |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
555 |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
556 |
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
|
557 |
|
51439
0517bd2a0eda
8209385: CDS runtime classpath checking is too strict when only classes from the system modules are archived
ccheung
parents:
51070
diff
changeset
|
558 |
// 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
|
559 |
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
|
560 |
if (i < module_paths_start_index) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
561 |
if (shared_path(i)->validate()) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
562 |
log_info(class, path)("ok"); |
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
563 |
} else { |
54927 | 564 |
if (_dynamic_archive_info != NULL && _dynamic_archive_info->_is_static) { |
565 |
assert(!UseSharedSpaces, "UseSharedSpaces should be disabled"); |
|
566 |
} |
|
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
567 |
return false; |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
568 |
} |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
569 |
} else if (i >= module_paths_start_index) { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
570 |
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
|
571 |
log_info(class, path)("ok"); |
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
572 |
} else { |
54927 | 573 |
if (_dynamic_archive_info != NULL && _dynamic_archive_info->_is_static) { |
574 |
assert(!UseSharedSpaces, "UseSharedSpaces should be disabled"); |
|
575 |
} |
|
52562
3a9384c12260
8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
jiangli
parents:
52514
diff
changeset
|
576 |
return false; |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
577 |
} |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
578 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
579 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
580 |
|
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
581 |
_validating_shared_path_table = false; |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
582 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
583 |
#if INCLUDE_JVMTI |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
584 |
if (_classpath_entries_for_jvmti != NULL) { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
585 |
os::free(_classpath_entries_for_jvmti); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
586 |
} |
54927 | 587 |
size_t sz = sizeof(ClassPathEntry*) * get_number_of_shared_paths(); |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
588 |
_classpath_entries_for_jvmti = (ClassPathEntry**)os::malloc(sz, mtClass); |
54927 | 589 |
memset((void*)_classpath_entries_for_jvmti, 0, sz); |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
590 |
#endif |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
591 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
592 |
return true; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
593 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
594 |
|
54927 | 595 |
bool FileMapInfo::same_files(const char* file1, const char* file2) { |
596 |
if (strcmp(file1, file2) == 0) { |
|
597 |
return true; |
|
598 |
} |
|
599 |
||
600 |
bool is_same = false; |
|
601 |
// if the two paths diff only in case |
|
602 |
struct stat st1; |
|
603 |
struct stat st2; |
|
604 |
int ret1; |
|
605 |
int ret2; |
|
606 |
ret1 = os::stat(file1, &st1); |
|
607 |
ret2 = os::stat(file2, &st2); |
|
608 |
if (ret1 < 0 || ret2 < 0) { |
|
609 |
// one of the files is invalid. So they are not the same. |
|
610 |
is_same = false; |
|
611 |
} else if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) { |
|
612 |
// different files |
|
613 |
is_same = false; |
|
614 |
#ifndef _WINDOWS |
|
615 |
} else if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) { |
|
616 |
// same files |
|
617 |
is_same = true; |
|
618 |
#else |
|
619 |
} else if ((st1.st_size == st2.st_size) && (st1.st_ctime == st2.st_ctime) && |
|
620 |
(st1.st_mtime == st2.st_mtime)) { |
|
621 |
// same files |
|
622 |
is_same = true; |
|
623 |
#endif |
|
624 |
} |
|
625 |
return is_same; |
|
626 |
} |
|
627 |
||
628 |
bool FileMapInfo::check_archive(const char* archive_name, bool is_static) { |
|
629 |
int fd = os::open(archive_name, O_RDONLY | O_BINARY, 0); |
|
630 |
if (fd < 0) { |
|
631 |
// do not vm_exit_during_initialization here because Arguments::init_shared_archive_paths() |
|
632 |
// requires a shared archive name. The open_for_read() function will log a message regarding |
|
633 |
// failure in opening a shared archive. |
|
634 |
return false; |
|
635 |
} |
|
636 |
||
637 |
size_t sz = is_static ? sizeof(FileMapHeader) : sizeof(DynamicArchiveHeader); |
|
638 |
void* header = os::malloc(sz, mtInternal); |
|
639 |
memset(header, 0, sz); |
|
640 |
size_t n = os::read(fd, header, (unsigned int)sz); |
|
641 |
if (n != sz) { |
|
642 |
os::free(header); |
|
643 |
os::close(fd); |
|
644 |
vm_exit_during_initialization("Unable to read header from shared archive", archive_name); |
|
645 |
return false; |
|
646 |
} |
|
647 |
if (is_static) { |
|
648 |
FileMapHeader* static_header = (FileMapHeader*)header; |
|
649 |
if (static_header->_magic != CDS_ARCHIVE_MAGIC) { |
|
650 |
os::free(header); |
|
651 |
os::close(fd); |
|
652 |
vm_exit_during_initialization("Not a base shared archive", archive_name); |
|
653 |
return false; |
|
654 |
} |
|
655 |
} else { |
|
656 |
DynamicArchiveHeader* dynamic_header = (DynamicArchiveHeader*)header; |
|
657 |
if (dynamic_header->_magic != CDS_DYNAMIC_ARCHIVE_MAGIC) { |
|
658 |
os::free(header); |
|
659 |
os::close(fd); |
|
660 |
vm_exit_during_initialization("Not a top shared archive", archive_name); |
|
661 |
return false; |
|
662 |
} |
|
663 |
} |
|
664 |
os::free(header); |
|
665 |
os::close(fd); |
|
666 |
return true; |
|
667 |
} |
|
668 |
||
669 |
bool FileMapInfo::get_base_archive_name_from_header(const char* archive_name, |
|
670 |
int* size, char** base_archive_name) { |
|
671 |
int fd = os::open(archive_name, O_RDONLY | O_BINARY, 0); |
|
672 |
if (fd < 0) { |
|
673 |
*size = 0; |
|
674 |
return false; |
|
675 |
} |
|
676 |
||
677 |
// read the header as a dynamic archive header |
|
678 |
size_t sz = sizeof(DynamicArchiveHeader); |
|
679 |
DynamicArchiveHeader* dynamic_header = (DynamicArchiveHeader*)os::malloc(sz, mtInternal); |
|
680 |
size_t n = os::read(fd, dynamic_header, (unsigned int)sz); |
|
681 |
if (n != sz) { |
|
682 |
fail_continue("Unable to read the file header."); |
|
683 |
os::free(dynamic_header); |
|
684 |
os::close(fd); |
|
685 |
return false; |
|
686 |
} |
|
687 |
if (dynamic_header->_magic != CDS_DYNAMIC_ARCHIVE_MAGIC) { |
|
688 |
// Not a dynamic header, no need to proceed further. |
|
689 |
*size = 0; |
|
690 |
os::free(dynamic_header); |
|
691 |
os::close(fd); |
|
692 |
return false; |
|
693 |
} |
|
694 |
if (dynamic_header->_base_archive_is_default) { |
|
695 |
*base_archive_name = Arguments::get_default_shared_archive_path(); |
|
696 |
} else { |
|
697 |
// skip over the _paths_misc_info |
|
698 |
sz = dynamic_header->_paths_misc_info_size; |
|
699 |
lseek(fd, (long)sz, SEEK_CUR); |
|
700 |
// read the base archive name |
|
701 |
size_t name_size = dynamic_header->_base_archive_name_size; |
|
702 |
if (name_size == 0) { |
|
703 |
os::free(dynamic_header); |
|
704 |
os::close(fd); |
|
705 |
return false; |
|
706 |
} |
|
707 |
*base_archive_name = NEW_C_HEAP_ARRAY(char, name_size, mtInternal); |
|
708 |
n = os::read(fd, *base_archive_name, (unsigned int)name_size); |
|
709 |
if (n != name_size) { |
|
710 |
fail_continue("Unable to read the base archive name from the header."); |
|
711 |
FREE_C_HEAP_ARRAY(char, *base_archive_name); |
|
712 |
*base_archive_name = NULL; |
|
713 |
os::free(dynamic_header); |
|
714 |
os::close(fd); |
|
715 |
return false; |
|
716 |
} |
|
717 |
} |
|
718 |
||
719 |
os::free(dynamic_header); |
|
720 |
os::close(fd); |
|
721 |
return true; |
|
722 |
} |
|
723 |
||
724 |
void FileMapInfo::restore_shared_path_table() { |
|
725 |
_shared_path_table = _current_info->_header->_shared_path_table; |
|
726 |
} |
|
727 |
||
1 | 728 |
// Read the FileMapInfo information from the file. |
729 |
||
54927 | 730 |
bool FileMapInfo::init_from_file(int fd, bool is_static) { |
731 |
size_t sz = is_static ? sizeof(FileMapHeader) : sizeof(DynamicArchiveHeader); |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
732 |
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
|
733 |
if (n != sz) { |
1 | 734 |
fail_continue("Unable to read the file header."); |
735 |
return false; |
|
736 |
} |
|
55694
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
737 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
738 |
if (!Arguments::has_jimage()) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
739 |
FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build."); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
740 |
return false; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
741 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
742 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
743 |
unsigned int expected_magic = is_static ? CDS_ARCHIVE_MAGIC : CDS_DYNAMIC_ARCHIVE_MAGIC; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
744 |
if (_header->_magic != expected_magic) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
745 |
log_info(cds)("_magic expected: 0x%08x", expected_magic); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
746 |
log_info(cds)(" actual: 0x%08x", _header->_magic); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
747 |
FileMapInfo::fail_continue("The shared archive file has a bad magic number."); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
748 |
return false; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
749 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
750 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
751 |
if (_header->_version != CURRENT_CDS_ARCHIVE_VERSION) { |
55694
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
752 |
log_info(cds)("_version expected: %d", CURRENT_CDS_ARCHIVE_VERSION); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
753 |
log_info(cds)(" actual: %d", _header->_version); |
1 | 754 |
fail_continue("The shared archive file has the wrong version."); |
755 |
return false; |
|
756 |
} |
|
55694
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
757 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
758 |
if (_header->_header_size != sz) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
759 |
log_info(cds)("_header_size expected: " SIZE_FORMAT, sz); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
760 |
log_info(cds)(" actual: " SIZE_FORMAT, _header->_header_size); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
761 |
FileMapInfo::fail_continue("The shared archive file has an incorrect header size."); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
762 |
return false; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
763 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
764 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
765 |
if (_header->_jvm_ident[JVM_IDENT_MAX-1] != 0) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
766 |
FileMapInfo::fail_continue("JVM version identifier is corrupted."); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
767 |
return false; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
768 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
769 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
770 |
char header_version[JVM_IDENT_MAX]; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
771 |
get_header_version(header_version); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
772 |
if (strncmp(_header->_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
773 |
log_info(cds)("_jvm_ident expected: %s", header_version); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
774 |
log_info(cds)(" actual: %s", _header->_jvm_ident); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
775 |
FileMapInfo::fail_continue("The shared archive file was created by a different" |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
776 |
" version or build of HotSpot"); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
777 |
return false; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
778 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
779 |
|
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
780 |
if (VerifySharedSpaces) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
781 |
int expected_crc = _header->compute_crc(); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
782 |
if (expected_crc != _header->_crc) { |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
783 |
log_info(cds)("_crc expected: %d", expected_crc); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
784 |
log_info(cds)(" actual: %d", _header->_crc); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
785 |
FileMapInfo::fail_continue("Header checksum verification failed."); |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
786 |
return false; |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
787 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
788 |
} |
7b7df2be6219
8226406: JVM fails to detect mismatched or corrupt CDS archive
ccheung
parents:
55296
diff
changeset
|
789 |
|
54927 | 790 |
_file_offset = n; |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
791 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
792 |
size_t info_size = _header->_paths_misc_info_size; |
54927 | 793 |
_paths_misc_info = NEW_C_HEAP_ARRAY(char, info_size, mtClass); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
794 |
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
|
795 |
if (n != info_size) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
796 |
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
|
797 |
FREE_C_HEAP_ARRAY(char, _paths_misc_info); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
798 |
_paths_misc_info = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
799 |
return false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
800 |
} |
54927 | 801 |
_file_offset += n + _header->_base_archive_name_size; // accounts for the size of _base_archive_name |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
802 |
|
54927 | 803 |
if (is_static) { |
804 |
// just checking the last region is sufficient since the archive is written |
|
805 |
// in sequential order |
|
806 |
size_t len = lseek(fd, 0, SEEK_END); |
|
807 |
CDSFileMapRegion* si = space_at(MetaspaceShared::last_valid_region); |
|
808 |
// The last space might be empty |
|
809 |
if (si->_file_offset > len || len - si->_file_offset < si->_used) { |
|
810 |
fail_continue("The shared archive file has been truncated."); |
|
811 |
return false; |
|
812 |
} |
|
813 |
||
814 |
SharedBaseAddress = _header->_shared_base_address; |
|
27025 | 815 |
} |
816 |
||
1 | 817 |
return true; |
818 |
} |
|
819 |
||
820 |
||
821 |
// Read the FileMapInfo information from the file. |
|
54927 | 822 |
bool FileMapInfo::open_for_read(const char* path) { |
823 |
if (_file_open) { |
|
824 |
return true; |
|
825 |
} |
|
826 |
if (path == NULL) { |
|
827 |
_full_path = Arguments::GetSharedArchivePath(); |
|
828 |
} else { |
|
829 |
_full_path = path; |
|
830 |
} |
|
53911
65f2a401e0eb
8218811: replace open by os::open in hotspot coding
mbaesken
parents:
53884
diff
changeset
|
831 |
int fd = os::open(_full_path, O_RDONLY | O_BINARY, 0); |
1 | 832 |
if (fd < 0) { |
833 |
if (errno == ENOENT) { |
|
834 |
// Not locating the shared archive is ok. |
|
54927 | 835 |
fail_continue("Specified shared archive not found (%s).", _full_path); |
1 | 836 |
} else { |
837 |
fail_continue("Failed to open shared archive file (%s).", |
|
37113 | 838 |
os::strerror(errno)); |
1 | 839 |
} |
840 |
return false; |
|
841 |
} |
|
842 |
||
843 |
_fd = fd; |
|
844 |
_file_open = true; |
|
845 |
return true; |
|
846 |
} |
|
847 |
||
848 |
// Write the FileMapInfo information to the file. |
|
849 |
||
54927 | 850 |
void FileMapInfo::open_for_write(const char* path) { |
851 |
if (path == NULL) { |
|
852 |
_full_path = Arguments::GetSharedArchivePath(); |
|
853 |
} else { |
|
854 |
_full_path = path; |
|
855 |
} |
|
48962
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
856 |
LogMessage(cds) msg; |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
857 |
if (msg.is_info()) { |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
858 |
msg.info("Dumping shared data to file: "); |
88ad6c676c87
8194994: Remove redundant string streams used for logging
mlarsson
parents:
48794
diff
changeset
|
859 |
msg.info(" %s", _full_path); |
1 | 860 |
} |
861 |
||
15461
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
862 |
#ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. |
54927 | 863 |
chmod(_full_path, _S_IREAD | _S_IWRITE); |
15461
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
864 |
#endif |
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
865 |
|
e3acbfdabafa
7197672: There are issues with shared data on windows
hseigel
parents:
15101
diff
changeset
|
866 |
// 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
|
867 |
// allow processes that have it open continued access to the file. |
1 | 868 |
remove(_full_path); |
53911
65f2a401e0eb
8218811: replace open by os::open in hotspot coding
mbaesken
parents:
53884
diff
changeset
|
869 |
int fd = os::open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); |
1 | 870 |
if (fd < 0) { |
28950
693ae3d5e1ff
8072694: Need errno info when CDS archive creation fails
hseigel
parents:
28023
diff
changeset
|
871 |
fail_stop("Unable to create shared archive file %s: (%s).", _full_path, |
37113 | 872 |
os::strerror(errno)); |
1 | 873 |
} |
874 |
_fd = fd; |
|
875 |
_file_offset = 0; |
|
876 |
_file_open = true; |
|
877 |
} |
|
878 |
||
879 |
||
880 |
// Write the header to the file, seek to the next allocation boundary. |
|
881 |
||
882 |
void FileMapInfo::write_header() { |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
883 |
int info_size = ClassLoader::get_shared_paths_misc_info_size(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
884 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
885 |
_header->_paths_misc_info_size = info_size; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
886 |
|
54927 | 887 |
char* base_archive_name = NULL; |
888 |
if (_header->_magic == CDS_DYNAMIC_ARCHIVE_MAGIC) { |
|
889 |
base_archive_name = (char*)Arguments::GetSharedArchivePath(); |
|
890 |
_header->_base_archive_name_size = (int)strlen(base_archive_name) + 1; |
|
891 |
_header->_base_archive_is_default = FLAG_IS_DEFAULT(SharedArchiveFile); |
|
892 |
} |
|
893 |
||
894 |
assert(is_file_position_aligned(), "must be"); |
|
895 |
write_bytes(_header, _header->_header_size); |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
896 |
write_bytes(ClassLoader::get_shared_paths_misc_info(), (size_t)info_size); |
54927 | 897 |
if (base_archive_name != NULL) { |
898 |
write_bytes(base_archive_name, (size_t)_header->_base_archive_name_size); |
|
899 |
} |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
900 |
align_file_position(); |
1 | 901 |
} |
902 |
||
903 |
// Dump region to file. |
|
54927 | 904 |
// This is called twice for each region during archiving, once before |
905 |
// the archive file is open (_file_open is false) and once after. |
|
1 | 906 |
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
|
907 |
bool read_only, bool allow_exec) { |
54927 | 908 |
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Dump time only"); |
909 |
||
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
910 |
CDSFileMapRegion* si = space_at(region); |
54927 | 911 |
char* target_base = base; |
912 |
if (DynamicDumpSharedSpaces) { |
|
913 |
target_base = DynamicArchive::buffer_to_target(base); |
|
914 |
} |
|
1 | 915 |
|
916 |
if (_file_open) { |
|
917 |
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
|
918 |
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
|
919 |
" bytes, addr " INTPTR_FORMAT " file offset " SIZE_FORMAT_HEX_W(08), |
54927 | 920 |
region, size, p2i(target_base), _file_offset); |
1 | 921 |
} else { |
922 |
si->_file_offset = _file_offset; |
|
923 |
} |
|
54927 | 924 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
925 |
if (HeapShared::is_heap_region(region)) { |
54927 | 926 |
assert((target_base - (char*)CompressedKlassPointers::base()) % HeapWordSize == 0, "Sanity"); |
927 |
if (target_base != NULL) { |
|
928 |
si->_addr._offset = (intx)CompressedOops::encode_not_null((oop)target_base); |
|
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
929 |
} else { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
930 |
si->_addr._offset = 0; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
931 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
932 |
} else { |
54927 | 933 |
si->_addr._base = target_base; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
934 |
} |
1 | 935 |
si->_used = size; |
936 |
si->_read_only = read_only; |
|
937 |
si->_allow_exec = allow_exec; |
|
54927 | 938 |
|
939 |
// Use the current 'base' when computing the CRC value and writing out data |
|
27025 | 940 |
si->_crc = ClassLoader::crc32(0, base, (jint)size); |
51070 | 941 |
if (base != NULL) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
942 |
write_bytes_aligned(base, size); |
51070 | 943 |
} |
1 | 944 |
} |
945 |
||
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
946 |
// 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
|
947 |
// 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
|
948 |
// 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
|
949 |
// |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
950 |
// 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
|
951 |
// size, there is only one MemRegion in the array. |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
952 |
// |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
953 |
// 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
|
954 |
// 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
|
955 |
// 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
|
956 |
// 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
|
957 |
// 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
|
958 |
// GC regions are combined into another MemRegion. |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
959 |
// |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
960 |
// 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
|
961 |
// + 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
|
962 |
// + 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
|
963 |
// |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
964 |
// 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
|
965 |
// Otherwise: |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
966 |
// |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
967 |
// "X" represented space that's occupied by heap objects. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
968 |
// "_" represented unused spaced in the heap region. |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
969 |
// |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
970 |
// |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
971 |
// |ah0 | ah1 | ah2| ...... | ahn| |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
972 |
// |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
|
973 |
// |<-r0->| |<- r1 ----------------->| |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
974 |
// ^^^ |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
975 |
// | |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
976 |
// +-- gap |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
977 |
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
|
978 |
GrowableArray<ArchiveHeapOopmapInfo> *oopmaps, |
52514
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
979 |
int first_region_id, int max_num_regions, |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
980 |
bool print_log) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
981 |
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
|
982 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
983 |
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
|
984 |
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
|
985 |
fail_stop("Unable to write archive heap memory regions: " |
52811
ff04b71bf6f1
8214388: CDS dumping fails with java heap fragmentation
iklam
parents:
52702
diff
changeset
|
986 |
"number of memory regions exceeds maximum due to fragmentation. " |
52702
10c6e9066819
8214217: [TESTBUG] runtime/appcds/LotsOfClasses.java failed with fragmented heap
jiangli
parents:
52674
diff
changeset
|
987 |
"Please increase java heap size " |
10c6e9066819
8214217: [TESTBUG] runtime/appcds/LotsOfClasses.java failed with fragmented heap
jiangli
parents:
52674
diff
changeset
|
988 |
"(current MaxHeapSize is " SIZE_FORMAT ", InitialHeapSize is " SIZE_FORMAT ").", |
10c6e9066819
8214217: [TESTBUG] runtime/appcds/LotsOfClasses.java failed with fragmented heap
jiangli
parents:
52674
diff
changeset
|
989 |
MaxHeapSize, InitialHeapSize); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
990 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
991 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
992 |
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
|
993 |
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
|
994 |
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
|
995 |
i++, arr_idx++) { |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
996 |
char* start = NULL; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
997 |
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
|
998 |
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
|
999 |
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
|
1000 |
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
|
1001 |
total_size += size; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1002 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1003 |
|
52514
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
1004 |
if (print_log) { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
1005 |
log_info(cds)("Archive heap region %d " INTPTR_FORMAT " - " INTPTR_FORMAT " = " SIZE_FORMAT_W(8) " bytes", |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
1006 |
i, p2i(start), p2i(start + size), size); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
52402
diff
changeset
|
1007 |
} |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1008 |
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
|
1009 |
if (size > 0) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1010 |
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
|
1011 |
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
|
1012 |
} |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1013 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1014 |
return total_size; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1015 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1016 |
|
1 | 1017 |
// Dump bytes to file -- at the current file position. |
1018 |
||
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1019 |
void FileMapInfo::write_bytes(const void* buffer, size_t nbytes) { |
1 | 1020 |
if (_file_open) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1021 |
size_t n = os::write(_fd, buffer, (unsigned int)nbytes); |
1 | 1022 |
if (n != nbytes) { |
54927 | 1023 |
// If the shared archive is corrupted, close it and remove it. |
1 | 1024 |
close(); |
1025 |
remove(_full_path); |
|
26296 | 1026 |
fail_stop("Unable to write to shared archive file."); |
1 | 1027 |
} |
1028 |
} |
|
1029 |
_file_offset += nbytes; |
|
1030 |
} |
|
1031 |
||
54927 | 1032 |
bool FileMapInfo::is_file_position_aligned() const { |
1033 |
return _file_offset == align_up(_file_offset, |
|
1034 |
os::vm_allocation_granularity()); |
|
1035 |
} |
|
1 | 1036 |
|
1037 |
// Align file position to an allocation unit boundary. |
|
1038 |
||
1039 |
void FileMapInfo::align_file_position() { |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
1040 |
size_t new_file_offset = align_up(_file_offset, |
27025 | 1041 |
os::vm_allocation_granularity()); |
1 | 1042 |
if (new_file_offset != _file_offset) { |
1043 |
_file_offset = new_file_offset; |
|
1044 |
if (_file_open) { |
|
1045 |
// Seek one byte back from the target and write a byte to insure |
|
1046 |
// that the written file is the correct length. |
|
1047 |
_file_offset -= 1; |
|
27025 | 1048 |
if (lseek(_fd, (long)_file_offset, SEEK_SET) < 0) { |
26296 | 1049 |
fail_stop("Unable to seek."); |
1 | 1050 |
} |
1051 |
char zero = 0; |
|
1052 |
write_bytes(&zero, 1); |
|
1053 |
} |
|
1054 |
} |
|
1055 |
} |
|
1056 |
||
1057 |
||
1058 |
// Dump bytes to file -- at the current file position. |
|
1059 |
||
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1060 |
void FileMapInfo::write_bytes_aligned(const void* buffer, size_t nbytes) { |
1 | 1061 |
align_file_position(); |
1062 |
write_bytes(buffer, nbytes); |
|
1063 |
align_file_position(); |
|
1064 |
} |
|
1065 |
||
1066 |
||
1067 |
// Close the shared archive file. This does NOT unmap mapped regions. |
|
1068 |
||
1069 |
void FileMapInfo::close() { |
|
1070 |
if (_file_open) { |
|
1071 |
if (::close(_fd) < 0) { |
|
1072 |
fail_stop("Unable to close the shared archive file."); |
|
1073 |
} |
|
1074 |
_file_open = false; |
|
1075 |
_fd = -1; |
|
1076 |
} |
|
1077 |
} |
|
1078 |
||
1079 |
||
1080 |
// JVM/TI RedefineClasses() support: |
|
1081 |
// Remap the shared readonly space to shared readwrite, private. |
|
1082 |
bool FileMapInfo::remap_shared_readonly_as_readwrite() { |
|
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1083 |
int idx = MetaspaceShared::ro; |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1084 |
CDSFileMapRegion* si = space_at(idx); |
1 | 1085 |
if (!si->_read_only) { |
1086 |
// the space is already readwrite so we are done |
|
1087 |
return true; |
|
1088 |
} |
|
1089 |
size_t used = si->_used; |
|
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
1090 |
size_t size = align_up(used, os::vm_allocation_granularity()); |
1 | 1091 |
if (!open_for_read()) { |
1092 |
return false; |
|
1093 |
} |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1094 |
char *addr = region_addr(idx); |
1 | 1095 |
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
|
1096 |
addr, size, false /* !read_only */, |
1 | 1097 |
si->_allow_exec); |
1098 |
close(); |
|
54573
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1099 |
// These have to be errors because the shared region is now unmapped. |
1 | 1100 |
if (base == NULL) { |
54573
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1101 |
log_error(cds)("Unable to remap shared readonly space (errno=%d).", errno); |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1102 |
vm_exit(1); |
1 | 1103 |
} |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1104 |
if (base != addr) { |
54573
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1105 |
log_error(cds)("Unable to remap shared readonly space (errno=%d).", errno); |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1106 |
vm_exit(1); |
1 | 1107 |
} |
1108 |
si->_read_only = false; |
|
1109 |
return true; |
|
1110 |
} |
|
1111 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1112 |
// 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
|
1113 |
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
|
1114 |
char* requested_addr = region_addr(0); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1115 |
size_t size = FileMapInfo::core_spaces_size(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1116 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1117 |
// 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
|
1118 |
// other reserved memory (like the code cache). |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1119 |
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
|
1120 |
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
|
1121 |
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
|
1122 |
INTPTR_FORMAT, p2i(requested_addr)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1123 |
return rs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1124 |
} |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13728
diff
changeset
|
1125 |
// 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
|
1126 |
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
|
1127 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1128 |
return rs; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1129 |
} |
1 | 1130 |
|
1131 |
// Memory map a region in the address space. |
|
55296 | 1132 |
static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1133 |
"String1", "String2", "OpenArchive1", "OpenArchive2" }; |
1 | 1134 |
|
54927 | 1135 |
char* FileMapInfo::map_regions(int regions[], char* saved_base[], size_t len) { |
1136 |
char* prev_top = NULL; |
|
1137 |
char* curr_base; |
|
1138 |
char* curr_top; |
|
1139 |
int i = 0; |
|
1140 |
for (i = 0; i < (int)len; i++) { |
|
1141 |
curr_base = map_region(regions[i], &curr_top); |
|
1142 |
if (curr_base == NULL) { |
|
1143 |
return NULL; |
|
1144 |
} |
|
1145 |
if (i > 0) { |
|
55296 | 1146 |
// We require that mc->rw->ro->md to be laid out consecutively, with no |
54927 | 1147 |
// gaps between them. That way, we can ensure that the OS won't be able to |
1148 |
// allocate any new memory spaces inside _shared_metaspace_{base,top}, which |
|
1149 |
// would mess up the simple comparision in MetaspaceShared::is_in_shared_metaspace(). |
|
1150 |
assert(curr_base == prev_top, "must be"); |
|
1151 |
} |
|
1152 |
log_info(cds)("Mapped region #%d at base %p top %p", regions[i], curr_base, curr_top); |
|
1153 |
saved_base[i] = curr_base; |
|
1154 |
prev_top = curr_top; |
|
1155 |
} |
|
1156 |
return curr_top; |
|
1157 |
} |
|
1158 |
||
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
1159 |
char* FileMapInfo::map_region(int i, char** top_ret) { |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1160 |
assert(!HeapShared::is_heap_region(i), "sanity"); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1161 |
CDSFileMapRegion* si = space_at(i); |
1 | 1162 |
size_t used = si->_used; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1163 |
size_t alignment = os::vm_allocation_granularity(); |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
1164 |
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
|
1165 |
char *requested_addr = region_addr(i); |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
1166 |
|
54573
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1167 |
#ifdef _WINDOWS |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1168 |
// Windows cannot remap read-only shared memory to read-write when required for |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1169 |
// RedefineClasses, which is also used by JFR. Always map windows regions as RW. |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1170 |
si->_read_only = false; |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1171 |
#else |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1172 |
// If a tool agent is in use (debugging enabled), or JFR, we must map the address space RW |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1173 |
if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space() || |
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1174 |
Arguments::has_jfr_option()) { |
31375
aa5ecd9a5716
8087153: EXCEPTION_ACCESS_VIOLATION when CDS RO section vanished on win32
cjplummer
parents:
31364
diff
changeset
|
1175 |
si->_read_only = false; |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
1176 |
} |
54573
b73893f7fee3
8222379: JFR TestClassLoadEvent.java failed due to EXCEPTION_ACCESS_VIOLATION
coleenp
parents:
54340
diff
changeset
|
1177 |
#endif // _WINDOWS |
31332
dc17890f352d
8054386: Allow Java debugging when CDS is enabled
cjplummer
parents:
28950
diff
changeset
|
1178 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7405
diff
changeset
|
1179 |
// map the contents of the CDS archive in this memory |
1 | 1180 |
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
|
1181 |
requested_addr, size, si->_read_only, |
1 | 1182 |
si->_allow_exec); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1183 |
if (base == NULL || base != requested_addr) { |
26296 | 1184 |
fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]); |
54927 | 1185 |
_memory_mapping_failed = true; |
1 | 1186 |
return NULL; |
1187 |
} |
|
15100
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
1188 |
#ifdef _WINDOWS |
0ae85ac7c8b0
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
14577
diff
changeset
|
1189 |
// 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
|
1190 |
// 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
|
1191 |
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
|
1192 |
#endif |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1193 |
|
54838 | 1194 |
if (VerifySharedSpaces && !verify_region_checksum(i)) { |
48794
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
1195 |
return NULL; |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
1196 |
} |
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
1197 |
|
ea0d0781c63c
8178351: Simplify MetaspaceShared::is_in_shared_space and MetaspaceObj::is_shared
iklam
parents:
47991
diff
changeset
|
1198 |
*top_ret = base + size; |
1 | 1199 |
return base; |
1200 |
} |
|
1201 |
||
54927 | 1202 |
size_t FileMapInfo::read_bytes(void* buffer, size_t count) { |
1203 |
assert(_file_open, "Archive file is not open"); |
|
1204 |
size_t n = os::read(_fd, buffer, (unsigned int)count); |
|
1205 |
if (n != count) { |
|
1206 |
// Close the file if there's a problem reading it. |
|
1207 |
close(); |
|
1208 |
return 0; |
|
1209 |
} |
|
1210 |
_file_offset += count; |
|
1211 |
return count; |
|
1212 |
} |
|
1213 |
||
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1214 |
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
|
1215 |
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
|
1216 |
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
|
1217 |
} else { |
51720
b7bfd64e43a6
8210523: runtime/appcds/cacheObject/DifferentHeapSizes.java crash
iklam
parents:
51491
diff
changeset
|
1218 |
return (address)HeapShared::decode_from_archive(offset_of_space(spc)); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1219 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1220 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1221 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1222 |
static MemRegion *closed_archive_heap_ranges = NULL; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1223 |
static MemRegion *open_archive_heap_ranges = NULL; |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1224 |
static int num_closed_archive_heap_ranges = 0; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1225 |
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
|
1226 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1227 |
#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
|
1228 |
bool FileMapInfo::has_heap_regions() { |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1229 |
return (_header->_space[MetaspaceShared::first_closed_archive_heap_region]._used > 0); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1230 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1231 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1232 |
// 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
|
1233 |
// 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
|
1234 |
// 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
|
1235 |
// 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
|
1236 |
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
|
1237 |
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
|
1238 |
address end = NULL; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1239 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1240 |
for (int i = MetaspaceShared::first_closed_archive_heap_region; |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1241 |
i <= MetaspaceShared::last_valid_region; |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1242 |
i++) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1243 |
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
|
1244 |
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
|
1245 |
if (size > 0) { |
51720
b7bfd64e43a6
8210523: runtime/appcds/cacheObject/DifferentHeapSizes.java crash
iklam
parents:
51491
diff
changeset
|
1246 |
address s = start_address_as_decoded_with_current_oop_encoding_mode(si); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1247 |
address e = s + size; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1248 |
if (start > s) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1249 |
start = s; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1250 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1251 |
if (end < e) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1252 |
end = e; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1253 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1254 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1255 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1256 |
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
|
1257 |
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
|
1258 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1259 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1260 |
// |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1261 |
// Map the closed and open archive heap objects to the runtime java heap. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1262 |
// |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1263 |
// The shared objects are mapped at (or close to ) the java heap top in |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1264 |
// closed archive regions. The mapped objects contain no out-going |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1265 |
// references to any other java heap regions. GC does not write into the |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1266 |
// mapped closed archive heap region. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1267 |
// |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1268 |
// The open archive heap objects are mapped below the shared objects in |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1269 |
// the runtime java heap. The mapped open archive heap data only contains |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1270 |
// references to the shared objects and open archive objects initially. |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1271 |
// 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
|
1272 |
// 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
|
1273 |
// open archive objects. |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1274 |
void FileMapInfo::map_heap_regions_impl() { |
52062
8dbf1a13af49
8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents:
51823
diff
changeset
|
1275 |
if (!HeapShared::is_heap_object_archiving_allowed()) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1276 |
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
|
1277 |
"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
|
1278 |
return; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1279 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1280 |
|
52319
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1281 |
if (JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()) { |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1282 |
ShouldNotReachHere(); // CDS should have been disabled. |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1283 |
// The archived objects are mapped at JVM start-up, but we don't know if |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1284 |
// j.l.String or j.l.Class might be replaced by the ClassFileLoadHook, |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1285 |
// which would make the archived String or mirror objects invalid. Let's be safe and not |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1286 |
// use the archived objects. These 2 classes are loaded during the JVMTI "early" stage. |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1287 |
// |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1288 |
// If JvmtiExport::has_early_class_hook_env() is false, the classes of some objects |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1289 |
// in the archived subgraphs may be replaced by the ClassFileLoadHook. But that's OK |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1290 |
// because we won't install an archived object subgraph if the klass of any of the |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1291 |
// referenced objects are replaced. See HeapShared::initialize_from_archived_subgraph(). |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1292 |
} |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1293 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1294 |
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
|
1295 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1296 |
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
|
1297 |
max_heap_size()/M); |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1298 |
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
|
1299 |
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
|
1300 |
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
|
1301 |
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
|
1302 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1303 |
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
|
1304 |
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
|
1305 |
log_info(cds)(" narrow_klass_base = " PTR_FORMAT ", narrow_klass_shift = %d", |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1306 |
p2i(CompressedKlassPointers::base()), CompressedKlassPointers::shift()); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1307 |
log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1308 |
CompressedOops::mode(), p2i(CompressedOops::base()), CompressedOops::shift()); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1309 |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1310 |
if (narrow_klass_base() != CompressedKlassPointers::base() || |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1311 |
narrow_klass_shift() != CompressedKlassPointers::shift()) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1312 |
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
|
1313 |
return; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1314 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1315 |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1316 |
if (narrow_oop_mode() != CompressedOops::mode() || |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1317 |
narrow_oop_base() != CompressedOops::base() || |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54573
diff
changeset
|
1318 |
narrow_oop_shift() != CompressedOops::shift()) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1319 |
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
|
1320 |
_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
|
1321 |
} else { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1322 |
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
|
1323 |
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
|
1324 |
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
|
1325 |
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
|
1326 |
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
|
1327 |
_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
|
1328 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1329 |
} |
47599
0fb1d501c408
8174986: CDS archived java heap region may not compatible with AOT
jiangli
parents:
47216
diff
changeset
|
1330 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1331 |
ptrdiff_t delta = 0; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1332 |
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
|
1333 |
// dumptime heap end ------------v |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1334 |
// [ |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
|
1335 |
// [ |archived heap regions| ] |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1336 |
// |<-----delta-------------------->| |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1337 |
// |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1338 |
// 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
|
1339 |
// 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
|
1340 |
// 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
|
1341 |
// 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
|
1342 |
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
|
1343 |
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
|
1344 |
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
|
1345 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1346 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1347 |
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
|
1348 |
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
|
1349 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1350 |
CDSFileMapRegion* si = space_at(MetaspaceShared::first_closed_archive_heap_region); |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1351 |
address relocated_closed_heap_region_bottom = start_address_as_decoded_from_archive(si); |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1352 |
if (!is_aligned(relocated_closed_heap_region_bottom, HeapRegion::GrainBytes)) { |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1353 |
// Align the bottom of the closed archive heap regions at G1 region boundary. |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1354 |
// This will avoid the situation where the highest open region and the lowest |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1355 |
// closed region sharing the same G1 region. Otherwise we will fail to map the |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1356 |
// open regions. |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1357 |
size_t align = size_t(relocated_closed_heap_region_bottom) % HeapRegion::GrainBytes; |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1358 |
delta -= align; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1359 |
log_info(cds)("CDS heap data need to be relocated lower by a further " SIZE_FORMAT |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1360 |
" bytes to " INTX_FORMAT " to be aligned with HeapRegion::GrainBytes", |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1361 |
align, delta); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1362 |
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
|
1363 |
_heap_pointers_need_patching = true; |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1364 |
relocated_closed_heap_region_bottom = start_address_as_decoded_from_archive(si); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1365 |
} |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1366 |
assert(is_aligned(relocated_closed_heap_region_bottom, HeapRegion::GrainBytes), |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1367 |
"must be"); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1368 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1369 |
// Map the closed_archive_heap regions, GC does not write into the regions. |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1370 |
if (map_heap_data(&closed_archive_heap_ranges, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1371 |
MetaspaceShared::first_closed_archive_heap_region, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1372 |
MetaspaceShared::max_closed_archive_heap_region, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1373 |
&num_closed_archive_heap_ranges)) { |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1374 |
HeapShared::set_closed_archive_heap_region_mapped(); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1375 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1376 |
// 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
|
1377 |
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
|
1378 |
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
|
1379 |
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
|
1380 |
&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
|
1381 |
true /* open */)) { |
52062
8dbf1a13af49
8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents:
51823
diff
changeset
|
1382 |
HeapShared::set_open_archive_heap_region_mapped(); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1383 |
} |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1384 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1385 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1386 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1387 |
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
|
1388 |
if (has_heap_regions()) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1389 |
map_heap_regions_impl(); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1390 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1391 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1392 |
if (!HeapShared::closed_archive_heap_region_mapped()) { |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1393 |
assert(closed_archive_heap_ranges == NULL && |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1394 |
num_closed_archive_heap_ranges == 0, "sanity"); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1395 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1396 |
|
52062
8dbf1a13af49
8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents:
51823
diff
changeset
|
1397 |
if (!HeapShared::open_archive_heap_region_mapped()) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1398 |
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
|
1399 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1400 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1401 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1402 |
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
|
1403 |
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
|
1404 |
MemRegion * regions = new MemRegion[max]; |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1405 |
CDSFileMapRegion* si; |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1406 |
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
|
1407 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1408 |
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
|
1409 |
i < first + max; i++) { |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1410 |
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
|
1411 |
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
|
1412 |
if (size > 0) { |
51720
b7bfd64e43a6
8210523: runtime/appcds/cacheObject/DifferentHeapSizes.java crash
iklam
parents:
51491
diff
changeset
|
1413 |
HeapWord* start = (HeapWord*)start_address_as_decoded_from_archive(si); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1414 |
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
|
1415 |
region_num ++; |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1416 |
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
|
1417 |
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
|
1418 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1419 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1420 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1421 |
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
|
1422 |
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
|
1423 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1424 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1425 |
// 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
|
1426 |
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
|
1427 |
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
|
1428 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1429 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1430 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1431 |
// 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
|
1432 |
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
|
1433 |
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
|
1434 |
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
|
1435 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1436 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1437 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1438 |
// 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
|
1439 |
// 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
|
1440 |
// already recorded. |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1441 |
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
|
1442 |
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
|
1443 |
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
|
1444 |
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
|
1445 |
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
|
1446 |
si->_allow_exec); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1447 |
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
|
1448 |
// dealloc the regions from java heap |
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1449 |
dealloc_archive_heap_regions(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
|
1450 |
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
|
1451 |
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
|
1452 |
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
|
1453 |
return false; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1454 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1455 |
|
54927 | 1456 |
if (VerifySharedSpaces && !region_crc_check(addr, regions[i].byte_size(), si->_crc)) { |
1457 |
// dealloc the regions from java heap |
|
1458 |
dealloc_archive_heap_regions(regions, region_num, is_open_archive); |
|
1459 |
log_info(cds)("UseSharedSpaces: mapped heap regions are corrupt"); |
|
1460 |
return false; |
|
1461 |
} |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1462 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1463 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1464 |
// 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
|
1465 |
*heap_mem = regions; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1466 |
*num = region_num; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1467 |
return true; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1468 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1469 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1470 |
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
|
1471 |
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
|
1472 |
return; |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1473 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1474 |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1475 |
patch_archived_heap_embedded_pointers(closed_archive_heap_ranges, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1476 |
num_closed_archive_heap_ranges, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1477 |
MetaspaceShared::first_closed_archive_heap_region); |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1478 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1479 |
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
|
1480 |
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
|
1481 |
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
|
1482 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1483 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1484 |
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
|
1485 |
int first_region_idx) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1486 |
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
|
1487 |
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
|
1488 |
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
|
1489 |
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
|
1490 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1491 |
} |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1492 |
|
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1493 |
// 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
|
1494 |
// 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
|
1495 |
void FileMapInfo::fixup_mapped_heap_regions() { |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1496 |
// If any closed regions were found, call the fill routine to make them parseable. |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1497 |
// Note that closed_archive_heap_ranges may be non-NULL even if no ranges were found. |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1498 |
if (num_closed_archive_heap_ranges != 0) { |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1499 |
assert(closed_archive_heap_ranges != NULL, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1500 |
"Null closed_archive_heap_ranges array with non-zero count"); |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1501 |
G1CollectedHeap::heap()->fill_archive_regions(closed_archive_heap_ranges, |
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1502 |
num_closed_archive_heap_ranges); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1503 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1504 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1505 |
// 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
|
1506 |
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
|
1507 |
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
|
1508 |
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
|
1509 |
num_open_archive_heap_ranges); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1510 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1511 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1512 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1513 |
// dealloc the archive regions from java heap |
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1514 |
void FileMapInfo::dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) { |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1515 |
if (num > 0) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1516 |
assert(regions != NULL, "Null archive ranges array with non-zero count"); |
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1517 |
G1CollectedHeap::heap()->dealloc_archive_regions(regions, num, is_open); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1518 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1519 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1520 |
#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
|
1521 |
|
54927 | 1522 |
bool FileMapInfo::region_crc_check(char* buf, size_t size, int expected_crc) { |
1523 |
int crc = ClassLoader::crc32(0, buf, (jint)size); |
|
1524 |
if (crc != expected_crc) { |
|
1525 |
fail_continue("Checksum verification failed."); |
|
1526 |
return false; |
|
1527 |
} |
|
1528 |
return true; |
|
1529 |
} |
|
1530 |
||
27025 | 1531 |
bool FileMapInfo::verify_region_checksum(int i) { |
54838 | 1532 |
assert(VerifySharedSpaces, "sanity"); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1533 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1534 |
size_t sz = space_at(i)->_used; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1535 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1536 |
if (sz == 0) { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1537 |
return true; // no data |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1538 |
} |
54927 | 1539 |
|
1540 |
return region_crc_check(region_addr(i), sz, space_at(i)->_crc); |
|
1541 |
} |
|
1542 |
||
1543 |
void FileMapInfo::unmap_regions(int regions[], char* saved_base[], size_t len) { |
|
1544 |
for (int i = 0; i < (int)len; i++) { |
|
1545 |
if (saved_base[i] != NULL) { |
|
1546 |
unmap_region(regions[i]); |
|
1547 |
} |
|
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1548 |
} |
27025 | 1549 |
} |
1 | 1550 |
|
1551 |
// Unmap a memory region in the address space. |
|
1552 |
||
1553 |
void FileMapInfo::unmap_region(int i) { |
|
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1554 |
assert(!HeapShared::is_heap_region(i), "sanity"); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1555 |
CDSFileMapRegion* si = space_at(i); |
1 | 1556 |
size_t used = si->_used; |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
46560
diff
changeset
|
1557 |
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
|
1558 |
|
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1559 |
if (used == 0) { |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1560 |
return; |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1561 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1562 |
|
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1563 |
char* addr = region_addr(i); |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1564 |
if (!os::unmap_memory(addr, size)) { |
1 | 1565 |
fail_stop("Unable to unmap shared space."); |
1566 |
} |
|
1567 |
} |
|
1568 |
||
1569 |
void FileMapInfo::assert_mark(bool check) { |
|
1570 |
if (!check) { |
|
26296 | 1571 |
fail_stop("Mark mismatch while restoring from shared file."); |
1 | 1572 |
} |
1573 |
} |
|
1574 |
||
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1575 |
void FileMapInfo::metaspace_pointers_do(MetaspaceClosure* it) { |
54927 | 1576 |
_shared_path_table.metaspace_pointers_do(it); |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1577 |
} |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1578 |
|
1 | 1579 |
FileMapInfo* FileMapInfo::_current_info = NULL; |
54927 | 1580 |
FileMapInfo* FileMapInfo::_dynamic_archive_info = NULL; |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1581 |
bool FileMapInfo::_heap_pointers_need_patching = false; |
54927 | 1582 |
SharedPathTable FileMapInfo::_shared_path_table; |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1583 |
bool FileMapInfo::_validating_shared_path_table = false; |
54927 | 1584 |
bool FileMapInfo::_memory_mapping_failed = false; |
1 | 1585 |
|
1586 |
// Open the shared archive file, read and validate the header |
|
1587 |
// information (version, boot classpath, etc.). If initialization |
|
1588 |
// fails, shared spaces are disabled and the file is closed. [See |
|
1589 |
// fail_continue.] |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1590 |
// |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1591 |
// Validation of the archive is done in two steps: |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1592 |
// |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1593 |
// [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
|
1594 |
// [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
|
1595 |
// region of the archive, which is not mapped yet. |
54927 | 1596 |
bool FileMapInfo::initialize(bool is_static) { |
1 | 1597 |
assert(UseSharedSpaces, "UseSharedSpaces expected."); |
1598 |
||
52319
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1599 |
if (JvmtiExport::should_post_class_file_load_hook() && JvmtiExport::has_early_class_hook_env()) { |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1600 |
// CDS assumes that no classes resolved in SystemDictionary::resolve_well_known_classes |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1601 |
// are replaced at runtime by JVMTI ClassFileLoadHook. All of those classes are resolved |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1602 |
// during the JVMTI "early" stage, so we can still use CDS if |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1603 |
// JvmtiExport::has_early_class_hook_env() is false. |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1604 |
FileMapInfo::fail_continue("CDS is disabled because early JVMTI ClassFileLoadHook is in use."); |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1605 |
return false; |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1606 |
} |
625f6c742392
8212200: assert when shared java.lang.Object is redefined by JVMTI agent
iklam
parents:
52314
diff
changeset
|
1607 |
|
1 | 1608 |
if (!open_for_read()) { |
1609 |
return false; |
|
1610 |
} |
|
1611 |
||
54927 | 1612 |
init_from_file(_fd, is_static); |
1613 |
if (!validate_header(is_static)) { |
|
1 | 1614 |
return false; |
1615 |
} |
|
1616 |
return true; |
|
1617 |
} |
|
1618 |
||
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1619 |
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
|
1620 |
CDSFileMapRegion* si = space_at(idx); |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1621 |
if (HeapShared::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
|
1622 |
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
|
1623 |
return si->_used > 0 ? |
51720
b7bfd64e43a6
8210523: runtime/appcds/cacheObject/DifferentHeapSizes.java crash
iklam
parents:
51491
diff
changeset
|
1624 |
(char*)start_address_as_decoded_with_current_oop_encoding_mode(si) : NULL; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1625 |
} else { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1626 |
return si->_addr._base; |
31345
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1627 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1628 |
} |
1bba15125d8d
8015086: add interned strings to the shared archive.
jiangli
parents:
31332
diff
changeset
|
1629 |
|
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1630 |
int FileMapHeader::compute_crc() { |
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1631 |
char* start = (char*)this; |
27025 | 1632 |
// start computing from the field after _crc |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1633 |
char* buf = (char*)&_crc + sizeof(_crc); |
54927 | 1634 |
size_t sz = _header_size - (buf - start); |
27025 | 1635 |
int crc = ClassLoader::crc32(0, buf, (jint)sz); |
1636 |
return crc; |
|
1637 |
} |
|
1638 |
||
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
49592
diff
changeset
|
1639 |
// 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
|
1640 |
bool FileMapHeader::validate() { |
27025 | 1641 |
|
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1642 |
if (_obj_alignment != ObjectAlignmentInBytes) { |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1643 |
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
|
1644 |
" does not equal the current ObjectAlignmentInBytes of " INTX_FORMAT ".", |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1645 |
_obj_alignment, ObjectAlignmentInBytes); |
1 | 1646 |
return false; |
1647 |
} |
|
33628 | 1648 |
if (_compact_strings != CompactStrings) { |
1649 |
FileMapInfo::fail_continue("The shared archive file's CompactStrings setting (%s)" |
|
1650 |
" does not equal the current CompactStrings setting (%s).", |
|
1651 |
_compact_strings ? "enabled" : "disabled", |
|
1652 |
CompactStrings ? "enabled" : "disabled"); |
|
1653 |
return false; |
|
1654 |
} |
|
1 | 1655 |
|
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1656 |
// 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
|
1657 |
// header data |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1658 |
const char* prop = Arguments::get_property("java.system.class.loader"); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1659 |
if (prop != NULL) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1660 |
warning("Archived non-system classes are disabled because the " |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1661 |
"java.system.class.loader property is specified (value = \"%s\"). " |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1662 |
"To use archived non-system classes, this property must not be set", prop); |
50039
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1663 |
_has_platform_or_app_classes = false; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1664 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1665 |
|
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1666 |
// For backwards compatibility, we don't check the verification setting |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1667 |
// if the archive only contains system classes. |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1668 |
if (_has_platform_or_app_classes && |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1669 |
((!_verify_local && BytecodeVerificationLocal) || |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1670 |
(!_verify_remote && BytecodeVerificationRemote))) { |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1671 |
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
|
1672 |
"verification setting than the current setting."); |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1673 |
return false; |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1674 |
} |
9fec54fe663d
8197954: Remove unnecessary intermediary APIs from AppCDS implementation
iklam
parents:
49982
diff
changeset
|
1675 |
|
52596
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1676 |
// Java agents are allowed during run time. Therefore, the following condition is not |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1677 |
// checked: (!_allow_archiving_with_java_agent && AllowArchivingWithJavaAgent) |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1678 |
// Note: _allow_archiving_with_java_agent is set in the shared archive during dump time |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1679 |
// while AllowArchivingWithJavaAgent is set during the current run. |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1680 |
if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) { |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1681 |
FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different " |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1682 |
"from the setting in the shared archive."); |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1683 |
return false; |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1684 |
} |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1685 |
|
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1686 |
if (_allow_archiving_with_java_agent) { |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1687 |
warning("This archive was created with AllowArchivingWithJavaAgent. It should be used " |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1688 |
"for testing purposes only and should not be used in a production environment"); |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1689 |
} |
dfa02b3f728c
8201375: Add the AllowArchivingWithJavaAgent diagnostic vm option to allow the use of the -javaagent option during CDS dumping
ccheung
parents:
52562
diff
changeset
|
1690 |
|
1 | 1691 |
return true; |
1692 |
} |
|
1693 |
||
54927 | 1694 |
bool FileMapInfo::validate_header(bool is_static) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1695 |
bool status = _header->validate(); |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1696 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1697 |
if (status) { |
54927 | 1698 |
if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size, is_static)) { |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1699 |
if (!PrintSharedArchiveAndExit) { |
38151
fffedc5e5cf8
8154110: Update class* and safepoint* logging subsystems
mockner
parents:
38108
diff
changeset
|
1700 |
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
|
1701 |
status = false; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1702 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1703 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1704 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1705 |
|
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1706 |
if (_paths_misc_info != NULL) { |
27880
afb974a04396
8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents:
27025
diff
changeset
|
1707 |
FREE_C_HEAP_ARRAY(char, _paths_misc_info); |
26135
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1708 |
_paths_misc_info = NULL; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1709 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1710 |
return status; |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1711 |
} |
82b516c550f7
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
25715
diff
changeset
|
1712 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1713 |
// 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
|
1714 |
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
|
1715 |
assert(idx == MetaspaceShared::ro || |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1716 |
idx == MetaspaceShared::rw || |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1717 |
idx == MetaspaceShared::mc || |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46742
diff
changeset
|
1718 |
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
|
1719 |
char* base = region_addr(idx); |
51477
e77d7687c831
8209657: Refactor filemap.hpp to simplify integration with Serviceability Agent
iklam
parents:
51439
diff
changeset
|
1720 |
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
|
1721 |
return true; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1722 |
} |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1723 |
return false; |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1724 |
} |
e8970711113b
8145221: Use trampolines for i2i and i2c entries in Methods that are stored in CDS archive
ccheung
parents:
37179
diff
changeset
|
1725 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1726 |
// Unmap mapped regions of shared space. |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1727 |
void FileMapInfo::stop_sharing_and_unmap(const char* msg) { |
54927 | 1728 |
MetaspaceShared::set_shared_metaspace_range(NULL, NULL); |
52314
e53af5fa0dae
8212205: VM asserts after CDS archive has been unmapped
iklam
parents:
52126
diff
changeset
|
1729 |
|
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1730 |
FileMapInfo *map_info = FileMapInfo::current_info(); |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1731 |
if (map_info) { |
26296 | 1732 |
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
|
1733 |
for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) { |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1734 |
if (!HeapShared::is_heap_region(i)) { |
51491
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1735 |
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
|
1736 |
if (addr != NULL) { |
187c84a5efe1
8208658: Make CDS archived heap regions usable even if compressed oop encoding has changed
iklam
parents:
51480
diff
changeset
|
1737 |
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
|
1738 |
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
|
1739 |
} |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1740 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1741 |
} |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46746
diff
changeset
|
1742 |
// 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
|
1743 |
// 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
|
1744 |
map_info->dealloc_archive_heap_regions(open_archive_heap_ranges, |
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1745 |
num_open_archive_heap_ranges, |
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1746 |
true); |
52402
72d4e10305b9
8212995: Placing the Integer.IntegerCache and cached Integer objects in the closed archive heap region.
jiangli
parents:
52319
diff
changeset
|
1747 |
map_info->dealloc_archive_heap_regions(closed_archive_heap_ranges, |
52674
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1748 |
num_closed_archive_heap_ranges, |
c9325aa887da
8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents:
52596
diff
changeset
|
1749 |
false); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1750 |
} else if (DumpSharedSpaces) { |
26296 | 1751 |
fail_stop("%s", msg); |
19319
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1752 |
} |
0ad35be0733a
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
18483
diff
changeset
|
1753 |
} |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1754 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1755 |
#if INCLUDE_JVMTI |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1756 |
ClassPathEntry** FileMapInfo::_classpath_entries_for_jvmti = NULL; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1757 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1758 |
ClassPathEntry* FileMapInfo::get_classpath_entry_for_jvmti(int i, TRAPS) { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1759 |
ClassPathEntry* ent = _classpath_entries_for_jvmti[i]; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1760 |
if (ent == NULL) { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1761 |
if (i == 0) { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1762 |
ent = ClassLoader:: get_jrt_entry(); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1763 |
assert(ent != NULL, "must be"); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1764 |
} else { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1765 |
SharedClassPathEntry* scpe = shared_path(i); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1766 |
assert(scpe->is_jar(), "must be"); // other types of scpe will not produce archived classes |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1767 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1768 |
const char* path = scpe->name(); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1769 |
struct stat st; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1770 |
if (os::stat(path, &st) != 0) { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1771 |
char *msg = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(path) + 128); ; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1772 |
jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1773 |
THROW_MSG_(vmSymbols::java_io_IOException(), msg, NULL); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1774 |
} else { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1775 |
ent = ClassLoader::create_class_path_entry(path, &st, /*throw_exception=*/true, false, CHECK_NULL); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1776 |
} |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1777 |
} |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1778 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1779 |
MutexLocker mu(CDSClassFileStream_lock, THREAD); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1780 |
if (_classpath_entries_for_jvmti[i] == NULL) { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1781 |
_classpath_entries_for_jvmti[i] = ent; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1782 |
} else { |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1783 |
// Another thread has beat me to creating this entry |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1784 |
delete ent; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1785 |
ent = _classpath_entries_for_jvmti[i]; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1786 |
} |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1787 |
} |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1788 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1789 |
return ent; |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1790 |
} |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1791 |
|
54340
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1792 |
ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS) { |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1793 |
int path_index = ik->shared_classpath_index(); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1794 |
assert(path_index >= 0, "should be called for shared built-in classes only"); |
54927 | 1795 |
assert(path_index < (int)get_number_of_shared_paths(), "sanity"); |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1796 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1797 |
ClassPathEntry* cpe = get_classpath_entry_for_jvmti(path_index, CHECK_NULL); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1798 |
assert(cpe != NULL, "must be"); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1799 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1800 |
Symbol* name = ik->name(); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1801 |
const char* const class_name = name->as_C_string(); |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1802 |
const char* const file_name = ClassLoader::file_name_for_class_name(class_name, |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1803 |
name->utf8_length()); |
54340
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1804 |
ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1805 |
ClassFileStream* cfs = cpe->open_stream_for_loader(file_name, loader_data, THREAD); |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1806 |
assert(cfs != NULL, "must be able to read the classfile data of shared classes for built-in loaders."); |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1807 |
log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index, |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1808 |
cfs->source(), cfs->length()); |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53911
diff
changeset
|
1809 |
return cfs; |
53884
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1810 |
} |
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1811 |
|
1a7b57d02107
8218751: Do not store original classfiles inside the CDS archive
iklam
parents:
52811
diff
changeset
|
1812 |
#endif |