Mercurial > hg > truffle
annotate src/share/vm/memory/filemap.cpp @ 21202:a03e95b6d629
MoveResolver: refactor handling of blocked registers.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 27 Apr 2015 16:26:14 +0200 |
parents | 0558eb13dcf3 |
children |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12157
diff
changeset
|
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
605
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
605
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
605
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/classLoader.hpp" | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
27 #include "classfile/sharedClassUtil.hpp" |
1972 | 28 #include "classfile/symbolTable.hpp" |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
29 #include "classfile/systemDictionaryShared.hpp" |
7174
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
30 #include "classfile/altHashing.hpp" |
1972 | 31 #include "memory/filemap.hpp" |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
32 #include "memory/metadataFactory.hpp" |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
33 #include "memory/oopFactory.hpp" |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
34 #include "oops/objArrayOop.hpp" |
1972 | 35 #include "runtime/arguments.hpp" |
36 #include "runtime/java.hpp" | |
37 #include "runtime/os.hpp" | |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6725
diff
changeset
|
38 #include "services/memTracker.hpp" |
1972 | 39 #include "utilities/defaultStream.hpp" |
40 | |
0 | 41 # include <sys/stat.h> |
42 # include <errno.h> | |
43 | |
44 #ifndef O_BINARY // if defined (Win32) use binary files. | |
45 #define O_BINARY 0 // otherwise do nothing. | |
46 #endif | |
47 | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
12157
diff
changeset
|
48 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
0 | 49 extern address JVM_FunctionAtStart(); |
50 extern address JVM_FunctionAtEnd(); | |
51 | |
605 | 52 // Complain and stop. All error conditions occurring during the writing of |
0 | 53 // an archive file should stop the process. Unrecoverable errors during |
54 // the reading of the archive file should stop the process. | |
55 | |
56 static void fail(const char *msg, va_list ap) { | |
57 // This occurs very early during initialization: tty is not initialized. | |
58 jio_fprintf(defaultStream::error_stream(), | |
605 | 59 "An error has occurred while processing the" |
0 | 60 " shared archive file.\n"); |
61 jio_vfprintf(defaultStream::error_stream(), msg, ap); | |
62 jio_fprintf(defaultStream::error_stream(), "\n"); | |
12157
35b99e7e0af2
8023381: VM fails to initialize in runtime/CDSCompressedKPtrs/XShareAuto.java runtime/SharedArchiveFile/CdsSameObjectAlignment.java
hseigel
parents:
12056
diff
changeset
|
63 // Do not change the text of the below message because some tests check for it. |
0 | 64 vm_exit_during_initialization("Unable to use shared archive.", NULL); |
65 } | |
66 | |
67 | |
68 void FileMapInfo::fail_stop(const char *msg, ...) { | |
69 va_list ap; | |
70 va_start(ap, msg); | |
71 fail(msg, ap); // Never returns. | |
72 va_end(ap); // for completeness. | |
73 } | |
74 | |
75 | |
76 // Complain and continue. Recoverable errors during the reading of the | |
77 // archive file may continue (with sharing disabled). | |
78 // | |
79 // If we continue, then disable shared spaces and close the file. | |
80 | |
81 void FileMapInfo::fail_continue(const char *msg, ...) { | |
82 va_list ap; | |
83 va_start(ap, msg); | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
84 MetaspaceShared::set_archive_loading_failed(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
85 if (PrintSharedArchiveAndExit && _validating_classpath_entry_table) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
86 // If we are doing PrintSharedArchiveAndExit and some of the classpath entries |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
87 // do not validate, we can still continue "limping" to validate the remaining |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
88 // entries. No need to quit. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
89 tty->print("["); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
90 tty->vprint(msg, ap); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
91 tty->print_cr("]"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
92 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
93 if (RequireSharedSpaces) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
94 fail(msg, ap); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
95 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
96 if (PrintSharedSpaces) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
97 tty->print_cr("UseSharedSpaces: %s", msg); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
98 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
99 } |
20700
0558eb13dcf3
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
20527
diff
changeset
|
100 UseSharedSpaces = false; |
0558eb13dcf3
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
20527
diff
changeset
|
101 assert(current_info() != NULL, "singleton must be registered"); |
0558eb13dcf3
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
20527
diff
changeset
|
102 current_info()->close(); |
0 | 103 } |
104 va_end(ap); | |
105 } | |
106 | |
7174
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
107 // Fill in the fileMapInfo structure with data about this VM instance. |
0 | 108 |
7174
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
109 // This method copies the vm version info into header_version. If the version is too |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
110 // long then a truncated version, which has a hash code appended to it, is copied. |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
111 // |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
112 // Using a template enables this method to verify that header_version is an array of |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
113 // length JVM_IDENT_MAX. This ensures that the code that writes to the CDS file and |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
114 // the code that reads the CDS file will both use the same size buffer. Hence, will |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
115 // use identical truncation. This is necessary for matching of truncated versions. |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
116 template <int N> static void get_header_version(char (&header_version) [N]) { |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
117 assert(N == JVM_IDENT_MAX, "Bad header_version size"); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
118 |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
119 const char *vm_version = VM_Version::internal_vm_info_string(); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
120 const int version_len = (int)strlen(vm_version); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
121 |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
122 if (version_len < (JVM_IDENT_MAX-1)) { |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
123 strcpy(header_version, vm_version); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
124 |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
125 } else { |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
126 // Get the hash value. Use a static seed because the hash needs to return the same |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
127 // value over multiple jvm invocations. |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
128 unsigned int hash = AltHashing::murmur3_32(8191, (const jbyte*)vm_version, version_len); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
129 |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
130 // Truncate the ident, saving room for the 8 hex character hash value. |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
131 strncpy(header_version, vm_version, JVM_IDENT_MAX-9); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
132 |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
133 // Append the hash code as eight hex digits. |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
134 sprintf(&header_version[JVM_IDENT_MAX-9], "%08x", hash); |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
135 header_version[JVM_IDENT_MAX-1] = 0; // Null terminate. |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
136 } |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
137 } |
0 | 138 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
139 FileMapInfo::FileMapInfo() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
140 assert(_current_info == NULL, "must be singleton"); // not thread safe |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
141 _current_info = this; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
142 memset(this, 0, sizeof(FileMapInfo)); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
143 _file_offset = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
144 _file_open = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
145 _header = SharedClassUtil::allocate_file_map_header(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
146 _header->_version = _invalid_version; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
147 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
148 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
149 FileMapInfo::~FileMapInfo() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
150 assert(_current_info == this, "must be singleton"); // not thread safe |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
151 _current_info = NULL; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
152 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
153 |
0 | 154 void FileMapInfo::populate_header(size_t alignment) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
155 _header->populate(this, alignment); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
156 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
157 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
158 size_t FileMapInfo::FileMapHeader::data_size() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
159 return SharedClassUtil::file_map_header_size() - sizeof(FileMapInfo::FileMapHeaderBase); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
160 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
161 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
162 void FileMapInfo::FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
163 _magic = 0xf00baba2; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
164 _version = _current_version; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
165 _alignment = alignment; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
166 _obj_alignment = ObjectAlignmentInBytes; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
167 _classpath_entry_table_size = mapinfo->_classpath_entry_table_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
168 _classpath_entry_table = mapinfo->_classpath_entry_table; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
169 _classpath_entry_size = mapinfo->_classpath_entry_size; |
0 | 170 |
171 // The following fields are for sanity checks for whether this archive | |
172 // will function correctly with this JVM and the bootclasspath it's | |
173 // invoked with. | |
174 | |
175 // JVM version string ... changes on each build. | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
176 get_header_version(_jvm_ident); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
177 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
178 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
179 void FileMapInfo::allocate_classpath_entry_table() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
180 int bytes = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
181 int count = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
182 char* strptr = NULL; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
183 char* strptr_max = NULL; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
184 Thread* THREAD = Thread::current(); |
0 | 185 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
186 ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
187 size_t entry_size = SharedClassUtil::shared_class_path_entry_size(); |
0 | 188 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
189 for (int pass=0; pass<2; pass++) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
190 ClassPathEntry *cpe = ClassLoader::classpath_entry(0); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
191 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
192 for (int cur_entry = 0 ; cpe != NULL; cpe = cpe->next(), cur_entry++) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
193 const char *name = cpe->name(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
194 int name_bytes = (int)(strlen(name) + 1); |
0 | 195 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
196 if (pass == 0) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
197 count ++; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
198 bytes += (int)entry_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
199 bytes += name_bytes; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
200 if (TraceClassPaths || (TraceClassLoading && Verbose)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
201 tty->print_cr("[Add main shared path (%s) %s]", (cpe->is_jar_file() ? "jar" : "dir"), name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
202 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
203 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
204 SharedClassPathEntry* ent = shared_classpath(cur_entry); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
205 if (cpe->is_jar_file()) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
206 struct stat st; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
207 if (os::stat(name, &st) != 0) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
208 // The file/dir must exist, or it would not have been added |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
209 // into ClassLoader::classpath_entry(). |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
210 // |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
211 // If we can't access a jar file in the boot path, then we can't |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
212 // make assumptions about where classes get loaded from. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
213 FileMapInfo::fail_stop("Unable to open jar file %s.", name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
214 } |
0 | 215 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
216 EXCEPTION_MARK; // The following call should never throw, but would exit VM on error. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
217 SharedClassUtil::update_shared_classpath(cpe, ent, st.st_mtime, st.st_size, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
218 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
219 ent->_filesize = -1; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
220 if (!os::dir_is_empty(name)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
221 ClassLoader::exit_with_path_failure("Cannot have non-empty directory in archived classpaths", name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
222 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
223 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
224 ent->_name = strptr; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
225 if (strptr + name_bytes <= strptr_max) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
226 strncpy(strptr, name, (size_t)name_bytes); // name_bytes includes trailing 0. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
227 strptr += name_bytes; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
228 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
229 assert(0, "miscalculated buffer size"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
230 } |
0 | 231 } |
232 } | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
233 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
234 if (pass == 0) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
235 EXCEPTION_MARK; // The following call should never throw, but would exit VM on error. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
236 Array<u8>* arr = MetadataFactory::new_array<u8>(loader_data, (bytes + 7)/8, THREAD); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
237 strptr = (char*)(arr->data()); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
238 strptr_max = strptr + bytes; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
239 SharedClassPathEntry* table = (SharedClassPathEntry*)strptr; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
240 strptr += entry_size * count; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
241 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
242 _classpath_entry_table_size = count; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
243 _classpath_entry_table = table; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
244 _classpath_entry_size = entry_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
245 } |
0 | 246 } |
247 } | |
248 | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
249 bool FileMapInfo::validate_classpath_entry_table() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
250 _validating_classpath_entry_table = true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
251 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
252 int count = _header->_classpath_entry_table_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
253 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
254 _classpath_entry_table = _header->_classpath_entry_table; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
255 _classpath_entry_size = _header->_classpath_entry_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
256 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
257 for (int i=0; i<count; i++) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
258 SharedClassPathEntry* ent = shared_classpath(i); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
259 struct stat st; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
260 const char* name = ent->_name; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
261 bool ok = true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
262 if (TraceClassPaths || (TraceClassLoading && Verbose)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
263 tty->print_cr("[Checking shared classpath entry: %s]", name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
264 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
265 if (os::stat(name, &st) != 0) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
266 fail_continue("Required classpath entry does not exist: %s", name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
267 ok = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
268 } else if (ent->is_dir()) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
269 if (!os::dir_is_empty(name)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
270 fail_continue("directory is not empty: %s", name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
271 ok = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
272 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
273 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
274 if (ent->_timestamp != st.st_mtime || |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
275 ent->_filesize != st.st_size) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
276 ok = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
277 if (PrintSharedArchiveAndExit) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
278 fail_continue(ent->_timestamp != st.st_mtime ? |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
279 "Timestamp mismatch" : |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
280 "File size mismatch"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
281 } else { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
282 fail_continue("A jar file is not the one used while building" |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
283 " the shared archive file: %s", name); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
284 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
285 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
286 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
287 if (ok) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
288 if (TraceClassPaths || (TraceClassLoading && Verbose)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
289 tty->print_cr("[ok]"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
290 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
291 } else if (!PrintSharedArchiveAndExit) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
292 _validating_classpath_entry_table = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
293 return false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
294 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
295 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
296 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
297 _classpath_entry_table_size = _header->_classpath_entry_table_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
298 _validating_classpath_entry_table = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
299 return true; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
300 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
301 |
0 | 302 |
303 // Read the FileMapInfo information from the file. | |
304 | |
305 bool FileMapInfo::init_from_file(int fd) { | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
306 size_t sz = _header->data_size(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
307 char* addr = _header->data(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
308 size_t n = os::read(fd, addr, (unsigned int)sz); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
309 if (n != sz) { |
0 | 310 fail_continue("Unable to read the file header."); |
311 return false; | |
312 } | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
313 if (_header->_version != current_version()) { |
0 | 314 fail_continue("The shared archive file has the wrong version."); |
315 return false; | |
316 } | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
317 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
318 size_t info_size = _header->_paths_misc_info_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
319 _paths_misc_info = NEW_C_HEAP_ARRAY_RETURN_NULL(char, info_size, mtClass); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
320 if (_paths_misc_info == NULL) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
321 fail_continue("Unable to read the file header."); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
322 return false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
323 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
324 n = os::read(fd, _paths_misc_info, (unsigned int)info_size); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
325 if (n != info_size) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
326 fail_continue("Unable to read the shared path info header."); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
327 FREE_C_HEAP_ARRAY(char, _paths_misc_info, mtClass); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
328 _paths_misc_info = NULL; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
329 return false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
330 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
331 |
18096 | 332 size_t len = lseek(fd, 0, SEEK_END); |
333 struct FileMapInfo::FileMapHeader::space_info* si = | |
20527 | 334 &_header->_space[MetaspaceShared::mc]; |
18096 | 335 if (si->_file_offset >= len || len - si->_file_offset < si->_used) { |
336 fail_continue("The shared archive file has been truncated."); | |
337 return false; | |
338 } | |
20527 | 339 |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
340 _file_offset += (long)n; |
0 | 341 return true; |
342 } | |
343 | |
344 | |
345 // Read the FileMapInfo information from the file. | |
346 bool FileMapInfo::open_for_read() { | |
347 _full_path = Arguments::GetSharedArchivePath(); | |
348 int fd = open(_full_path, O_RDONLY | O_BINARY, 0); | |
349 if (fd < 0) { | |
350 if (errno == ENOENT) { | |
351 // Not locating the shared archive is ok. | |
352 fail_continue("Specified shared archive not found."); | |
353 } else { | |
354 fail_continue("Failed to open shared archive file (%s).", | |
355 strerror(errno)); | |
356 } | |
357 return false; | |
358 } | |
359 | |
360 _fd = fd; | |
361 _file_open = true; | |
362 return true; | |
363 } | |
364 | |
365 | |
366 // Write the FileMapInfo information to the file. | |
367 | |
368 void FileMapInfo::open_for_write() { | |
369 _full_path = Arguments::GetSharedArchivePath(); | |
370 if (PrintSharedSpaces) { | |
371 tty->print_cr("Dumping shared data to file: "); | |
372 tty->print_cr(" %s", _full_path); | |
373 } | |
374 | |
7980
c4ef3380a70b
7197672: There are issues with shared data on windows
hseigel
parents:
7461
diff
changeset
|
375 #ifdef _WINDOWS // On Windows, need WRITE permission to remove the file. |
c4ef3380a70b
7197672: There are issues with shared data on windows
hseigel
parents:
7461
diff
changeset
|
376 chmod(_full_path, _S_IREAD | _S_IWRITE); |
c4ef3380a70b
7197672: There are issues with shared data on windows
hseigel
parents:
7461
diff
changeset
|
377 #endif |
c4ef3380a70b
7197672: There are issues with shared data on windows
hseigel
parents:
7461
diff
changeset
|
378 |
c4ef3380a70b
7197672: There are issues with shared data on windows
hseigel
parents:
7461
diff
changeset
|
379 // Use remove() to delete the existing file because, on Unix, this will |
c4ef3380a70b
7197672: There are issues with shared data on windows
hseigel
parents:
7461
diff
changeset
|
380 // allow processes that have it open continued access to the file. |
0 | 381 remove(_full_path); |
382 int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444); | |
383 if (fd < 0) { | |
384 fail_stop("Unable to create shared archive file %s.", _full_path); | |
385 } | |
386 _fd = fd; | |
387 _file_offset = 0; | |
388 _file_open = true; | |
389 } | |
390 | |
391 | |
392 // Write the header to the file, seek to the next allocation boundary. | |
393 | |
394 void FileMapInfo::write_header() { | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
395 int info_size = ClassLoader::get_shared_paths_misc_info_size(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
396 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
397 _header->_paths_misc_info_size = info_size; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
398 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
399 align_file_position(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
400 size_t sz = _header->data_size(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
401 char* addr = _header->data(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
402 write_bytes(addr, (int)sz); // skip the C++ vtable |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
403 write_bytes(ClassLoader::get_shared_paths_misc_info(), info_size); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
404 align_file_position(); |
0 | 405 } |
406 | |
407 | |
408 // Dump shared spaces to file. | |
409 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
410 void FileMapInfo::write_space(int i, Metaspace* space, bool read_only) { |
0 | 411 align_file_position(); |
10183
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8804
diff
changeset
|
412 size_t used = space->used_bytes_slow(Metaspace::NonClassType); |
868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
jmasa
parents:
8804
diff
changeset
|
413 size_t capacity = space->capacity_bytes_slow(Metaspace::NonClassType); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
414 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i]; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
415 write_region(i, (char*)space->bottom(), used, capacity, read_only, false); |
0 | 416 } |
417 | |
418 | |
419 // Dump region to file. | |
420 | |
421 void FileMapInfo::write_region(int region, char* base, size_t size, | |
422 size_t capacity, bool read_only, | |
423 bool allow_exec) { | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
424 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[region]; |
0 | 425 |
426 if (_file_open) { | |
427 guarantee(si->_file_offset == _file_offset, "file offset mismatch."); | |
428 if (PrintSharedSpaces) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
429 tty->print_cr("Shared file region %d: 0x%6x bytes, addr " INTPTR_FORMAT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
430 " file offset 0x%6x", region, size, base, _file_offset); |
0 | 431 } |
432 } else { | |
433 si->_file_offset = _file_offset; | |
434 } | |
435 si->_base = base; | |
436 si->_used = size; | |
437 si->_capacity = capacity; | |
438 si->_read_only = read_only; | |
439 si->_allow_exec = allow_exec; | |
18096 | 440 si->_crc = ClassLoader::crc32(0, base, (jint)size); |
0 | 441 write_bytes_aligned(base, (int)size); |
442 } | |
443 | |
444 | |
445 // Dump bytes to file -- at the current file position. | |
446 | |
447 void FileMapInfo::write_bytes(const void* buffer, int nbytes) { | |
448 if (_file_open) { | |
449 int n = ::write(_fd, buffer, nbytes); | |
450 if (n != nbytes) { | |
451 // It is dangerous to leave the corrupted shared archive file around, | |
452 // close and remove the file. See bug 6372906. | |
453 close(); | |
454 remove(_full_path); | |
455 fail_stop("Unable to write to shared archive file.", NULL); | |
456 } | |
457 } | |
458 _file_offset += nbytes; | |
459 } | |
460 | |
461 | |
462 // Align file position to an allocation unit boundary. | |
463 | |
464 void FileMapInfo::align_file_position() { | |
18096 | 465 size_t new_file_offset = align_size_up(_file_offset, |
466 os::vm_allocation_granularity()); | |
0 | 467 if (new_file_offset != _file_offset) { |
468 _file_offset = new_file_offset; | |
469 if (_file_open) { | |
470 // Seek one byte back from the target and write a byte to insure | |
471 // that the written file is the correct length. | |
472 _file_offset -= 1; | |
18096 | 473 if (lseek(_fd, (long)_file_offset, SEEK_SET) < 0) { |
0 | 474 fail_stop("Unable to seek.", NULL); |
475 } | |
476 char zero = 0; | |
477 write_bytes(&zero, 1); | |
478 } | |
479 } | |
480 } | |
481 | |
482 | |
483 // Dump bytes to file -- at the current file position. | |
484 | |
485 void FileMapInfo::write_bytes_aligned(const void* buffer, int nbytes) { | |
486 align_file_position(); | |
487 write_bytes(buffer, nbytes); | |
488 align_file_position(); | |
489 } | |
490 | |
491 | |
492 // Close the shared archive file. This does NOT unmap mapped regions. | |
493 | |
494 void FileMapInfo::close() { | |
495 if (_file_open) { | |
496 if (::close(_fd) < 0) { | |
497 fail_stop("Unable to close the shared archive file."); | |
498 } | |
499 _file_open = false; | |
500 _fd = -1; | |
501 } | |
502 } | |
503 | |
504 | |
505 // JVM/TI RedefineClasses() support: | |
506 // Remap the shared readonly space to shared readwrite, private. | |
507 bool FileMapInfo::remap_shared_readonly_as_readwrite() { | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
508 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[0]; |
0 | 509 if (!si->_read_only) { |
510 // the space is already readwrite so we are done | |
511 return true; | |
512 } | |
513 size_t used = si->_used; | |
514 size_t size = align_size_up(used, os::vm_allocation_granularity()); | |
515 if (!open_for_read()) { | |
516 return false; | |
517 } | |
518 char *base = os::remap_memory(_fd, _full_path, si->_file_offset, | |
519 si->_base, size, false /* !read_only */, | |
520 si->_allow_exec); | |
521 close(); | |
522 if (base == NULL) { | |
523 fail_continue("Unable to remap shared readonly space (errno=%d).", errno); | |
524 return false; | |
525 } | |
526 if (base != si->_base) { | |
527 fail_continue("Unable to remap shared readonly space at required address."); | |
528 return false; | |
529 } | |
530 si->_read_only = false; | |
531 return true; | |
532 } | |
533 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
534 // Map the whole region at once, assumed to be allocated contiguously. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
535 ReservedSpace FileMapInfo::reserve_shared_memory() { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
536 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[0]; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
537 char* requested_addr = si->_base; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
538 |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
539 size_t size = FileMapInfo::shared_spaces_size(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
540 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
541 // Reserve the space first, then map otherwise map will go right over some |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
542 // other reserved memory (like the code cache). |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
543 ReservedSpace rs(size, os::vm_allocation_granularity(), false, requested_addr); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
544 if (!rs.is_reserved()) { |
8804
91bf0bdae37b
8008217: CDS: Class data sharing limits the malloc heap on Solaris
coleenp
parents:
7980
diff
changeset
|
545 fail_continue(err_msg("Unable to reserve shared space at required address " INTPTR_FORMAT, requested_addr)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
546 return rs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
547 } |
6882
716c64bda5ba
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
6725
diff
changeset
|
548 // the reserved virtual memory is for mapping class data sharing archive |
7460
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
549 MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared); |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
550 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
551 return rs; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
552 } |
0 | 553 |
554 // Memory map a region in the address space. | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
555 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode"}; |
0 | 556 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
557 char* FileMapInfo::map_region(int i) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
558 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i]; |
0 | 559 size_t used = si->_used; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
560 size_t alignment = os::vm_allocation_granularity(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
561 size_t size = align_size_up(used, alignment); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
562 char *requested_addr = si->_base; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
563 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
564 // map the contents of the CDS archive in this memory |
0 | 565 char *base = os::map_memory(_fd, _full_path, si->_file_offset, |
566 requested_addr, size, si->_read_only, | |
567 si->_allow_exec); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
568 if (base == NULL || base != si->_base) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
569 fail_continue(err_msg("Unable to map %s shared space at required address.", shared_region_name[i])); |
0 | 570 return NULL; |
571 } | |
7460
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
572 #ifdef _WINDOWS |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
573 // This call is Windows-only because the memory_type gets recorded for the other platforms |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
574 // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
575 MemTracker::record_virtual_memory_type((address)base, mtClassShared); |
6c3f47d964f3
8003705: CDS failed on Windows: can not map in the CDS.
hseigel
parents:
7174
diff
changeset
|
576 #endif |
0 | 577 return base; |
578 } | |
579 | |
18096 | 580 bool FileMapInfo::verify_region_checksum(int i) { |
581 if (!VerifySharedSpaces) { | |
582 return true; | |
583 } | |
20527 | 584 const char* buf = _header->_space[i]._base; |
585 size_t sz = _header->_space[i]._used; | |
18096 | 586 int crc = ClassLoader::crc32(0, buf, (jint)sz); |
20527 | 587 if (crc != _header->_space[i]._crc) { |
18096 | 588 fail_continue("Checksum verification failed."); |
589 return false; | |
590 } | |
591 return true; | |
592 } | |
0 | 593 |
594 // Unmap a memory region in the address space. | |
595 | |
596 void FileMapInfo::unmap_region(int i) { | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
597 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i]; |
0 | 598 size_t used = si->_used; |
599 size_t size = align_size_up(used, os::vm_allocation_granularity()); | |
600 if (!os::unmap_memory(si->_base, size)) { | |
601 fail_stop("Unable to unmap shared space."); | |
602 } | |
603 } | |
604 | |
605 | |
606 void FileMapInfo::assert_mark(bool check) { | |
607 if (!check) { | |
608 fail_stop("Mark mismatch while restoring from shared file.", NULL); | |
609 } | |
610 } | |
611 | |
612 | |
613 FileMapInfo* FileMapInfo::_current_info = NULL; | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
614 SharedClassPathEntry* FileMapInfo::_classpath_entry_table = NULL; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
615 int FileMapInfo::_classpath_entry_table_size = 0; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
616 size_t FileMapInfo::_classpath_entry_size = 0x1234baad; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
617 bool FileMapInfo::_validating_classpath_entry_table = false; |
0 | 618 |
619 // Open the shared archive file, read and validate the header | |
620 // information (version, boot classpath, etc.). If initialization | |
621 // fails, shared spaces are disabled and the file is closed. [See | |
622 // fail_continue.] | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
623 // |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
624 // Validation of the archive is done in two steps: |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
625 // |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
626 // [1] validate_header() - done here. This checks the header, including _paths_misc_info. |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
627 // [2] validate_classpath_entry_table - this is done later, because the table is in the RW |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
628 // region of the archive, which is not mapped yet. |
0 | 629 bool FileMapInfo::initialize() { |
630 assert(UseSharedSpaces, "UseSharedSpaces expected."); | |
631 | |
632 if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) { | |
633 fail_continue("Tool agent requires sharing to be disabled."); | |
634 return false; | |
635 } | |
636 | |
637 if (!open_for_read()) { | |
638 return false; | |
639 } | |
640 | |
641 init_from_file(_fd); | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
642 if (!validate_header()) { |
0 | 643 return false; |
644 } | |
645 | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
646 SharedReadOnlySize = _header->_space[0]._capacity; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
647 SharedReadWriteSize = _header->_space[1]._capacity; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
648 SharedMiscDataSize = _header->_space[2]._capacity; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
649 SharedMiscCodeSize = _header->_space[3]._capacity; |
0 | 650 return true; |
651 } | |
652 | |
20527 | 653 int FileMapInfo::FileMapHeader::compute_crc() { |
654 char* header = data(); | |
18096 | 655 // start computing from the field after _crc |
20527 | 656 char* buf = (char*)&_crc + sizeof(int); |
657 size_t sz = data_size() - (buf - header); | |
18096 | 658 int crc = ClassLoader::crc32(0, buf, (jint)sz); |
659 return crc; | |
660 } | |
0 | 661 |
20527 | 662 int FileMapInfo::compute_header_crc() { |
663 return _header->compute_crc(); | |
664 } | |
665 | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
666 bool FileMapInfo::FileMapHeader::validate() { |
20527 | 667 if (_magic != (int)0xf00baba2) { |
668 FileMapInfo::fail_continue("The shared archive file has a bad magic number."); | |
669 return false; | |
670 } | |
671 if (VerifySharedSpaces && compute_crc() != _crc) { | |
18096 | 672 fail_continue("Header checksum verification failed."); |
673 return false; | |
674 } | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
675 if (_version != current_version()) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
676 FileMapInfo::fail_continue("The shared archive file is the wrong version."); |
20527 | 677 |
0 | 678 return false; |
679 } | |
7174
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
680 char header_version[JVM_IDENT_MAX]; |
fe81517cfb77
6924920: Class Data Sharing limit on the java version string can create failures
hseigel
parents:
6882
diff
changeset
|
681 get_header_version(header_version); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
682 if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
683 if (TraceClassPaths) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
684 tty->print_cr("Expected: %s", header_version); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
685 tty->print_cr("Actual: %s", _jvm_ident); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
686 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
687 FileMapInfo::fail_continue("The shared archive file was created by a different" |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
688 " version or build of HotSpot"); |
0 | 689 return false; |
690 } | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
691 if (_obj_alignment != ObjectAlignmentInBytes) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
692 FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d" |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
693 " does not equal the current ObjectAlignmentInBytes of %d.", |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
694 _obj_alignment, ObjectAlignmentInBytes); |
0 | 695 return false; |
696 } | |
697 | |
698 return true; | |
699 } | |
700 | |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
701 bool FileMapInfo::validate_header() { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
702 bool status = _header->validate(); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
703 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
704 if (status) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
705 if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
706 if (!PrintSharedArchiveAndExit) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
707 fail_continue("shared class paths mismatch (hint: enable -XX:+TraceClassPaths to diagnose the failure)"); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
708 status = false; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
709 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
710 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
711 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
712 |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
713 if (_paths_misc_info != NULL) { |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
714 FREE_C_HEAP_ARRAY(char, _paths_misc_info, mtClass); |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
715 _paths_misc_info = NULL; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
716 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
717 return status; |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
718 } |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
719 |
0 | 720 // The following method is provided to see whether a given pointer |
721 // falls in the mapped shared space. | |
722 // Param: | |
723 // p, The given pointer | |
724 // Return: | |
725 // True if the p is within the mapped shared space, otherwise, false. | |
726 bool FileMapInfo::is_in_shared_space(const void* p) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1980
diff
changeset
|
727 for (int i = 0; i < MetaspaceShared::n_regions; i++) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
728 if (p >= _header->_space[i]._base && |
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
729 p < _header->_space[i]._base + _header->_space[i]._used) { |
0 | 730 return true; |
731 } | |
732 } | |
733 | |
734 return false; | |
735 } | |
11056
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
736 |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
737 void FileMapInfo::print_shared_spaces() { |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
738 gclog_or_tty->print_cr("Shared Spaces:"); |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
739 for (int i = 0; i < MetaspaceShared::n_regions; i++) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
740 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i]; |
11056
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
741 gclog_or_tty->print(" %s " INTPTR_FORMAT "-" INTPTR_FORMAT, |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
742 shared_region_name[i], |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
743 si->_base, si->_base + si->_used); |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
744 } |
221df7e37535
8016075: Win32 crash with CDS enabled and small heap size
iklam
parents:
10183
diff
changeset
|
745 } |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
746 |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
747 // Unmap mapped regions of shared space. |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
748 void FileMapInfo::stop_sharing_and_unmap(const char* msg) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
749 FileMapInfo *map_info = FileMapInfo::current_info(); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
750 if (map_info) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
751 map_info->fail_continue(msg); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
752 for (int i = 0; i < MetaspaceShared::n_regions; i++) { |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
753 if (map_info->_header->_space[i]._base != NULL) { |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
754 map_info->unmap_region(i); |
20375
6e0cb14ce59b
8046070: Class Data Sharing clean up and refactoring
iklam
parents:
17937
diff
changeset
|
755 map_info->_header->_space[i]._base = NULL; |
12056
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
756 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
757 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
758 } else if (DumpSharedSpaces) { |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
759 fail_stop(msg, NULL); |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
760 } |
740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents:
11056
diff
changeset
|
761 } |