author | stefank |
Thu, 09 May 2019 14:26:03 +0200 | |
changeset 54780 | f8d182aedc92 |
parent 54669 | ad45b3802d4e |
child 55159 | a38132298eda |
child 58678 | 9cf78a70fa4f |
permissions | -rw-r--r-- |
42650 | 1 |
/* |
53582 | 2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
42650 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
#include "precompiled.hpp" |
|
25 |
#include "aot/aotCodeHeap.hpp" |
|
26 |
#include "aot/aotLoader.inline.hpp" |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
27 |
#include "jvm.h" |
49360 | 28 |
#include "memory/allocation.inline.hpp" |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
54623
diff
changeset
|
29 |
#include "memory/resourceArea.hpp" |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
30 |
#include "oops/compressedOops.hpp" |
42650 | 31 |
#include "oops/method.hpp" |
49361
1956d0ec092a
8199319: Remove handles.inline.hpp include from reflectionUtils.hpp
stefank
parents:
49360
diff
changeset
|
32 |
#include "runtime/handles.inline.hpp" |
53582 | 33 |
#include "runtime/os.inline.hpp" |
46629
8eeacdc76bf2
8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents:
46560
diff
changeset
|
34 |
#include "runtime/timerTrace.hpp" |
42650 | 35 |
|
36 |
GrowableArray<AOTCodeHeap*>* AOTLoader::_heaps = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTCodeHeap*> (2, true); |
|
37 |
GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode) GrowableArray<AOTLib*> (2, true); |
|
38 |
||
39 |
// Iterate over all AOT CodeHeaps |
|
40 |
#define FOR_ALL_AOT_HEAPS(heap) for (GrowableArrayIterator<AOTCodeHeap*> heap = heaps()->begin(); heap != heaps()->end(); ++heap) |
|
41 |
// Iterate over all AOT Libraries |
|
42 |
#define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib) |
|
43 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
44 |
void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* thread) { |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
49847
diff
changeset
|
45 |
if (ik->is_unsafe_anonymous()) { |
47668 | 46 |
// don't even bother |
47 |
return; |
|
48 |
} |
|
42650 | 49 |
if (UseAOT) { |
52333
c401c536cea1
8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents:
52145
diff
changeset
|
50 |
// We allow hotswap to be enabled after the onload phase, but not breakpoints |
c401c536cea1
8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents:
52145
diff
changeset
|
51 |
assert(!JvmtiExport::can_post_breakpoint(), "AOT should have been disabled."); |
42650 | 52 |
FOR_ALL_AOT_HEAPS(heap) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
53 |
(*heap)->load_klass_data(ik, thread); |
42650 | 54 |
} |
55 |
} |
|
56 |
} |
|
57 |
||
58 |
uint64_t AOTLoader::get_saved_fingerprint(InstanceKlass* ik) { |
|
51770
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
59 |
assert(UseAOT, "called only when AOT is enabled"); |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
49847
diff
changeset
|
60 |
if (ik->is_unsafe_anonymous()) { |
47668 | 61 |
// don't even bother |
62 |
return 0; |
|
63 |
} |
|
42650 | 64 |
FOR_ALL_AOT_HEAPS(heap) { |
65 |
AOTKlassData* klass_data = (*heap)->find_klass(ik); |
|
66 |
if (klass_data != NULL) { |
|
67 |
return klass_data->_fingerprint; |
|
68 |
} |
|
69 |
} |
|
70 |
return 0; |
|
71 |
} |
|
72 |
||
73 |
void AOTLoader::oops_do(OopClosure* f) { |
|
74 |
if (UseAOT) { |
|
75 |
FOR_ALL_AOT_HEAPS(heap) { |
|
76 |
(*heap)->oops_do(f); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
||
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53641
diff
changeset
|
81 |
void AOTLoader::metadata_do(MetadataClosure* f) { |
42650 | 82 |
if (UseAOT) { |
83 |
FOR_ALL_AOT_HEAPS(heap) { |
|
84 |
(*heap)->metadata_do(f); |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
88 |
||
53641
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
89 |
void AOTLoader::mark_evol_dependent_methods(InstanceKlass* dependee) { |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
90 |
if (UseAOT) { |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
91 |
FOR_ALL_AOT_HEAPS(heap) { |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
92 |
(*heap)->mark_evol_dependent_methods(dependee); |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
93 |
} |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
94 |
} |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
95 |
} |
c572eb605087
8139551: Scalability problem with redefinition - multiple code cache walks
coleenp
parents:
53582
diff
changeset
|
96 |
|
42650 | 97 |
/** |
98 |
* List of core modules for which we search for shared libraries. |
|
99 |
*/ |
|
100 |
static const char* modules[] = { |
|
101 |
"java.base", |
|
102 |
"java.logging", |
|
103 |
"jdk.compiler", |
|
104 |
"jdk.scripting.nashorn", |
|
43972 | 105 |
"jdk.internal.vm.ci", |
106 |
"jdk.internal.vm.compiler" |
|
42650 | 107 |
}; |
108 |
||
109 |
void AOTLoader::initialize() { |
|
46629
8eeacdc76bf2
8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents:
46560
diff
changeset
|
110 |
TraceTime timer("AOT initialization", TRACETIME_LOG(Info, aot, startuptime)); |
8eeacdc76bf2
8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents:
46560
diff
changeset
|
111 |
|
42650 | 112 |
if (FLAG_IS_DEFAULT(UseAOT) && AOTLibrary != NULL) { |
113 |
// Don't need to set UseAOT on command line when AOTLibrary is specified |
|
114 |
FLAG_SET_DEFAULT(UseAOT, true); |
|
115 |
} |
|
116 |
if (UseAOT) { |
|
117 |
// EagerInitialization is not compatible with AOT |
|
118 |
if (EagerInitialization) { |
|
42658
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
119 |
if (PrintAOT) { |
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
120 |
warning("EagerInitialization is not compatible with AOT (switching AOT off)"); |
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
121 |
} |
42650 | 122 |
FLAG_SET_DEFAULT(UseAOT, false); |
123 |
return; |
|
124 |
} |
|
125 |
||
52333
c401c536cea1
8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents:
52145
diff
changeset
|
126 |
if (JvmtiExport::can_post_breakpoint()) { |
51770
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
127 |
if (PrintAOT) { |
52333
c401c536cea1
8211743: [AOT] crash in ScopeDesc::decode_body() when JVMTI walks AOT frames
dlong
parents:
52145
diff
changeset
|
128 |
warning("JVMTI capability to post breakpoint is not compatible with AOT (switching AOT off)"); |
51770
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
129 |
} |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
130 |
FLAG_SET_DEFAULT(UseAOT, false); |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
131 |
return; |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
132 |
} |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
133 |
|
42650 | 134 |
// -Xint is not compatible with AOT |
135 |
if (Arguments::is_interpreter_only()) { |
|
42658
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
136 |
if (PrintAOT) { |
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
137 |
warning("-Xint is not compatible with AOT (switching AOT off)"); |
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
138 |
} |
42650 | 139 |
FLAG_SET_DEFAULT(UseAOT, false); |
140 |
return; |
|
141 |
} |
|
142 |
||
52145
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
143 |
#ifdef _WINDOWS |
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
144 |
const char pathSep = ';'; |
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
145 |
#else |
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
146 |
const char pathSep = ':'; |
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
147 |
#endif |
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
148 |
|
42650 | 149 |
// Scan the AOTLibrary option. |
150 |
if (AOTLibrary != NULL) { |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
151 |
const int len = (int)strlen(AOTLibrary); |
42650 | 152 |
char* cp = NEW_C_HEAP_ARRAY(char, len+1, mtCode); |
153 |
if (cp != NULL) { // No memory? |
|
154 |
memcpy(cp, AOTLibrary, len); |
|
155 |
cp[len] = '\0'; |
|
156 |
char* end = cp + len; |
|
157 |
while (cp < end) { |
|
158 |
const char* name = cp; |
|
52145
89f3b013ab8f
8211740: [AOT] -XX:AOTLibrary doesn't accept windows path
bobv
parents:
51770
diff
changeset
|
159 |
while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != pathSep) cp++; |
42650 | 160 |
cp[0] = '\0'; // Terminate name |
161 |
cp++; |
|
162 |
load_library(name, true); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
48152
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
166 |
|
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
167 |
// Load well-know AOT libraries from Java installation directory. |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
168 |
const char* home = Arguments::get_java_home(); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
169 |
const char* file_separator = os::file_separator(); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
170 |
|
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
171 |
for (int i = 0; i < (int) (sizeof(modules) / sizeof(const char*)); i++) { |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
172 |
char library[JVM_MAXPATHLEN]; |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
173 |
jio_snprintf(library, sizeof(library), "%s%slib%slib%s%s%s%s", home, file_separator, file_separator, modules[i], UseCompressedOops ? "-coop" : "", UseG1GC ? "" : "-nong1", os::dll_file_extension()); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
174 |
load_library(library, false); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
175 |
} |
42650 | 176 |
} |
177 |
} |
|
178 |
||
179 |
void AOTLoader::universe_init() { |
|
180 |
if (UseAOT && libraries_count() > 0) { |
|
181 |
// Shifts are static values which initialized by 0 until java heap initialization. |
|
182 |
// AOT libs are loaded before heap initialized so shift values are not set. |
|
183 |
// It is okay since ObjectAlignmentInBytes flag which defines shifts value is set before AOT libs are loaded. |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
184 |
// AOT sets shift values during heap and metaspace initialization. |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
185 |
// Check shifts value to make sure thay did not change. |
42650 | 186 |
if (UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) { |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
187 |
int oop_shift = CompressedOops::shift(); |
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
188 |
FOR_ALL_AOT_LIBRARIES(lib) { |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
189 |
(*lib)->verify_flag((*lib)->config()->_narrowOopShift, oop_shift, "CompressedOops::shift"); |
42650 | 190 |
} |
191 |
if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
192 |
int klass_shift = CompressedKlassPointers::shift(); |
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
193 |
FOR_ALL_AOT_LIBRARIES(lib) { |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
194 |
(*lib)->verify_flag((*lib)->config()->_narrowKlassShift, klass_shift, "CompressedKlassPointers::shift"); |
42650 | 195 |
} |
196 |
} |
|
197 |
} |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
198 |
// Create heaps for all valid libraries |
42650 | 199 |
FOR_ALL_AOT_LIBRARIES(lib) { |
200 |
if ((*lib)->is_valid()) { |
|
201 |
AOTCodeHeap* heap = new AOTCodeHeap(*lib); |
|
202 |
{ |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54150
diff
changeset
|
203 |
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
42650 | 204 |
add_heap(heap); |
205 |
CodeCache::add_heap(heap); |
|
206 |
} |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
207 |
} else { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
208 |
// Unload invalid libraries |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
209 |
os::dll_unload((*lib)->dl_handle()); |
42650 | 210 |
} |
211 |
} |
|
212 |
} |
|
213 |
if (heaps_count() == 0) { |
|
214 |
if (FLAG_IS_DEFAULT(UseAOT)) { |
|
215 |
FLAG_SET_DEFAULT(UseAOT, false); |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
||
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
220 |
// Set shift value for compressed oops and classes based on first AOT library config. |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
221 |
// AOTLoader::universe_init(), which is called later, will check the shift value again to make sure nobody change it. |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
222 |
// This code is not executed during CDS dump because it runs in Interpreter mode and AOT is disabled in this mode. |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
223 |
|
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
224 |
void AOTLoader::set_narrow_oop_shift() { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
225 |
// This method is called from Universe::initialize_heap(). |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
226 |
if (UseAOT && libraries_count() > 0 && |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
227 |
UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) { |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
228 |
if (CompressedOops::shift() == 0) { |
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
229 |
// 0 is valid shift value for small heap but we can safely increase it |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
230 |
// at this point when nobody used it yet. |
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
231 |
CompressedOops::set_shift(AOTLib::narrow_oop_shift()); |
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
232 |
} |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
233 |
} |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
234 |
} |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
235 |
|
42650 | 236 |
void AOTLoader::set_narrow_klass_shift() { |
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
237 |
// This method is called from Metaspace::set_narrow_klass_base_and_shift(). |
42650 | 238 |
if (UseAOT && libraries_count() > 0 && |
239 |
UseCompressedOops && AOTLib::narrow_oop_shift_initialized() && |
|
240 |
UseCompressedClassPointers) { |
|
54780
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
241 |
if (CompressedKlassPointers::shift() == 0) { |
f8d182aedc92
8223136: Move compressed oops functions to CompressedOops class
stefank
parents:
54669
diff
changeset
|
242 |
CompressedKlassPointers::set_shift(AOTLib::narrow_klass_shift()); |
42650 | 243 |
} |
244 |
} |
|
245 |
} |
|
246 |
||
247 |
void AOTLoader::load_library(const char* name, bool exit_on_error) { |
|
48152
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
248 |
// Skip library if a library with the same name is already loaded. |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
249 |
const int file_separator = *os::file_separator(); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
250 |
const char* start = strrchr(name, file_separator); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
251 |
const char* new_name = (start == NULL) ? name : (start + 1); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
252 |
FOR_ALL_AOT_LIBRARIES(lib) { |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
253 |
const char* lib_name = (*lib)->name(); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
254 |
start = strrchr(lib_name, file_separator); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
255 |
const char* old_name = (start == NULL) ? lib_name : (start + 1); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
256 |
if (strcmp(old_name, new_name) == 0) { |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
257 |
if (PrintAOT) { |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
258 |
warning("AOT library %s is already loaded as %s.", name, lib_name); |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
259 |
} |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
260 |
return; |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
261 |
} |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
262 |
} |
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
263 |
char ebuf[1024]; |
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
264 |
void* handle = os::dll_load(name, ebuf, sizeof ebuf); |
42650 | 265 |
if (handle == NULL) { |
266 |
if (exit_on_error) { |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
267 |
tty->print_cr("error opening file: %s", ebuf); |
42650 | 268 |
vm_exit(1); |
269 |
} |
|
270 |
return; |
|
271 |
} |
|
272 |
const int dso_id = libraries_count() + 1; |
|
273 |
AOTLib* lib = new AOTLib(handle, name, dso_id); |
|
274 |
if (!lib->is_valid()) { |
|
275 |
delete lib; |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
276 |
os::dll_unload(handle); |
42650 | 277 |
return; |
278 |
} |
|
279 |
add_library(lib); |
|
280 |
} |
|
281 |
||
282 |
#ifndef PRODUCT |
|
283 |
void AOTLoader::print_statistics() { |
|
284 |
{ ttyLocker ttyl; |
|
285 |
tty->print_cr("--- AOT Statistics ---"); |
|
286 |
tty->print_cr("AOT libraries loaded: %d", heaps_count()); |
|
287 |
AOTCodeHeap::print_statistics(); |
|
288 |
} |
|
289 |
} |
|
290 |
#endif |
|
47668 | 291 |
|
292 |
||
293 |
bool AOTLoader::reconcile_dynamic_invoke(InstanceKlass* holder, int index, Method* adapter_method, Klass* appendix_klass) { |
|
294 |
if (!UseAOT) { |
|
295 |
return true; |
|
296 |
} |
|
297 |
JavaThread* thread = JavaThread::current(); |
|
298 |
ResourceMark rm(thread); |
|
299 |
RegisterMap map(thread, false); |
|
300 |
frame caller_frame = thread->last_frame().sender(&map); // Skip stub |
|
301 |
CodeBlob* caller_cb = caller_frame.cb(); |
|
302 |
guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method"); |
|
303 |
CompiledMethod* cm = caller_cb->as_compiled_method(); |
|
304 |
||
305 |
if (!cm->is_aot()) { |
|
306 |
return true; |
|
307 |
} |
|
308 |
AOTCompiledMethod* aot = (AOTCompiledMethod*)cm; |
|
309 |
||
310 |
AOTCodeHeap* caller_heap = NULL; |
|
311 |
FOR_ALL_AOT_HEAPS(heap) { |
|
312 |
if ((*heap)->contains_blob(aot)) { |
|
313 |
caller_heap = *heap; |
|
314 |
break; |
|
315 |
} |
|
316 |
} |
|
317 |
guarantee(caller_heap != NULL, "CodeHeap not found"); |
|
318 |
bool success = caller_heap->reconcile_dynamic_invoke(aot, holder, index, adapter_method, appendix_klass); |
|
319 |
vmassert(success || thread->last_frame().sender(&map).is_deoptimized_frame(), "caller not deoptimized on failure"); |
|
320 |
return success; |
|
321 |
} |