680 } 681 int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result); 682 assert(adjustment >= JVMCIRuntime::none && 683 adjustment <= JVMCIRuntime::by_full_signature, 684 "compilation level adjustment out of bounds"); 685 _comp_level_adjustment = (CompLevelAdjustment) adjustment; 686 _HotSpotJVMCIRuntime_initialized = true; 687 _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); 688 } 689 } 690 691 void JVMCIRuntime::initialize_JVMCI(TRAPS) { 692 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { 693 callStatic("jdk/vm/ci/runtime/JVMCI", 694 "getRuntime", 695 "()Ljdk/vm/ci/runtime/JVMCIRuntime;", NULL, CHECK); 696 } 697 assert(_HotSpotJVMCIRuntime_initialized == true, "what?"); 698 } 699 700 void JVMCIRuntime::initialize_well_known_classes(TRAPS) { 701 if (JVMCIRuntime::_well_known_classes_initialized == false) { 702 SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID; 703 SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK); 704 JVMCIJavaClasses::compute_offsets(CHECK); 705 JVMCIRuntime::_well_known_classes_initialized = true; 706 } 707 } 708 709 void JVMCIRuntime::metadata_do(void f(Metadata*)) { 710 // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in 711 // the SystemDictionary well known classes should ensure the other 712 // classes have already been loaded, so make sure their order in the 713 // table enforces that. 714 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) < 715 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); 716 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotConstantPool) < 717 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); 718 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) < 719 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); 720 721 if (HotSpotJVMCIMetaAccessContext::klass() == NULL || | 680 } 681 int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result); 682 assert(adjustment >= JVMCIRuntime::none && 683 adjustment <= JVMCIRuntime::by_full_signature, 684 "compilation level adjustment out of bounds"); 685 _comp_level_adjustment = (CompLevelAdjustment) adjustment; 686 _HotSpotJVMCIRuntime_initialized = true; 687 _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); 688 } 689 } 690 691 void JVMCIRuntime::initialize_JVMCI(TRAPS) { 692 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { 693 callStatic("jdk/vm/ci/runtime/JVMCI", 694 "getRuntime", 695 "()Ljdk/vm/ci/runtime/JVMCIRuntime;", NULL, CHECK); 696 } 697 assert(_HotSpotJVMCIRuntime_initialized == true, "what?"); 698 } 699 700 bool JVMCIRuntime::can_initialize_JVMCI() { 701 // Initializing JVMCI requires the module system to be initialized past phase 3. 702 // The JVMCI API itself isn't available until phase 2 and ServiceLoader (which 703 // JVMCI initialization requires) isn't usable until after phase 3. Testing 704 // whether the system loader is initialized satisfies all these invariants. 705 if (SystemDictionary::java_system_loader() == NULL) { 706 return false; 707 } 708 assert(Universe::is_module_initialized(), "must be"); 709 return true; 710 } 711 712 void JVMCIRuntime::initialize_well_known_classes(TRAPS) { 713 if (JVMCIRuntime::_well_known_classes_initialized == false) { 714 guarantee(can_initialize_JVMCI(), "VM is not yet sufficiently booted to initialize JVMCI"); 715 SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID; 716 SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK); 717 JVMCIJavaClasses::compute_offsets(CHECK); 718 JVMCIRuntime::_well_known_classes_initialized = true; 719 } 720 } 721 722 void JVMCIRuntime::metadata_do(void f(Metadata*)) { 723 // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in 724 // the SystemDictionary well known classes should ensure the other 725 // classes have already been loaded, so make sure their order in the 726 // table enforces that. 727 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) < 728 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); 729 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotConstantPool) < 730 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); 731 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) < 732 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); 733 734 if (HotSpotJVMCIMetaAccessContext::klass() == NULL || |