|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
37 | 37 | import java.util.IdentityHashMap;
|
38 | 38 | import java.util.List;
|
39 | 39 | import java.util.Map;
|
40 |
| -import java.util.ServiceLoader; |
41 | 40 | import java.util.Set;
|
42 | 41 | import java.util.TreeMap;
|
43 | 42 | import java.util.TreeSet;
|
|
46 | 45 | import java.util.function.Consumer;
|
47 | 46 | import java.util.stream.Collectors;
|
48 | 47 |
|
49 |
| -import jdk.graal.compiler.core.common.NativeImageSupport; |
50 |
| -import jdk.graal.compiler.hotspot.CompilerConfig; |
51 | 48 | import org.graalvm.collections.EconomicMap;
|
52 | 49 | import org.graalvm.jniutils.NativeBridgeSupport;
|
53 | 50 | import org.graalvm.nativeimage.ImageInfo;
|
|
62 | 59 |
|
63 | 60 | import jdk.graal.compiler.core.common.Fields;
|
64 | 61 | import jdk.graal.compiler.core.common.LibGraalSupport.HostedOnly;
|
| 62 | +import jdk.graal.compiler.core.common.NativeImageSupport; |
65 | 63 | import jdk.graal.compiler.core.common.spi.ForeignCallSignature;
|
66 | 64 | import jdk.graal.compiler.debug.GraalError;
|
67 | 65 | import jdk.graal.compiler.graph.Edges;
|
68 | 66 | import jdk.graal.compiler.graph.NodeClass;
|
| 67 | +import jdk.graal.compiler.hotspot.CompilerConfig; |
69 | 68 | import jdk.graal.compiler.hotspot.EncodedSnippets;
|
70 | 69 | import jdk.graal.compiler.hotspot.HotSpotForeignCallLinkage;
|
71 | 70 | import jdk.graal.compiler.hotspot.HotSpotReplacementsImpl;
|
72 | 71 | import jdk.graal.compiler.libgraal.truffle.LibGraalTruffleHostEnvironmentLookup;
|
73 | 72 | import jdk.graal.compiler.options.OptionDescriptor;
|
74 | 73 | import jdk.graal.compiler.options.OptionKey;
|
75 | 74 | import jdk.graal.compiler.options.OptionsParser;
|
76 |
| -import jdk.graal.compiler.serviceprovider.GraalServices; |
77 | 75 | import jdk.graal.compiler.truffle.host.TruffleHostEnvironment;
|
78 | 76 | import jdk.graal.compiler.util.ObjectCopier;
|
79 | 77 | import jdk.internal.module.Modules;
|
80 |
| -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; |
81 |
| -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
82 | 78 | import jdk.vm.ci.hotspot.HotSpotModifiers;
|
83 |
| -import jdk.vm.ci.services.JVMCIServiceLocator; |
84 | 79 |
|
85 | 80 | /**
|
86 | 81 | * This feature builds the libgraal shared library (e.g., libjvmcicompiler.so on linux).
|
@@ -360,8 +355,6 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
|
360 | 355 | RuntimeReflection.registerAllDeclaredClasses(Long.class);
|
361 | 356 | RuntimeReflection.register(lookupField(lookupClass("java.lang.Long$LongCache"), "cache"));
|
362 | 357 |
|
363 |
| - doLegacyJVMCIInitialization(); |
364 |
| - |
365 | 358 | GetCompilerConfig.Result configResult = GetCompilerConfig.from(libgraalJavaHome);
|
366 | 359 | for (var e : configResult.opens().entrySet()) {
|
367 | 360 | Module module = ModuleLayer.boot().findModule(e.getKey()).orElseThrow();
|
@@ -394,45 +387,6 @@ private static void checkNodeClasses(EncodedSnippets encodedSnippets, String act
|
394 | 387 | GraalError.guarantee(actual.equals(expect), "%n%s%n !=%n%s", actual, expect);
|
395 | 388 | }
|
396 | 389 |
|
397 |
| - /** |
398 |
| - * Initialization of JVMCI code that needs to be done for JDK versions that do not include |
399 |
| - * JDK-8346781. |
400 |
| - */ |
401 |
| - private void doLegacyJVMCIInitialization() { |
402 |
| - if (!BeforeJDK8346781.VALUE) { |
403 |
| - return; |
404 |
| - } |
405 |
| - try { |
406 |
| - String rawArch = GraalServices.getSavedProperty("os.arch"); |
407 |
| - String arch = switch (rawArch) { |
408 |
| - case "x86_64", "amd64" -> "AMD64"; |
409 |
| - case "aarch64" -> "aarch64"; |
410 |
| - case "riscv64" -> "riscv64"; |
411 |
| - default -> throw new GraalError("Unknown or unsupported arch: %s", rawArch); |
412 |
| - }; |
413 |
| - |
414 |
| - ClassLoader cl = (ClassLoader) libgraalLoader; |
415 |
| - Field cachedHotSpotJVMCIBackendFactoriesField = ObjectCopier.getField(HotSpotJVMCIRuntime.class, "cachedHotSpotJVMCIBackendFactories"); |
416 |
| - GraalError.guarantee(cachedHotSpotJVMCIBackendFactoriesField.get(null) == null, "Expect cachedHotSpotJVMCIBackendFactories to be null"); |
417 |
| - ServiceLoader<HotSpotJVMCIBackendFactory> load = ServiceLoader.load(HotSpotJVMCIBackendFactory.class, cl); |
418 |
| - List<HotSpotJVMCIBackendFactory> backendFactories = load.stream()// |
419 |
| - .map(ServiceLoader.Provider::get)// |
420 |
| - .filter(s -> s.getArchitecture().equals(arch))// |
421 |
| - .toList(); |
422 |
| - cachedHotSpotJVMCIBackendFactoriesField.set(null, backendFactories); |
423 |
| - GraalError.guarantee(backendFactories.size() == 1, "%s", backendFactories); |
424 |
| - |
425 |
| - var jvmciServiceLocatorCachedLocatorsField = ObjectCopier.getField(JVMCIServiceLocator.class, "cachedLocators"); |
426 |
| - GraalError.guarantee(jvmciServiceLocatorCachedLocatorsField.get(null) == null, "Expect cachedLocators to be null"); |
427 |
| - Iterable<JVMCIServiceLocator> serviceLocators = ServiceLoader.load(JVMCIServiceLocator.class, cl); |
428 |
| - List<JVMCIServiceLocator> cachedLocators = new ArrayList<>(); |
429 |
| - serviceLocators.forEach(cachedLocators::add); |
430 |
| - jvmciServiceLocatorCachedLocatorsField.set(null, cachedLocators); |
431 |
| - } catch (Throwable e) { |
432 |
| - throw new GraalError(e); |
433 |
| - } |
434 |
| - } |
435 |
| - |
436 | 390 | @Override
|
437 | 391 | public void afterAnalysis(AfterAnalysisAccess access) {
|
438 | 392 | optionCollector.afterAnalysis(access);
|
|
0 commit comments