author | stefank |
Fri, 04 May 2018 11:41:35 +0200 | |
changeset 49982 | 9042ffe5b7fe |
parent 49837 | 32ba0c867a46 |
child 50860 | 480a96a43b62 |
permissions | -rw-r--r-- |
42650 | 1 |
/* |
49012 | 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" |
|
25 |
||
26 |
#include "aot/aotCodeHeap.hpp" |
|
27 |
#include "aot/aotLoader.hpp" |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49360
diff
changeset
|
28 |
#include "ci/ciUtilities.inline.hpp" |
43405
1fab8e6866d7
8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents:
42650
diff
changeset
|
29 |
#include "classfile/javaAssertions.hpp" |
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49012
diff
changeset
|
30 |
#include "gc/shared/cardTable.hpp" |
49455
848864ed9b17
8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents:
49449
diff
changeset
|
31 |
#include "gc/shared/cardTableBarrierSet.hpp" |
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49455
diff
changeset
|
32 |
#include "gc/shared/collectedHeap.hpp" |
42650 | 33 |
#include "gc/g1/heapRegion.hpp" |
34 |
#include "interpreter/abstractInterpreter.hpp" |
|
35 |
#include "jvmci/compilerRuntime.hpp" |
|
36 |
#include "jvmci/jvmciRuntime.hpp" |
|
49360 | 37 |
#include "memory/allocation.inline.hpp" |
49340
4e82736053ae
8191102: Incorrect include file use in classLoader.hpp
hseigel
parents:
49164
diff
changeset
|
38 |
#include "oops/method.inline.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49360
diff
changeset
|
39 |
#include "runtime/handles.inline.hpp" |
42650 | 40 |
#include "runtime/os.hpp" |
41 |
#include "runtime/sharedRuntime.hpp" |
|
42 |
#include "runtime/vm_operations.hpp" |
|
43 |
||
44 |
bool AOTLib::_narrow_oop_shift_initialized = false; |
|
45 |
int AOTLib::_narrow_oop_shift = 0; |
|
46 |
int AOTLib::_narrow_klass_shift = 0; |
|
47 |
||
48 |
address AOTLib::load_symbol(const char *name) { |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
49 |
address symbol = (address) os::dll_lookup(_dl_handle, name); |
42650 | 50 |
if (symbol == NULL) { |
51 |
tty->print_cr("Shared file %s error: missing %s", _name, name); |
|
52 |
vm_exit(1); |
|
53 |
} |
|
54 |
return symbol; |
|
55 |
} |
|
56 |
||
57 |
Klass* AOTCodeHeap::get_klass_from_got(const char* klass_name, int klass_len, const Method* method) { |
|
58 |
AOTKlassData* klass_data = (AOTKlassData*)_lib->load_symbol(klass_name); |
|
46949 | 59 |
Klass* k = (Klass*)_klasses_got[klass_data->_got_index]; |
42650 | 60 |
if (k == NULL) { |
61 |
Thread* thread = Thread::current(); |
|
62 |
k = lookup_klass(klass_name, klass_len, method, thread); |
|
63 |
// Note, exceptions are cleared. |
|
64 |
if (k == NULL) { |
|
65 |
fatal("Shared file %s error: klass %s should be resolved already", _lib->name(), klass_name); |
|
66 |
vm_exit(1); |
|
67 |
} |
|
47668 | 68 |
// Patch now to avoid extra runtime lookup |
46949 | 69 |
_klasses_got[klass_data->_got_index] = k; |
47668 | 70 |
if (k->is_instance_klass()) { |
71 |
InstanceKlass* ik = InstanceKlass::cast(k); |
|
72 |
if (ik->is_initialized()) { |
|
73 |
_klasses_got[klass_data->_got_index - 1] = ik; |
|
74 |
} |
|
75 |
} |
|
42650 | 76 |
} |
77 |
return k; |
|
78 |
} |
|
79 |
||
80 |
Klass* AOTCodeHeap::lookup_klass(const char* name, int len, const Method* method, Thread* thread) { |
|
81 |
ResourceMark rm(thread); |
|
82 |
assert(method != NULL, "incorrect call parameter"); |
|
83 |
methodHandle caller(thread, (Method*)method); |
|
84 |
||
85 |
// Use class loader of aot method. |
|
86 |
Handle loader(thread, caller->method_holder()->class_loader()); |
|
87 |
Handle protection_domain(thread, caller->method_holder()->protection_domain()); |
|
88 |
||
89 |
// Ignore wrapping L and ; |
|
90 |
if (name[0] == 'L') { |
|
91 |
assert(len > 2, "small name %s", name); |
|
92 |
name++; |
|
93 |
len -= 2; |
|
94 |
} |
|
95 |
TempNewSymbol sym = SymbolTable::probe(name, len); |
|
96 |
if (sym == NULL) { |
|
97 |
log_debug(aot, class, resolve)("Probe failed for AOT class %s", name); |
|
98 |
return NULL; |
|
99 |
} |
|
100 |
Klass* k = SystemDictionary::find_instance_or_array_klass(sym, loader, protection_domain, thread); |
|
101 |
assert(!thread->has_pending_exception(), "should not throw"); |
|
102 |
||
103 |
if (k != NULL) { |
|
104 |
log_info(aot, class, resolve)("%s %s (lookup)", caller->method_holder()->external_name(), k->external_name()); |
|
105 |
} |
|
106 |
return k; |
|
107 |
} |
|
108 |
||
109 |
void AOTLib::handle_config_error(const char* format, ...) { |
|
110 |
if (PrintAOT) { |
|
111 |
va_list ap; |
|
112 |
va_start(ap, format); |
|
113 |
tty->vprint_cr(format, ap); |
|
114 |
va_end(ap); |
|
115 |
} |
|
116 |
if (UseAOTStrictLoading) { |
|
117 |
vm_exit(1); |
|
118 |
} |
|
119 |
_valid = false; |
|
120 |
} |
|
121 |
||
122 |
void AOTLib::verify_flag(bool aot_flag, bool flag, const char* name) { |
|
123 |
if (_valid && aot_flag != flag) { |
|
124 |
handle_config_error("Shared file %s error: %s has different value '%s' from current '%s'", _name, name , (aot_flag ? "true" : "false"), (flag ? "true" : "false")); |
|
125 |
} |
|
126 |
} |
|
127 |
||
128 |
void AOTLib::verify_flag(int aot_flag, int flag, const char* name) { |
|
129 |
if (_valid && aot_flag != flag) { |
|
130 |
handle_config_error("Shared file %s error: %s has different value '%d' from current '%d'", _name, name , aot_flag, flag); |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
void AOTLib::verify_config() { |
|
135 |
GrowableArray<AOTLib*>* libraries = AOTLoader::libraries(); |
|
136 |
for (GrowableArrayIterator<AOTLib*> lib = libraries->begin(); lib != libraries->end(); ++lib) { |
|
137 |
if ((*lib)->_config == _config) { |
|
138 |
handle_config_error("AOT library %s already loaded.", (*lib)->_name); |
|
139 |
return; |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
if (_header->_version != AOTHeader::AOT_SHARED_VERSION) { |
|
144 |
handle_config_error("Invalid version of the shared file %s. Expected %d but was %d", _name, _header->_version, AOTHeader::AOT_SHARED_VERSION); |
|
145 |
return; |
|
146 |
} |
|
147 |
||
148 |
const char* aot_jvm_version = (const char*)_header + _header->_jvm_version_offset + 2; |
|
149 |
if (strcmp(aot_jvm_version, VM_Version::jre_release_version()) != 0) { |
|
150 |
handle_config_error("JVM version '%s' recorded in the shared file %s does not match current version '%s'", aot_jvm_version, _name, VM_Version::jre_release_version()); |
|
151 |
return; |
|
152 |
} |
|
153 |
||
154 |
// Debug VM has different layout of runtime and metadata structures |
|
155 |
#ifdef ASSERT |
|
156 |
verify_flag(_config->_debug_VM, true, "Debug VM version"); |
|
157 |
#else |
|
158 |
verify_flag(!(_config->_debug_VM), true, "Product VM version"); |
|
159 |
#endif |
|
160 |
// Check configuration size |
|
161 |
verify_flag(_config->_config_size, AOTConfiguration::CONFIG_SIZE, "AOT configuration size"); |
|
162 |
||
163 |
// Check flags |
|
164 |
verify_flag(_config->_useCompressedOops, UseCompressedOops, "UseCompressedOops"); |
|
165 |
verify_flag(_config->_useCompressedClassPointers, UseCompressedClassPointers, "UseCompressedClassPointers"); |
|
166 |
verify_flag(_config->_useG1GC, UseG1GC, "UseG1GC"); |
|
167 |
verify_flag(_config->_useTLAB, UseTLAB, "UseTLAB"); |
|
168 |
verify_flag(_config->_useBiasedLocking, UseBiasedLocking, "UseBiasedLocking"); |
|
169 |
verify_flag(_config->_objectAlignment, ObjectAlignmentInBytes, "ObjectAlignmentInBytes"); |
|
170 |
verify_flag(_config->_contendedPaddingWidth, ContendedPaddingWidth, "ContendedPaddingWidth"); |
|
171 |
verify_flag(_config->_fieldsAllocationStyle, FieldsAllocationStyle, "FieldsAllocationStyle"); |
|
172 |
verify_flag(_config->_compactFields, CompactFields, "CompactFields"); |
|
173 |
verify_flag(_config->_enableContended, EnableContended, "EnableContended"); |
|
174 |
verify_flag(_config->_restrictContended, RestrictContended, "RestrictContended"); |
|
48172
e26fc5201707
8191437: AOT doesn't work easily after thread local handshakes
dlong
parents:
47798
diff
changeset
|
175 |
verify_flag(_config->_threadLocalHandshakes, ThreadLocalHandshakes, "ThreadLocalHandshakes"); |
42650 | 176 |
|
177 |
if (!TieredCompilation && _config->_tieredAOT) { |
|
178 |
handle_config_error("Shared file %s error: Expected to run with tiered compilation on", _name); |
|
179 |
} |
|
180 |
||
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. |
|
184 |
// Set shifts value based on first AOT library config. |
|
185 |
if (UseCompressedOops && _valid) { |
|
186 |
if (!_narrow_oop_shift_initialized) { |
|
187 |
_narrow_oop_shift = _config->_narrowOopShift; |
|
188 |
if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set |
|
189 |
_narrow_klass_shift = _config->_narrowKlassShift; |
|
190 |
} |
|
191 |
_narrow_oop_shift_initialized = true; |
|
192 |
} else { |
|
193 |
verify_flag(_config->_narrowOopShift, _narrow_oop_shift, "aot_config->_narrowOopShift"); |
|
194 |
if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set |
|
195 |
verify_flag(_config->_narrowKlassShift, _narrow_klass_shift, "aot_config->_narrowKlassShift"); |
|
196 |
} |
|
197 |
} |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
AOTLib::~AOTLib() { |
|
49012 | 202 |
os::free((void*) _name); |
42650 | 203 |
} |
204 |
||
205 |
AOTCodeHeap::~AOTCodeHeap() { |
|
206 |
if (_classes != NULL) { |
|
207 |
FREE_C_HEAP_ARRAY(AOTClass, _classes); |
|
208 |
} |
|
209 |
if (_code_to_aot != NULL) { |
|
210 |
FREE_C_HEAP_ARRAY(CodeToAMethod, _code_to_aot); |
|
211 |
} |
|
212 |
} |
|
213 |
||
214 |
AOTLib::AOTLib(void* handle, const char* name, int dso_id) : _valid(true), _dl_handle(handle), _dso_id(dso_id) { |
|
49012 | 215 |
_name = (const char*) os::strdup(name); |
42650 | 216 |
|
217 |
// Verify that VM runs with the same parameters as AOT tool. |
|
46949 | 218 |
_config = (AOTConfiguration*) load_symbol("A.config"); |
219 |
_header = (AOTHeader*) load_symbol("A.header"); |
|
42650 | 220 |
|
221 |
verify_config(); |
|
222 |
||
223 |
if (!_valid && PrintAOT) { |
|
224 |
tty->print("%7d ", (int) tty->time_stamp().milliseconds()); |
|
225 |
tty->print_cr("%4d skipped %s aot library", _dso_id, _name); |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
AOTCodeHeap::AOTCodeHeap(AOTLib* lib) : |
|
230 |
CodeHeap("CodeHeap 'AOT'", CodeBlobType::AOT), _lib(lib), _classes(NULL), _code_to_aot(NULL) { |
|
231 |
assert(_lib->is_valid(), "invalid library"); |
|
232 |
||
233 |
_lib_symbols_initialized = false; |
|
234 |
_aot_id = 0; |
|
235 |
||
236 |
_class_count = _lib->header()->_class_count; |
|
237 |
_method_count = _lib->header()->_method_count; |
|
238 |
||
239 |
// Collect metaspace info: names -> address in .got section |
|
46949 | 240 |
_metaspace_names = (const char*) _lib->load_symbol("A.meta.names"); |
241 |
_method_metadata = (address) _lib->load_symbol("A.meth.metadata"); |
|
242 |
_methods_offsets = (address) _lib->load_symbol("A.meth.offsets"); |
|
243 |
_klasses_offsets = (address) _lib->load_symbol("A.kls.offsets"); |
|
244 |
_dependencies = (address) _lib->load_symbol("A.kls.dependencies"); |
|
245 |
_code_space = (address) _lib->load_symbol("A.text"); |
|
42650 | 246 |
|
247 |
// First cell is number of elements. |
|
46949 | 248 |
_klasses_got = (Metadata**) _lib->load_symbol("A.kls.got"); |
249 |
_klasses_got_size = _lib->header()->_klasses_got_size; |
|
42650 | 250 |
|
46949 | 251 |
_metadata_got = (Metadata**) _lib->load_symbol("A.meta.got"); |
42650 | 252 |
_metadata_got_size = _lib->header()->_metadata_got_size; |
253 |
||
46949 | 254 |
_oop_got = (oop*) _lib->load_symbol("A.oop.got"); |
42650 | 255 |
_oop_got_size = _lib->header()->_oop_got_size; |
256 |
||
257 |
// Collect stubs info |
|
46949 | 258 |
_stubs_offsets = (int*) _lib->load_symbol("A.stubs.offsets"); |
42650 | 259 |
|
260 |
// code segments table |
|
46949 | 261 |
_code_segments = (address) _lib->load_symbol("A.code.segments"); |
42650 | 262 |
|
263 |
// method state |
|
46949 | 264 |
_method_state = (jlong*) _lib->load_symbol("A.meth.state"); |
42650 | 265 |
|
266 |
// Create a table for mapping classes |
|
267 |
_classes = NEW_C_HEAP_ARRAY(AOTClass, _class_count, mtCode); |
|
268 |
memset(_classes, 0, _class_count * sizeof(AOTClass)); |
|
269 |
||
270 |
// Create table for searching AOTCompiledMethod based on pc. |
|
271 |
_code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode); |
|
272 |
memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod)); |
|
273 |
||
274 |
_memory.set_low_boundary((char *)_code_space); |
|
275 |
_memory.set_high_boundary((char *)_code_space); |
|
276 |
_memory.set_low((char *)_code_space); |
|
277 |
_memory.set_high((char *)_code_space); |
|
278 |
||
279 |
_segmap.set_low_boundary((char *)_code_segments); |
|
280 |
_segmap.set_low((char *)_code_segments); |
|
281 |
||
282 |
_log2_segment_size = exact_log2(_lib->config()->_codeSegmentSize); |
|
283 |
||
284 |
// Register aot stubs |
|
285 |
register_stubs(); |
|
286 |
||
287 |
if (PrintAOT || (PrintCompilation && PrintAOT)) { |
|
288 |
tty->print("%7d ", (int) tty->time_stamp().milliseconds()); |
|
289 |
tty->print_cr("%4d loaded %s aot library", _lib->id(), _lib->name()); |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
void AOTCodeHeap::publish_aot(const methodHandle& mh, AOTMethodData* method_data, int code_id) { |
|
294 |
// The method may be explicitly excluded by the user. |
|
295 |
// Or Interpreter uses an intrinsic for this method. |
|
296 |
if (CompilerOracle::should_exclude(mh) || !AbstractInterpreter::can_be_compiled(mh)) { |
|
297 |
return; |
|
298 |
} |
|
299 |
||
300 |
address code = method_data->_code; |
|
301 |
const char* name = method_data->_name; |
|
302 |
aot_metadata* meta = method_data->_meta; |
|
303 |
||
304 |
if (meta->scopes_pcs_begin() == meta->scopes_pcs_end()) { |
|
305 |
// When the AOT compiler compiles something big we fail to generate metadata |
|
306 |
// in CodeInstaller::gather_metadata. In that case the scopes_pcs_begin == scopes_pcs_end. |
|
307 |
// In all successful cases we always have 2 entries of scope pcs. |
|
43416
f8c241512446
8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents:
43405
diff
changeset
|
308 |
log_info(aot, class, resolve)("Failed to load %s (no metadata available)", mh->name_and_sig_as_C_string()); |
f8c241512446
8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents:
43405
diff
changeset
|
309 |
_code_to_aot[code_id]._state = invalid; |
42650 | 310 |
return; |
311 |
} |
|
312 |
||
313 |
jlong* state_adr = &_method_state[code_id]; |
|
314 |
address metadata_table = method_data->_metadata_table; |
|
315 |
int metadata_size = method_data->_metadata_size; |
|
316 |
assert(code_id < _method_count, "sanity"); |
|
317 |
_aot_id++; |
|
318 |
||
319 |
#ifdef ASSERT |
|
320 |
if (_aot_id > CIStop || _aot_id < CIStart) { |
|
321 |
// Skip compilation |
|
322 |
return; |
|
323 |
} |
|
324 |
#endif |
|
325 |
// Check one more time. |
|
326 |
if (_code_to_aot[code_id]._state == invalid) { |
|
327 |
return; |
|
328 |
} |
|
329 |
AOTCompiledMethod *aot = new AOTCompiledMethod(code, mh(), meta, metadata_table, metadata_size, state_adr, this, name, code_id, _aot_id); |
|
330 |
assert(_code_to_aot[code_id]._aot == NULL, "should be not initialized"); |
|
331 |
_code_to_aot[code_id]._aot = aot; // Should set this first |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46949
diff
changeset
|
332 |
if (Atomic::cmpxchg(in_use, &_code_to_aot[code_id]._state, not_set) != not_set) { |
42650 | 333 |
_code_to_aot[code_id]._aot = NULL; // Clean |
334 |
} else { // success |
|
335 |
// Publish method |
|
336 |
#ifdef TIERED |
|
337 |
mh->set_aot_code(aot); |
|
338 |
#endif |
|
339 |
Method::set_code(mh, aot); |
|
340 |
if (PrintAOT || (PrintCompilation && PrintAOT)) { |
|
341 |
aot->print_on(tty, NULL); |
|
342 |
} |
|
343 |
// Publish oop only after we are visible to CompiledMethodIterator |
|
344 |
aot->set_oop(mh()->method_holder()->klass_holder()); |
|
345 |
} |
|
346 |
} |
|
347 |
||
348 |
void AOTCodeHeap::link_primitive_array_klasses() { |
|
349 |
ResourceMark rm; |
|
350 |
for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) { |
|
351 |
BasicType t = (BasicType)i; |
|
352 |
if (is_java_primitive(t)) { |
|
353 |
const Klass* arr_klass = Universe::typeArrayKlassObj(t); |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
354 |
AOTKlassData* klass_data = (AOTKlassData*) os::dll_lookup(_lib->dl_handle(), arr_klass->signature_name()); |
42650 | 355 |
if (klass_data != NULL) { |
356 |
// Set both GOT cells, resolved and initialized klass pointers. |
|
357 |
// _got_index points to second cell - resolved klass pointer. |
|
46949 | 358 |
_klasses_got[klass_data->_got_index-1] = (Metadata*)arr_klass; // Initialized |
359 |
_klasses_got[klass_data->_got_index ] = (Metadata*)arr_klass; // Resolved |
|
42650 | 360 |
if (PrintAOT) { |
361 |
tty->print_cr("[Found %s in %s]", arr_klass->internal_name(), _lib->name()); |
|
362 |
} |
|
363 |
} |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
void AOTCodeHeap::register_stubs() { |
|
369 |
int stubs_count = _stubs_offsets[0]; // contains number |
|
370 |
_stubs_offsets++; |
|
371 |
AOTMethodOffsets* stub_offsets = (AOTMethodOffsets*)_stubs_offsets; |
|
372 |
for (int i = 0; i < stubs_count; ++i) { |
|
373 |
const char* stub_name = _metaspace_names + stub_offsets[i]._name_offset; |
|
374 |
address entry = _code_space + stub_offsets[i]._code_offset; |
|
375 |
aot_metadata* meta = (aot_metadata *) (_method_metadata + stub_offsets[i]._meta_offset); |
|
376 |
address metadata_table = (address)_metadata_got + stub_offsets[i]._metadata_got_offset; |
|
377 |
int metadata_size = stub_offsets[i]._metadata_got_size; |
|
378 |
int code_id = stub_offsets[i]._code_id; |
|
379 |
assert(code_id < _method_count, "sanity"); |
|
380 |
jlong* state_adr = &_method_state[code_id]; |
|
381 |
int len = build_u2_from((address)stub_name); |
|
382 |
stub_name += 2; |
|
383 |
char* full_name = NEW_C_HEAP_ARRAY(char, len+5, mtCode); |
|
384 |
if (full_name == NULL) { // No memory? |
|
385 |
break; |
|
386 |
} |
|
387 |
memcpy(full_name, "AOT ", 4); |
|
388 |
memcpy(full_name+4, stub_name, len); |
|
389 |
full_name[len+4] = 0; |
|
390 |
guarantee(_code_to_aot[code_id]._state != invalid, "stub %s can't be invalidated", full_name); |
|
391 |
AOTCompiledMethod* aot = new AOTCompiledMethod(entry, NULL, meta, metadata_table, metadata_size, state_adr, this, full_name, code_id, i); |
|
392 |
assert(_code_to_aot[code_id]._aot == NULL, "should be not initialized"); |
|
393 |
_code_to_aot[code_id]._aot = aot; |
|
46958
a13bd8c6b7a2
8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents:
46949
diff
changeset
|
394 |
if (Atomic::cmpxchg(in_use, &_code_to_aot[code_id]._state, not_set) != not_set) { |
42650 | 395 |
fatal("stab '%s' code state is %d", full_name, _code_to_aot[code_id]._state); |
396 |
} |
|
397 |
// Adjust code buffer boundaries only for stubs because they are last in the buffer. |
|
398 |
adjust_boundaries(aot); |
|
399 |
if (PrintAOT && Verbose) { |
|
400 |
aot->print_on(tty, NULL); |
|
401 |
} |
|
402 |
} |
|
403 |
} |
|
404 |
||
405 |
#define SET_AOT_GLOBAL_SYMBOL_VALUE(AOTSYMNAME, AOTSYMTYPE, VMSYMVAL) \ |
|
406 |
{ \ |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
407 |
AOTSYMTYPE * adr = (AOTSYMTYPE *) os::dll_lookup(_lib->dl_handle(), AOTSYMNAME); \ |
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
408 |
/* Check for a lookup error */ \ |
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
409 |
guarantee(adr != NULL, "AOT Symbol not found %s", AOTSYMNAME); \ |
42650 | 410 |
*adr = (AOTSYMTYPE) VMSYMVAL; \ |
411 |
} |
|
412 |
||
413 |
void AOTCodeHeap::link_graal_runtime_symbols() { |
|
414 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_monitorenter", address, JVMCIRuntime::monitorenter); |
|
415 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_monitorexit", address, JVMCIRuntime::monitorexit); |
|
416 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_object", address, JVMCIRuntime::log_object); |
|
417 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_printf", address, JVMCIRuntime::log_printf); |
|
418 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_primitive", address, JVMCIRuntime::log_primitive); |
|
419 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_instance", address, JVMCIRuntime::new_instance); |
|
420 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_array", address, JVMCIRuntime::new_array); |
|
421 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_multi_array", address, JVMCIRuntime::new_multi_array); |
|
422 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_array", address, JVMCIRuntime::dynamic_new_array); |
|
423 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_validate_object", address, JVMCIRuntime::validate_object); |
|
49982 | 424 |
#if INCLUDE_G1GC |
42650 | 425 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_pre", address, JVMCIRuntime::write_barrier_pre); |
49982 | 426 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_post", address, JVMCIRuntime::write_barrier_post); |
427 |
#endif |
|
42650 | 428 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_identity_hash_code", address, JVMCIRuntime::identity_hash_code); |
429 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_instance", address, JVMCIRuntime::dynamic_new_instance); |
|
430 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_thread_is_interrupted", address, JVMCIRuntime::thread_is_interrupted); |
|
431 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_exception_handler_for_pc", address, JVMCIRuntime::exception_handler_for_pc); |
|
432 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_test_deoptimize_call_int", address, JVMCIRuntime::test_deoptimize_call_int); |
|
433 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_throw_and_post_jvmti_exception", address, JVMCIRuntime::throw_and_post_jvmti_exception); |
|
434 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_throw_klass_external_name_exception", address, JVMCIRuntime::throw_klass_external_name_exception); |
|
435 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_throw_class_cast_exception", address, JVMCIRuntime::throw_class_cast_exception); |
|
436 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_vm_message", address, JVMCIRuntime::vm_message); |
|
437 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_vm_error", address, JVMCIRuntime::vm_error); |
|
438 |
} |
|
439 |
||
440 |
void AOTCodeHeap::link_shared_runtime_symbols() { |
|
441 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_resolve_static_entry", address, SharedRuntime::get_resolve_static_call_stub()); |
|
442 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_resolve_virtual_entry", address, SharedRuntime::get_resolve_virtual_call_stub()); |
|
443 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_resolve_opt_virtual_entry", address, SharedRuntime::get_resolve_opt_virtual_call_stub()); |
|
444 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_deopt_blob_unpack", address, SharedRuntime::deopt_blob()->unpack()); |
|
445 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_deopt_blob_uncommon_trap", address, SharedRuntime::deopt_blob()->uncommon_trap()); |
|
446 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_ic_miss_stub", address, SharedRuntime::get_ic_miss_stub()); |
|
447 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_handle_wrong_method_stub", address, SharedRuntime::get_handle_wrong_method_stub()); |
|
448 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_exception_handler_for_return_address", address, SharedRuntime::exception_handler_for_return_address); |
|
449 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_register_finalizer", address, SharedRuntime::register_finalizer); |
|
49837
32ba0c867a46
8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents:
49594
diff
changeset
|
450 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_object_notify", address, JVMCIRuntime::object_notify); |
32ba0c867a46
8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents:
49594
diff
changeset
|
451 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_object_notifyAll", address, JVMCIRuntime::object_notifyAll); |
42650 | 452 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_OSR_migration_end", address, SharedRuntime::OSR_migration_end); |
47668 | 453 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_resolve_dynamic_invoke", address, CompilerRuntime::resolve_dynamic_invoke); |
42650 | 454 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_resolve_string_by_symbol", address, CompilerRuntime::resolve_string_by_symbol); |
455 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_resolve_klass_by_symbol", address, CompilerRuntime::resolve_klass_by_symbol); |
|
456 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_resolve_method_by_symbol_and_load_counters", address, CompilerRuntime::resolve_method_by_symbol_and_load_counters); |
|
457 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_initialize_klass_by_symbol", address, CompilerRuntime::initialize_klass_by_symbol); |
|
458 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_invocation_event", address, CompilerRuntime::invocation_event); |
|
459 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_backedge_event", address, CompilerRuntime::backedge_event); |
|
460 |
||
461 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dpow", address, SharedRuntime::dpow); |
|
462 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dexp", address, SharedRuntime::dexp); |
|
463 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dcos", address, SharedRuntime::dcos); |
|
464 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dsin", address, SharedRuntime::dsin); |
|
465 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dtan", address, SharedRuntime::dtan); |
|
466 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dlog", address, SharedRuntime::dlog); |
|
467 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_shared_runtime_dlog10", address, SharedRuntime::dlog10); |
|
468 |
} |
|
469 |
||
470 |
void AOTCodeHeap::link_stub_routines_symbols() { |
|
471 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jbyte_arraycopy", address, StubRoutines::_jbyte_arraycopy); |
|
472 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jshort_arraycopy", address, StubRoutines::_jshort_arraycopy); |
|
473 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jint_arraycopy", address, StubRoutines::_jint_arraycopy); |
|
474 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jlong_arraycopy", address, StubRoutines::_jlong_arraycopy); |
|
475 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_oop_arraycopy", address, StubRoutines::_oop_arraycopy); |
|
476 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_oop_arraycopy_uninit", address, StubRoutines::_oop_arraycopy_uninit); |
|
477 |
||
478 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jbyte_disjoint_arraycopy", address, StubRoutines::_jbyte_disjoint_arraycopy); |
|
479 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jshort_disjoint_arraycopy", address, StubRoutines::_jshort_disjoint_arraycopy); |
|
480 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jint_disjoint_arraycopy", address, StubRoutines::_jint_disjoint_arraycopy); |
|
481 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_jlong_disjoint_arraycopy", address, StubRoutines::_jlong_disjoint_arraycopy); |
|
482 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_oop_disjoint_arraycopy", address, StubRoutines::_oop_disjoint_arraycopy); |
|
483 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_oop_disjoint_arraycopy_uninit", address, StubRoutines::_oop_disjoint_arraycopy_uninit); |
|
484 |
||
485 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jbyte_arraycopy", address, StubRoutines::_arrayof_jbyte_arraycopy); |
|
486 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jshort_arraycopy", address, StubRoutines::_arrayof_jshort_arraycopy); |
|
487 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jint_arraycopy", address, StubRoutines::_arrayof_jint_arraycopy); |
|
488 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jlong_arraycopy", address, StubRoutines::_arrayof_jlong_arraycopy); |
|
489 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_oop_arraycopy", address, StubRoutines::_arrayof_oop_arraycopy); |
|
490 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_oop_arraycopy_uninit", address, StubRoutines::_arrayof_oop_arraycopy_uninit); |
|
491 |
||
492 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jbyte_disjoint_arraycopy", address, StubRoutines::_arrayof_jbyte_disjoint_arraycopy); |
|
493 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jshort_disjoint_arraycopy", address, StubRoutines::_arrayof_jshort_disjoint_arraycopy); |
|
494 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jint_disjoint_arraycopy", address, StubRoutines::_arrayof_jint_disjoint_arraycopy); |
|
495 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_jlong_disjoint_arraycopy", address, StubRoutines::_arrayof_jlong_disjoint_arraycopy); |
|
496 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_oop_disjoint_arraycopy", address, StubRoutines::_arrayof_oop_disjoint_arraycopy); |
|
497 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_arrayof_oop_disjoint_arraycopy_uninit", address, StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit); |
|
498 |
||
47084 | 499 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_unsafe_arraycopy", address, StubRoutines::_unsafe_arraycopy); |
500 |
||
42650 | 501 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_checkcast_arraycopy", address, StubRoutines::_checkcast_arraycopy); |
502 |
||
47798 | 503 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_generic_arraycopy", address, StubRoutines::_generic_arraycopy); |
504 |
||
42650 | 505 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_aescrypt_encryptBlock", address, StubRoutines::_aescrypt_encryptBlock); |
506 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_aescrypt_decryptBlock", address, StubRoutines::_aescrypt_decryptBlock); |
|
507 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_cipherBlockChaining_encryptAESCrypt", address, StubRoutines::_cipherBlockChaining_encryptAESCrypt); |
|
508 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_cipherBlockChaining_decryptAESCrypt", address, StubRoutines::_cipherBlockChaining_decryptAESCrypt); |
|
509 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_update_bytes_crc32", address, StubRoutines::_updateBytesCRC32); |
|
510 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_crc_table_adr", address, StubRoutines::_crc_table_adr); |
|
511 |
||
512 |
||
513 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_sha1_implCompress", address, StubRoutines::_sha1_implCompress); |
|
514 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_sha1_implCompressMB", address, StubRoutines::_sha1_implCompressMB); |
|
515 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_sha256_implCompress", address, StubRoutines::_sha256_implCompress); |
|
516 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_sha256_implCompressMB", address, StubRoutines::_sha256_implCompressMB); |
|
517 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_sha512_implCompress", address, StubRoutines::_sha512_implCompress); |
|
518 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_sha512_implCompressMB", address, StubRoutines::_sha512_implCompressMB); |
|
519 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_multiplyToLen", address, StubRoutines::_multiplyToLen); |
|
520 |
||
521 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_counterMode_AESCrypt", address, StubRoutines::_counterMode_AESCrypt); |
|
522 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_ghash_processBlocks", address, StubRoutines::_ghash_processBlocks); |
|
523 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_crc32c_table_addr", address, StubRoutines::_crc32c_table_addr); |
|
524 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_updateBytesCRC32C", address, StubRoutines::_updateBytesCRC32C); |
|
525 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_updateBytesAdler32", address, StubRoutines::_updateBytesAdler32); |
|
526 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_squareToLen", address, StubRoutines::_squareToLen); |
|
527 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_mulAdd", address, StubRoutines::_mulAdd); |
|
528 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_montgomeryMultiply", address, StubRoutines::_montgomeryMultiply); |
|
529 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_montgomerySquare", address, StubRoutines::_montgomerySquare); |
|
530 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_vectorizedMismatch", address, StubRoutines::_vectorizedMismatch); |
|
531 |
||
532 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_stub_routines_throw_delayed_StackOverflowError_entry", address, StubRoutines::_throw_delayed_StackOverflowError_entry); |
|
533 |
||
534 |
} |
|
535 |
||
536 |
void AOTCodeHeap::link_os_symbols() { |
|
537 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_os_javaTimeMillis", address, os::javaTimeMillis); |
|
538 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_os_javaTimeNanos", address, os::javaTimeNanos); |
|
539 |
} |
|
540 |
||
541 |
/* |
|
542 |
* Link any global symbols in precompiled DSO with dlopen() _dl_handle |
|
543 |
* dso_handle. |
|
544 |
*/ |
|
545 |
||
546 |
void AOTCodeHeap::link_global_lib_symbols() { |
|
547 |
if (!_lib_symbols_initialized) { |
|
548 |
_lib_symbols_initialized = true; |
|
549 |
||
550 |
CollectedHeap* heap = Universe::heap(); |
|
49164
7e958a8ebcd3
8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents:
49012
diff
changeset
|
551 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_card_table_address", address, ci_card_table_address()); |
42650 | 552 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_heap_top_address", address, (heap->supports_inline_contig_alloc() ? heap->top_addr() : NULL)); |
553 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_heap_end_address", address, (heap->supports_inline_contig_alloc() ? heap->end_addr() : NULL)); |
|
554 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_polling_page", address, os::get_polling_page()); |
|
555 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_narrow_klass_base_address", address, Universe::narrow_klass_base()); |
|
43435 | 556 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_narrow_oop_base_address", address, Universe::narrow_oop_base()); |
49982 | 557 |
#if INCLUDE_G1GC |
42650 | 558 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_log_of_heap_region_grain_bytes", int, HeapRegion::LogOfHRGrainBytes); |
49982 | 559 |
#endif |
42650 | 560 |
SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_inline_contiguous_allocation_supported", bool, heap->supports_inline_contig_alloc()); |
561 |
link_shared_runtime_symbols(); |
|
562 |
link_stub_routines_symbols(); |
|
563 |
link_os_symbols(); |
|
564 |
link_graal_runtime_symbols(); |
|
565 |
||
566 |
// Link primitive array klasses. |
|
567 |
link_primitive_array_klasses(); |
|
568 |
} |
|
569 |
} |
|
570 |
||
571 |
#ifndef PRODUCT |
|
572 |
int AOTCodeHeap::klasses_seen = 0; |
|
573 |
int AOTCodeHeap::aot_klasses_found = 0; |
|
574 |
int AOTCodeHeap::aot_klasses_fp_miss = 0; |
|
575 |
int AOTCodeHeap::aot_klasses_cl_miss = 0; |
|
576 |
int AOTCodeHeap::aot_methods_found = 0; |
|
577 |
||
578 |
void AOTCodeHeap::print_statistics() { |
|
579 |
tty->print_cr("Classes seen: %d AOT classes found: %d AOT methods found: %d", klasses_seen, aot_klasses_found, aot_methods_found); |
|
580 |
tty->print_cr("AOT fingerprint mismatches: %d AOT class loader mismatches: %d", aot_klasses_fp_miss, aot_klasses_cl_miss); |
|
581 |
} |
|
582 |
#endif |
|
583 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
584 |
Method* AOTCodeHeap::find_method(Klass* klass, Thread* thread, const char* method_name) { |
42650 | 585 |
int method_name_len = build_u2_from((address)method_name); |
586 |
method_name += 2; |
|
587 |
const char* signature_name = method_name + method_name_len; |
|
588 |
int signature_name_len = build_u2_from((address)signature_name); |
|
589 |
signature_name += 2; |
|
590 |
// The class should have been loaded so the method and signature should already be |
|
591 |
// in the symbol table. If they're not there, the method doesn't exist. |
|
592 |
TempNewSymbol name = SymbolTable::probe(method_name, method_name_len); |
|
593 |
TempNewSymbol signature = SymbolTable::probe(signature_name, signature_name_len); |
|
594 |
||
595 |
Method* m; |
|
596 |
if (name == NULL || signature == NULL) { |
|
597 |
m = NULL; |
|
598 |
} else if (name == vmSymbols::object_initializer_name() || |
|
599 |
name == vmSymbols::class_initializer_name()) { |
|
600 |
// Never search superclasses for constructors |
|
601 |
if (klass->is_instance_klass()) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
602 |
m = InstanceKlass::cast(klass)->find_method(name, signature); |
42650 | 603 |
} else { |
604 |
m = NULL; |
|
605 |
} |
|
606 |
} else { |
|
607 |
m = klass->lookup_method(name, signature); |
|
608 |
if (m == NULL && klass->is_instance_klass()) { |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
609 |
m = InstanceKlass::cast(klass)->lookup_method_in_ordered_interfaces(name, signature); |
42650 | 610 |
} |
611 |
} |
|
612 |
if (m == NULL) { |
|
613 |
// Fatal error because we assume classes and methods should not be changed since aot compilation. |
|
614 |
const char* klass_name = klass->external_name(); |
|
615 |
int klass_len = (int)strlen(klass_name); |
|
616 |
char* meta_name = NEW_RESOURCE_ARRAY(char, klass_len + 1 + method_name_len + signature_name_len + 1); |
|
617 |
memcpy(meta_name, klass_name, klass_len); |
|
618 |
meta_name[klass_len] = '.'; |
|
619 |
memcpy(&meta_name[klass_len + 1], method_name, method_name_len); |
|
620 |
memcpy(&meta_name[klass_len + 1 + method_name_len], signature_name, signature_name_len); |
|
621 |
meta_name[klass_len + 1 + method_name_len + signature_name_len] = '\0'; |
|
622 |
Handle exception = Exceptions::new_exception(thread, vmSymbols::java_lang_NoSuchMethodError(), meta_name); |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
46260
diff
changeset
|
623 |
java_lang_Throwable::print(exception(), tty); |
42650 | 624 |
tty->cr(); |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
46260
diff
changeset
|
625 |
java_lang_Throwable::print_stack_trace(exception, tty); |
42650 | 626 |
tty->cr(); |
627 |
fatal("Failed to find method '%s'", meta_name); |
|
628 |
} |
|
629 |
NOT_PRODUCT( aot_methods_found++; ) |
|
630 |
return m; |
|
631 |
} |
|
632 |
||
47668 | 633 |
AOTKlassData* AOTCodeHeap::find_klass(const char *name) { |
634 |
return (AOTKlassData*) os::dll_lookup(_lib->dl_handle(), name); |
|
635 |
} |
|
636 |
||
42650 | 637 |
AOTKlassData* AOTCodeHeap::find_klass(InstanceKlass* ik) { |
638 |
ResourceMark rm; |
|
47668 | 639 |
AOTKlassData* klass_data = find_klass(ik->signature_name()); |
42650 | 640 |
return klass_data; |
641 |
} |
|
642 |
||
643 |
bool AOTCodeHeap::is_dependent_method(Klass* dependee, AOTCompiledMethod* aot) { |
|
644 |
InstanceKlass *dependee_ik = InstanceKlass::cast(dependee); |
|
645 |
AOTKlassData* klass_data = find_klass(dependee_ik); |
|
646 |
if (klass_data == NULL) { |
|
647 |
return false; // no AOT records for this class - no dependencies |
|
648 |
} |
|
649 |
if (!dependee_ik->has_passed_fingerprint_check()) { |
|
650 |
return false; // different class |
|
651 |
} |
|
652 |
||
653 |
int methods_offset = klass_data->_dependent_methods_offset; |
|
654 |
if (methods_offset >= 0) { |
|
655 |
address methods_cnt_adr = _dependencies + methods_offset; |
|
656 |
int methods_cnt = *(int*)methods_cnt_adr; |
|
657 |
int* indexes = (int*)(methods_cnt_adr + 4); |
|
658 |
for (int i = 0; i < methods_cnt; ++i) { |
|
659 |
int code_id = indexes[i]; |
|
660 |
if (_code_to_aot[code_id]._aot == aot) { |
|
661 |
return true; // found dependent method |
|
662 |
} |
|
663 |
} |
|
664 |
} |
|
665 |
return false; |
|
666 |
} |
|
667 |
||
47668 | 668 |
void AOTCodeHeap::sweep_dependent_methods(int* indexes, int methods_cnt) { |
669 |
int marked = 0; |
|
670 |
for (int i = 0; i < methods_cnt; ++i) { |
|
671 |
int code_id = indexes[i]; |
|
672 |
// Invalidate aot code. |
|
673 |
if (Atomic::cmpxchg(invalid, &_code_to_aot[code_id]._state, not_set) != not_set) { |
|
674 |
if (_code_to_aot[code_id]._state == in_use) { |
|
675 |
AOTCompiledMethod* aot = _code_to_aot[code_id]._aot; |
|
676 |
assert(aot != NULL, "aot should be set"); |
|
677 |
if (!aot->is_runtime_stub()) { // Something is wrong - should not invalidate stubs. |
|
678 |
aot->mark_for_deoptimization(false); |
|
679 |
marked++; |
|
680 |
} |
|
681 |
} |
|
682 |
} |
|
683 |
} |
|
684 |
if (marked > 0) { |
|
685 |
VM_Deoptimize op; |
|
686 |
VMThread::execute(&op); |
|
687 |
} |
|
688 |
} |
|
689 |
||
42650 | 690 |
void AOTCodeHeap::sweep_dependent_methods(AOTKlassData* klass_data) { |
691 |
// Make dependent methods non_entrant forever. |
|
692 |
int methods_offset = klass_data->_dependent_methods_offset; |
|
693 |
if (methods_offset >= 0) { |
|
694 |
address methods_cnt_adr = _dependencies + methods_offset; |
|
695 |
int methods_cnt = *(int*)methods_cnt_adr; |
|
696 |
int* indexes = (int*)(methods_cnt_adr + 4); |
|
47668 | 697 |
sweep_dependent_methods(indexes, methods_cnt); |
42650 | 698 |
} |
699 |
} |
|
700 |
||
47668 | 701 |
void AOTCodeHeap::sweep_dependent_methods(InstanceKlass* ik) { |
702 |
AOTKlassData* klass_data = find_klass(ik); |
|
703 |
vmassert(klass_data != NULL, "dependency data missing"); |
|
704 |
sweep_dependent_methods(klass_data); |
|
705 |
} |
|
706 |
||
707 |
void AOTCodeHeap::sweep_method(AOTCompiledMethod *aot) { |
|
708 |
int indexes[] = {aot->method_index()}; |
|
709 |
sweep_dependent_methods(indexes, 1); |
|
710 |
vmassert(aot->method()->code() != aot && aot->method()->aot_code() == NULL, "method still active"); |
|
711 |
} |
|
712 |
||
713 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
714 |
bool AOTCodeHeap::load_klass_data(InstanceKlass* ik, Thread* thread) { |
42650 | 715 |
ResourceMark rm; |
716 |
||
717 |
NOT_PRODUCT( klasses_seen++; ) |
|
718 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
719 |
AOTKlassData* klass_data = find_klass(ik); |
42650 | 720 |
if (klass_data == NULL) { |
721 |
return false; |
|
722 |
} |
|
723 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
724 |
if (!ik->has_passed_fingerprint_check()) { |
42650 | 725 |
NOT_PRODUCT( aot_klasses_fp_miss++; ) |
726 |
log_trace(aot, class, fingerprint)("class %s%s has bad fingerprint in %s tid=" INTPTR_FORMAT, |
|
46949 | 727 |
ik->internal_name(), ik->is_shared() ? " (shared)" : "", |
728 |
_lib->name(), p2i(thread)); |
|
42650 | 729 |
sweep_dependent_methods(klass_data); |
730 |
return false; |
|
731 |
} |
|
732 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
733 |
if (ik->has_been_redefined()) { |
42650 | 734 |
log_trace(aot, class, load)("class %s%s in %s has been redefined tid=" INTPTR_FORMAT, |
46949 | 735 |
ik->internal_name(), ik->is_shared() ? " (shared)" : "", |
736 |
_lib->name(), p2i(thread)); |
|
42650 | 737 |
sweep_dependent_methods(klass_data); |
738 |
return false; |
|
739 |
} |
|
740 |
||
741 |
assert(klass_data->_class_id < _class_count, "invalid class id"); |
|
742 |
AOTClass* aot_class = &_classes[klass_data->_class_id]; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
743 |
if (aot_class->_classloader != NULL && aot_class->_classloader != ik->class_loader_data()) { |
42650 | 744 |
log_trace(aot, class, load)("class %s in %s already loaded for classloader %p vs %p tid=" INTPTR_FORMAT, |
46949 | 745 |
ik->internal_name(), _lib->name(), aot_class->_classloader, ik->class_loader_data(), p2i(thread)); |
42650 | 746 |
NOT_PRODUCT( aot_klasses_cl_miss++; ) |
747 |
return false; |
|
748 |
} |
|
749 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
750 |
if (_lib->config()->_omitAssertions && JavaAssertions::enabled(ik->name()->as_C_string(), ik->class_loader() == NULL)) { |
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
751 |
log_trace(aot, class, load)("class %s in %s does not have java assertions in compiled code, but assertions are enabled for this execution.", ik->internal_name(), _lib->name()); |
43405
1fab8e6866d7
8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents:
42650
diff
changeset
|
752 |
sweep_dependent_methods(klass_data); |
1fab8e6866d7
8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents:
42650
diff
changeset
|
753 |
return false; |
1fab8e6866d7
8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents:
42650
diff
changeset
|
754 |
} |
1fab8e6866d7
8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents:
42650
diff
changeset
|
755 |
|
42650 | 756 |
NOT_PRODUCT( aot_klasses_found++; ) |
757 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
758 |
log_trace(aot, class, load)("found %s in %s for classloader %p tid=" INTPTR_FORMAT, ik->internal_name(), _lib->name(), ik->class_loader_data(), p2i(thread)); |
42650 | 759 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
760 |
aot_class->_classloader = ik->class_loader_data(); |
42650 | 761 |
// Set klass's Resolve (second) got cell. |
46949 | 762 |
_klasses_got[klass_data->_got_index] = ik; |
47668 | 763 |
if (ik->is_initialized()) { |
764 |
_klasses_got[klass_data->_got_index - 1] = ik; |
|
765 |
} |
|
42650 | 766 |
|
43405
1fab8e6866d7
8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents:
42650
diff
changeset
|
767 |
// Initialize global symbols of the DSO to the corresponding VM symbol values. |
42650 | 768 |
link_global_lib_symbols(); |
769 |
||
770 |
int methods_offset = klass_data->_compiled_methods_offset; |
|
771 |
if (methods_offset >= 0) { |
|
772 |
address methods_cnt_adr = _methods_offsets + methods_offset; |
|
773 |
int methods_cnt = *(int*)methods_cnt_adr; |
|
774 |
// Collect data about compiled methods |
|
775 |
AOTMethodData* methods_data = NEW_RESOURCE_ARRAY(AOTMethodData, methods_cnt); |
|
776 |
AOTMethodOffsets* methods_offsets = (AOTMethodOffsets*)(methods_cnt_adr + 4); |
|
777 |
for (int i = 0; i < methods_cnt; ++i) { |
|
778 |
AOTMethodOffsets* method_offsets = &methods_offsets[i]; |
|
779 |
int code_id = method_offsets->_code_id; |
|
780 |
if (_code_to_aot[code_id]._state == invalid) { |
|
781 |
continue; // skip AOT methods slots which have been invalidated |
|
782 |
} |
|
783 |
AOTMethodData* method_data = &methods_data[i]; |
|
784 |
const char* aot_name = _metaspace_names + method_offsets->_name_offset; |
|
785 |
method_data->_name = aot_name; |
|
786 |
method_data->_code = _code_space + method_offsets->_code_offset; |
|
787 |
method_data->_meta = (aot_metadata*)(_method_metadata + method_offsets->_meta_offset); |
|
788 |
method_data->_metadata_table = (address)_metadata_got + method_offsets->_metadata_got_offset; |
|
789 |
method_data->_metadata_size = method_offsets->_metadata_got_size; |
|
790 |
// aot_name format: "<u2_size>Ljava/lang/ThreadGroup;<u2_size>addUnstarted<u2_size>()V" |
|
791 |
int klass_len = build_u2_from((address)aot_name); |
|
792 |
const char* method_name = aot_name + 2 + klass_len; |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
793 |
Method* m = AOTCodeHeap::find_method(ik, thread, method_name); |
42650 | 794 |
methodHandle mh(thread, m); |
795 |
if (mh->code() != NULL) { // Does it have already compiled code? |
|
796 |
continue; // Don't overwrite |
|
797 |
} |
|
798 |
publish_aot(mh, method_data, code_id); |
|
799 |
} |
|
800 |
} |
|
801 |
return true; |
|
802 |
} |
|
803 |
||
804 |
AOTCompiledMethod* AOTCodeHeap::next_in_use_at(int start) const { |
|
805 |
for (int index = start; index < _method_count; index++) { |
|
806 |
if (_code_to_aot[index]._state != in_use) { |
|
807 |
continue; // Skip uninitialized entries. |
|
808 |
} |
|
809 |
AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
|
810 |
return aot; |
|
811 |
} |
|
812 |
return NULL; |
|
813 |
} |
|
814 |
||
815 |
void* AOTCodeHeap::first() const { |
|
816 |
return next_in_use_at(0); |
|
817 |
} |
|
818 |
||
819 |
void* AOTCodeHeap::next(void* p) const { |
|
820 |
AOTCompiledMethod *aot = (AOTCompiledMethod *)p; |
|
821 |
int next_index = aot->method_index() + 1; |
|
822 |
assert(next_index <= _method_count, ""); |
|
823 |
if (next_index == _method_count) { |
|
824 |
return NULL; |
|
825 |
} |
|
826 |
return next_in_use_at(next_index); |
|
827 |
} |
|
828 |
||
829 |
void* AOTCodeHeap::find_start(void* p) const { |
|
830 |
if (!contains(p)) { |
|
831 |
return NULL; |
|
832 |
} |
|
833 |
size_t offset = pointer_delta(p, low_boundary(), 1); |
|
834 |
// Use segments table |
|
835 |
size_t seg_idx = offset / _lib->config()->_codeSegmentSize; |
|
836 |
if ((int)(_code_segments[seg_idx]) == 0xff) { |
|
837 |
return NULL; |
|
838 |
} |
|
839 |
while (_code_segments[seg_idx] > 0) { |
|
840 |
seg_idx -= (int)_code_segments[seg_idx]; |
|
841 |
} |
|
842 |
int code_offset = (int)seg_idx * _lib->config()->_codeSegmentSize; |
|
843 |
int aot_index = *(int*)(_code_space + code_offset); |
|
844 |
AOTCompiledMethod* aot = _code_to_aot[aot_index]._aot; |
|
845 |
assert(aot != NULL, "should find registered aot method"); |
|
846 |
return aot; |
|
847 |
} |
|
848 |
||
849 |
AOTCompiledMethod* AOTCodeHeap::find_aot(address p) const { |
|
850 |
assert(contains(p), "should be here"); |
|
851 |
return (AOTCompiledMethod *)find_start(p); |
|
852 |
} |
|
853 |
||
854 |
CodeBlob* AOTCodeHeap::find_blob_unsafe(void* start) const { |
|
855 |
return (CodeBlob*)AOTCodeHeap::find_start(start); |
|
856 |
} |
|
857 |
||
858 |
void AOTCodeHeap::oops_do(OopClosure* f) { |
|
859 |
for (int i = 0; i < _oop_got_size; i++) { |
|
860 |
oop* p = &_oop_got[i]; |
|
861 |
if (*p == NULL) continue; // skip non-oops |
|
862 |
f->do_oop(p); |
|
863 |
} |
|
864 |
for (int index = 0; index < _method_count; index++) { |
|
865 |
if (_code_to_aot[index]._state != in_use) { |
|
866 |
continue; // Skip uninitialized entries. |
|
867 |
} |
|
868 |
AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
|
869 |
aot->do_oops(f); |
|
870 |
} |
|
871 |
} |
|
872 |
||
46949 | 873 |
// Scan only klasses_got cells which should have only Klass*, |
43942
fff6b7b5611f
8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents:
43461
diff
changeset
|
874 |
// metadata_got cells are scanned only for alive AOT methods |
fff6b7b5611f
8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents:
43461
diff
changeset
|
875 |
// by AOTCompiledMethod::metadata_do(). |
42650 | 876 |
void AOTCodeHeap::got_metadata_do(void f(Metadata*)) { |
46949 | 877 |
for (int i = 1; i < _klasses_got_size; i++) { |
878 |
Metadata** p = &_klasses_got[i]; |
|
42650 | 879 |
Metadata* md = *p; |
880 |
if (md == NULL) continue; // skip non-oops |
|
881 |
if (Metaspace::contains(md)) { |
|
882 |
f(md); |
|
883 |
} else { |
|
43942
fff6b7b5611f
8173794: [REDO] [AOT] Missing GC scan of _metaspace_got array containing Klass*
kvn
parents:
43461
diff
changeset
|
884 |
intptr_t meta = (intptr_t)md; |
47668 | 885 |
fatal("Invalid value in _klasses_got[%d] = " INTPTR_FORMAT, i, meta); |
42650 | 886 |
} |
887 |
} |
|
888 |
} |
|
889 |
||
890 |
void AOTCodeHeap::cleanup_inline_caches() { |
|
891 |
for (int index = 0; index < _method_count; index++) { |
|
892 |
if (_code_to_aot[index]._state != in_use) { |
|
893 |
continue; // Skip uninitialized entries. |
|
894 |
} |
|
895 |
AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
|
896 |
aot->cleanup_inline_caches(); |
|
897 |
} |
|
898 |
} |
|
899 |
||
900 |
#ifdef ASSERT |
|
901 |
int AOTCodeHeap::verify_icholder_relocations() { |
|
902 |
int count = 0; |
|
903 |
for (int index = 0; index < _method_count; index++) { |
|
904 |
if (_code_to_aot[index]._state != in_use) { |
|
905 |
continue; // Skip uninitialized entries. |
|
906 |
} |
|
907 |
AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
|
908 |
count += aot->verify_icholder_relocations(); |
|
909 |
} |
|
910 |
return count; |
|
911 |
} |
|
912 |
#endif |
|
913 |
||
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
46327
diff
changeset
|
914 |
void AOTCodeHeap::flush_evol_dependents_on(InstanceKlass* dependee) { |
42650 | 915 |
for (int index = 0; index < _method_count; index++) { |
916 |
if (_code_to_aot[index]._state != in_use) { |
|
917 |
continue; // Skip uninitialized entries. |
|
918 |
} |
|
919 |
AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
|
920 |
aot->flush_evol_dependents_on(dependee); |
|
921 |
} |
|
922 |
} |
|
923 |
||
924 |
void AOTCodeHeap::metadata_do(void f(Metadata*)) { |
|
925 |
for (int index = 0; index < _method_count; index++) { |
|
926 |
if (_code_to_aot[index]._state != in_use) { |
|
927 |
continue; // Skip uninitialized entries. |
|
928 |
} |
|
929 |
AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
|
930 |
if (aot->_is_alive()) { |
|
931 |
aot->metadata_do(f); |
|
932 |
} |
|
933 |
} |
|
47668 | 934 |
// Scan klasses_got cells. |
42650 | 935 |
got_metadata_do(f); |
936 |
} |
|
47668 | 937 |
|
938 |
bool AOTCodeHeap::reconcile_dynamic_klass(AOTCompiledMethod *caller, InstanceKlass* holder, int index, Klass *dyno_klass, const char *descriptor1, const char *descriptor2) { |
|
939 |
const char * const descriptors[2] = {descriptor1, descriptor2}; |
|
940 |
JavaThread *thread = JavaThread::current(); |
|
941 |
ResourceMark rm(thread); |
|
942 |
||
943 |
AOTKlassData* holder_data = find_klass(holder); |
|
944 |
vmassert(holder_data != NULL, "klass %s not found", holder->signature_name()); |
|
945 |
vmassert(is_dependent_method(holder, caller), "sanity"); |
|
946 |
||
947 |
AOTKlassData* dyno_data = NULL; |
|
948 |
bool adapter_failed = false; |
|
949 |
char buf[64]; |
|
950 |
int descriptor_index = 0; |
|
951 |
// descriptors[0] specific name ("adapter:<method_id>") for matching |
|
952 |
// descriptors[1] fall-back name ("adapter") for depdencies |
|
953 |
while (descriptor_index < 2) { |
|
954 |
const char *descriptor = descriptors[descriptor_index]; |
|
955 |
if (descriptor == NULL) { |
|
956 |
break; |
|
957 |
} |
|
958 |
jio_snprintf(buf, sizeof buf, "%s<%d:%d>", descriptor, holder_data->_class_id, index); |
|
959 |
dyno_data = find_klass(buf); |
|
960 |
if (dyno_data != NULL) { |
|
961 |
break; |
|
962 |
} |
|
963 |
// If match failed then try fall-back for dependencies |
|
964 |
++descriptor_index; |
|
965 |
adapter_failed = true; |
|
966 |
} |
|
967 |
||
968 |
if (dyno_data == NULL && dyno_klass == NULL) { |
|
969 |
// all is well, no (appendix) at compile-time, and still none |
|
970 |
return true; |
|
971 |
} |
|
972 |
||
973 |
if (dyno_data == NULL) { |
|
974 |
// no (appendix) at build-time, but now there is |
|
975 |
sweep_dependent_methods(holder_data); |
|
976 |
return false; |
|
977 |
} |
|
978 |
||
979 |
if (adapter_failed) { |
|
980 |
// adapter method mismatch |
|
981 |
sweep_dependent_methods(holder_data); |
|
982 |
sweep_dependent_methods(dyno_data); |
|
983 |
return false; |
|
984 |
} |
|
985 |
||
986 |
if (dyno_klass == NULL) { |
|
987 |
// (appendix) at build-time, none now |
|
988 |
sweep_dependent_methods(holder_data); |
|
989 |
sweep_dependent_methods(dyno_data); |
|
990 |
return false; |
|
991 |
} |
|
992 |
||
993 |
// TODO: support array appendix object |
|
994 |
if (!dyno_klass->is_instance_klass()) { |
|
995 |
sweep_dependent_methods(holder_data); |
|
996 |
sweep_dependent_methods(dyno_data); |
|
997 |
return false; |
|
998 |
} |
|
999 |
||
1000 |
InstanceKlass* dyno = InstanceKlass::cast(dyno_klass); |
|
1001 |
||
1002 |
if (!dyno->is_anonymous()) { |
|
1003 |
if (_klasses_got[dyno_data->_got_index] != dyno) { |
|
1004 |
// compile-time class different from runtime class, fail and deoptimize |
|
1005 |
sweep_dependent_methods(holder_data); |
|
1006 |
sweep_dependent_methods(dyno_data); |
|
1007 |
return false; |
|
1008 |
} |
|
1009 |
||
1010 |
if (dyno->is_initialized()) { |
|
1011 |
_klasses_got[dyno_data->_got_index - 1] = dyno; |
|
1012 |
} |
|
1013 |
return true; |
|
1014 |
} |
|
1015 |
||
1016 |
// TODO: support anonymous supers |
|
1017 |
if (!dyno->supers_have_passed_fingerprint_checks() || dyno->get_stored_fingerprint() != dyno_data->_fingerprint) { |
|
1018 |
NOT_PRODUCT( aot_klasses_fp_miss++; ) |
|
1019 |
log_trace(aot, class, fingerprint)("class %s%s has bad fingerprint in %s tid=" INTPTR_FORMAT, |
|
1020 |
dyno->internal_name(), dyno->is_shared() ? " (shared)" : "", |
|
1021 |
_lib->name(), p2i(thread)); |
|
1022 |
sweep_dependent_methods(holder_data); |
|
1023 |
sweep_dependent_methods(dyno_data); |
|
1024 |
return false; |
|
1025 |
} |
|
1026 |
||
1027 |
_klasses_got[dyno_data->_got_index] = dyno; |
|
1028 |
if (dyno->is_initialized()) { |
|
1029 |
_klasses_got[dyno_data->_got_index - 1] = dyno; |
|
1030 |
} |
|
1031 |
||
1032 |
// TODO: hook up any AOT code |
|
1033 |
// load_klass_data(dyno_data, thread); |
|
1034 |
return true; |
|
1035 |
} |
|
1036 |
||
1037 |
bool AOTCodeHeap::reconcile_dynamic_method(AOTCompiledMethod *caller, InstanceKlass* holder, int index, Method *adapter_method) { |
|
1038 |
InstanceKlass *adapter_klass = adapter_method->method_holder(); |
|
1039 |
char buf[64]; |
|
1040 |
jio_snprintf(buf, sizeof buf, "adapter:%d", adapter_method->method_idnum()); |
|
1041 |
if (!reconcile_dynamic_klass(caller, holder, index, adapter_klass, buf, "adapter")) { |
|
1042 |
return false; |
|
1043 |
} |
|
1044 |
return true; |
|
1045 |
} |
|
1046 |
||
1047 |
bool AOTCodeHeap::reconcile_dynamic_invoke(AOTCompiledMethod* caller, InstanceKlass* holder, int index, Method* adapter_method, Klass *appendix_klass) { |
|
1048 |
if (!reconcile_dynamic_klass(caller, holder, index, appendix_klass, "appendix")) { |
|
1049 |
return false; |
|
1050 |
} |
|
1051 |
||
1052 |
if (!reconcile_dynamic_method(caller, holder, index, adapter_method)) { |
|
1053 |
return false; |
|
1054 |
} |
|
1055 |
||
1056 |
return true; |
|
1057 |
} |