author | kvn |
Mon, 17 Sep 2018 13:43:22 -0700 | |
changeset 51770 | b19734760ed3 |
parent 51731 | 8745f8f1b0f8 |
child 52145 | 89f3b013ab8f |
child 56967 | 23adfcd11311 |
permissions | -rw-r--r-- |
42650 | 1 |
/* |
49360 | 2 |
* Copyright (c) 2016, 2018, 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" |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47668
diff
changeset
|
25 |
#include "jvm.h" |
42650 | 26 |
|
27 |
#include "aot/aotCodeHeap.hpp" |
|
28 |
#include "aot/aotLoader.inline.hpp" |
|
29 |
#include "jvmci/jvmciRuntime.hpp" |
|
49360 | 30 |
#include "memory/allocation.inline.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" |
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
33 |
#include "runtime/os.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) { |
51770
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
50 |
if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
51 |
if (PrintAOT) { |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
52 |
warning("JVMTI capability to hotswap and post breakpoint is not compatible with AOT (switching AOT off)"); |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
53 |
} |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
54 |
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
|
55 |
return; |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
56 |
} |
42650 | 57 |
FOR_ALL_AOT_HEAPS(heap) { |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
58 |
(*heap)->load_klass_data(ik, thread); |
42650 | 59 |
} |
60 |
} |
|
61 |
} |
|
62 |
||
63 |
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
|
64 |
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
|
65 |
if (ik->is_unsafe_anonymous()) { |
47668 | 66 |
// don't even bother |
67 |
return 0; |
|
68 |
} |
|
42650 | 69 |
FOR_ALL_AOT_HEAPS(heap) { |
70 |
AOTKlassData* klass_data = (*heap)->find_klass(ik); |
|
71 |
if (klass_data != NULL) { |
|
72 |
return klass_data->_fingerprint; |
|
73 |
} |
|
74 |
} |
|
75 |
return 0; |
|
76 |
} |
|
77 |
||
78 |
void AOTLoader::oops_do(OopClosure* f) { |
|
79 |
if (UseAOT) { |
|
80 |
FOR_ALL_AOT_HEAPS(heap) { |
|
81 |
(*heap)->oops_do(f); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
||
86 |
void AOTLoader::metadata_do(void f(Metadata*)) { |
|
87 |
if (UseAOT) { |
|
88 |
FOR_ALL_AOT_HEAPS(heap) { |
|
89 |
(*heap)->metadata_do(f); |
|
90 |
} |
|
91 |
} |
|
92 |
} |
|
93 |
||
94 |
/** |
|
95 |
* List of core modules for which we search for shared libraries. |
|
96 |
*/ |
|
97 |
static const char* modules[] = { |
|
98 |
"java.base", |
|
99 |
"java.logging", |
|
100 |
"jdk.compiler", |
|
101 |
"jdk.scripting.nashorn", |
|
43972 | 102 |
"jdk.internal.vm.ci", |
103 |
"jdk.internal.vm.compiler" |
|
42650 | 104 |
}; |
105 |
||
106 |
void AOTLoader::initialize() { |
|
46629
8eeacdc76bf2
8183262: noexecstack check in os::dll_load on Linux is too expensive
kvn
parents:
46560
diff
changeset
|
107 |
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
|
108 |
|
42650 | 109 |
if (FLAG_IS_DEFAULT(UseAOT) && AOTLibrary != NULL) { |
110 |
// Don't need to set UseAOT on command line when AOTLibrary is specified |
|
111 |
FLAG_SET_DEFAULT(UseAOT, true); |
|
112 |
} |
|
113 |
if (UseAOT) { |
|
114 |
// EagerInitialization is not compatible with AOT |
|
115 |
if (EagerInitialization) { |
|
42658
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
116 |
if (PrintAOT) { |
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
117 |
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
|
118 |
} |
42650 | 119 |
FLAG_SET_DEFAULT(UseAOT, false); |
120 |
return; |
|
121 |
} |
|
122 |
||
51770
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
123 |
if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
124 |
if (PrintAOT) { |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
125 |
warning("JVMTI capability to hotswap and post breakpoint is not compatible with AOT (switching AOT off)"); |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
126 |
} |
b19734760ed3
8209574: [AOT] breakpoint events are generated in different threads does not meet expected count
kvn
parents:
51731
diff
changeset
|
127 |
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
|
128 |
return; |
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 |
|
42650 | 131 |
// -Xint is not compatible with AOT |
132 |
if (Arguments::is_interpreter_only()) { |
|
42658
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
133 |
if (PrintAOT) { |
9b8b24e4fc01
8171137: Avoid warning: -Xint is not compatible with AOT (switching AOT off)
kvn
parents:
42650
diff
changeset
|
134 |
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
|
135 |
} |
42650 | 136 |
FLAG_SET_DEFAULT(UseAOT, false); |
137 |
return; |
|
138 |
} |
|
139 |
||
140 |
// Scan the AOTLibrary option. |
|
141 |
if (AOTLibrary != NULL) { |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
142 |
const int len = (int)strlen(AOTLibrary); |
42650 | 143 |
char* cp = NEW_C_HEAP_ARRAY(char, len+1, mtCode); |
144 |
if (cp != NULL) { // No memory? |
|
145 |
memcpy(cp, AOTLibrary, len); |
|
146 |
cp[len] = '\0'; |
|
147 |
char* end = cp + len; |
|
148 |
while (cp < end) { |
|
149 |
const char* name = cp; |
|
150 |
while ((*cp) != '\0' && (*cp) != '\n' && (*cp) != ',' && (*cp) != ':' && (*cp) != ';') cp++; |
|
151 |
cp[0] = '\0'; // Terminate name |
|
152 |
cp++; |
|
153 |
load_library(name, true); |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
48152
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
157 |
|
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
158 |
// 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
|
159 |
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
|
160 |
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
|
161 |
|
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
} |
42650 | 167 |
} |
168 |
} |
|
169 |
||
170 |
void AOTLoader::universe_init() { |
|
171 |
if (UseAOT && libraries_count() > 0) { |
|
172 |
// Shifts are static values which initialized by 0 until java heap initialization. |
|
173 |
// AOT libs are loaded before heap initialized so shift values are not set. |
|
174 |
// 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
|
175 |
// 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
|
176 |
// Check shifts value to make sure thay did not change. |
42650 | 177 |
if (UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) { |
178 |
int oop_shift = Universe::narrow_oop_shift(); |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
179 |
FOR_ALL_AOT_LIBRARIES(lib) { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
180 |
(*lib)->verify_flag((*lib)->config()->_narrowOopShift, oop_shift, "Universe::narrow_oop_shift"); |
42650 | 181 |
} |
182 |
if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set |
|
183 |
int klass_shift = Universe::narrow_klass_shift(); |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
184 |
FOR_ALL_AOT_LIBRARIES(lib) { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
185 |
(*lib)->verify_flag((*lib)->config()->_narrowKlassShift, klass_shift, "Universe::narrow_klass_shift"); |
42650 | 186 |
} |
187 |
} |
|
188 |
} |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
189 |
// Create heaps for all valid libraries |
42650 | 190 |
FOR_ALL_AOT_LIBRARIES(lib) { |
191 |
if ((*lib)->is_valid()) { |
|
192 |
AOTCodeHeap* heap = new AOTCodeHeap(*lib); |
|
193 |
{ |
|
194 |
MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
195 |
add_heap(heap); |
|
196 |
CodeCache::add_heap(heap); |
|
197 |
} |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
198 |
} else { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
199 |
// Unload invalid libraries |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
200 |
os::dll_unload((*lib)->dl_handle()); |
42650 | 201 |
} |
202 |
} |
|
203 |
} |
|
204 |
if (heaps_count() == 0) { |
|
205 |
if (FLAG_IS_DEFAULT(UseAOT)) { |
|
206 |
FLAG_SET_DEFAULT(UseAOT, false); |
|
207 |
} |
|
208 |
} |
|
209 |
} |
|
210 |
||
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
211 |
// 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
|
212 |
// 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
|
213 |
// 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
|
214 |
|
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
215 |
void AOTLoader::set_narrow_oop_shift() { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
216 |
// 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
|
217 |
if (UseAOT && libraries_count() > 0 && |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
218 |
UseCompressedOops && AOTLib::narrow_oop_shift_initialized()) { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
219 |
if (Universe::narrow_oop_shift() == 0) { |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
220 |
// 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
|
221 |
// at this point when nobody used it yet. |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
222 |
Universe::set_narrow_oop_shift(AOTLib::narrow_oop_shift()); |
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 |
} |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
225 |
} |
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
226 |
|
42650 | 227 |
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
|
228 |
// This method is called from Metaspace::set_narrow_klass_base_and_shift(). |
42650 | 229 |
if (UseAOT && libraries_count() > 0 && |
230 |
UseCompressedOops && AOTLib::narrow_oop_shift_initialized() && |
|
231 |
UseCompressedClassPointers) { |
|
49847
f22c0b4caad7
8201850: [AOT] vm crash when run test compiler/aot/fingerprint/SelfChangedCDS.java
kvn
parents:
49361
diff
changeset
|
232 |
if (Universe::narrow_klass_shift() == 0) { |
42650 | 233 |
Universe::set_narrow_klass_shift(AOTLib::narrow_klass_shift()); |
234 |
} |
|
235 |
} |
|
236 |
} |
|
237 |
||
238 |
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
|
239 |
// 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
|
240 |
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
|
241 |
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
|
242 |
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
|
243 |
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
|
244 |
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
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
if (PrintAOT) { |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
249 |
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
|
250 |
} |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
251 |
return; |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
252 |
} |
bef902d8fef1
8184361: AOT lib at jdk/lib/libjava.base-coop.so seems to override -XX:AOTLibrary=
kvn
parents:
47765
diff
changeset
|
253 |
} |
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
254 |
char ebuf[1024]; |
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
255 |
void* handle = os::dll_load(name, ebuf, sizeof ebuf); |
42650 | 256 |
if (handle == NULL) { |
257 |
if (exit_on_error) { |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
258 |
tty->print_cr("error opening file: %s", ebuf); |
42650 | 259 |
vm_exit(1); |
260 |
} |
|
261 |
return; |
|
262 |
} |
|
263 |
const int dso_id = libraries_count() + 1; |
|
264 |
AOTLib* lib = new AOTLib(handle, name, dso_id); |
|
265 |
if (!lib->is_valid()) { |
|
266 |
delete lib; |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42658
diff
changeset
|
267 |
os::dll_unload(handle); |
42650 | 268 |
return; |
269 |
} |
|
270 |
add_library(lib); |
|
271 |
} |
|
272 |
||
273 |
#ifndef PRODUCT |
|
274 |
void AOTLoader::print_statistics() { |
|
275 |
{ ttyLocker ttyl; |
|
276 |
tty->print_cr("--- AOT Statistics ---"); |
|
277 |
tty->print_cr("AOT libraries loaded: %d", heaps_count()); |
|
278 |
AOTCodeHeap::print_statistics(); |
|
279 |
} |
|
280 |
} |
|
281 |
#endif |
|
47668 | 282 |
|
283 |
||
284 |
bool AOTLoader::reconcile_dynamic_invoke(InstanceKlass* holder, int index, Method* adapter_method, Klass* appendix_klass) { |
|
285 |
if (!UseAOT) { |
|
286 |
return true; |
|
287 |
} |
|
288 |
JavaThread* thread = JavaThread::current(); |
|
289 |
ResourceMark rm(thread); |
|
290 |
RegisterMap map(thread, false); |
|
291 |
frame caller_frame = thread->last_frame().sender(&map); // Skip stub |
|
292 |
CodeBlob* caller_cb = caller_frame.cb(); |
|
293 |
guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method"); |
|
294 |
CompiledMethod* cm = caller_cb->as_compiled_method(); |
|
295 |
||
296 |
if (!cm->is_aot()) { |
|
297 |
return true; |
|
298 |
} |
|
299 |
AOTCompiledMethod* aot = (AOTCompiledMethod*)cm; |
|
300 |
||
301 |
AOTCodeHeap* caller_heap = NULL; |
|
302 |
FOR_ALL_AOT_HEAPS(heap) { |
|
303 |
if ((*heap)->contains_blob(aot)) { |
|
304 |
caller_heap = *heap; |
|
305 |
break; |
|
306 |
} |
|
307 |
} |
|
308 |
guarantee(caller_heap != NULL, "CodeHeap not found"); |
|
309 |
bool success = caller_heap->reconcile_dynamic_invoke(aot, holder, index, adapter_method, appendix_klass); |
|
310 |
vmassert(success || thread->last_frame().sender(&map).is_deoptimized_frame(), "caller not deoptimized on failure"); |
|
311 |
return success; |
|
312 |
} |