698 }
699 assert(_HotSpotJVMCIRuntime_initialized == true, "what?");
700 }
701
702 bool JVMCIRuntime::can_initialize_JVMCI() {
703 // Initializing JVMCI requires the module system to be initialized past phase 3.
704 // The JVMCI API itself isn't available until phase 2 and ServiceLoader (which
705 // JVMCI initialization requires) isn't usable until after phase 3. Testing
706 // whether the system loader is initialized satisfies all these invariants.
707 if (SystemDictionary::java_system_loader() == NULL) {
708 return false;
709 }
710 assert(Universe::is_module_initialized(), "must be");
711 return true;
712 }
713
714 void JVMCIRuntime::initialize_well_known_classes(TRAPS) {
715 if (JVMCIRuntime::_well_known_classes_initialized == false) {
716 guarantee(can_initialize_JVMCI(), "VM is not yet sufficiently booted to initialize JVMCI");
717 SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID;
718 SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK);
719 JVMCIJavaClasses::compute_offsets(CHECK);
720 JVMCIRuntime::_well_known_classes_initialized = true;
721 }
722 }
723
724 void JVMCIRuntime::metadata_do(void f(Metadata*)) {
725 // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in
726 // the SystemDictionary well known classes should ensure the other
727 // classes have already been loaded, so make sure their order in the
728 // table enforces that.
729 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) <
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_HotSpotConstantPool) <
732 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
733 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) <
734 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
735
736 if (HotSpotJVMCIMetaAccessContext::klass() == NULL ||
737 !HotSpotJVMCIMetaAccessContext::klass()->is_linked()) {
738 // Nothing could be registered yet
|
698 }
699 assert(_HotSpotJVMCIRuntime_initialized == true, "what?");
700 }
701
702 bool JVMCIRuntime::can_initialize_JVMCI() {
703 // Initializing JVMCI requires the module system to be initialized past phase 3.
704 // The JVMCI API itself isn't available until phase 2 and ServiceLoader (which
705 // JVMCI initialization requires) isn't usable until after phase 3. Testing
706 // whether the system loader is initialized satisfies all these invariants.
707 if (SystemDictionary::java_system_loader() == NULL) {
708 return false;
709 }
710 assert(Universe::is_module_initialized(), "must be");
711 return true;
712 }
713
714 void JVMCIRuntime::initialize_well_known_classes(TRAPS) {
715 if (JVMCIRuntime::_well_known_classes_initialized == false) {
716 guarantee(can_initialize_JVMCI(), "VM is not yet sufficiently booted to initialize JVMCI");
717 SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID;
718 SystemDictionary::resolve_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK);
719 JVMCIJavaClasses::compute_offsets(CHECK);
720 JVMCIRuntime::_well_known_classes_initialized = true;
721 }
722 }
723
724 void JVMCIRuntime::metadata_do(void f(Metadata*)) {
725 // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in
726 // the SystemDictionary well known classes should ensure the other
727 // classes have already been loaded, so make sure their order in the
728 // table enforces that.
729 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) <
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_HotSpotConstantPool) <
732 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
733 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) <
734 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
735
736 if (HotSpotJVMCIMetaAccessContext::klass() == NULL ||
737 !HotSpotJVMCIMetaAccessContext::klass()->is_linked()) {
738 // Nothing could be registered yet
|