Mercurial > hg > graal-compiler
changeset 11586:9652640fae42
tightened option verifier to check all class initializers in the hierarchy of a class that declares at least one @Option
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 10 Sep 2013 21:29:31 +0200 |
parents | 516b93ccf7c9 |
children | a8132e3fd0d8 |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java |
diffstat | 5 files changed, 37 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Tue Sep 10 21:26:44 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Tue Sep 10 21:29:31 2013 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.compiler.phases; +import static com.oracle.graal.compiler.phases.HighTier.Options.*; import static com.oracle.graal.phases.GraalOptions.*; import com.oracle.graal.api.code.*; @@ -36,12 +37,15 @@ public class HighTier extends PhaseSuite<HighTierContext> { - // @formatter:off - @Option(help = "") - public static final OptionValue<Boolean> VerifyUsageWithEquals = new OptionValue<>(true); - @Option(help = "Enable inlining") - public static final OptionValue<Boolean> Inline = new OptionValue<>(true); - // @formatter:on + static class Options { + + // @formatter:off + @Option(help = "") + public static final OptionValue<Boolean> VerifyUsageWithEquals = new OptionValue<>(true); + @Option(help = "Enable inlining") + public static final OptionValue<Boolean> Inline = new OptionValue<>(true); + // @formatter:on + } public HighTier() { CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java Tue Sep 10 21:26:44 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java Tue Sep 10 21:29:31 2013 +0200 @@ -57,21 +57,25 @@ for (OptionDescriptor desc : opts) { if (HotSpotOptions.isHotSpotOption(desc)) { HotSpotResolvedObjectType holder = (HotSpotResolvedObjectType) runtime.lookupJavaType(desc.getDeclaringClass()); - checkType(runtime, checked, holder); + checkType(holder, desc, runtime, checked); } } } return true; } - private static void checkType(HotSpotRuntime runtime, Set<HotSpotResolvedObjectType> checked, HotSpotResolvedObjectType holder) { - if (!checked.contains(holder)) { - checked.add(holder); - for (ResolvedJavaMethod method : holder.getMethods()) { + private static void checkType(HotSpotResolvedObjectType type, OptionDescriptor option, HotSpotRuntime runtime, Set<HotSpotResolvedObjectType> checked) { + if (!checked.contains(type)) { + checked.add(type); + HotSpotResolvedObjectType superType = type.getSupertype(); + if (superType != null && !MetaUtil.isJavaLangObject(superType)) { + checkType(superType, option, runtime, checked); + } + for (ResolvedJavaMethod method : type.getMethods()) { if (method.isClassInitializer()) { StructuredGraph graph = new StructuredGraph(method); new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); - new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph); + new VerifyHotSpotOptionsPhase(type, runtime, option).apply(graph); } } } @@ -81,11 +85,13 @@ private final ResolvedJavaType declaringClass; private final ResolvedJavaType optionValueType; private final Set<ResolvedJavaType> boxingTypes; + private final OptionDescriptor option; - public VerifyHotSpotOptionsPhase(ResolvedJavaType declaringClass, HotSpotRuntime runtime) { + public VerifyHotSpotOptionsPhase(ResolvedJavaType declaringClass, HotSpotRuntime runtime, OptionDescriptor option) { this.runtime = runtime; this.declaringClass = declaringClass; this.optionValueType = runtime.lookupJavaType(OptionValue.class); + this.option = option; this.boxingTypes = new HashSet<>(); for (Class c : new Class[]{Boolean.class, Byte.class, Short.class, Character.class, Integer.class, Float.class, Long.class, Double.class}) { this.boxingTypes.add(runtime.lookupJavaType(c)); @@ -140,7 +146,9 @@ private void error(Node node, String message) { String loc = GraphUtil.approxSourceLocation(node); - throw new GraalInternalError(String.format("HotSpot option declarer %s contains code pattern implying action other than initialization of an option:%n %s%n %s", + throw new GraalInternalError(String.format("The " + option.getName() + " option is declared in " + option.getDeclaringClass() + + " whose class hierarchy contains a class initializer (in %s) with a code pattern at or near %s implying an action other than initialization of an option:%n%n %s%n%n" + + "The recommended solution is to move " + option.getName() + " into a separate class (e.g., " + option.getDeclaringClass().getName() + ".Options).%n", toJavaName(declaringClass), loc, message)); } }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Tue Sep 10 21:26:44 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Tue Sep 10 21:29:31 2013 +0200 @@ -41,11 +41,12 @@ private static final int MAX_ITERATION_PER_NODE = 10; private static final DebugMetric METRIC_CANONICALIZED_NODES = Debug.metric("CanonicalizedNodes"); + private static final DebugMetric METRIC_PROCESSED_NODES = Debug.metric("ProcessedNodes"); private static final DebugMetric METRIC_CANONICALIZATION_CONSIDERED_NODES = Debug.metric("CanonicalizationConsideredNodes"); private static final DebugMetric METRIC_INFER_STAMP_CALLED = Debug.metric("InferStampCalled"); private static final DebugMetric METRIC_STAMP_CHANGED = Debug.metric("StampChanged"); private static final DebugMetric METRIC_SIMPLIFICATION_CONSIDERED_NODES = Debug.metric("SimplificationConsideredNodes"); - public static final DebugMetric METRIC_GLOBAL_VALUE_NUMBERING_HITS = Debug.metric("GlobalValueNumberingHits"); + private static final DebugMetric METRIC_GLOBAL_VALUE_NUMBERING_HITS = Debug.metric("GlobalValueNumberingHits"); private final boolean canonicalizeReads; private final CustomCanonicalizer customCanonicalizer;
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java Tue Sep 10 21:26:44 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java Tue Sep 10 21:29:31 2013 +0200 @@ -33,8 +33,8 @@ public abstract class BasePhase<C> { private String name; + private static final DebugMetric metricPhaseRuns = Debug.metric("Runs"); - protected static final DebugMetric METRIC_PROCESSED_NODES = Debug.metric("ProcessedNodes"); protected BasePhase() { this.name = this.getClass().getSimpleName();
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Tue Sep 10 21:26:44 2013 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapePhase.java Tue Sep 10 21:29:31 2013 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.virtual.phases.ea; import static com.oracle.graal.phases.GraalOptions.*; +import static com.oracle.graal.virtual.phases.ea.PartialEscapePhase.Options.*; import java.util.*; @@ -40,10 +41,13 @@ public class PartialEscapePhase extends EffectsPhase<PhaseContext> { - //@formatter:off - @Option(help = "") - public static final OptionValue<Boolean> OptEarlyReadElimination = new OptionValue<>(true); - //@formatter:on + static class Options { + + //@formatter:off + @Option(help = "") + public static final OptionValue<Boolean> OptEarlyReadElimination = new OptionValue<>(true); + //@formatter:on + } private final boolean readElimination;