1 /*
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
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"
28 #include "gc/g1/heapRegion.hpp"
29 #include "gc/shared/gcLocker.hpp"
30 #include "interpreter/abstractInterpreter.hpp"
31 #include "jvmci/compilerRuntime.hpp"
32 #include "jvmci/jvmciRuntime.hpp"
33 #include "oops/method.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/sharedRuntime.hpp"
36 #include "runtime/vm_operations.hpp"
37
38 bool AOTLib::_narrow_oop_shift_initialized = false;
39 int AOTLib::_narrow_oop_shift = 0;
40 int AOTLib::_narrow_klass_shift = 0;
41
42 address AOTLib::load_symbol(const char *name) {
43 address symbol = (address) dlsym(_dl_handle, name);
44 if (symbol == NULL) {
45 tty->print_cr("Shared file %s error: missing %s", _name, name);
46 vm_exit(1);
47 }
48 return symbol;
49 }
50
51 Klass* AOTCodeHeap::get_klass_from_got(const char* klass_name, int klass_len, const Method* method) {
52 AOTKlassData* klass_data = (AOTKlassData*)_lib->load_symbol(klass_name);
53 Klass* k = (Klass*)_metaspace_got[klass_data->_got_index];
54 if (k == NULL) {
55 Thread* thread = Thread::current();
56 k = lookup_klass(klass_name, klass_len, method, thread);
57 // Note, exceptions are cleared.
58 if (k == NULL) {
59 fatal("Shared file %s error: klass %s should be resolved already", _lib->name(), klass_name);
60 vm_exit(1);
61 }
62 _metaspace_got[klass_data->_got_index] = k;
63 }
207
208 verify_config();
209
210 if (!_valid && PrintAOT) {
211 tty->print("%7d ", (int) tty->time_stamp().milliseconds());
212 tty->print_cr("%4d skipped %s aot library", _dso_id, _name);
213 }
214 }
215
216 AOTCodeHeap::AOTCodeHeap(AOTLib* lib) :
217 CodeHeap("CodeHeap 'AOT'", CodeBlobType::AOT), _lib(lib), _classes(NULL), _code_to_aot(NULL) {
218 assert(_lib->is_valid(), "invalid library");
219
220 _lib_symbols_initialized = false;
221 _aot_id = 0;
222
223 _class_count = _lib->header()->_class_count;
224 _method_count = _lib->header()->_method_count;
225
226 // Collect metaspace info: names -> address in .got section
227 _metaspace_names = (const char*) _lib->load_symbol("JVM.metaspace.names");
228 _method_metadata = (address) _lib->load_symbol("JVM.method.metadata");
229 _methods_offsets = (address) _lib->load_symbol("JVM.methods.offsets");
230 _klasses_offsets = (address) _lib->load_symbol("JVM.klasses.offsets");
231 _dependencies = (address) _lib->load_symbol("JVM.klasses.dependencies");
232 _code_space = (address) _lib->load_symbol("JVM.text");
233
234 // First cell is number of elements.
235 jlong* got_sect;
236 _metaspace_got = (Metadata**) _lib->load_symbol("JVM.metaspace.got");
237 _metaspace_got_size = _lib->header()->_metaspace_got_size;
238
239 _metadata_got = (Metadata**) _lib->load_symbol("JVM.metadata.got");
240 _metadata_got_size = _lib->header()->_metadata_got_size;
241
242 _oop_got = (oop*) _lib->load_symbol("JVM.oop.got");
243 _oop_got_size = _lib->header()->_oop_got_size;
244
245 // Collect stubs info
246 _stubs_offsets = (int*) _lib->load_symbol("JVM.stubs.offsets");
247
248 // code segments table
249 _code_segments = (address) _lib->load_symbol("JVM.code.segments");
250
251 // method state
252 _method_state = (jlong*) _lib->load_symbol("JVM.method.state");
253
254 // Create a table for mapping classes
255 _classes = NEW_C_HEAP_ARRAY(AOTClass, _class_count, mtCode);
256 memset(_classes, 0, _class_count * sizeof(AOTClass));
257
258 // Create table for searching AOTCompiledMethod based on pc.
259 _code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode);
260 memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod));
261
262 _low_boundary = _code_space;
263 _memory.set_low_boundary((char *)_code_space);
264 _memory.set_high_boundary((char *)_code_space);
265 _memory.set_low((char *)_code_space);
266 _memory.set_high((char *)_code_space);
267
268 _segmap.set_low_boundary((char *)_code_segments);
269 _segmap.set_low((char *)_code_segments);
270
271 _log2_segment_size = exact_log2(_lib->config()->_codeSegmentSize);
272
321 } else { // success
322 // Publish method
323 #ifdef TIERED
324 mh->set_aot_code(aot);
325 #endif
326 Method::set_code(mh, aot);
327 if (PrintAOT || (PrintCompilation && PrintAOT)) {
328 aot->print_on(tty, NULL);
329 }
330 // Publish oop only after we are visible to CompiledMethodIterator
331 aot->set_oop(mh()->method_holder()->klass_holder());
332 }
333 }
334
335 void AOTCodeHeap::link_primitive_array_klasses() {
336 ResourceMark rm;
337 for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
338 BasicType t = (BasicType)i;
339 if (is_java_primitive(t)) {
340 const Klass* arr_klass = Universe::typeArrayKlassObj(t);
341 AOTKlassData* klass_data = (AOTKlassData*) dlsym(_lib->dl_handle(), arr_klass->signature_name());
342 if (klass_data != NULL) {
343 // Set both GOT cells, resolved and initialized klass pointers.
344 // _got_index points to second cell - resolved klass pointer.
345 _metaspace_got[klass_data->_got_index-1] = (Metadata*)arr_klass; // Initialized
346 _metaspace_got[klass_data->_got_index ] = (Metadata*)arr_klass; // Resolved
347 if (PrintAOT) {
348 tty->print_cr("[Found %s in %s]", arr_klass->internal_name(), _lib->name());
349 }
350 }
351 }
352 }
353 }
354
355 void AOTCodeHeap::register_stubs() {
356 int stubs_count = _stubs_offsets[0]; // contains number
357 _stubs_offsets++;
358 AOTMethodOffsets* stub_offsets = (AOTMethodOffsets*)_stubs_offsets;
359 for (int i = 0; i < stubs_count; ++i) {
360 const char* stub_name = _metaspace_names + stub_offsets[i]._name_offset;
361 address entry = _code_space + stub_offsets[i]._code_offset;
374 memcpy(full_name, "AOT ", 4);
375 memcpy(full_name+4, stub_name, len);
376 full_name[len+4] = 0;
377 guarantee(_code_to_aot[code_id]._state != invalid, "stub %s can't be invalidated", full_name);
378 AOTCompiledMethod* aot = new AOTCompiledMethod(entry, NULL, meta, metadata_table, metadata_size, state_adr, this, full_name, code_id, i);
379 assert(_code_to_aot[code_id]._aot == NULL, "should be not initialized");
380 _code_to_aot[code_id]._aot = aot;
381 if (Atomic::cmpxchg(in_use, (jint*)&_code_to_aot[code_id]._state, not_set) != not_set) {
382 fatal("stab '%s' code state is %d", full_name, _code_to_aot[code_id]._state);
383 }
384 // Adjust code buffer boundaries only for stubs because they are last in the buffer.
385 adjust_boundaries(aot);
386 if (PrintAOT && Verbose) {
387 aot->print_on(tty, NULL);
388 }
389 }
390 }
391
392 #define SET_AOT_GLOBAL_SYMBOL_VALUE(AOTSYMNAME, AOTSYMTYPE, VMSYMVAL) \
393 { \
394 char* error; \
395 /* Clear any existing error */ \
396 dlerror(); \
397 AOTSYMTYPE * adr = (AOTSYMTYPE *) dlsym(_lib->dl_handle(), AOTSYMNAME); \
398 /* Check for any dlsym lookup error */ \
399 error = dlerror(); \
400 guarantee(error == NULL, "%s", error); \
401 *adr = (AOTSYMTYPE) VMSYMVAL; \
402 }
403
404 void AOTCodeHeap::link_graal_runtime_symbols() {
405 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_monitorenter", address, JVMCIRuntime::monitorenter);
406 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_monitorexit", address, JVMCIRuntime::monitorexit);
407 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_object", address, JVMCIRuntime::log_object);
408 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_printf", address, JVMCIRuntime::log_printf);
409 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_primitive", address, JVMCIRuntime::log_primitive);
410 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_instance", address, JVMCIRuntime::new_instance);
411 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_array", address, JVMCIRuntime::new_array);
412 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_multi_array", address, JVMCIRuntime::new_multi_array);
413 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_array", address, JVMCIRuntime::dynamic_new_array);
414 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_validate_object", address, JVMCIRuntime::validate_object);
415 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_pre", address, JVMCIRuntime::write_barrier_pre);
416 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_identity_hash_code", address, JVMCIRuntime::identity_hash_code);
417 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_post", address, JVMCIRuntime::write_barrier_post);
418 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_instance", address, JVMCIRuntime::dynamic_new_instance);
419 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_thread_is_interrupted", address, JVMCIRuntime::thread_is_interrupted);
420 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_exception_handler_for_pc", address, JVMCIRuntime::exception_handler_for_pc);
595 int klass_len = (int)strlen(klass_name);
596 char* meta_name = NEW_RESOURCE_ARRAY(char, klass_len + 1 + method_name_len + signature_name_len + 1);
597 memcpy(meta_name, klass_name, klass_len);
598 meta_name[klass_len] = '.';
599 memcpy(&meta_name[klass_len + 1], method_name, method_name_len);
600 memcpy(&meta_name[klass_len + 1 + method_name_len], signature_name, signature_name_len);
601 meta_name[klass_len + 1 + method_name_len + signature_name_len] = '\0';
602 Handle exception = Exceptions::new_exception(thread, vmSymbols::java_lang_NoSuchMethodError(), meta_name);
603 java_lang_Throwable::print(exception, tty);
604 tty->cr();
605 java_lang_Throwable::print_stack_trace(exception(), tty);
606 tty->cr();
607 fatal("Failed to find method '%s'", meta_name);
608 }
609 NOT_PRODUCT( aot_methods_found++; )
610 return m;
611 }
612
613 AOTKlassData* AOTCodeHeap::find_klass(InstanceKlass* ik) {
614 ResourceMark rm;
615 AOTKlassData* klass_data = (AOTKlassData*) dlsym(_lib->dl_handle(), ik->signature_name());
616 return klass_data;
617 }
618
619 bool AOTCodeHeap::is_dependent_method(Klass* dependee, AOTCompiledMethod* aot) {
620 InstanceKlass *dependee_ik = InstanceKlass::cast(dependee);
621 AOTKlassData* klass_data = find_klass(dependee_ik);
622 if (klass_data == NULL) {
623 return false; // no AOT records for this class - no dependencies
624 }
625 if (!dependee_ik->has_passed_fingerprint_check()) {
626 return false; // different class
627 }
628
629 int methods_offset = klass_data->_dependent_methods_offset;
630 if (methods_offset >= 0) {
631 address methods_cnt_adr = _dependencies + methods_offset;
632 int methods_cnt = *(int*)methods_cnt_adr;
633 int* indexes = (int*)(methods_cnt_adr + 4);
634 for (int i = 0; i < methods_cnt; ++i) {
635 int code_id = indexes[i];
|
1 /*
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
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"
28 #include "gc/g1/heapRegion.hpp"
29 #include "gc/shared/gcLocker.hpp"
30 #include "interpreter/abstractInterpreter.hpp"
31 #include "jvmci/compilerRuntime.hpp"
32 #include "jvmci/jvmciRuntime.hpp"
33 #include "oops/method.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/sharedRuntime.hpp"
36 #include "runtime/vm_operations.hpp"
37
38 bool AOTLib::_narrow_oop_shift_initialized = false;
39 int AOTLib::_narrow_oop_shift = 0;
40 int AOTLib::_narrow_klass_shift = 0;
41
42 address AOTLib::load_symbol(const char *name) {
43 address symbol = (address) os::dll_lookup(_dl_handle, name);
44 if (symbol == NULL) {
45 tty->print_cr("Shared file %s error: missing %s", _name, name);
46 vm_exit(1);
47 }
48 return symbol;
49 }
50
51 Klass* AOTCodeHeap::get_klass_from_got(const char* klass_name, int klass_len, const Method* method) {
52 AOTKlassData* klass_data = (AOTKlassData*)_lib->load_symbol(klass_name);
53 Klass* k = (Klass*)_metaspace_got[klass_data->_got_index];
54 if (k == NULL) {
55 Thread* thread = Thread::current();
56 k = lookup_klass(klass_name, klass_len, method, thread);
57 // Note, exceptions are cleared.
58 if (k == NULL) {
59 fatal("Shared file %s error: klass %s should be resolved already", _lib->name(), klass_name);
60 vm_exit(1);
61 }
62 _metaspace_got[klass_data->_got_index] = k;
63 }
207
208 verify_config();
209
210 if (!_valid && PrintAOT) {
211 tty->print("%7d ", (int) tty->time_stamp().milliseconds());
212 tty->print_cr("%4d skipped %s aot library", _dso_id, _name);
213 }
214 }
215
216 AOTCodeHeap::AOTCodeHeap(AOTLib* lib) :
217 CodeHeap("CodeHeap 'AOT'", CodeBlobType::AOT), _lib(lib), _classes(NULL), _code_to_aot(NULL) {
218 assert(_lib->is_valid(), "invalid library");
219
220 _lib_symbols_initialized = false;
221 _aot_id = 0;
222
223 _class_count = _lib->header()->_class_count;
224 _method_count = _lib->header()->_method_count;
225
226 // Collect metaspace info: names -> address in .got section
227 _metaspace_names = (const char*) _lib->load_symbol("JVM.meta.names");
228 _method_metadata = (address) _lib->load_symbol("JVM.meth.metadata");
229 _methods_offsets = (address) _lib->load_symbol("JVM.methods.offsets");
230 _klasses_offsets = (address) _lib->load_symbol("JVM.kls.offsets");
231 _dependencies = (address) _lib->load_symbol("JVM.kls.dependencies");
232 _code_space = (address) _lib->load_symbol("JVM.text");
233
234 // First cell is number of elements.
235 _metaspace_got = (Metadata**) _lib->load_symbol("JVM.meta.got");
236 _metaspace_got_size = _lib->header()->_metaspace_got_size;
237
238 _metadata_got = (Metadata**) _lib->load_symbol("JVM.metadata.got");
239 _metadata_got_size = _lib->header()->_metadata_got_size;
240
241 _oop_got = (oop*) _lib->load_symbol("JVM.oop.got");
242 _oop_got_size = _lib->header()->_oop_got_size;
243
244 // Collect stubs info
245 _stubs_offsets = (int*) _lib->load_symbol("JVM.stubs.offsets");
246
247 // code segments table
248 _code_segments = (address) _lib->load_symbol("JVM.code.segments");
249
250 // method state
251 _method_state = (jlong*) _lib->load_symbol("JVM.meth.state");
252
253 // Create a table for mapping classes
254 _classes = NEW_C_HEAP_ARRAY(AOTClass, _class_count, mtCode);
255 memset(_classes, 0, _class_count * sizeof(AOTClass));
256
257 // Create table for searching AOTCompiledMethod based on pc.
258 _code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode);
259 memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod));
260
261 _low_boundary = _code_space;
262 _memory.set_low_boundary((char *)_code_space);
263 _memory.set_high_boundary((char *)_code_space);
264 _memory.set_low((char *)_code_space);
265 _memory.set_high((char *)_code_space);
266
267 _segmap.set_low_boundary((char *)_code_segments);
268 _segmap.set_low((char *)_code_segments);
269
270 _log2_segment_size = exact_log2(_lib->config()->_codeSegmentSize);
271
320 } else { // success
321 // Publish method
322 #ifdef TIERED
323 mh->set_aot_code(aot);
324 #endif
325 Method::set_code(mh, aot);
326 if (PrintAOT || (PrintCompilation && PrintAOT)) {
327 aot->print_on(tty, NULL);
328 }
329 // Publish oop only after we are visible to CompiledMethodIterator
330 aot->set_oop(mh()->method_holder()->klass_holder());
331 }
332 }
333
334 void AOTCodeHeap::link_primitive_array_klasses() {
335 ResourceMark rm;
336 for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
337 BasicType t = (BasicType)i;
338 if (is_java_primitive(t)) {
339 const Klass* arr_klass = Universe::typeArrayKlassObj(t);
340 AOTKlassData* klass_data = (AOTKlassData*) os::dll_lookup(_lib->dl_handle(), arr_klass->signature_name());
341 if (klass_data != NULL) {
342 // Set both GOT cells, resolved and initialized klass pointers.
343 // _got_index points to second cell - resolved klass pointer.
344 _metaspace_got[klass_data->_got_index-1] = (Metadata*)arr_klass; // Initialized
345 _metaspace_got[klass_data->_got_index ] = (Metadata*)arr_klass; // Resolved
346 if (PrintAOT) {
347 tty->print_cr("[Found %s in %s]", arr_klass->internal_name(), _lib->name());
348 }
349 }
350 }
351 }
352 }
353
354 void AOTCodeHeap::register_stubs() {
355 int stubs_count = _stubs_offsets[0]; // contains number
356 _stubs_offsets++;
357 AOTMethodOffsets* stub_offsets = (AOTMethodOffsets*)_stubs_offsets;
358 for (int i = 0; i < stubs_count; ++i) {
359 const char* stub_name = _metaspace_names + stub_offsets[i]._name_offset;
360 address entry = _code_space + stub_offsets[i]._code_offset;
373 memcpy(full_name, "AOT ", 4);
374 memcpy(full_name+4, stub_name, len);
375 full_name[len+4] = 0;
376 guarantee(_code_to_aot[code_id]._state != invalid, "stub %s can't be invalidated", full_name);
377 AOTCompiledMethod* aot = new AOTCompiledMethod(entry, NULL, meta, metadata_table, metadata_size, state_adr, this, full_name, code_id, i);
378 assert(_code_to_aot[code_id]._aot == NULL, "should be not initialized");
379 _code_to_aot[code_id]._aot = aot;
380 if (Atomic::cmpxchg(in_use, (jint*)&_code_to_aot[code_id]._state, not_set) != not_set) {
381 fatal("stab '%s' code state is %d", full_name, _code_to_aot[code_id]._state);
382 }
383 // Adjust code buffer boundaries only for stubs because they are last in the buffer.
384 adjust_boundaries(aot);
385 if (PrintAOT && Verbose) {
386 aot->print_on(tty, NULL);
387 }
388 }
389 }
390
391 #define SET_AOT_GLOBAL_SYMBOL_VALUE(AOTSYMNAME, AOTSYMTYPE, VMSYMVAL) \
392 { \
393 AOTSYMTYPE * adr = (AOTSYMTYPE *) os::dll_lookup(_lib->dl_handle(), AOTSYMNAME); \
394 /* Check for a lookup error */ \
395 guarantee(adr != NULL, "AOT Symbol not found %s", AOTSYMNAME); \
396 *adr = (AOTSYMTYPE) VMSYMVAL; \
397 }
398
399 void AOTCodeHeap::link_graal_runtime_symbols() {
400 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_monitorenter", address, JVMCIRuntime::monitorenter);
401 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_monitorexit", address, JVMCIRuntime::monitorexit);
402 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_object", address, JVMCIRuntime::log_object);
403 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_printf", address, JVMCIRuntime::log_printf);
404 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_log_primitive", address, JVMCIRuntime::log_primitive);
405 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_instance", address, JVMCIRuntime::new_instance);
406 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_array", address, JVMCIRuntime::new_array);
407 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_new_multi_array", address, JVMCIRuntime::new_multi_array);
408 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_array", address, JVMCIRuntime::dynamic_new_array);
409 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_validate_object", address, JVMCIRuntime::validate_object);
410 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_pre", address, JVMCIRuntime::write_barrier_pre);
411 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_identity_hash_code", address, JVMCIRuntime::identity_hash_code);
412 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_write_barrier_post", address, JVMCIRuntime::write_barrier_post);
413 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_dynamic_new_instance", address, JVMCIRuntime::dynamic_new_instance);
414 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_thread_is_interrupted", address, JVMCIRuntime::thread_is_interrupted);
415 SET_AOT_GLOBAL_SYMBOL_VALUE("_aot_jvmci_runtime_exception_handler_for_pc", address, JVMCIRuntime::exception_handler_for_pc);
590 int klass_len = (int)strlen(klass_name);
591 char* meta_name = NEW_RESOURCE_ARRAY(char, klass_len + 1 + method_name_len + signature_name_len + 1);
592 memcpy(meta_name, klass_name, klass_len);
593 meta_name[klass_len] = '.';
594 memcpy(&meta_name[klass_len + 1], method_name, method_name_len);
595 memcpy(&meta_name[klass_len + 1 + method_name_len], signature_name, signature_name_len);
596 meta_name[klass_len + 1 + method_name_len + signature_name_len] = '\0';
597 Handle exception = Exceptions::new_exception(thread, vmSymbols::java_lang_NoSuchMethodError(), meta_name);
598 java_lang_Throwable::print(exception, tty);
599 tty->cr();
600 java_lang_Throwable::print_stack_trace(exception(), tty);
601 tty->cr();
602 fatal("Failed to find method '%s'", meta_name);
603 }
604 NOT_PRODUCT( aot_methods_found++; )
605 return m;
606 }
607
608 AOTKlassData* AOTCodeHeap::find_klass(InstanceKlass* ik) {
609 ResourceMark rm;
610 AOTKlassData* klass_data = (AOTKlassData*) os::dll_lookup(_lib->dl_handle(), ik->signature_name());
611 return klass_data;
612 }
613
614 bool AOTCodeHeap::is_dependent_method(Klass* dependee, AOTCompiledMethod* aot) {
615 InstanceKlass *dependee_ik = InstanceKlass::cast(dependee);
616 AOTKlassData* klass_data = find_klass(dependee_ik);
617 if (klass_data == NULL) {
618 return false; // no AOT records for this class - no dependencies
619 }
620 if (!dependee_ik->has_passed_fingerprint_check()) {
621 return false; // different class
622 }
623
624 int methods_offset = klass_data->_dependent_methods_offset;
625 if (methods_offset >= 0) {
626 address methods_cnt_adr = _dependencies + methods_offset;
627 int methods_cnt = *(int*)methods_cnt_adr;
628 int* indexes = (int*)(methods_cnt_adr + 4);
629 for (int i = 0; i < methods_cnt; ++i) {
630 int code_id = indexes[i];
|