From 46bf4bbe506eff1e81ef6ee3da3cda4154c91c9e Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Tue, 14 Jan 2025 00:09:36 +0900 Subject: [PATCH] make OptionsParser#libgraalOptions final --- .../graal/compiler/libgraal/LibGraalFeature.java | 15 +++------------ .../jdk/graal/compiler/options/OptionsParser.java | 12 ++---------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/libgraal/LibGraalFeature.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/libgraal/LibGraalFeature.java index 9c21e289e989..0e95d5baa57a 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/libgraal/LibGraalFeature.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/libgraal/LibGraalFeature.java @@ -188,20 +188,11 @@ public void duringSetup(DuringSetupAccess access) { * Collects all instances of the LibGraalLoader loaded {@link OptionKey} class reached by the * static analysis. */ - private class OptionCollector implements Consumer> { + private final class OptionCollector implements Consumer> { private final Set> options = Collections.newSetFromMap(new ConcurrentHashMap<>()); - /** - * Libgraal compiler options info. - */ - private final OptionsParser.LibGraalOptionsInfo compilerOptionsInfo; - private boolean sealed; - OptionCollector() { - compilerOptionsInfo = OptionsParser.setLibgraalOptions(OptionsParser.LibGraalOptionsInfo.create()); - } - @Override public void accept(OptionKey option) { if (sealed) { @@ -221,11 +212,11 @@ void afterAnalysis(AfterAnalysisAccess access) { GraalError.guarantee(access.isReachable(descriptor.getClass()), "%s", descriptor.getClass()); String name = option.getName(); - compilerOptionsInfo.descriptors().put(name, descriptor); + OptionsParser.libgraalOptions.descriptors().put(name, descriptor); String module = modules.get(descriptor.getDeclaringClass().getName()); if (module.contains("enterprise")) { - compilerOptionsInfo.enterpriseOptions().add(name); + OptionsParser.libgraalOptions.enterpriseOptions().add(name); } } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/options/OptionsParser.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/options/OptionsParser.java index 7499a9186710..eb41fd021f92 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/options/OptionsParser.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/options/OptionsParser.java @@ -38,7 +38,7 @@ import java.util.Set; import java.util.regex.Pattern; -import jdk.graal.compiler.debug.GraalError; +import jdk.graal.nativeimage.LibGraalLoader; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.EconomicSet; import org.graalvm.collections.MapCursor; @@ -68,7 +68,7 @@ public static LibGraalOptionsInfo create() { * Compiler options info available in libgraal. This field is only non-null when * {@link OptionsParser} is loaded by a {@link jdk.graal.nativeimage.LibGraalLoader}. */ - private static LibGraalOptionsInfo libgraalOptions; + public static final LibGraalOptionsInfo libgraalOptions = OptionsParser.class.getClassLoader() instanceof LibGraalLoader ? LibGraalOptionsInfo.create() : null; /** * Gets an iterable of available {@link OptionDescriptors}. @@ -97,14 +97,6 @@ public static Iterable getOptionsLoader() { } } - @ExcludeFromJacocoGeneratedReport("only called when building libgraal") - public static LibGraalOptionsInfo setLibgraalOptions(LibGraalOptionsInfo info) { - GraalError.guarantee(inImageBuildtimeCode(), "Can only set libgraal compiler options when building libgraal"); - GraalError.guarantee(libgraalOptions == null, "Libgraal compiler options must be set exactly once"); - OptionsParser.libgraalOptions = info; - return info; - } - /** * Parses a map representing assignments of values to options. *