491 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created by debug VM, it can't be used by product VM");
492 return false;
493 }
494 #endif
495
496 CollectedHeap::Name aot_gc = (CollectedHeap::Name)_gc;
497 if (aot_gc != Universe::heap()->kind()) {
498 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with different GC: %s vs current %s", GCConfig::hs_err_name(aot_gc), GCConfig::hs_err_name());
499 return false;
500 }
501
502 if (((_flags & compressedClassPointers) != 0) != UseCompressedClassPointers) {
503 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with UseCompressedClassPointers = %s", UseCompressedClassPointers ? "false" : "true");
504 return false;
505 }
506 if (_compressedKlassShift != (uint)CompressedKlassPointers::shift()) {
507 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with CompressedKlassPointers::shift() = %d vs current %d", _compressedKlassShift, CompressedKlassPointers::shift());
508 return false;
509 }
510
511 // The following checks do not affect AOT adapters caching
512
513 if (((_flags & compressedOops) != 0) != UseCompressedOops) {
514 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with UseCompressedOops = %s", UseCompressedOops ? "false" : "true");
515 AOTStubCaching = false;
516 }
517 if (_compressedOopShift != (uint)CompressedOops::shift()) {
518 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with different CompressedOops::shift(): %d vs current %d", _compressedOopShift, CompressedOops::shift());
519 AOTStubCaching = false;
520 }
521
522 // This should be the last check as it only disables AOTStubCaching
523 if ((_compressedOopBase == nullptr || CompressedOops::base() == nullptr) && (_compressedOopBase != CompressedOops::base())) {
524 log_debug(aot, codecache, init)("AOTStubCaching is disabled: incompatible CompressedOops::base(): %p vs current %p", _compressedOopBase, CompressedOops::base());
525 AOTStubCaching = false;
526 }
527
528 if (!verify_cpu_features(cache)) {
529 return false;
530 }
531 return true;
532 }
533
534 bool AOTCodeCache::Header::verify(uint load_size) const {
535 if (_version != AOT_CODE_VERSION) {
536 log_debug(aot, codecache, init)("AOT Code Cache disabled: different AOT Code version %d vs %d recorded in AOT Code header", AOT_CODE_VERSION, _version);
537 return false;
538 }
539 if (load_size < _cache_size) {
540 log_debug(aot, codecache, init)("AOT Code Cache disabled: AOT Code Cache size %d < %d recorded in AOT Code header", load_size, _cache_size);
541 return false;
542 }
543 return true;
544 }
545
1329 assert(type##_length <= type##_max, "increase size"); \
1330 }
1331
1332 static bool initializing_extrs = false;
1333
1334 void AOTCodeAddressTable::init_extrs() {
1335 if (_extrs_complete || initializing_extrs) return; // Done already
1336
1337 assert(_blobs_end <= _all_max, "AOTCodeAddress table ranges need adjusting");
1338
1339 initializing_extrs = true;
1340 _extrs_addr = NEW_C_HEAP_ARRAY(address, _extrs_max, mtCode);
1341
1342 _extrs_length = 0;
1343
1344 // Record addresses of VM runtime methods
1345 SET_ADDRESS(_extrs, SharedRuntime::fixup_callers_callsite);
1346 SET_ADDRESS(_extrs, SharedRuntime::handle_wrong_method);
1347 SET_ADDRESS(_extrs, SharedRuntime::handle_wrong_method_abstract);
1348 SET_ADDRESS(_extrs, SharedRuntime::handle_wrong_method_ic_miss);
1349 #if defined(AARCH64) && !defined(ZERO)
1350 SET_ADDRESS(_extrs, JavaThread::aarch64_get_thread_helper);
1351 #endif
1352 {
1353 // Required by Shared blobs
1354 SET_ADDRESS(_extrs, Deoptimization::fetch_unroll_info);
1355 SET_ADDRESS(_extrs, Deoptimization::unpack_frames);
1356 SET_ADDRESS(_extrs, SafepointSynchronize::handle_polling_page_exception);
1357 SET_ADDRESS(_extrs, SharedRuntime::resolve_opt_virtual_call_C);
1358 SET_ADDRESS(_extrs, SharedRuntime::resolve_virtual_call_C);
1359 SET_ADDRESS(_extrs, SharedRuntime::resolve_static_call_C);
1360 SET_ADDRESS(_extrs, SharedRuntime::throw_StackOverflowError);
1361 SET_ADDRESS(_extrs, SharedRuntime::throw_delayed_StackOverflowError);
1362 SET_ADDRESS(_extrs, SharedRuntime::throw_AbstractMethodError);
1363 SET_ADDRESS(_extrs, SharedRuntime::throw_IncompatibleClassChangeError);
1364 SET_ADDRESS(_extrs, SharedRuntime::throw_NullPointerException_at_call);
1365 }
1366
1367 #ifdef COMPILER1
1368 {
1378 SET_ADDRESS(_extrs, Runtime1::new_type_array);
1379 SET_ADDRESS(_extrs, Runtime1::new_object_array);
1380 SET_ADDRESS(_extrs, Runtime1::new_multi_array);
1381 SET_ADDRESS(_extrs, Runtime1::throw_range_check_exception);
1382 SET_ADDRESS(_extrs, Runtime1::throw_index_exception);
1383 SET_ADDRESS(_extrs, Runtime1::throw_div0_exception);
1384 SET_ADDRESS(_extrs, Runtime1::throw_null_pointer_exception);
1385 SET_ADDRESS(_extrs, Runtime1::throw_array_store_exception);
1386 SET_ADDRESS(_extrs, Runtime1::throw_class_cast_exception);
1387 SET_ADDRESS(_extrs, Runtime1::throw_incompatible_class_change_error);
1388 SET_ADDRESS(_extrs, Runtime1::is_instance_of);
1389 SET_ADDRESS(_extrs, Runtime1::monitorenter);
1390 SET_ADDRESS(_extrs, Runtime1::monitorexit);
1391 SET_ADDRESS(_extrs, Runtime1::deoptimize);
1392 SET_ADDRESS(_extrs, Runtime1::access_field_patching);
1393 SET_ADDRESS(_extrs, Runtime1::move_klass_patching);
1394 SET_ADDRESS(_extrs, Runtime1::move_mirror_patching);
1395 SET_ADDRESS(_extrs, Runtime1::move_appendix_patching);
1396 SET_ADDRESS(_extrs, Runtime1::predicate_failed_trap);
1397 SET_ADDRESS(_extrs, Runtime1::unimplemented_entry);
1398 SET_ADDRESS(_extrs, Thread::current);
1399 SET_ADDRESS(_extrs, CompressedKlassPointers::base_addr());
1400 #ifndef PRODUCT
1401 SET_ADDRESS(_extrs, os::breakpoint);
1402 #endif
1403 }
1404 #endif
1405
1406 #ifdef COMPILER2
1407 {
1408 // Required by C2 blobs
1409 SET_ADDRESS(_extrs, Deoptimization::uncommon_trap);
1410 SET_ADDRESS(_extrs, OptoRuntime::handle_exception_C);
1411 SET_ADDRESS(_extrs, OptoRuntime::new_instance_C);
1412 SET_ADDRESS(_extrs, OptoRuntime::new_array_C);
1413 SET_ADDRESS(_extrs, OptoRuntime::new_array_nozero_C);
1414 SET_ADDRESS(_extrs, OptoRuntime::multianewarray2_C);
1415 SET_ADDRESS(_extrs, OptoRuntime::multianewarray3_C);
1416 SET_ADDRESS(_extrs, OptoRuntime::multianewarray4_C);
1417 SET_ADDRESS(_extrs, OptoRuntime::multianewarray5_C);
1418 SET_ADDRESS(_extrs, OptoRuntime::multianewarrayN_C);
1419 SET_ADDRESS(_extrs, OptoRuntime::complete_monitor_locking_C);
1420 SET_ADDRESS(_extrs, OptoRuntime::monitor_notify_C);
1421 SET_ADDRESS(_extrs, OptoRuntime::monitor_notifyAll_C);
1422 SET_ADDRESS(_extrs, OptoRuntime::rethrow_C);
1423 SET_ADDRESS(_extrs, OptoRuntime::slow_arraycopy_C);
1424 SET_ADDRESS(_extrs, OptoRuntime::register_finalizer_C);
1425 SET_ADDRESS(_extrs, OptoRuntime::vthread_end_first_transition_C);
1426 SET_ADDRESS(_extrs, OptoRuntime::vthread_start_final_transition_C);
1427 SET_ADDRESS(_extrs, OptoRuntime::vthread_start_transition_C);
1428 SET_ADDRESS(_extrs, OptoRuntime::vthread_end_transition_C);
1429 #if defined(AARCH64)
1430 SET_ADDRESS(_extrs, JavaThread::verify_cross_modify_fence_failure);
1431 #endif // AARCH64
1432 }
1433 #endif // COMPILER2
1434
1435 #if INCLUDE_G1GC
1436 SET_ADDRESS(_extrs, G1BarrierSetRuntime::write_ref_field_pre_entry);
1437 #endif
1438 #if INCLUDE_SHENANDOAHGC
1439 SET_ADDRESS(_extrs, ShenandoahRuntime::write_barrier_pre);
1440 SET_ADDRESS(_extrs, ShenandoahRuntime::load_reference_barrier_phantom);
1441 SET_ADDRESS(_extrs, ShenandoahRuntime::load_reference_barrier_phantom_narrow);
1442 #endif
1443 #if INCLUDE_ZGC
1444 SET_ADDRESS(_extrs, ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr());
1445 SET_ADDRESS(_extrs, ZBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded_addr());
1446 #if defined(AMD64)
1447 SET_ADDRESS(_extrs, &ZPointerLoadShift);
1448 #endif
1449 #endif
1450 #ifndef ZERO
1451 #if defined(AMD64) || defined(AARCH64) || defined(RISCV64)
1452 SET_ADDRESS(_extrs, MacroAssembler::debug64);
1453 #endif
1454 #endif // ZERO
1455
1456 // addresses of fields in AOT runtime constants area
1457 address* p = AOTRuntimeConstants::field_addresses_list();
1458 while (*p != nullptr) {
1459 SET_ADDRESS(_extrs, *p++);
1460 }
1461
1462 _extrs_complete = true;
1463 log_debug(aot, codecache, init)("External addresses recorded");
1464 }
1465
1466 static bool initializing_early_stubs = false;
1467
1468 void AOTCodeAddressTable::init_early_stubs() {
1469 if (_complete || initializing_early_stubs) return; // Done already
1470 initializing_early_stubs = true;
1471 _stubs_addr = NEW_C_HEAP_ARRAY(address, _stubs_max, mtCode);
1472 _stubs_length = 0;
1473 SET_ADDRESS(_stubs, StubRoutines::forward_exception_entry());
1474
1475 {
|
491 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created by debug VM, it can't be used by product VM");
492 return false;
493 }
494 #endif
495
496 CollectedHeap::Name aot_gc = (CollectedHeap::Name)_gc;
497 if (aot_gc != Universe::heap()->kind()) {
498 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with different GC: %s vs current %s", GCConfig::hs_err_name(aot_gc), GCConfig::hs_err_name());
499 return false;
500 }
501
502 if (((_flags & compressedClassPointers) != 0) != UseCompressedClassPointers) {
503 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with UseCompressedClassPointers = %s", UseCompressedClassPointers ? "false" : "true");
504 return false;
505 }
506 if (_compressedKlassShift != (uint)CompressedKlassPointers::shift()) {
507 log_debug(aot, codecache, init)("AOT Code Cache disabled: it was created with CompressedKlassPointers::shift() = %d vs current %d", _compressedKlassShift, CompressedKlassPointers::shift());
508 return false;
509 }
510
511 // The following checks do not affect AOT code, but can disable
512 // AOT stub/adapters caching if they are incompatible with runtime settings
513 // (adapters too as they access oops when buffering scalarized value objects).
514
515 if (((_flags & compressedOops) != 0) != UseCompressedOops) {
516 log_debug(aot, codecache, init)("AOT Stub/Adapter Cache disabled: it was created with UseCompressedOops = %s", UseCompressedOops ? "false" : "true");
517 AOTStubCaching = false;
518 if (InlineTypePassFieldsAsArgs) {
519 AOTAdapterCaching = false;
520 }
521 }
522 if (_compressedOopShift != (uint)CompressedOops::shift()) {
523 log_debug(aot, codecache, init)("AOT Stub/Adapter Cache disabled: it was created with different CompressedOops::shift(): %d vs current %d", _compressedOopShift, CompressedOops::shift());
524 AOTStubCaching = false;
525 if (InlineTypePassFieldsAsArgs) {
526 AOTAdapterCaching = false;
527 }
528 }
529
530 // This should be the last check as it only disables AOTStub/AdapterCaching
531 if ((_compressedOopBase == nullptr || CompressedOops::base() == nullptr) && (_compressedOopBase != CompressedOops::base())) {
532 log_debug(aot, codecache, init)("AOT Stub/Adapter Cache disabled: incompatible CompressedOops::base(): %p vs current %p", _compressedOopBase, CompressedOops::base());
533 AOTStubCaching = false;
534 if (InlineTypePassFieldsAsArgs) {
535 AOTAdapterCaching = false;
536 }
537 }
538
539 if (!verify_cpu_features(cache)) {
540 return false;
541 }
542 return true;
543 }
544
545 bool AOTCodeCache::Header::verify(uint load_size) const {
546 if (_version != AOT_CODE_VERSION) {
547 log_debug(aot, codecache, init)("AOT Code Cache disabled: different AOT Code version %d vs %d recorded in AOT Code header", AOT_CODE_VERSION, _version);
548 return false;
549 }
550 if (load_size < _cache_size) {
551 log_debug(aot, codecache, init)("AOT Code Cache disabled: AOT Code Cache size %d < %d recorded in AOT Code header", load_size, _cache_size);
552 return false;
553 }
554 return true;
555 }
556
1340 assert(type##_length <= type##_max, "increase size"); \
1341 }
1342
1343 static bool initializing_extrs = false;
1344
1345 void AOTCodeAddressTable::init_extrs() {
1346 if (_extrs_complete || initializing_extrs) return; // Done already
1347
1348 assert(_blobs_end <= _all_max, "AOTCodeAddress table ranges need adjusting");
1349
1350 initializing_extrs = true;
1351 _extrs_addr = NEW_C_HEAP_ARRAY(address, _extrs_max, mtCode);
1352
1353 _extrs_length = 0;
1354
1355 // Record addresses of VM runtime methods
1356 SET_ADDRESS(_extrs, SharedRuntime::fixup_callers_callsite);
1357 SET_ADDRESS(_extrs, SharedRuntime::handle_wrong_method);
1358 SET_ADDRESS(_extrs, SharedRuntime::handle_wrong_method_abstract);
1359 SET_ADDRESS(_extrs, SharedRuntime::handle_wrong_method_ic_miss);
1360 SET_ADDRESS(_extrs, SharedRuntime::allocate_inline_types);
1361 #if defined(AARCH64) && !defined(ZERO)
1362 SET_ADDRESS(_extrs, JavaThread::aarch64_get_thread_helper);
1363 #endif
1364 {
1365 // Required by Shared blobs
1366 SET_ADDRESS(_extrs, Deoptimization::fetch_unroll_info);
1367 SET_ADDRESS(_extrs, Deoptimization::unpack_frames);
1368 SET_ADDRESS(_extrs, SafepointSynchronize::handle_polling_page_exception);
1369 SET_ADDRESS(_extrs, SharedRuntime::resolve_opt_virtual_call_C);
1370 SET_ADDRESS(_extrs, SharedRuntime::resolve_virtual_call_C);
1371 SET_ADDRESS(_extrs, SharedRuntime::resolve_static_call_C);
1372 SET_ADDRESS(_extrs, SharedRuntime::throw_StackOverflowError);
1373 SET_ADDRESS(_extrs, SharedRuntime::throw_delayed_StackOverflowError);
1374 SET_ADDRESS(_extrs, SharedRuntime::throw_AbstractMethodError);
1375 SET_ADDRESS(_extrs, SharedRuntime::throw_IncompatibleClassChangeError);
1376 SET_ADDRESS(_extrs, SharedRuntime::throw_NullPointerException_at_call);
1377 }
1378
1379 #ifdef COMPILER1
1380 {
1390 SET_ADDRESS(_extrs, Runtime1::new_type_array);
1391 SET_ADDRESS(_extrs, Runtime1::new_object_array);
1392 SET_ADDRESS(_extrs, Runtime1::new_multi_array);
1393 SET_ADDRESS(_extrs, Runtime1::throw_range_check_exception);
1394 SET_ADDRESS(_extrs, Runtime1::throw_index_exception);
1395 SET_ADDRESS(_extrs, Runtime1::throw_div0_exception);
1396 SET_ADDRESS(_extrs, Runtime1::throw_null_pointer_exception);
1397 SET_ADDRESS(_extrs, Runtime1::throw_array_store_exception);
1398 SET_ADDRESS(_extrs, Runtime1::throw_class_cast_exception);
1399 SET_ADDRESS(_extrs, Runtime1::throw_incompatible_class_change_error);
1400 SET_ADDRESS(_extrs, Runtime1::is_instance_of);
1401 SET_ADDRESS(_extrs, Runtime1::monitorenter);
1402 SET_ADDRESS(_extrs, Runtime1::monitorexit);
1403 SET_ADDRESS(_extrs, Runtime1::deoptimize);
1404 SET_ADDRESS(_extrs, Runtime1::access_field_patching);
1405 SET_ADDRESS(_extrs, Runtime1::move_klass_patching);
1406 SET_ADDRESS(_extrs, Runtime1::move_mirror_patching);
1407 SET_ADDRESS(_extrs, Runtime1::move_appendix_patching);
1408 SET_ADDRESS(_extrs, Runtime1::predicate_failed_trap);
1409 SET_ADDRESS(_extrs, Runtime1::unimplemented_entry);
1410 SET_ADDRESS(_extrs, Runtime1::new_null_free_array);
1411 SET_ADDRESS(_extrs, Runtime1::load_flat_array);
1412 SET_ADDRESS(_extrs, Runtime1::store_flat_array);
1413 SET_ADDRESS(_extrs, Runtime1::substitutability_check);
1414 SET_ADDRESS(_extrs, Runtime1::buffer_inline_args);
1415 SET_ADDRESS(_extrs, Runtime1::buffer_inline_args_no_receiver);
1416 SET_ADDRESS(_extrs, Runtime1::throw_identity_exception);
1417 SET_ADDRESS(_extrs, Runtime1::throw_illegal_monitor_state_exception);
1418 SET_ADDRESS(_extrs, Thread::current);
1419 SET_ADDRESS(_extrs, CompressedKlassPointers::base_addr());
1420 #ifndef PRODUCT
1421 SET_ADDRESS(_extrs, os::breakpoint);
1422 #endif
1423 }
1424 #endif
1425
1426 #ifdef COMPILER2
1427 {
1428 // Required by C2 blobs
1429 SET_ADDRESS(_extrs, Deoptimization::uncommon_trap);
1430 SET_ADDRESS(_extrs, OptoRuntime::handle_exception_C);
1431 SET_ADDRESS(_extrs, OptoRuntime::new_instance_C);
1432 SET_ADDRESS(_extrs, OptoRuntime::new_array_C);
1433 SET_ADDRESS(_extrs, OptoRuntime::new_array_nozero_C);
1434 SET_ADDRESS(_extrs, OptoRuntime::multianewarray2_C);
1435 SET_ADDRESS(_extrs, OptoRuntime::multianewarray3_C);
1436 SET_ADDRESS(_extrs, OptoRuntime::multianewarray4_C);
1437 SET_ADDRESS(_extrs, OptoRuntime::multianewarray5_C);
1438 SET_ADDRESS(_extrs, OptoRuntime::multianewarrayN_C);
1439 SET_ADDRESS(_extrs, OptoRuntime::complete_monitor_locking_C);
1440 SET_ADDRESS(_extrs, OptoRuntime::monitor_notify_C);
1441 SET_ADDRESS(_extrs, OptoRuntime::monitor_notifyAll_C);
1442 SET_ADDRESS(_extrs, OptoRuntime::rethrow_C);
1443 SET_ADDRESS(_extrs, OptoRuntime::slow_arraycopy_C);
1444 SET_ADDRESS(_extrs, OptoRuntime::register_finalizer_C);
1445 SET_ADDRESS(_extrs, OptoRuntime::load_unknown_inline_C);
1446 SET_ADDRESS(_extrs, OptoRuntime::store_unknown_inline_C);
1447 SET_ADDRESS(_extrs, OptoRuntime::vthread_end_first_transition_C);
1448 SET_ADDRESS(_extrs, OptoRuntime::vthread_start_final_transition_C);
1449 SET_ADDRESS(_extrs, OptoRuntime::vthread_start_transition_C);
1450 SET_ADDRESS(_extrs, OptoRuntime::vthread_end_transition_C);
1451 #if defined(AARCH64)
1452 SET_ADDRESS(_extrs, JavaThread::verify_cross_modify_fence_failure);
1453 #endif // AARCH64
1454 }
1455 #endif // COMPILER2
1456
1457 #if INCLUDE_G1GC
1458 SET_ADDRESS(_extrs, G1BarrierSetRuntime::write_ref_field_pre_entry);
1459 #endif
1460 #if INCLUDE_SHENANDOAHGC
1461 SET_ADDRESS(_extrs, ShenandoahRuntime::write_barrier_pre);
1462 SET_ADDRESS(_extrs, ShenandoahRuntime::load_reference_barrier_phantom);
1463 SET_ADDRESS(_extrs, ShenandoahRuntime::load_reference_barrier_phantom_narrow);
1464 #endif
1465 #if INCLUDE_ZGC
1466 SET_ADDRESS(_extrs, ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr());
1467 SET_ADDRESS(_extrs, ZBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded_addr());
1468 #if defined(AMD64)
1469 SET_ADDRESS(_extrs, &ZPointerLoadShift);
1470 #endif
1471 #endif
1472 #ifndef ZERO
1473 #if defined(AMD64) || defined(AARCH64) || defined(RISCV64)
1474 SET_ADDRESS(_extrs, MacroAssembler::debug64);
1475 #endif
1476 #endif // ZERO
1477
1478 if (UseCompressedOops) {
1479 SET_ADDRESS(_extrs, CompressedOops::base_addr());
1480 }
1481
1482 // addresses of fields in AOT runtime constants area
1483 address* p = AOTRuntimeConstants::field_addresses_list();
1484 while (*p != nullptr) {
1485 SET_ADDRESS(_extrs, *p++);
1486 }
1487
1488 _extrs_complete = true;
1489 log_debug(aot, codecache, init)("External addresses recorded");
1490 }
1491
1492 static bool initializing_early_stubs = false;
1493
1494 void AOTCodeAddressTable::init_early_stubs() {
1495 if (_complete || initializing_early_stubs) return; // Done already
1496 initializing_early_stubs = true;
1497 _stubs_addr = NEW_C_HEAP_ARRAY(address, _stubs_max, mtCode);
1498 _stubs_length = 0;
1499 SET_ADDRESS(_stubs, StubRoutines::forward_exception_entry());
1500
1501 {
|