# HG changeset patch
# User Thomas Wuerthinger
# Date 1423770440 -3600
# Node ID 57c53b1044a769bddb45170af0020608910650e8
# Parent fcefaa7f103d0980d5aa75aa4aeceb91ff521b06# Parent 2778032e1beb9282d2bd41297c696e5a143d3dd7
Merge.
diff -r fcefaa7f103d -r 57c53b1044a7 CHANGELOG.md
--- a/CHANGELOG.md Thu Feb 12 20:46:56 2015 +0100
+++ b/CHANGELOG.md Thu Feb 12 20:47:20 2015 +0100
@@ -7,6 +7,7 @@
### Graal
* Add utilities ModifiersProvider#isConcrete, ResolvedJavaMethod#hasBytecodes, ResolvedJavaMethod#hasReceiver to Graal API.
* Add `GraalDirectives` API, containing methods to influence compiler behavior for unittests and microbenchmarks.
+* Introduce `LIRSuites`, an extensible configuration for the low-level compiler pipeline.
* ...
### Truffle
@@ -18,12 +19,21 @@
* Instrumentation: A new example "instrumentation tool" is a language-agnostic collector of code coverage information (CoverageTracker); there are two other examples.
### Truffle-DSL
-* All methods enclosed in a @TypeSystem must now be static.
-* All methods enclosed in generated type system classes are static.
-* Deprecated the public singleton used in the generated type system classes.
-* NodeFactory implementations are no longer generated by default. Use {Node}Gen#create instead of {Node}Factory#create to create new instances of nodes.
+* Implemented a new generated code layout that reduces the code size.
+* Changed all methods enclosed in a @TypeSystem must now be static.
+* Changed all methods enclosed in generated type system classes are now static.
+* Deprecated the type system constant used in the generated type system classes.
+* Changed NodeFactory implementations are no longer generated by default. Use {Node}Gen#create instead of {Node}Factory#create to create new instances of nodes.
* Added @GenerateNodeFactory to generate NodeFactory implementations for this node and its subclasses.
-
+* Deprecated @NodeAssumptions for removal in the next release.
+* Deprecated experimental @Implies for removal in the next release.
+* Added new package c.o.t.api.dsl.examples to the c.o.t.api.dsl project containing documented and debug-able Truffle-DSL use cases.
+* Changed "typed execute methods" are no longer required for use as specialization return type or parameter. It is now sufficient to declare them in the @TypeSystem.
+* Added @Cached annotation to express specialization local state.
+* Added Specialization#limit to declare a limit expression for the maximum number of specialization instantiations.
+* Changed syntax and semantics of Specialization#assumptions and Specialization#guards. They now use a Java like expression syntax.
+* Changed guard expressions that do not bind any dynamic parameter are invoked just once per specialization instantiation. They are now asserted to be true on the fast path.
+* Renamed @ImportGuards to @ImportStatic.
## Version 0.6
19-Dec-2014, [Repository Revision](http://hg.openjdk.java.net/graal/graal/shortlog/graal-0.6)
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,8 +22,6 @@
*/
package com.oracle.graal.api.code;
-import static com.oracle.graal.api.meta.MetaUtil.*;
-
import java.io.*;
import java.lang.invoke.*;
import java.util.*;
@@ -31,20 +29,25 @@
import com.oracle.graal.api.meta.*;
/**
- * Class for recording optimistic assumptions made during compilation.
+ * Class for recording assumptions made during compilation.
*/
public final class Assumptions implements Serializable, Iterable {
private static final long serialVersionUID = 5152062717588239131L;
/**
- * Abstract base class for assumptions.
+ * Abstract base class for assumptions. An assumption assumes a property of the runtime that may
+ * be invalidated by subsequent execution (e.g., that a class has no subclasses implementing
+ * {@link NoFinalizableSubclass Object.finalize()}).
*/
public abstract static class Assumption implements Serializable {
private static final long serialVersionUID = -1936652569665112915L;
}
+ /**
+ * An assumption that a given class has no subclasses implementing {@link Object#finalize()}).
+ */
public static final class NoFinalizableSubclass extends Assumption {
private static final long serialVersionUID = 6451169735564055081L;
@@ -77,7 +80,7 @@
}
/**
- * An assumption about a unique subtype of a given type.
+ * An assumption that a given type has a given unique subtype.
*/
public static final class ConcreteSubtype extends Assumption {
@@ -125,7 +128,7 @@
}
/**
- * An assumption about a unique implementation of a virtual method.
+ * An assumption that a given virtual method has a given unique implementation.
*/
public static final class ConcreteMethod extends Assumption {
@@ -174,45 +177,12 @@
@Override
public String toString() {
- return "ConcreteMethod[method=" + method.format("%H.%n(%p)") + ", context=" + context.toJavaName() + ", impl=" + impl.format("%H.%n(%p)") + "]";
+ return "ConcreteMethod[method=" + method.format("%H.%n(%p)%r") + ", context=" + context.toJavaName() + ", impl=" + impl.format("%H.%n(%p)%r") + "]";
}
}
/**
- * An assumption that specified that a method was used during the compilation.
- */
- public static final class MethodContents extends Assumption {
-
- private static final long serialVersionUID = -4821594103928571659L;
-
- public final ResolvedJavaMethod method;
-
- public MethodContents(ResolvedJavaMethod method) {
- this.method = method;
- }
-
- @Override
- public int hashCode() {
- return 31 + method.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MethodContents) {
- MethodContents other = (MethodContents) obj;
- return other.method.equals(method);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "MethodContents[method=" + method.format("%H.%n(%p)") + "]";
- }
- }
-
- /**
- * Assumption that a call site's method handle did not change.
+ * An assumption that a given call site's method handle did not change.
*/
public static final class CallSiteTargetValue extends Assumption {
@@ -250,18 +220,7 @@
}
}
- /**
- * Array with the assumptions. This field is directly accessed from C++ code in the
- * Graal/HotSpot implementation.
- */
- private Assumption[] list;
- private boolean useOptimisticAssumptions;
- private int count;
-
- public Assumptions(boolean useOptimisticAssumptions) {
- this.useOptimisticAssumptions = useOptimisticAssumptions;
- list = new Assumption[4];
- }
+ private final Set assumptions = new HashSet<>();
/**
* Returns whether any assumptions have been registered.
@@ -269,11 +228,7 @@
* @return {@code true} if at least one assumption has been registered, {@code false} otherwise.
*/
public boolean isEmpty() {
- return count == 0;
- }
-
- public boolean useOptimisticAssumptions() {
- return useOptimisticAssumptions;
+ return assumptions.isEmpty();
}
@Override
@@ -282,25 +237,15 @@
}
@Override
- public String toString() {
- return identityHashCodeString(this);
- }
-
- @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Assumptions) {
Assumptions that = (Assumptions) obj;
- if (useOptimisticAssumptions != that.useOptimisticAssumptions || count != that.count) {
+ if (!this.assumptions.equals(that.assumptions)) {
return false;
}
- for (int i = 0; i < count; i++) {
- if (!list[i].equals(that.list[i])) {
- return false;
- }
- }
return true;
}
return false;
@@ -308,28 +253,7 @@
@Override
public Iterator iterator() {
- return new Iterator() {
-
- int index;
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Assumption next() {
- if (index >= count) {
- throw new NoSuchElementException();
- }
- return list[index++];
- }
-
- @Override
- public boolean hasNext() {
- return index < count;
- }
- };
+ return assumptions.iterator();
}
/**
@@ -338,7 +262,6 @@
* @param receiverType the type that is assumed to have no finalizable subclasses
*/
public void recordNoFinalizableSubclassAssumption(ResolvedJavaType receiverType) {
- assert useOptimisticAssumptions;
record(new NoFinalizableSubclass(receiverType));
}
@@ -350,7 +273,6 @@
* @param subtype the one concrete subtype
*/
public void recordConcreteSubtype(ResolvedJavaType context, ResolvedJavaType subtype) {
- assert useOptimisticAssumptions;
record(new ConcreteSubtype(context, subtype));
}
@@ -363,64 +285,30 @@
* @param impl the concrete method that is the only possible target for the virtual call
*/
public void recordConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl) {
- assert useOptimisticAssumptions;
record(new ConcreteMethod(method, context, impl));
}
- /**
- * Records that {@code method} was used during the compilation.
- *
- * @param method a method whose contents were used
- */
- public void recordMethodContents(ResolvedJavaMethod method) {
- record(new MethodContents(method));
- }
-
public void record(Assumption assumption) {
- if (list == null) {
- list = new Assumption[4];
- } else {
- for (int i = 0; i < count; ++i) {
- if (assumption.equals(list[i])) {
- return;
- }
- }
- }
- if (list.length == count) {
- Assumption[] newList = new Assumption[list.length * 2];
- for (int i = 0; i < list.length; ++i) {
- newList[i] = list[i];
- }
- list = newList;
- }
- list[count] = assumption;
- count++;
+ assumptions.add(assumption);
}
- public Assumption[] getAssumptions() {
- return list;
+ /**
+ * Gets a copy of the assumptions recorded in this object as an array.
+ */
+ public Assumption[] toArray() {
+ return assumptions.toArray(new Assumption[assumptions.size()]);
}
- public void record(Assumptions assumptions) {
- for (int i = 0; i < assumptions.count; i++) {
- record(assumptions.list[i]);
- }
+ /**
+ * Copies assumptions recorded by another {@link Assumptions} object into this object.
+ */
+ public void record(Assumptions other) {
+ assert other != this;
+ assumptions.addAll(other.assumptions);
}
- public void print(PrintStream out) {
- List nonNullList = new ArrayList<>();
- if (list != null) {
- for (int i = 0; i < list.length; ++i) {
- Assumption a = list[i];
- if (a != null) {
- nonNullList.add(a);
- }
- }
- }
-
- out.printf("%d assumptions:%n", nonNullList.size());
- for (Assumption a : nonNullList) {
- out.println(a.toString());
- }
+ @Override
+ public String toString() {
+ return "Assumptions[" + assumptions + "]";
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,6 +28,7 @@
import java.io.*;
import java.util.*;
+import com.oracle.graal.api.code.Assumptions.Assumption;
import com.oracle.graal.api.code.CodeUtil.RefMapFormatter;
import com.oracle.graal.api.meta.*;
@@ -528,7 +529,12 @@
private ArrayList annotations;
- private Assumptions assumptions;
+ private Assumption[] assumptions;
+
+ /**
+ * The list of the methods whose bytecodes were used as input to the compilation.
+ */
+ private ResolvedJavaMethod[] methods;
public CompilationResult() {
this(null);
@@ -564,12 +570,12 @@
this.targetCodeSize == that.targetCodeSize &&
Objects.equals(this.name, that.name) &&
Objects.equals(this.annotations, that.annotations) &&
- Objects.equals(this.assumptions, that.assumptions) &&
Objects.equals(this.dataSection, that.dataSection) &&
Objects.equals(this.exceptionHandlers, that.exceptionHandlers) &&
Objects.equals(this.dataPatches, that.dataPatches) &&
Objects.equals(this.infopoints, that.infopoints) &&
Objects.equals(this.marks, that.marks) &&
+ Arrays.equals(this.assumptions, that.assumptions) &&
Arrays.equals(targetCode, that.targetCode)) {
return true;
}
@@ -606,12 +612,34 @@
this.entryBCI = entryBCI;
}
- public void setAssumptions(Assumptions assumptions) {
+ /**
+ * Sets the assumptions made during compilation.
+ */
+ public void setAssumptions(Assumption[] assumptions) {
this.assumptions = assumptions;
}
- public Assumptions getAssumptions() {
- return assumptions;
+ /**
+ * Gets a fixed-size {@linkplain Arrays#asList(Object...) view} of the assumptions made during
+ * compilation.
+ */
+ public Collection getAssumptions() {
+ return assumptions == null ? Collections.emptyList() : Arrays.asList(assumptions);
+ }
+
+ /**
+ * Sets the methods whose bytecodes were used as input to the compilation.
+ */
+ public void setMethods(ResolvedJavaMethod[] methods) {
+ this.methods = methods;
+ }
+
+ /**
+ * Gets a fixed-size {@linkplain Arrays#asList(Object...) view} of the methods whose bytecodes
+ * were used as input to the compilation.
+ */
+ public Collection getMethods() {
+ return methods == null ? Collections.emptyList() : Arrays.asList(methods);
}
public DataSection getDataSection() {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TypeCheckHints.java Thu Feb 12 20:47:20 2015 +0100
@@ -97,7 +97,7 @@
} else {
ResolvedJavaType uniqueSubtype = targetType == null ? null : targetType.findUniqueConcreteSubtype();
if (uniqueSubtype != null) {
- if (assumptions.useOptimisticAssumptions()) {
+ if (assumptions != null) {
assumptions.recordConcreteSubtype(targetType, uniqueSubtype);
exact = uniqueSubtype;
} else {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Thu Feb 12 20:47:20 2015 +0100
@@ -145,9 +145,9 @@
throw Debug.handle(e);
}
- try (Scope s = Debug.scope("LowLevelTier", this)) {
- LowLevelSuites lowLevelSuites = backend.getSuites().getDefaultLowLevelSuites();
- return GraalCompiler.emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, gen, lowLevelSuites);
+ try (Scope s = Debug.scope("LIRTier", this)) {
+ LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites();
+ return GraalCompiler.emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, gen, lirSuites);
} catch (Throwable e) {
throw Debug.handle(e);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,6 +24,8 @@
import static com.oracle.graal.compiler.common.GraalOptions.*;
+import java.util.*;
+
import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.*;
@@ -67,8 +69,8 @@
}
// emitCode
- Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
- GraalCompiler.emitCode(backend, assumptions, res, compilationResult, installedCodeOwner, factory);
+ Assumptions assumptions = OptAssumptions.getValue() ? new Assumptions() : null;
+ GraalCompiler.emitCode(backend, assumptions, Collections.emptySet(), res, compilationResult, installedCodeOwner, factory);
return compilationResult;
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Thu Feb 12 20:47:20 2015 +0100
@@ -122,23 +122,11 @@
public static final OptionValue LoopUnswitch = new OptionValue<>(true);
@Option(help = "", type = OptionType.Expert)
- public static final OptionValue FullUnrollMaxNodes = new OptionValue<>(300);
-
- @Option(help = "", type = OptionType.Expert)
- public static final OptionValue ExactFullUnrollMaxNodes = new OptionValue<>(1200);
-
- @Option(help = "", type = OptionType.Expert)
public static final OptionValue MinimumPeelProbability = new OptionValue<>(0.35f);
@Option(help = "", type = OptionType.Expert)
public static final OptionValue LoopMaxUnswitch = new OptionValue<>(3);
- @Option(help = "", type = OptionType.Expert)
- public static final OptionValue LoopUnswitchMaxIncrease = new OptionValue<>(50);
-
- @Option(help = "", type = OptionType.Expert)
- public static final OptionValue LoopUnswitchUncertaintyBoost = new OptionValue<>(5);
-
@Option(help = "", type = OptionType.Debug)
public static final OptionValue UseLoopLimitChecks = new OptionValue<>(true);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.loop.phases.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.common.inlining.*;
@@ -305,9 +305,8 @@
}
private void processMethod(final String snippet) {
- graph = parseEager(snippet);
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ graph = parseEager(snippet, AllowAssumptions.NO);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new PartialEscapePhase(false, new CanonicalizerPhase(true)).apply(graph, context);
}
@@ -317,10 +316,8 @@
}
private void compareGraphs(final String snippet, final String referenceSnippet, final boolean loopPeeling, final boolean excludeVirtual) {
- graph = parseEager(snippet);
-
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ graph = parseEager(snippet, AllowAssumptions.NO);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
canonicalizer.apply(graph, context);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
@@ -334,7 +331,7 @@
new DeadCodeEliminationPhase().apply(graph);
canonicalizer.apply(graph, context);
- StructuredGraph referenceGraph = parseEager(referenceSnippet);
+ StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
new InliningPhase(new CanonicalizerPhase(true)).apply(referenceGraph, context);
new DeadCodeEliminationPhase().apply(referenceGraph);
new CanonicalizerPhase(true).apply(referenceGraph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Thu Feb 12 20:47:20 2015 +0100
@@ -44,6 +44,7 @@
import com.oracle.graal.java.*;
import com.oracle.graal.nodeinfo.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.VerifyPhase.VerificationError;
import com.oracle.graal.phases.graph.*;
@@ -69,7 +70,7 @@
PhaseSuite graphBuilderSuite = new PhaseSuite<>();
graphBuilderSuite.appendPhase(new GraphBuilderPhase(GraphBuilderConfiguration.getEagerDefault()));
- HighTierContext context = new HighTierContext(providers, new Assumptions(false), null, graphBuilderSuite, OptimisticOptimizations.NONE);
+ HighTierContext context = new HighTierContext(providers, null, graphBuilderSuite, OptimisticOptimizations.NONE);
Assume.assumeTrue(VerifyPhase.class.desiredAssertionStatus());
@@ -138,7 +139,7 @@
if (matches(filters, methodName)) {
executor.execute(() -> {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
- StructuredGraph graph = new StructuredGraph(method);
+ StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO);
try (DebugConfigScope s = Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT)); Debug.Scope ds = Debug.scope("CheckingGraph", graph, method)) {
graphBuilderSuite.apply(graph, context);
// update phi stamps
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CompareCanonicalizerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,8 +26,8 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.calc.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -35,8 +35,8 @@
public class CompareCanonicalizerTest extends GraalCompilerTest {
private StructuredGraph getCanonicalizedGraph(String name) {
- StructuredGraph graph = parseEager(name);
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
+ StructuredGraph graph = parseEager(name, AllowAssumptions.YES);
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
return graph;
}
@@ -48,13 +48,12 @@
@Test
public void testCanonicalComparison() {
- StructuredGraph referenceGraph = parseEager("referenceCanonicalComparison");
+ StructuredGraph referenceGraph = parseEager("referenceCanonicalComparison", AllowAssumptions.NO);
for (int i = 1; i < 4; i++) {
- StructuredGraph graph = parseEager("canonicalCompare" + i);
+ StructuredGraph graph = parseEager("canonicalCompare" + i, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
- Assumptions assumptions = new Assumptions(false);
- new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders(), assumptions));
+ new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders()));
for (int i = 1; i < 4; i++) {
StructuredGraph graph = getCanonicalizedGraph("canonicalCompare" + i);
assertEquals(referenceGraph, graph);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -25,6 +25,7 @@
import org.junit.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -90,9 +91,9 @@
@Test
public void testRedundantCompares() {
- StructuredGraph graph = parseEager("testRedundantComparesSnippet");
+ StructuredGraph graph = parseEager("testRedundantComparesSnippet", AllowAssumptions.YES);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
- PhaseContext context = new PhaseContext(getProviders(), null);
+ PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
@@ -113,10 +114,10 @@
@Test
@Ignore
public void testInstanceOfCheckCastLowered() {
- StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet");
+ StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet", AllowAssumptions.YES);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
- PhaseContext context = new PhaseContext(getProviders(), null);
+ PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/DegeneratedLoopsTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,10 +24,10 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.common.inlining.*;
@@ -81,12 +81,12 @@
private void test(final String snippet) {
try (Scope s = Debug.scope("DegeneratedLoopsTest", new DebugDumpScope(snippet))) {
- StructuredGraph graph = parseEager(snippet);
- HighTierContext context = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new CanonicalizerPhase(true).apply(graph, context);
Debug.dump(graph, "Graph");
- StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET);
+ StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
Debug.dump(referenceGraph, "ReferenceGraph");
assertEquals(referenceGraph, graph);
} catch (Throwable e) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,10 +24,10 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -106,11 +106,11 @@
}
private StructuredGraph compileSnippet(final String snippet, final int checkcasts, final int afterCanon) {
- final StructuredGraph graph = parseEager(snippet);
+ final StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
try (Scope s = Debug.scope("NestedCheckCastsTest", graph)) {
Debug.dump(graph, "After parsing: " + snippet);
Assert.assertEquals(checkcasts, graph.getNodes().filter(CheckCastNode.class).count());
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
Assert.assertEquals(afterCanon, graph.getNodes().filter(CheckCastNode.class).count());
return graph;
} catch (Throwable e) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FinalizableSubclassTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -35,6 +35,7 @@
import com.oracle.graal.debug.*;
import com.oracle.graal.java.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
@@ -60,28 +61,30 @@
}
}
- private StructuredGraph parseAndProcess(Class> cl, Assumptions assumptions) {
+ private StructuredGraph parseAndProcess(Class> cl, AllowAssumptions allowAssumptions) {
Constructor>[] constructors = cl.getConstructors();
Assert.assertTrue(constructors.length == 1);
final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(constructors[0]);
- StructuredGraph graph = new StructuredGraph(javaMethod);
+ StructuredGraph graph = new StructuredGraph(javaMethod, allowAssumptions);
GraphBuilderConfiguration conf = GraphBuilderConfiguration.getSnippetDefault();
- new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), assumptions, getProviders().getConstantReflection(), conf, OptimisticOptimizations.ALL).apply(graph);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), getProviders().getConstantReflection(), conf, OptimisticOptimizations.ALL).apply(graph);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new CanonicalizerPhase(true).apply(graph, context);
return graph;
}
- private void checkForRegisterFinalizeNode(Class> cl, boolean shouldContainFinalizer, boolean optimistic) {
- Assumptions assumptions = new Assumptions(optimistic);
- StructuredGraph graph = parseAndProcess(cl, assumptions);
+ private void checkForRegisterFinalizeNode(Class> cl, boolean shouldContainFinalizer, AllowAssumptions allowAssumptions) {
+ StructuredGraph graph = parseAndProcess(cl, allowAssumptions);
Assert.assertTrue(graph.getNodes().filter(RegisterFinalizerNode.class).count() == (shouldContainFinalizer ? 1 : 0));
int noFinalizerAssumption = 0;
- for (Assumption a : assumptions) {
- if (a instanceof NoFinalizableSubclass) {
- noFinalizerAssumption++;
+ Assumptions assumptions = graph.getAssumptions();
+ if (assumptions != null) {
+ for (Assumption a : assumptions) {
+ if (a instanceof NoFinalizableSubclass) {
+ noFinalizerAssumption++;
+ }
}
}
Assert.assertTrue(noFinalizerAssumption == (shouldContainFinalizer ? 0 : 1));
@@ -95,13 +98,13 @@
public void test1() throws ClassNotFoundException {
for (int i = 0; i < 2; i++) {
ClassTemplateLoader loader = new ClassTemplateLoader();
- checkForRegisterFinalizeNode(loader.findClass("NoFinalizerEverAAAA"), true, false);
- checkForRegisterFinalizeNode(loader.findClass("NoFinalizerEverAAAA"), false, true);
+ checkForRegisterFinalizeNode(loader.findClass("NoFinalizerEverAAAA"), true, AllowAssumptions.NO);
+ checkForRegisterFinalizeNode(loader.findClass("NoFinalizerEverAAAA"), false, AllowAssumptions.YES);
- checkForRegisterFinalizeNode(loader.findClass("NoFinalizerYetAAAA"), false, true);
+ checkForRegisterFinalizeNode(loader.findClass("NoFinalizerYetAAAA"), false, AllowAssumptions.YES);
- checkForRegisterFinalizeNode(loader.findClass("WithFinalizerAAAA"), true, true);
- checkForRegisterFinalizeNode(loader.findClass("NoFinalizerYetAAAA"), true, true);
+ checkForRegisterFinalizeNode(loader.findClass("WithFinalizerAAAA"), true, AllowAssumptions.YES);
+ checkForRegisterFinalizeNode(loader.findClass("NoFinalizerYetAAAA"), true, AllowAssumptions.YES);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,11 +24,11 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.common.*;
@@ -58,8 +58,8 @@
private void test(final String snippet) {
try (Scope s = Debug.scope("FloatingReadTest", new DebugDumpScope(snippet))) {
- StructuredGraph graph = parseEager(snippet);
- PhaseContext context = new PhaseContext(getProviders(), new Assumptions(false));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -53,6 +53,7 @@
import com.oracle.graal.lir.phases.*;
import com.oracle.graal.nodeinfo.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.nodes.virtual.*;
@@ -71,7 +72,7 @@
*
* White box tests for Graal compiler transformations use this pattern:
*
- * - Create a graph by {@linkplain #parseEager(String) parsing} a method.
+ * - Create a graph by {@linkplain #parseEager(String, AllowAssumptions) parsing} a method.
* - Manually modify the graph (e.g. replace a parameter node with a constant).
* - Apply a transformation to the graph.
* - Assert that the transformed graph is equal to an expected graph.
@@ -90,7 +91,7 @@
private final Providers providers;
private final Backend backend;
private final DerivedOptionValue suites;
- private final DerivedOptionValue lowLevelSuites;
+ private final DerivedOptionValue lirSuites;
/**
* Can be overridden by unit tests to verify properties of the graph.
@@ -166,8 +167,8 @@
return ret;
}
- protected LowLevelSuites createLowLevelSuites() {
- LowLevelSuites ret = backend.getSuites().createLowLevelSuites();
+ protected LIRSuites createLIRSuites() {
+ LIRSuites ret = backend.getSuites().createLIRSuites();
return ret;
}
@@ -175,7 +176,7 @@
this.backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
this.providers = getBackend().getProviders();
this.suites = new DerivedOptionValue<>(this::createSuites);
- this.lowLevelSuites = new DerivedOptionValue<>(this::createLowLevelSuites);
+ this.lirSuites = new DerivedOptionValue<>(this::createLIRSuites);
installSubstitutions();
}
@@ -196,7 +197,7 @@
}
this.providers = backend.getProviders();
this.suites = new DerivedOptionValue<>(this::createSuites);
- this.lowLevelSuites = new DerivedOptionValue<>(this::createLowLevelSuites);
+ this.lirSuites = new DerivedOptionValue<>(this::createLIRSuites);
installSubstitutions();
}
@@ -364,8 +365,8 @@
return suites.getValue();
}
- protected LowLevelSuites getLowLevelSuites() {
- return lowLevelSuites.getValue();
+ protected LIRSuites getLIRSuites() {
+ return lirSuites.getValue();
}
protected Providers getProviders() {
@@ -661,7 +662,7 @@
/**
* Gets installed code for a given method, compiling it first if necessary. The graph is parsed
- * {@link #parseEager(ResolvedJavaMethod) eagerly}.
+ * {@link #parseEager(ResolvedJavaMethod, AllowAssumptions) eagerly}.
*/
protected InstalledCode getCode(ResolvedJavaMethod method) {
return getCode(method, null);
@@ -735,10 +736,10 @@
* is null.
*
* The default implementation in {@link GraalCompilerTest} is to call
- * {@link #parseEager(ResolvedJavaMethod)}.
+ * {@link #parseEager(ResolvedJavaMethod, AllowAssumptions)}.
*/
protected StructuredGraph parseForCompile(ResolvedJavaMethod method) {
- return parseEager(method);
+ return parseEager(method, AllowAssumptions.YES);
}
/**
@@ -754,7 +755,7 @@
lastCompiledGraph = graphToCompile;
CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graphToCompile.method(), false);
Request request = new Request<>(graphToCompile, cc, installedCodeOwner, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(),
- OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), getLowLevelSuites(), new CompilationResult(),
+ OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), getLIRSuites(), new CompilationResult(),
CompilationResultBuilderFactory.Default);
return GraalCompiler.compile(request);
}
@@ -815,16 +816,16 @@
*
* @param methodName the name of the method in {@code this.getClass()} to be parsed
*/
- protected StructuredGraph parseProfiled(String methodName) {
- return parseProfiled(getResolvedJavaMethod(methodName));
+ protected StructuredGraph parseProfiled(String methodName, AllowAssumptions allowAssumptions) {
+ return parseProfiled(getResolvedJavaMethod(methodName), allowAssumptions);
}
/**
* Parses a Java method in {@linkplain GraphBuilderConfiguration#getDefault() default} mode to
* produce a graph.
*/
- protected StructuredGraph parseProfiled(ResolvedJavaMethod m) {
- return parse1(m, getDefaultGraphBuilderSuite());
+ protected StructuredGraph parseProfiled(ResolvedJavaMethod m, AllowAssumptions allowAssumptions) {
+ return parse1(m, getDefaultGraphBuilderSuite(), allowAssumptions);
}
/**
@@ -833,31 +834,31 @@
*
* @param methodName the name of the method in {@code this.getClass()} to be parsed
*/
- protected StructuredGraph parseEager(String methodName) {
- return parseEager(getResolvedJavaMethod(methodName));
+ protected StructuredGraph parseEager(String methodName, AllowAssumptions allowAssumptions) {
+ return parseEager(getResolvedJavaMethod(methodName), allowAssumptions);
}
/**
* Parses a Java method in {@linkplain GraphBuilderConfiguration#getEagerDefault() eager} mode
* to produce a graph.
*/
- protected StructuredGraph parseEager(ResolvedJavaMethod m) {
- return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerDefault()));
+ protected StructuredGraph parseEager(ResolvedJavaMethod m, AllowAssumptions allowAssumptions) {
+ return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerDefault()), allowAssumptions);
}
/**
* Parses a Java method in {@linkplain GraphBuilderConfiguration#getFullDebugDefault() full
* debug} mode to produce a graph.
*/
- protected StructuredGraph parseDebug(ResolvedJavaMethod m) {
- return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault()));
+ protected StructuredGraph parseDebug(ResolvedJavaMethod m, AllowAssumptions allowAssumptions) {
+ return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault()), allowAssumptions);
}
- private StructuredGraph parse1(ResolvedJavaMethod javaMethod, PhaseSuite graphBuilderSuite) {
+ private StructuredGraph parse1(ResolvedJavaMethod javaMethod, PhaseSuite graphBuilderSuite, AllowAssumptions allowAssumptions) {
assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod;
try (Scope ds = Debug.scope("Parsing", javaMethod)) {
- StructuredGraph graph = new StructuredGraph(javaMethod);
- graphBuilderSuite.apply(graph, new HighTierContext(providers, null, null, graphBuilderSuite, OptimisticOptimizations.ALL));
+ StructuredGraph graph = new StructuredGraph(javaMethod, allowAssumptions);
+ graphBuilderSuite.apply(graph, new HighTierContext(providers, null, graphBuilderSuite, OptimisticOptimizations.ALL));
return graph;
} catch (Throwable e) {
throw Debug.handle(e);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,10 +26,10 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
@@ -180,11 +180,11 @@
}
private void testCombinedIf(String snippet, int count) {
- StructuredGraph graph = parseEager(snippet);
- PhaseContext context = new PhaseContext(getProviders(), new Assumptions(false));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
- MidTierContext midContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
+ MidTierContext midContext = new MidTierContext(getProviders(), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
new GuardLoweringPhase().apply(graph, midContext);
new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
new ValueAnchorCleanupPhase().apply(graph);
@@ -193,19 +193,19 @@
}
private void test(String snippet) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
ParameterNode param = graph.getNodes(ParameterNode.class).iterator().next();
ConstantNode constant = ConstantNode.forInt(0, graph);
for (Node n : param.usages().filter(isNotA(FrameState.class)).snapshot()) {
n.replaceFirstInput(param, constant);
}
Debug.dump(graph, "Graph");
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
for (FrameState fs : param.usages().filter(FrameState.class).snapshot()) {
fs.replaceFirstInput(param, null);
param.safeDelete();
}
- StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET);
+ StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
assertEquals(referenceGraph, graph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,6 +24,7 @@
import static com.oracle.graal.api.code.CodeUtil.*;
import static com.oracle.graal.compiler.GraalCompiler.*;
+import static com.oracle.graal.compiler.common.GraalOptions.*;
import static org.junit.Assert.*;
import org.junit.*;
@@ -36,6 +37,7 @@
import com.oracle.graal.java.*;
import com.oracle.graal.lir.asm.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.tiers.*;
@@ -58,10 +60,10 @@
@Test
public void callInfopoints() {
final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
- final StructuredGraph graph = parseEager(method);
+ final StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(),
- OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), getLowLevelSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
+ OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
for (Infopoint sp : cr.getInfopoints()) {
assertNotNull(sp.reason);
if (sp instanceof Call) {
@@ -73,7 +75,7 @@
@Test
public void lineInfopoints() {
final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
- final StructuredGraph graph = parseDebug(method);
+ final StructuredGraph graph = parseDebug(method, AllowAssumptions.from(OptAssumptions.getValue()));
int graphLineSPs = 0;
for (FullInfopointNode ipn : graph.getNodes().filter(FullInfopointNode.class)) {
if (ipn.getReason() == InfopointReason.LINE_NUMBER) {
@@ -84,7 +86,7 @@
CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
PhaseSuite graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault());
final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL,
- getProfilingInfo(graph), getSpeculationLog(), getSuites(), getLowLevelSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
+ getProfilingInfo(graph), getSpeculationLog(), getSuites(), getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
int lineSPs = 0;
for (Infopoint sp : cr.getInfopoints()) {
assertNotNull(sp.reason);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IntegerEqualsCanonicalizerTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IntegerEqualsCanonicalizerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IntegerEqualsCanonicalizerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -25,6 +25,7 @@
import org.junit.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -112,8 +113,8 @@
}
private StructuredGraph getCanonicalizedGraph(String snippet) {
- StructuredGraph graph = parseEager(snippet);
- new CanonicalizerPhase(false).apply(graph, new PhaseContext(getProviders(), null));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ new CanonicalizerPhase(false).apply(graph, new PhaseContext(getProviders()));
for (FrameState state : graph.getNodes(FrameState.class).snapshot()) {
state.replaceAtUsages(null);
state.safeDelete();
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeExceptionTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,8 +26,8 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.common.inlining.*;
@@ -61,13 +61,12 @@
}
private void test(String snippet) {
- StructuredGraph graph = parseProfiled(snippet);
+ StructuredGraph graph = parseProfiled(snippet, AllowAssumptions.NO);
Map hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context);
new CanonicalizerPhase(true).apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InvokeHintsTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,8 +26,8 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.common.inlining.*;
@@ -71,18 +71,17 @@
}
private void test(String snippet) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
Map hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context);
new CanonicalizerPhase(true).apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
- StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET);
+ StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.*;
@@ -62,7 +62,7 @@
test("testSynchronizedSnippet", new A(), new A());
StructuredGraph graph = getGraph("testSynchronizedSnippet");
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
new LockEliminationPhase().apply(graph);
assertDeepEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count());
assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count());
@@ -80,7 +80,7 @@
test("testSynchronizedMethodSnippet", new A());
StructuredGraph graph = getGraph("testSynchronizedMethodSnippet");
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), null));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
new LockEliminationPhase().apply(graph);
assertDeepEquals(1, graph.getNodes().filter(MonitorEnterNode.class).count());
assertDeepEquals(1, graph.getNodes().filter(MonitorExitNode.class).count());
@@ -88,9 +88,8 @@
private StructuredGraph getGraph(String snippet) {
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
- StructuredGraph graph = parseEager(method);
- Assumptions assumptions = new Assumptions(true);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new CanonicalizerPhase(true).apply(graph, context);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new CanonicalizerPhase(true).apply(graph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LoopUnswitchTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,12 +24,12 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.graph.*;
import com.oracle.graal.loop.phases.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -121,8 +121,8 @@
}
private void test(String snippet, String referenceSnippet) {
- final StructuredGraph graph = parseEager(snippet);
- final StructuredGraph referenceGraph = parseEager(referenceSnippet);
+ final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
+ final StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
new LoopUnswitchingPhase().apply(graph);
@@ -134,9 +134,8 @@
((StateSplit) stateSplit).setStateAfter(null);
}
- Assumptions assumptions = new Assumptions(false);
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
- new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders(), assumptions));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
+ new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders()));
try (Scope s = Debug.scope("Test", new DebugDumpScope("Test:" + snippet))) {
assertEquals(referenceGraph, graph);
} catch (Throwable e) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -29,12 +29,12 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.graph.*;
import com.oracle.graal.graph.iterators.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.spi.*;
@@ -596,11 +596,10 @@
}
private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
- final StructuredGraph graph = parseEager(snippet);
+ final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
try (Scope d = Debug.scope("FloatingReadTest", graph)) {
try (OverrideScope s = OptionValue.override(OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS, OptImplicitNullChecks, false)) {
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
canonicalizer.apply(graph, context);
if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
@@ -623,7 +622,7 @@
new FloatingReadPhase().apply(graph);
new RemoveValueProxyPhase().apply(graph);
- MidTierContext midContext = new MidTierContext(getProviders(), assumptions, getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
+ MidTierContext midContext = new MidTierContext(getProviders(), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
new GuardLoweringPhase().apply(graph, midContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, midContext);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MergeCanonicalizerTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MergeCanonicalizerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MergeCanonicalizerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -57,9 +57,9 @@
}
private void testReturnCount(String snippet, int returnCount) {
- StructuredGraph graph = parseEager(snippet);
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
Debug.dump(graph, "Graph");
assertDeepEquals(returnCount, graph.getNodes(ReturnNode.class).count());
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MonitorGraphTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,10 +28,10 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.graph.iterators.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
@@ -84,7 +84,7 @@
}
private StructuredGraph parseAndProcess(String snippet) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
ParameterNode param = graph.getNodes(ParameterNode.class).first();
if (param != null) {
ConstantNode constant = ConstantNode.forInt(0, graph);
@@ -96,8 +96,7 @@
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context);
new CanonicalizerPhase(true).apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
@@ -106,7 +105,7 @@
private void test(String snippet) {
StructuredGraph graph = parseAndProcess(snippet);
- StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET);
+ StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/NestedLoopTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,6 +28,7 @@
import com.oracle.graal.debug.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.java.*;
@@ -145,7 +146,7 @@
}
private void test(String snippet, int rootExits, int nestedExits, int innerExits) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
Debug.dump(graph, "Graph");
ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PhiCreationTests.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,6 +26,7 @@
import com.oracle.graal.debug.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
/**
* In the following tests, the correct removal of redundant phis during graph building is tested.
@@ -40,7 +41,7 @@
@Test
public void test1() {
- StructuredGraph graph = parseEager("test1Snippet");
+ StructuredGraph graph = parseEager("test1Snippet", AllowAssumptions.YES);
Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
@@ -53,7 +54,7 @@
@Test
public void test2() {
- StructuredGraph graph = parseEager("test2Snippet");
+ StructuredGraph graph = parseEager("test2Snippet", AllowAssumptions.YES);
Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
@@ -66,7 +67,7 @@
@Test
public void test3() {
- StructuredGraph graph = parseEager("test3Snippet");
+ StructuredGraph graph = parseEager("test3Snippet", AllowAssumptions.YES);
Debug.dump(graph, "Graph");
Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
@@ -82,7 +83,7 @@
@Test
public void test4() {
- StructuredGraph graph = parseEager("test4Snippet");
+ StructuredGraph graph = parseEager("test4Snippet", AllowAssumptions.YES);
Debug.dump(graph, "Graph");
Assert.assertFalse(graph.getNodes().filter(ValuePhiNode.class).iterator().hasNext());
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,12 +24,12 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.calc.*;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.spi.*;
@@ -91,8 +91,8 @@
}
private StructuredGraph compileTestSnippet(final String snippet) {
- StructuredGraph graph = parseEager(snippet);
- PhaseContext context = new PhaseContext(getProviders(), new Assumptions(false));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushThroughIfTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushThroughIfTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushThroughIfTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.util.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -57,21 +57,21 @@
}
private void test(String snippet, String reference) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
Debug.dump(graph, "Graph");
for (FrameState fs : graph.getNodes(FrameState.class).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
}
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
- StructuredGraph referenceGraph = parseEager(reference);
+ StructuredGraph referenceGraph = parseEager(reference, AllowAssumptions.YES);
for (FrameState fs : referenceGraph.getNodes(FrameState.class).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
}
- new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders(), new Assumptions(false)));
+ new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders()));
assertEquals(referenceGraph, graph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,10 +24,10 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.common.*;
@@ -81,8 +81,8 @@
try (Scope s = Debug.scope("ReadAfterCheckCastTest", new DebugDumpScope(snippet))) {
// check shape of graph, with lots of assumptions. will probably fail if graph
// structure changes significantly
- StructuredGraph graph = parseEager(snippet);
- PhaseContext context = new PhaseContext(getProviders(), new Assumptions(false));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReassociateAndCanonicalTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -243,11 +243,10 @@
}
private void test(String test, String ref) {
- StructuredGraph testGraph = parseEager(test);
- Assumptions assumptions = new Assumptions(false);
- new CanonicalizerPhase(true).apply(testGraph, new PhaseContext(getProviders(), assumptions));
- StructuredGraph refGraph = parseEager(ref);
- new CanonicalizerPhase(true).apply(refGraph, new PhaseContext(getProviders(), assumptions));
+ StructuredGraph testGraph = parseEager(test, AllowAssumptions.NO);
+ new CanonicalizerPhase(true).apply(testGraph, new PhaseContext(getProviders()));
+ StructuredGraph refGraph = parseEager(ref, AllowAssumptions.NO);
+ new CanonicalizerPhase(true).apply(refGraph, new PhaseContext(getProviders()));
assertEquals(testGraph, refGraph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ScalarTypeSystemTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -130,12 +130,11 @@
private void test(final String snippet, final String referenceSnippet) {
// No debug scope to reduce console noise for @Test(expected = ...) tests
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
Debug.dump(graph, "Graph");
- Assumptions assumptions = new Assumptions(false);
- PhaseContext context = new PhaseContext(getProviders(), assumptions);
+ PhaseContext context = new PhaseContext(getProviders());
new CanonicalizerPhase(true).apply(graph, context);
- StructuredGraph referenceGraph = parseEager(referenceSnippet);
+ StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SchedulingTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SchedulingTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SchedulingTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -30,6 +30,7 @@
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.calc.*;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.util.*;
@@ -51,7 +52,7 @@
@Test
public void testValueProxyInputs() {
- StructuredGraph graph = parseEager("testValueProxyInputsSnippet");
+ StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES);
for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SimpleCFGTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -30,6 +30,7 @@
import com.oracle.graal.debug.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.cfg.*;
public class SimpleCFGTest extends GraalCompilerTest {
@@ -40,7 +41,7 @@
@Test
public void testImplies() {
- StructuredGraph graph = new StructuredGraph();
+ StructuredGraph graph = new StructuredGraph(AllowAssumptions.YES);
AbstractEndNode trueEnd = graph.add(new EndNode());
AbstractEndNode falseEnd = graph.add(new EndNode());
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -109,8 +109,8 @@
}
private void testZeroReturn(String methodName) {
- StructuredGraph graph = parseEager(methodName);
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
+ StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
new DeadCodeEliminationPhase().apply(graph);
assertConstantReturn(graph, 0);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StraighteningTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -87,10 +87,10 @@
private void test(final String snippet) {
// No debug scope to reduce console noise for @Test(expected = ...) tests
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
Debug.dump(graph, "Graph");
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
- StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET);
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
+ StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
assertEquals(referenceGraph, graph);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/TypeSystemTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,11 +26,11 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodeinfo.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.phases.common.*;
@@ -170,20 +170,19 @@
}
private void test(String snippet, String referenceSnippet) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
Debug.dump(graph, "Graph");
- Assumptions assumptions = new Assumptions(false);
/*
* When using FlowSensitiveReductionPhase instead of ConditionalEliminationPhase,
* tail-duplication gets activated thus resulting in a graph with more nodes than the
* reference graph.
*/
- new ConditionalEliminationPhase().apply(graph, new PhaseContext(getProviders(), assumptions));
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
+ new ConditionalEliminationPhase().apply(graph, new PhaseContext(getProviders()));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
// a second canonicalizer is needed to process nested MaterializeNodes
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
- StructuredGraph referenceGraph = parseEager(referenceSnippet);
- new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders(), assumptions));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
+ StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
+ new CanonicalizerPhase(true).apply(referenceGraph, new PhaseContext(getProviders()));
assertEquals(referenceGraph, graph);
}
@@ -230,10 +229,9 @@
}
private void testHelper(String snippet, Class clazz) {
- StructuredGraph graph = parseEager(snippet);
- Assumptions assumptions = new Assumptions(false);
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), assumptions));
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
Debug.dump(graph, "Graph " + snippet);
Assert.assertFalse("shouldn't have nodes of type " + clazz, graph.getNodes().filter(clazz).iterator().hasNext());
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -34,11 +34,12 @@
import com.oracle.graal.lir.*;
import com.oracle.graal.lir.StandardOp.MoveOp;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
public class AllocatorTest extends BackendTest {
protected void testAllocation(String snippet, final int expectedRegisters, final int expectedRegRegMoves, final int expectedSpillMoves) {
- final StructuredGraph graph = parseEager(snippet);
+ final StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
try (Scope s = Debug.scope("AllocatorTest", graph, graph.method(), getCodeCache())) {
final RegisterStats stats = new RegisterStats(getLIRGenerationResult(graph).getLIR());
try (Scope s2 = Debug.scope("Assertions", stats.lir)) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -23,7 +23,6 @@
package com.oracle.graal.compiler.test.backend;
import static com.oracle.graal.api.code.CodeUtil.*;
-import static com.oracle.graal.compiler.common.GraalOptions.*;
import com.oracle.graal.api.code.*;
import com.oracle.graal.api.code.CallingConvention.Type;
@@ -47,18 +46,16 @@
}
protected LIRGenerationResult getLIRGenerationResult(final StructuredGraph graph) {
- final Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
-
SchedulePhase schedule = null;
try (Scope s = Debug.scope("FrontEnd")) {
- schedule = GraalCompiler.emitFrontEnd(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
+ schedule = GraalCompiler.emitFrontEnd(getProviders(), getBackend().getTarget(), graph, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
graph.method().getProfilingInfo(), null, getSuites());
} catch (Throwable e) {
throw Debug.handle(e);
}
CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
- LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null, getLowLevelSuites());
+ LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null, getLIRSuites());
return lirGen;
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,6 +28,7 @@
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -51,8 +52,8 @@
@Test
public void test1() {
final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod");
- final StructuredGraph graph = parseEager(javaMethod);
- new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false)));
+ final StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.NO);
+ new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders()));
new DeadCodeEliminationPhase().apply(graph);
for (ConstantNode node : ConstantNode.getConstantNodes(graph)) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -30,6 +30,7 @@
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
public final class MonitorDeoptTest extends GraalCompilerTest {
@@ -134,7 +135,7 @@
public void run0() throws Throwable {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod("test");
- StructuredGraph graph = parseEager(javaMethod);
+ StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES);
removeLoopSafepoint(graph);
CompilationResult compilationResult = compile(javaMethod, graph);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,13 +26,13 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.java.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.nodes.virtual.*;
import com.oracle.graal.phases.*;
@@ -149,12 +149,11 @@
protected void prepareGraph(String snippet, final boolean iterativeEscapeAnalysis) {
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
- graph = new StructuredGraph(method);
+ graph = new StructuredGraph(method, AllowAssumptions.NO);
try (Scope s = Debug.scope(getClass(), graph, method, getCodeCache())) {
- Assumptions assumptions = new Assumptions(false);
- new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), assumptions, getProviders().getConstantReflection(), GraphBuilderConfiguration.getEagerDefault(),
+ new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), getProviders().getConstantReflection(), GraphBuilderConfiguration.getEagerDefault(),
OptimisticOptimizations.ALL).apply(graph);
- context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
new CanonicalizerPhase(true).apply(graph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EarlyReadEliminationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,7 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.common.inlining.*;
@@ -40,9 +40,8 @@
@Override
protected void processMethod(final String snippet) {
- graph = parseEager(snippet);
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ graph = parseEager(getResolvedJavaMethod(snippet), AllowAssumptions.NO);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new EarlyReadEliminationPhase(new CanonicalizerPhase(true)).apply(graph, context);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,10 +28,10 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.compiler.test.ea.EATestBase.TestClassInt;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
@@ -84,8 +84,8 @@
}
private void processMethod(final String snippet) {
- graph = parseEager(snippet);
- HighTierContext context = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ graph = parseEager(snippet, AllowAssumptions.YES);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new IterativeInliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,9 +28,9 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
@@ -244,9 +244,8 @@
}
protected void processMethod(final String snippet) {
- graph = parseEager(snippet);
- Assumptions assumptions = new Assumptions(false);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ graph = parseEager(snippet, AllowAssumptions.NO);
+ HighTierContext context = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
new PartialEscapePhase(false, true, new CanonicalizerPhase(true), null).apply(graph, context);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PoorMansEATest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PoorMansEATest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PoorMansEATest.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,12 +24,12 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.*;
@@ -39,7 +39,7 @@
/**
* Tests {@link AbstractNewObjectNode#simplify(com.oracle.graal.graph.spi.SimplifierTool)}.
- *
+ *
*/
public class PoorMansEATest extends GraalCompilerTest {
public static class A {
@@ -59,11 +59,10 @@
private void test(final String snippet) {
try (Scope s = Debug.scope("PoorMansEATest", new DebugDumpScope(snippet))) {
- StructuredGraph graph = parseEager(snippet);
- Assumptions assumptions = new Assumptions(false);
- HighTierContext highTierContext = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
+ HighTierContext highTierContext = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext);
- PhaseContext context = new PhaseContext(getProviders(), assumptions);
+ PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
// remove framestates in order to trigger the simplification.
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -34,6 +34,7 @@
import com.oracle.graal.graph.*;
import com.oracle.graal.java.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.common.inlining.*;
@@ -231,10 +232,9 @@
private StructuredGraph getGraph(final String snippet, final boolean eagerInfopointMode) {
try (Scope s = Debug.scope("InliningTest", new DebugDumpScope(snippet))) {
ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
- StructuredGraph graph = eagerInfopointMode ? parseDebug(method) : parseEager(method);
+ StructuredGraph graph = eagerInfopointMode ? parseDebug(method, AllowAssumptions.YES) : parseEager(method, AllowAssumptions.YES);
PhaseSuite graphBuilderSuite = eagerInfopointMode ? getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault()) : getDefaultGraphBuilderSuite();
- Assumptions assumptions = new Assumptions(true);
- HighTierContext context = new HighTierContext(getProviders(), assumptions, null, graphBuilderSuite, OptimisticOptimizations.ALL);
+ HighTierContext context = new HighTierContext(getProviders(), null, graphBuilderSuite, OptimisticOptimizations.ALL);
Debug.dump(graph, "Graph");
new CanonicalizerPhase(true).apply(graph, context);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Thu Feb 12 20:47:20 2015 +0100
@@ -37,6 +37,7 @@
import com.oracle.graal.lir.asm.*;
import com.oracle.graal.lir.phases.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.tiers.*;
import com.oracle.graal.phases.util.*;
@@ -78,9 +79,11 @@
/*
* The graph that is compiled. We leave it empty (no nodes added yet). This means that
- * it will be filled according to the graphBuilderSuite defined below.
+ * it will be filled according to the graphBuilderSuite defined below. We also specify
+ * that we want the compilation to make optimistic assumptions about runtime state such
+ * as the loaded class hierarchy.
*/
- StructuredGraph graph = new StructuredGraph(method);
+ StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.YES);
/*
* The phases used to build the graph. Usually this is just the GraphBuilderPhase. If
@@ -97,7 +100,7 @@
/*
* The low-level phases that are applied to the low-level representation.
*/
- LowLevelSuites lowLevelSuites = backend.getSuites().createLowLevelSuites();
+ LIRSuites lirSuites = backend.getSuites().createLIRSuites();
/*
* The calling convention for the machine code. You should have a very good reason
@@ -123,7 +126,7 @@
SpeculationLog speculationLog = null;
/* Invoke the whole Graal compilation pipeline. */
- GraalCompiler.compileGraph(graph, callingConvention, method, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lowLevelSuites,
+ GraalCompiler.compileGraph(graph, callingConvention, method, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lirSuites,
compilationResult, factory);
/*
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/StaticAnalysis.java
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/StaticAnalysis.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/StaticAnalysis.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.*;
import com.oracle.graal.debug.*;
@@ -33,6 +32,7 @@
import com.oracle.graal.java.*;
import com.oracle.graal.nodes.CallTargetNode.InvokeKind;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.nodes.util.*;
@@ -210,7 +210,7 @@
* Build the Graal graph for the method using the bytecode parser provided by Graal.
*/
- StructuredGraph graph = new StructuredGraph(method);
+ StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO);
/*
* Support for graph dumping, IGV uses this information to show the method name of a
* graph.
@@ -236,9 +236,8 @@
* wrong.
*/
OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
- Assumptions assumptions = new Assumptions(false);
- GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(metaAccess, stampProvider, assumptions, null, graphBuilderConfig, optimisticOpts);
+ GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(metaAccess, stampProvider, null, graphBuilderConfig, optimisticOpts);
graphBuilder.apply(graph);
} catch (Throwable ex) {
Debug.handle(ex);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import static com.oracle.graal.compiler.GraalCompiler.Options.*;
import static com.oracle.graal.compiler.MethodFilter.*;
-import static com.oracle.graal.compiler.common.GraalOptions.*;
import static com.oracle.graal.phases.common.DeadCodeEliminationPhase.Optionality.*;
import java.util.*;
@@ -45,9 +44,9 @@
import com.oracle.graal.lir.framemap.*;
import com.oracle.graal.lir.gen.*;
import com.oracle.graal.lir.phases.*;
-import com.oracle.graal.lir.phases.LowLevelHighTierPhase.LowLevelHighTierContext;
-import com.oracle.graal.lir.phases.LowLevelLowTierPhase.LowLevelLowTierContext;
-import com.oracle.graal.lir.phases.LowLevelMidTierPhase.LowLevelMidTierContext;
+import com.oracle.graal.lir.phases.LIRHighTierPhase.LIRHighTierContext;
+import com.oracle.graal.lir.phases.LIRLowTierPhase.LIRLowTierContext;
+import com.oracle.graal.lir.phases.LIRMidTierPhase.LIRMidTierContext;
import com.oracle.graal.nodes.*;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.spi.*;
@@ -144,7 +143,7 @@
public final ProfilingInfo profilingInfo;
public final SpeculationLog speculationLog;
public final Suites suites;
- public final LowLevelSuites lowLevelSuites;
+ public final LIRSuites lirSuites;
public final T compilationResult;
public final CompilationResultBuilderFactory factory;
@@ -162,13 +161,13 @@
* @param profilingInfo
* @param speculationLog
* @param suites
- * @param lowLevelSuites
+ * @param lirSuites
* @param compilationResult
* @param factory
*/
public Request(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target,
Map cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo,
- SpeculationLog speculationLog, Suites suites, LowLevelSuites lowLevelSuites, T compilationResult, CompilationResultBuilderFactory factory) {
+ SpeculationLog speculationLog, Suites suites, LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) {
this.graph = graph;
this.cc = cc;
this.installedCodeOwner = installedCodeOwner;
@@ -181,7 +180,7 @@
this.profilingInfo = profilingInfo;
this.speculationLog = speculationLog;
this.suites = suites;
- this.lowLevelSuites = lowLevelSuites;
+ this.lirSuites = lirSuites;
this.compilationResult = compilationResult;
this.factory = factory;
}
@@ -207,8 +206,8 @@
*/
public static T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend,
TargetDescription target, Map cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts,
- ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, LowLevelSuites lowLevelSuites, T compilationResult, CompilationResultBuilderFactory factory) {
- return compile(new Request<>(graph, cc, installedCodeOwner, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lowLevelSuites,
+ ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) {
+ return compile(new Request<>(graph, cc, installedCodeOwner, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lirSuites,
compilationResult, factory));
}
@@ -220,9 +219,8 @@
public static T compile(Request r) {
assert !r.graph.isFrozen();
try (Scope s0 = Debug.scope("GraalCompiler", r.graph, r.providers.getCodeCache())) {
- Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
- SchedulePhase schedule = emitFrontEnd(r.providers, r.target, r.graph, assumptions, r.cache, r.graphBuilderSuite, r.optimisticOpts, r.profilingInfo, r.speculationLog, r.suites);
- emitBackEnd(r.graph, null, r.cc, r.installedCodeOwner, r.backend, r.target, r.compilationResult, r.factory, assumptions, schedule, null, r.lowLevelSuites);
+ SchedulePhase schedule = emitFrontEnd(r.providers, r.target, r.graph, r.cache, r.graphBuilderSuite, r.optimisticOpts, r.profilingInfo, r.speculationLog, r.suites);
+ emitBackEnd(r.graph, null, r.cc, r.installedCodeOwner, r.backend, r.target, r.compilationResult, r.factory, schedule, null, r.lirSuites);
} catch (Throwable e) {
throw Debug.handle(e);
}
@@ -240,14 +238,14 @@
/**
* Builds the graph, optimizes it.
*/
- public static SchedulePhase emitFrontEnd(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map cache,
+ public static SchedulePhase emitFrontEnd(Providers providers, TargetDescription target, StructuredGraph graph, Map cache,
PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) {
try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
if (speculationLog != null) {
speculationLog.collectFailedSpeculations();
}
- HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, graphBuilderSuite, optimisticOpts);
+ HighTierContext highTierContext = new HighTierContext(providers, cache, graphBuilderSuite, optimisticOpts);
if (graph.start().next() == null) {
graphBuilderSuite.apply(graph, highTierContext);
new DeadCodeEliminationPhase(Optional).apply(graph);
@@ -258,11 +256,11 @@
suites.getHighTier().apply(graph, highTierContext);
graph.maybeCompress();
- MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
+ MidTierContext midTierContext = new MidTierContext(providers, target, optimisticOpts, profilingInfo, speculationLog);
suites.getMidTier().apply(graph, midTierContext);
graph.maybeCompress();
- LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
+ LowTierContext lowTierContext = new LowTierContext(providers, target);
suites.getLowTier().apply(graph, lowTierContext);
graph.maybeCompress();
@@ -277,13 +275,12 @@
}
public static void emitBackEnd(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Backend backend,
- TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, Assumptions assumptions, SchedulePhase schedule, RegisterConfig registerConfig,
- LowLevelSuites lowLevelSuites) {
+ TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, SchedulePhase schedule, RegisterConfig registerConfig, LIRSuites lirSuites) {
try (TimerCloseable a = BackEnd.start()) {
LIRGenerationResult lirGen = null;
- lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig, lowLevelSuites);
+ lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig, lirSuites);
try (Scope s = Debug.scope("CodeGen", lirGen, lirGen.getLIR())) {
- emitCode(backend, assumptions, lirGen, compilationResult, installedCodeOwner, factory);
+ emitCode(backend, graph.getAssumptions(), graph.getMethods(), lirGen, compilationResult, installedCodeOwner, factory);
} catch (Throwable e) {
throw Debug.handle(e);
}
@@ -304,7 +301,7 @@
}
public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc,
- RegisterConfig registerConfig, LowLevelSuites lowLevelSuites) {
+ RegisterConfig registerConfig, LIRSuites lirSuites) {
List blocks = schedule.getCFG().getBlocks();
Block startBlock = schedule.getCFG().getStartBlock();
assert startBlock != null;
@@ -343,8 +340,8 @@
throw Debug.handle(e);
}
- try (Scope s = Debug.scope("LowLevelTier", nodeLirGen)) {
- return emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, lirGen, lowLevelSuites);
+ try (Scope s = Debug.scope("LIRTier", nodeLirGen)) {
+ return emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, lirGen, lirSuites);
} catch (Throwable e) {
throw Debug.handle(e);
}
@@ -354,27 +351,30 @@
}
public static > LIRGenerationResult emitLowLevel(TargetDescription target, List codeEmittingOrder, List linearScanOrder, LIRGenerationResult lirGenRes,
- LIRGeneratorTool lirGen, LowLevelSuites lowLevelSuites) {
- LowLevelHighTierContext highTierContext = new LowLevelHighTierContext(lirGen);
- lowLevelSuites.getHighTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, highTierContext);
+ LIRGeneratorTool lirGen, LIRSuites lirSuites) {
+ LIRHighTierContext highTierContext = new LIRHighTierContext(lirGen);
+ lirSuites.getHighTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, highTierContext);
- LowLevelMidTierContext midTierContext = new LowLevelMidTierContext();
- lowLevelSuites.getMidTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, midTierContext);
+ LIRMidTierContext midTierContext = new LIRMidTierContext();
+ lirSuites.getMidTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, midTierContext);
- LowLevelLowTierContext lowTierContext = new LowLevelLowTierContext();
- lowLevelSuites.getLowTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, lowTierContext);
+ LIRLowTierContext lowTierContext = new LIRLowTierContext();
+ lirSuites.getLowTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, lowTierContext);
return lirGenRes;
}
- public static void emitCode(Backend backend, Assumptions assumptions, LIRGenerationResult lirGenRes, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner,
- CompilationResultBuilderFactory factory) {
+ public static void emitCode(Backend backend, Assumptions assumptions, Set methods, LIRGenerationResult lirGenRes, CompilationResult compilationResult,
+ ResolvedJavaMethod installedCodeOwner, CompilationResultBuilderFactory factory) {
FrameMap frameMap = lirGenRes.getFrameMap();
CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGenRes, frameMap, compilationResult, factory);
backend.emitCode(crb, lirGenRes.getLIR(), installedCodeOwner);
crb.finish();
- if (!assumptions.isEmpty()) {
- compilationResult.setAssumptions(assumptions);
+ if (assumptions != null && !assumptions.isEmpty()) {
+ compilationResult.setAssumptions(assumptions.toArray());
+ }
+ if (methods != null) {
+ compilationResult.setMethods(methods.toArray(new ResolvedJavaMethod[methods.size()]));
}
if (Debug.isMeterEnabled()) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,9 +24,9 @@
import com.oracle.graal.api.runtime.*;
import com.oracle.graal.lir.phases.*;
-import com.oracle.graal.lir.phases.LowLevelHighTierPhase.*;
-import com.oracle.graal.lir.phases.LowLevelLowTierPhase.*;
-import com.oracle.graal.lir.phases.LowLevelMidTierPhase.*;
+import com.oracle.graal.lir.phases.LIRHighTierPhase.*;
+import com.oracle.graal.lir.phases.LIRLowTierPhase.*;
+import com.oracle.graal.lir.phases.LIRMidTierPhase.*;
import com.oracle.graal.phases.*;
import com.oracle.graal.phases.tiers.*;
@@ -45,16 +45,16 @@
return new LowTier();
}
- public LowLevelPhaseSuite createLowLevelHighTier() {
- return new LowLevelHighTier();
+ public LIRPhaseSuite createLIRHighTier() {
+ return new LIRHighTier();
}
- public LowLevelPhaseSuite createLowLevelMidTier() {
- return new LowLevelMidTier();
+ public LIRPhaseSuite createLIRMidTier() {
+ return new LIRMidTier();
}
- public LowLevelPhaseSuite createLowLevelLowTier() {
- return new LowLevelLowTier();
+ public LIRPhaseSuite createLIRLowTier() {
+ return new LIRLowTier();
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu Feb 12 20:47:20 2015 +0100
@@ -467,6 +467,10 @@
log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
+ public static void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) {
+ log(DEFAULT_LOG_LEVEL, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ }
+
/**
* @see #log(int, String, Object)
*/
@@ -476,6 +480,12 @@
}
}
+ public static void log(int logLevel, String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) {
+ if (ENABLED) {
+ DebugScope.getInstance().log(logLevel, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+ }
+ }
+
public static void logv(String format, Object... args) {
logv(DEFAULT_LOG_LEVEL, format, args);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUnionFind.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeUnionFind.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.graph;
+
+/**
+ * Union-find data structure for {@link Node Nodes}.
+ *
+ * All operations have an accumulated worst-case complexity of O(a(n)), where a(n) is the inverse of
+ * the Ackermann function A(n,n).
+ */
+public class NodeUnionFind extends NodeIdAccessor {
+
+ private int[] rank;
+ private int[] parent;
+
+ /**
+ * Create a new union-find data structure for a {@link Graph}. Initially, all nodes are in their
+ * own equivalence set.
+ */
+ public NodeUnionFind(Graph graph) {
+ super(graph);
+ rank = new int[graph.nodeIdCount()];
+ parent = new int[graph.nodeIdCount()];
+ for (int i = 0; i < parent.length; i++) {
+ parent[i] = i;
+ }
+ }
+
+ /**
+ * Merge the equivalence sets of two nodes.
+ *
+ * After calling this function, find(a) == find(b).
+ */
+ public void union(Node a, Node b) {
+ union(getNodeId(a), getNodeId(b));
+ }
+
+ /**
+ * Get a representative element of the equivalence set of a node.
+ *
+ * This function returns the same representative element for all members of the same equivalence
+ * set, i.e., find(a) == find(b) if and only if a and b are in the same set.
+ */
+ public Node find(Node a) {
+ int id = find(getNodeId(a));
+ return graph.getNode(id);
+ }
+
+ public boolean equiv(Node a, Node b) {
+ return find(getNodeId(a)) == find(getNodeId(b));
+ }
+
+ private void union(int a, int b) {
+ int aRoot = find(a);
+ int bRoot = find(b);
+ if (rank[aRoot] < rank[bRoot]) {
+ parent[aRoot] = bRoot;
+ } else {
+ parent[bRoot] = aRoot;
+ if (rank[aRoot] == rank[bRoot]) {
+ rank[aRoot]++;
+ }
+ }
+ }
+
+ private int find(int a) {
+ int ret = a;
+ while (ret != parent[ret]) {
+ parent[ret] = parent[parent[ret]];
+ ret = parent[ret];
+ }
+ return ret;
+ }
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/CanonicalizerTool.java
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/CanonicalizerTool.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/spi/CanonicalizerTool.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,13 +22,10 @@
*/
package com.oracle.graal.graph.spi;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
public interface CanonicalizerTool {
- Assumptions assumptions();
-
MetaAccessProvider getMetaAccess();
ConstantReflectionProvider getConstantReflection();
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Thu Feb 12 20:47:20 2015 +0100
@@ -152,15 +152,12 @@
try (InitTimer rt = timer("create Lowerer provider")) {
lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers, target);
}
- // Replacements cannot have speculative optimizations since they have
- // to be valid for the entire run of the VM.
- Assumptions assumptions = new Assumptions(false);
Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider());
try (InitTimer rt = timer("create SnippetReflection provider")) {
snippetReflection = createSnippetReflection(runtime);
}
try (InitTimer rt = timer("create Replacements provider")) {
- replacements = createReplacements(runtime, assumptions, p, snippetReflection);
+ replacements = createReplacements(runtime, p, snippetReflection);
}
try (InitTimer rt = timer("create Disassembler provider")) {
disassembler = createDisassembler(runtime);
@@ -187,8 +184,8 @@
return new HotSpotDisassemblerProvider(runtime);
}
- protected Replacements createReplacements(HotSpotGraalRuntimeProvider runtime, Assumptions assumptions, Providers p, SnippetReflectionProvider snippetReflection) {
- return new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), assumptions, p.getCodeCache().getTarget());
+ protected Replacements createReplacements(HotSpotGraalRuntimeProvider runtime, Providers p, SnippetReflectionProvider snippetReflection) {
+ return new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), p.getCodeCache().getTarget());
}
protected AMD64HotSpotForeignCallsProvider createForeignCalls(HotSpotGraalRuntimeProvider runtime, HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache,
@@ -251,15 +248,15 @@
} else {
/*
* System V Application Binary Interface, AMD64 Architecture Processor Supplement
- *
+ *
* Draft Version 0.96
- *
+ *
* http://www.uclibc.org/docs/psABI-x86_64.pdf
- *
+ *
* 3.2.1
- *
+ *
* ...
- *
+ *
* This subsection discusses usage of each register. Registers %rbp, %rbx and %r12
* through %r15 "belong" to the calling function and the called function is required to
* preserve their values. In other words, a called function must preserve these
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Thu Feb 12 20:47:20 2015 +0100
@@ -60,12 +60,9 @@
Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig());
HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters);
LoweringProvider lowerer = new SPARCHotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers, target);
- // Replacements cannot have speculative optimizations since they have
- // to be valid for the entire run of the VM.
- Assumptions assumptions = new Assumptions(false);
Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null, new HotSpotStampProvider());
HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime);
- HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), assumptions, target);
+ HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), target);
HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime);
HotSpotSuitesProvider suites = new HotSpotSuitesProvider(runtime);
HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, snippetReflection);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -41,6 +41,7 @@
import com.oracle.graal.lir.asm.*;
import com.oracle.graal.lir.phases.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.options.*;
import com.oracle.graal.options.OptionValue.OverrideScope;
@@ -204,7 +205,7 @@
}
private StructuredGraph compile(String test, boolean compileAOT) {
- StructuredGraph graph = parseEager(test);
+ StructuredGraph graph = parseEager(test, AllowAssumptions.YES);
ResolvedJavaMethod method = graph.method();
try (OverrideScope s = OptionValue.override(ImmutableCode, compileAOT)) {
@@ -212,10 +213,9 @@
// create suites everytime, as we modify options for the compiler
SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites();
final Suites suitesLocal = suitesProvider.createSuites();
- final LowLevelSuites lowLevelSuitesLocal = suitesProvider.createLowLevelSuites();
+ final LIRSuites lirSuitesLocal = suitesProvider.createLIRSuites();
final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(),
- OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, lowLevelSuitesLocal, new CompilationResult(),
- CompilationResultBuilderFactory.Default);
+ OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, lirSuitesLocal, new CompilationResult(), CompilationResultBuilderFactory.Default);
addMethod(method, compResult);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ClassSubstitutionsTests.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ClassSubstitutionsTests.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ClassSubstitutionsTests.java Thu Feb 12 20:47:20 2015 +0100
@@ -32,6 +32,7 @@
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
public class ClassSubstitutionsTests extends GraalCompilerTest {
@@ -43,7 +44,7 @@
protected StructuredGraph test(final String snippet) {
try (Scope s = Debug.scope("ClassSubstitutionsTest", getMetaAccess().lookupJavaMethod(getMethod(snippet)))) {
- StructuredGraph graph = parseEager(snippet);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
compile(graph.method(), graph);
assertNotInGraph(graph, Invoke.class);
Debug.dump(graph, snippet);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -28,6 +28,7 @@
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
public class HotSpotNmethodTest extends GraalCompilerTest {
@@ -36,7 +37,7 @@
@Test
public void testInstallCodeInvalidation() {
final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
- final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo"));
+ final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
Assert.assertTrue(nmethod.isValid());
Object result;
try {
@@ -59,7 +60,7 @@
@Test
public void testInstallCodeInvalidationWhileRunning() {
final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
- final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo"));
+ final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
Object result;
try {
result = nmethod.executeVarargs(nmethod, null, null);
@@ -73,7 +74,7 @@
@Test
public void testInstalledCodeCalledFromCompiledCode() {
final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
- final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo"));
+ final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
Assert.assertTrue(nmethod.isValid());
try {
for (int i = 0; i < ITERATION_COUNT; ++i) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNodeSubstitutionsTest.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNodeSubstitutionsTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNodeSubstitutionsTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,6 +26,7 @@
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.replacements.test.*;
/**
@@ -35,7 +36,7 @@
@Test
public void test() {
- StructuredGraph graph = new StructuredGraph();
+ StructuredGraph graph = new StructuredGraph(AllowAssumptions.YES);
test("getNodeClass", ConstantNode.forInt(42, graph));
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -31,6 +31,7 @@
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.hotspot.meta.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
public class InstalledCodeExecuteHelperTest extends GraalCompilerTest {
@@ -68,8 +69,8 @@
}
@Override
- protected StructuredGraph parseEager(ResolvedJavaMethod m) {
- StructuredGraph graph = super.parseEager(m);
+ protected StructuredGraph parseEager(ResolvedJavaMethod m, AllowAssumptions allowAssumptions) {
+ StructuredGraph graph = super.parseEager(m, allowAssumptions);
if (argsToBind != null) {
Object receiver = isStatic(m.getModifiers()) ? null : this;
Object[] args = argsWithReceiver(receiver, argsToBind);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Thu Feb 12 20:47:20 2015 +0100
@@ -34,6 +34,7 @@
import com.oracle.graal.hotspot.*;
import com.oracle.graal.hotspot.CompileTheWorld.Config;
import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.printer.*;
/**
@@ -134,10 +135,10 @@
method.reprofile();
int id = method.allocateCompileId(INVOCATION_ENTRY_BCI);
- long ctask = 0L;
+ long graalEnv = 0L;
try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) {
- CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id, false);
+ CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, graalEnv, id, false);
task.runCompilation();
}
}
@@ -151,9 +152,9 @@
method.reprofile();
int id = method.allocateCompileId(INVOCATION_ENTRY_BCI);
- long ctask = 0L;
+ long graalEnv = 0L;
try (AllocSpy as = AllocSpy.open(methodName)) {
- CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id, false);
+ CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, graalEnv, id, false);
task.runCompilation();
}
}
@@ -164,7 +165,7 @@
private void compileAndTime(String methodName) {
// Parse in eager mode to resolve methods/fields/classes
- parseEager(methodName);
+ parseEager(methodName, AllowAssumptions.YES);
// Warm up and initialize compiler phases used by this compilation
for (int i = 0; i < 10; i++) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,7 +26,6 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.*;
import com.oracle.graal.compiler.test.*;
@@ -39,6 +38,7 @@
import com.oracle.graal.hotspot.replacements.*;
import com.oracle.graal.nodes.HeapAccess.BarrierType;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.*;
@@ -244,9 +244,9 @@
private void testHelper(final String snippetName, final int expectedBarriers) throws Exception, SecurityException {
ResolvedJavaMethod snippet = getResolvedJavaMethod(snippetName);
try (Scope s = Debug.scope("WriteBarrierAdditionTest", snippet)) {
- StructuredGraph graph = parseEager(snippet);
- HighTierContext highContext = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
- MidTierContext midContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
+ StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
+ HighTierContext highContext = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ MidTierContext midContext = new MidTierContext(getProviders(), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
new NodeIntrinsificationPhase(getProviders(), getSnippetReflection()).apply(graph);
new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase(true)).apply(graph, highContext);
new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,7 +26,6 @@
import org.junit.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.debug.*;
@@ -37,6 +36,7 @@
import com.oracle.graal.hotspot.phases.*;
import com.oracle.graal.hotspot.replacements.arraycopy.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.phases.*;
@@ -626,11 +626,11 @@
private void testPredicate(final String snippet, final GraphPredicate expectedBarriers, final int... removedBarrierIndices) {
try (Scope d = Debug.scope("WriteBarrierVerificationTest", new DebugDumpScope(snippet))) {
- final StructuredGraph graph = parseEager(snippet);
- HighTierContext highTierContext = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
+ final StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
+ HighTierContext highTierContext = new HighTierContext(getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
new InliningPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext);
- MidTierContext midTierContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
+ MidTierContext midTierContext = new MidTierContext(getProviders(), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highTierContext);
new GuardLoweringPhase().apply(graph, midTierContext);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Feb 12 20:47:20 2015 +0100
@@ -97,17 +97,16 @@
private static final com.sun.management.ThreadMXBean threadMXBean = (com.sun.management.ThreadMXBean) ManagementFactory.getThreadMXBean();
/**
- * The address of the native CompileTask associated with this compilation or 0L if no such
- * association exists.
+ * The address of the GraalEnv associated with this compilation or 0L if no such object exists.
*/
- private final long ctask;
+ private final long graalEnv;
- public CompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long ctask, int id, boolean installAsDefault) {
+ public CompilationTask(HotSpotBackend backend, HotSpotResolvedJavaMethod method, int entryBCI, long graalEnv, int id, boolean installAsDefault) {
this.backend = backend;
this.method = method;
this.entryBCI = entryBCI;
this.id = id;
- this.ctask = ctask;
+ this.graalEnv = graalEnv;
this.installAsDefault = installAsDefault;
}
@@ -139,8 +138,8 @@
return providers.getSuites().getDefaultSuites();
}
- protected LowLevelSuites getLowLevelSuites(HotSpotProviders providers) {
- return providers.getSuites().getDefaultLowLevelSuites();
+ protected LIRSuites getLIRSuites(HotSpotProviders providers) {
+ return providers.getSuites().getDefaultLIRSuites();
}
protected PhaseSuite getGraphBuilderSuite(HotSpotProviders providers) {
@@ -209,14 +208,19 @@
graphCache = new HashMap<>();
}
+ boolean recordEvolMethodDeps = graalEnv == 0 || unsafe.getByte(graalEnv + config.graalEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0;
+
HotSpotProviders providers = backend.getProviders();
Replacements replacements = providers.getReplacements();
graph = replacements.getMethodSubstitution(method);
if (graph == null || entryBCI != INVOCATION_ENTRY_BCI) {
- graph = new StructuredGraph(method, entryBCI);
+ graph = new StructuredGraph(method, entryBCI, AllowAssumptions.from(OptAssumptions.getValue()));
+ if (!recordEvolMethodDeps) {
+ graph.disableMethodRecording();
+ }
} else {
// Compiling method substitution - must clone the graph
- graph = graph.copy();
+ graph = graph.copy(graph.name, method, AllowAssumptions.from(OptAssumptions.getValue()), recordEvolMethodDeps);
}
InlinedBytecodes.add(method.getCodeSize());
CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
@@ -228,7 +232,7 @@
cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0));
}
Suites suites = getSuites(providers);
- LowLevelSuites lowLevelSuites = getLowLevelSuites(providers);
+ LIRSuites lirSuites = getLIRSuites(providers);
ProfilingInfo profilingInfo = getProfilingInfo();
OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo);
if (isOSR) {
@@ -237,7 +241,7 @@
optimisticOpts.remove(Optimization.RemoveNeverExecutedCode);
}
result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo,
- method.getSpeculationLog(), suites, lowLevelSuites, new CompilationResult(), CompilationResultBuilderFactory.Default);
+ method.getSpeculationLog(), suites, lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default);
}
result.setId(getId());
result.setEntryBCI(entryBCI);
@@ -313,7 +317,9 @@
compilationEvent.commit();
}
- if (ctask != 0) {
+ if (graalEnv != 0) {
+ long ctask = unsafe.getAddress(graalEnv + config.graalEnvTaskOffset);
+ assert ctask != 0L;
unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, processedBytes);
}
if ((config.ciTime || config.ciTimeEach) && installedCode != null) {
@@ -335,7 +341,7 @@
final HotSpotCodeCacheProvider codeCache = backend.getProviders().getCodeCache();
InstalledCode installedCode = null;
try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) {
- installedCode = codeCache.installMethod(method, compResult, ctask, installAsDefault);
+ installedCode = codeCache.installMethod(method, compResult, graalEnv, installAsDefault);
} catch (Throwable e) {
throw Debug.handle(e);
}
@@ -354,11 +360,11 @@
*
* @param metaspaceMethod
* @param entryBCI
- * @param ctask address of native CompileTask object
+ * @param graalEnv address of native GraalEnv object
* @param id CompileTask::_compile_id
*/
@SuppressWarnings("unused")
- private static void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long ctask, int id) {
+ private static void compileMetaspaceMethod(long metaspaceMethod, int entryBCI, long graalEnv, int id) {
// Ensure a Graal runtime is initialized prior to Debug being initialized as the former
// may include processing command line options used by the latter.
Graal.getRuntime();
@@ -369,15 +375,15 @@
}
HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod);
- compileMethod(method, entryBCI, ctask, id);
+ compileMethod(method, entryBCI, graalEnv, id);
}
/**
* Compiles a method to machine code.
*/
- static void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long ctask, int id) {
+ static void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long graalEnv, int id) {
HotSpotBackend backend = runtime().getHostBackend();
- CompilationTask task = new CompilationTask(backend, method, entryBCI, ctask, id, true);
+ CompilationTask task = new CompilationTask(backend, method, entryBCI, graalEnv, id, true);
try (DebugConfigScope dcs = setConfig(new TopLevelDebugConfig())) {
task.runCompilation();
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java Thu Feb 12 20:47:20 2015 +0100
@@ -34,17 +34,22 @@
public final HotSpotResolvedJavaMethod method;
public final int entryBCI;
public final int id;
- public final long ctask;
+ public final long graalEnv;
public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult) {
this(method, compResult, 0L);
}
- public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long ctask) {
+ public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv) {
super(compResult);
this.method = method;
this.entryBCI = compResult.getEntryBCI();
this.id = compResult.getId();
- this.ctask = ctask;
+ this.graalEnv = graalEnv;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + id + ":" + method.format("%H.%n(%p)%r@") + entryBCI + "]";
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java Thu Feb 12 20:47:20 2015 +0100
@@ -51,7 +51,13 @@
* Checks the conditions a compilation must satisfy to be installed as a RuntimeStub.
*/
private boolean checkStubInvariants(CompilationResult compResult) {
- assert compResult.getExceptionHandlers().isEmpty();
+ assert compResult.getExceptionHandlers().isEmpty() : this;
+
+ // Stubs cannot be recompiled so they cannot be compiled with
+ // assumptions and there is no point in recording evol_method dependencies
+ assert compResult.getAssumptions().isEmpty() : "stubs should not use assumptions: " + this;
+ assert compResult.getMethods().isEmpty() : "stubs should not record evol_method dependencies: " + this;
+
for (DataPatch data : compResult.getDataPatches()) {
if (data.reference instanceof ConstantReference) {
ConstantReference ref = (ConstantReference) data.reference;
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Thu Feb 12 20:47:20 2015 +0100
@@ -69,10 +69,7 @@
try (InitTimer st = timer("graphBuilderPlugins.initialize")) {
GraphBuilderPhase phase = (GraphBuilderPhase) providers.getSuites().getDefaultGraphBuilderSuite().findPhase(GraphBuilderPhase.class).previous();
GraphBuilderPlugins plugins = phase.getGraphBuilderPlugins();
- Iterable sl = Services.load(GraphBuilderPluginsProvider.class);
- for (GraphBuilderPluginsProvider p : sl) {
- p.registerPlugins(providers.getMetaAccess(), plugins);
- }
+ registerGraphBuilderPlugins(providers.getMetaAccess(), plugins);
}
try (InitTimer st = timer("foreignCalls.initialize")) {
@@ -103,4 +100,9 @@
}
}
}
+
+ protected void registerGraphBuilderPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
+ StandardGraphBuilderPlugins.registerPlugins(metaAccess, plugins);
+ HotSpotGraphBuilderPlugins.registerPlugins(metaAccess, plugins);
+ }
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Thu Feb 12 20:47:20 2015 +0100
@@ -44,8 +44,8 @@
private final HotSpotVMConfig config;
- public HotSpotReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, HotSpotVMConfig config, Assumptions assumptions, TargetDescription target) {
- super(providers, snippetReflection, assumptions, target);
+ public HotSpotReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, HotSpotVMConfig config, TargetDescription target) {
+ super(providers, snippetReflection, target);
this.config = config;
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Thu Feb 12 20:47:20 2015 +0100
@@ -1082,6 +1082,8 @@
@HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch;
@HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes;
+ @HotSpotVMField(name = "GraalEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvTaskOffset;
+ @HotSpotVMField(name = "GraalEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvJvmtiCanHotswapOrPostBreakpointOffset;
@HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset;
/**
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Thu Feb 12 20:47:20 2015 +0100
@@ -239,12 +239,12 @@
return installedCode;
}
- public InstalledCode installMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long ctask, boolean isDefault) {
+ public InstalledCode installMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult, long graalEnv, boolean isDefault) {
if (compResult.getId() == -1) {
compResult.setId(method.allocateCompileId(compResult.getEntryBCI()));
}
HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), isDefault);
- runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, compResult, ctask), installedCode, method.getSpeculationLog());
+ runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, compResult, graalEnv), installedCode, method.getSpeculationLog());
return logOrDump(installedCode, compResult);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.meta;
+
+import static com.oracle.graal.java.GraphBuilderContext.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.common.type.*;
+import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.java.*;
+import com.oracle.graal.java.GraphBuilderPlugins.InvocationPlugin;
+import com.oracle.graal.java.GraphBuilderPlugins.Registration;
+import com.oracle.graal.java.GraphBuilderPlugins.Registration.Receiver;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.options.*;
+
+/**
+ * Provider of HotSpot specific {@link GraphBuilderPlugin}s.
+ */
+public class HotSpotGraphBuilderPlugins {
+ public static void registerPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
+ // Object.class
+ Registration r = new Registration(plugins, metaAccess, Object.class);
+ r.register1("getClass", Receiver.class, new InvocationPlugin() {
+ public boolean apply(GraphBuilderContext builder, ValueNode rcvr) {
+ ObjectStamp objectStamp = (ObjectStamp) rcvr.stamp();
+ ValueNode mirror;
+ if (objectStamp.isExactType() && objectStamp.nonNull()) {
+ mirror = builder.append(ConstantNode.forConstant(objectStamp.type().getJavaClass(), builder.getMetaAccess()));
+ } else {
+ StampProvider stampProvider = builder.getStampProvider();
+ LoadHubNode hub = builder.append(new LoadHubNode(stampProvider, nullCheckedValue(builder, rcvr)));
+ mirror = builder.append(new HubGetClassNode(builder.getMetaAccess(), hub));
+ }
+ builder.push(Kind.Object, mirror);
+ return true;
+ }
+ });
+
+ // Class.class
+ r = new Registration(plugins, metaAccess, Class.class);
+ r.register2("cast", Receiver.class, Object.class, new InvocationPlugin() {
+ public boolean apply(GraphBuilderContext builder, ValueNode rcvr, ValueNode object) {
+ if (rcvr.isConstant() && !rcvr.isNullConstant() && object.isConstant()) {
+ ResolvedJavaType type = builder.getConstantReflection().asJavaType(rcvr.asConstant());
+ if (type != null && !type.isPrimitive() && type.isInstance(object.asJavaConstant())) {
+ builder.push(Kind.Object, object);
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+ r.register2("isInstance", Receiver.class, Object.class, new InvocationPlugin() {
+ public boolean apply(GraphBuilderContext builder, ValueNode rcvr, ValueNode object) {
+ if (rcvr.isConstant() && !rcvr.isNullConstant() && object.isConstant()) {
+ ResolvedJavaType type = builder.getConstantReflection().asJavaType(rcvr.asConstant());
+ if (type != null && !type.isPrimitive()) {
+ builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(type.isInstance(object.asJavaConstant()))));
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+
+ // StableOptionValue.class
+ r = new Registration(plugins, metaAccess, StableOptionValue.class);
+ r.register1("getValue", Receiver.class, new InvocationPlugin() {
+ public boolean apply(GraphBuilderContext builder, ValueNode rcvr) {
+ if (rcvr.isConstant() && !rcvr.isNullConstant()) {
+ Object object = ((HotSpotObjectConstantImpl) rcvr.asConstant()).object();
+ StableOptionValue> option = (StableOptionValue>) object;
+ ConstantNode value = builder.append(ConstantNode.forConstant(HotSpotObjectConstantImpl.forObject(option.getValue()), builder.getMetaAccess()));
+ builder.push(Kind.Object, value);
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPluginsProvider.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.hotspot.meta;
-
-import static com.oracle.graal.java.GraphBuilderContext.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.compiler.common.type.*;
-import com.oracle.graal.hotspot.replacements.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.java.GraphBuilderPlugins.InvocationPlugin;
-import com.oracle.graal.java.GraphBuilderPlugins.Registration;
-import com.oracle.graal.java.GraphBuilderPlugins.Registration.Receiver;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.*;
-import com.oracle.graal.options.*;
-
-/**
- * Provider of HotSpot specific {@link GraphBuilderPlugin}s.
- */
-@ServiceProvider(GraphBuilderPluginsProvider.class)
-public class HotSpotGraphBuilderPluginsProvider implements GraphBuilderPluginsProvider {
- public void registerPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
- // Object.class
- Registration r = new Registration(plugins, metaAccess, Object.class);
- r.register1("getClass", Receiver.class, new InvocationPlugin() {
- public boolean apply(GraphBuilderContext builder, ValueNode rcvr) {
- ObjectStamp objectStamp = (ObjectStamp) rcvr.stamp();
- ValueNode mirror;
- if (objectStamp.isExactType() && objectStamp.nonNull()) {
- mirror = builder.append(ConstantNode.forConstant(objectStamp.type().getJavaClass(), builder.getMetaAccess()));
- } else {
- StampProvider stampProvider = builder.getStampProvider();
- LoadHubNode hub = builder.append(new LoadHubNode(stampProvider, nullCheckedValue(builder, rcvr)));
- mirror = builder.append(new HubGetClassNode(builder.getMetaAccess(), hub));
- }
- builder.push(Kind.Object, mirror);
- return true;
- }
- });
-
- // Class.class
- r = new Registration(plugins, metaAccess, Class.class);
- r.register2("cast", Receiver.class, Object.class, new InvocationPlugin() {
- public boolean apply(GraphBuilderContext builder, ValueNode rcvr, ValueNode object) {
- if (rcvr.isConstant() && !rcvr.isNullConstant() && object.isConstant()) {
- ResolvedJavaType type = builder.getConstantReflection().asJavaType(rcvr.asConstant());
- if (type != null && !type.isPrimitive() && type.isInstance(object.asJavaConstant())) {
- builder.push(Kind.Object, object);
- return true;
- }
- }
- return false;
- }
- });
- r.register2("isInstance", Receiver.class, Object.class, new InvocationPlugin() {
- public boolean apply(GraphBuilderContext builder, ValueNode rcvr, ValueNode object) {
- if (rcvr.isConstant() && !rcvr.isNullConstant() && object.isConstant()) {
- ResolvedJavaType type = builder.getConstantReflection().asJavaType(rcvr.asConstant());
- if (type != null && !type.isPrimitive()) {
- builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(type.isInstance(object.asJavaConstant()))));
- return true;
- }
- }
- return false;
- }
- });
-
- // StableOptionValue.class
- r = new Registration(plugins, metaAccess, StableOptionValue.class);
- r.register1("getValue", Receiver.class, new InvocationPlugin() {
- public boolean apply(GraphBuilderContext builder, ValueNode rcvr) {
- if (rcvr.isConstant() && !rcvr.isNullConstant()) {
- Object object = ((HotSpotObjectConstantImpl) rcvr.asConstant()).object();
- StableOptionValue> option = (StableOptionValue>) object;
- ConstantNode value = builder.append(ConstantNode.forConstant(HotSpotObjectConstantImpl.forObject(option.getValue()), builder.getMetaAccess()));
- builder.push(Kind.Object, value);
- return true;
- }
- return false;
- }
- });
- }
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotObjectConstantImpl.java Thu Feb 12 20:47:20 2015 +0100
@@ -183,7 +183,7 @@
CallSite callSite = (CallSite) object;
MethodHandle target = callSite.getTarget();
if (!(callSite instanceof ConstantCallSite)) {
- if (assumptions == null || !assumptions.useOptimisticAssumptions()) {
+ if (assumptions == null) {
return null;
}
assumptions.record(new Assumptions.CallSiteTargetValue(callSite, target));
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Thu Feb 12 20:47:20 2015 +0100
@@ -45,7 +45,7 @@
protected final DerivedOptionValue defaultSuites;
protected final PhaseSuite defaultGraphBuilderSuite;
- private final DerivedOptionValue defaultLowLevelSuites;
+ private final DerivedOptionValue defaultLIRSuites;
protected final HotSpotGraalRuntimeProvider runtime;
private class SuitesSupplier implements OptionSupplier {
@@ -58,12 +58,12 @@
}
- private class LowLevelSuitesSupplier implements OptionSupplier {
+ private class LIRSuitesSupplier implements OptionSupplier {
private static final long serialVersionUID = -1558586374095874299L;
- public LowLevelSuites get() {
- return createLowLevelSuites();
+ public LIRSuites get() {
+ return createLIRSuites();
}
}
@@ -72,7 +72,7 @@
this.runtime = runtime;
this.defaultGraphBuilderSuite = createGraphBuilderSuite();
this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier());
- this.defaultLowLevelSuites = new DerivedOptionValue<>(new LowLevelSuitesSupplier());
+ this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier());
}
public Suites getDefaultSuites() {
@@ -135,12 +135,12 @@
return gbs;
}
- public LowLevelSuites getDefaultLowLevelSuites() {
- return defaultLowLevelSuites.getValue();
+ public LIRSuites getDefaultLIRSuites() {
+ return defaultLIRSuites.getValue();
}
- public LowLevelSuites createLowLevelSuites() {
- return Suites.createDefaultLowLevelSuites();
+ public LIRSuites createLIRSuites() {
+ return Suites.createDefaultLIRSuites();
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Thu Feb 12 20:47:20 2015 +0100
@@ -161,11 +161,11 @@
private InstalledCode installNativeFunctionStub(long functionPointer, Class> returnType, Class>... argumentTypes) {
StructuredGraph g = getGraph(providers, factory, functionPointer, returnType, argumentTypes);
Suites suites = providers.getSuites().createSuites();
- LowLevelSuites lowLevelSuites = providers.getSuites().createLowLevelSuites();
+ LIRSuites lirSuites = providers.getSuites().createLIRSuites();
PhaseSuite phaseSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy();
CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, g.method(), false);
CompilationResult compResult = GraalCompiler.compileGraph(g, cc, g.method(), providers, backend, backend.getTarget(), null, phaseSuite, OptimisticOptimizations.ALL,
- DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, lowLevelSuites, new CompilationResult(), CompilationResultBuilderFactory.Default);
+ DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default);
InstalledCode installedCode;
try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache(), g.method())) {
installedCode = providers.getCodeCache().addMethod(g.method(), compResult, null, null);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/NativeCallStubGraphBuilder.java Thu Feb 12 20:47:20 2015 +0100
@@ -32,6 +32,7 @@
import com.oracle.graal.hotspot.meta.*;
import com.oracle.graal.hotspot.word.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.extended.*;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.nodes.virtual.*;
@@ -52,7 +53,7 @@
public static StructuredGraph getGraph(HotSpotProviders providers, RawNativeCallNodeFactory factory, long functionPointer, Class> returnType, Class>... argumentTypes) {
try {
ResolvedJavaMethod method = providers.getMetaAccess().lookupJavaMethod(NativeCallStubGraphBuilder.class.getMethod("libCall", Object.class, Object.class, Object.class));
- StructuredGraph g = new StructuredGraph(method);
+ StructuredGraph g = new StructuredGraph(method, AllowAssumptions.NO);
ParameterNode arg0 = g.unique(new ParameterNode(0, StampFactory.forKind(Kind.Object)));
ParameterNode arg1 = g.unique(new ParameterNode(1, StampFactory.forKind(Kind.Object)));
ParameterNode arg2 = g.unique(new ParameterNode(2, StampFactory.forKind(Kind.Object)));
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CallSiteTargetNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,7 +22,6 @@
*/
package com.oracle.graal.hotspot.replacements;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.graph.spi.*;
@@ -43,10 +42,10 @@
return arguments.get(0);
}
- private ConstantNode getConstantCallTarget(MetaAccessProvider metaAccess, Assumptions assumptions) {
+ private ConstantNode getConstantCallTarget(MetaAccessProvider metaAccess) {
if (getCallSite().isConstant() && !getCallSite().isNullConstant()) {
HotSpotObjectConstant c = (HotSpotObjectConstant) getCallSite().asConstant();
- JavaConstant target = c.getCallSiteTarget(assumptions);
+ JavaConstant target = c.getCallSiteTarget(graph().getAssumptions());
if (target != null) {
return ConstantNode.forConstant(target, metaAccess);
}
@@ -56,7 +55,7 @@
@Override
public Node canonical(CanonicalizerTool tool) {
- ConstantNode target = getConstantCallTarget(tool.getMetaAccess(), tool.assumptions());
+ ConstantNode target = getConstantCallTarget(tool.getMetaAccess());
if (target != null) {
return target;
}
@@ -66,7 +65,7 @@
@Override
public void lower(LoweringTool tool) {
- ConstantNode target = getConstantCallTarget(tool.getMetaAccess(), tool.assumptions());
+ ConstantNode target = getConstantCallTarget(tool.getMetaAccess());
if (target != null) {
graph().replaceFixedWithFloating(this, target);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Thu Feb 12 20:47:20 2015 +0100
@@ -226,7 +226,8 @@
if (replacer.instanceOf instanceof InstanceOfNode) {
InstanceOfNode instanceOf = (InstanceOfNode) replacer.instanceOf;
ValueNode object = instanceOf.getValue();
- TypeCheckHints hintInfo = new TypeCheckHints(instanceOf.type(), instanceOf.profile(), tool.assumptions(), TypeCheckMinProfileHitProbability.getValue(), TypeCheckMaxHints.getValue());
+ Assumptions assumptions = instanceOf.graph().getAssumptions();
+ TypeCheckHints hintInfo = new TypeCheckHints(instanceOf.type(), instanceOf.profile(), assumptions, TypeCheckMinProfileHitProbability.getValue(), TypeCheckMaxHints.getValue());
final HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) instanceOf.type();
ConstantNode hub = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), type.klass(), providers.getMetaAccess(), instanceOf.graph());
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,11 +26,13 @@
import java.lang.reflect.*;
+import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.nodeinfo.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.nodes.java.*;
import com.oracle.graal.nodes.spi.*;
import com.oracle.graal.nodes.type.*;
@@ -68,9 +70,10 @@
}
assert false : "unhandled array type " + type.getComponentType().getKind();
} else {
- type = getConcreteType(getObject().stamp(), tool.assumptions(), tool.getMetaAccess());
+ Assumptions assumptions = graph().getAssumptions();
+ type = getConcreteType(getObject().stamp(), assumptions, tool.getMetaAccess());
if (type != null) {
- StructuredGraph newGraph = new StructuredGraph();
+ StructuredGraph newGraph = new StructuredGraph(AllowAssumptions.from(assumptions != null));
ParameterNode param = newGraph.unique(new ParameterNode(0, getObject().stamp()));
NewInstanceNode newInstance = newGraph.add(new NewInstanceNode(type, true));
newGraph.addAfterFixed(newGraph.start(), newInstance);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/arraycopy/ArrayCopyNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -73,7 +73,7 @@
}
// the canonicalization before loop unrolling is needed to propagate the length into
// additions, etc.
- PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions(), tool.getStampProvider());
+ PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.getStampProvider());
new CanonicalizerPhase(true).apply(snippetGraph, context);
new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context);
new CanonicalizerPhase(true).apply(snippetGraph, context);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Thu Feb 12 20:47:20 2015 +0100
@@ -36,6 +36,7 @@
import com.oracle.graal.hotspot.replacements.*;
import com.oracle.graal.hotspot.word.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.util.*;
import com.oracle.graal.replacements.*;
import com.oracle.graal.replacements.nodes.*;
@@ -190,7 +191,8 @@
Class>[] args = linkage.getDescriptor().getArgumentTypes();
boolean isObjectResult = linkage.getOutgoingCallingConvention().getReturn().getKind() == Kind.Object;
- StructuredGraph graph = new StructuredGraph(toString(), null);
+ StructuredGraph graph = new StructuredGraph(toString(), null, AllowAssumptions.NO);
+ graph.disableMethodRecording();
GraphKit kit = new HotSpotGraphKit(graph, providers);
ParameterNode[] params = createParameters(kit, args);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Thu Feb 12 20:47:20 2015 +0100
@@ -23,7 +23,6 @@
package com.oracle.graal.hotspot.stubs;
import static com.oracle.graal.compiler.GraalCompiler.*;
-import static com.oracle.graal.compiler.common.GraalOptions.*;
import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
import java.util.*;
@@ -158,6 +157,12 @@
if (code == null) {
try (Scope d = Debug.sandbox("CompilingStub", DebugScope.getConfig(), providers.getCodeCache(), debugScopeContext())) {
final StructuredGraph graph = getGraph();
+
+ // Stubs cannot be recompiled so they cannot be compiled with
+ // assumptions and there is no point in recording evol_method dependencies
+ assert graph.getAssumptions() == null;
+ assert !graph.isMethodRecordingEnabled() : graph;
+
if (!(graph.start() instanceof StubStartNode)) {
StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
newStart.setStateAfter(graph.start().stateAfter());
@@ -171,14 +176,12 @@
compResult = new CompilationResult(toString());
try (Scope s0 = Debug.scope("StubCompilation", graph, providers.getCodeCache())) {
- Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
Suites defaultSuites = providers.getSuites().getDefaultSuites();
Suites suites = new Suites(new PhaseSuite<>(), defaultSuites.getMidTier(), defaultSuites.getLowTier());
- SchedulePhase schedule = emitFrontEnd(providers, target, graph, assumptions, null, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL,
- getProfilingInfo(graph), null, suites);
- LowLevelSuites lowLevelSuites = providers.getSuites().getDefaultLowLevelSuites();
- emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, assumptions, schedule,
- getRegisterConfig(), lowLevelSuites);
+ SchedulePhase schedule = emitFrontEnd(providers, target, graph, null, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph),
+ null, suites);
+ LIRSuites lirSuites = providers.getSuites().getDefaultLIRSuites();
+ emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, schedule, getRegisterConfig(), lirSuites);
} catch (Throwable e) {
throw Debug.handle(e);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultGraphBuilderPlugins.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultGraphBuilderPlugins.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultGraphBuilderPlugins.java Thu Feb 12 20:47:20 2015 +0100
@@ -55,6 +55,12 @@
return plugins.get(method);
}
+ public DefaultGraphBuilderPlugins copy() {
+ DefaultGraphBuilderPlugins result = new DefaultGraphBuilderPlugins();
+ result.plugins.putAll(plugins);
+ return result;
+ }
+
@Override
public String toString() {
return plugins.keySet().stream().map(m -> m.format("%H.%n(%p)")).collect(Collectors.joining(", "));
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Thu Feb 12 20:47:20 2015 +0100
@@ -32,7 +32,7 @@
private final DerivedOptionValue defaultSuites;
private final PhaseSuite defaultGraphBuilderSuite;
- private final DerivedOptionValue defaultLowLevelSuites;
+ private final DerivedOptionValue defaultLIRSuites;
private class SuitesSupplier implements OptionSupplier {
@@ -44,12 +44,12 @@
}
- private class LowLevelSuitesSupplier implements OptionSupplier {
+ private class LIRSuitesSupplier implements OptionSupplier {
private static final long serialVersionUID = 312070237227476252L;
- public LowLevelSuites get() {
- return createLowLevelSuites();
+ public LIRSuites get() {
+ return createLIRSuites();
}
}
@@ -57,7 +57,7 @@
public DefaultSuitesProvider() {
this.defaultGraphBuilderSuite = createGraphBuilderSuite();
this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier());
- this.defaultLowLevelSuites = new DerivedOptionValue<>(new LowLevelSuitesSupplier());
+ this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier());
}
public Suites getDefaultSuites() {
@@ -78,12 +78,12 @@
return suite;
}
- public LowLevelSuites getDefaultLowLevelSuites() {
- return defaultLowLevelSuites.getValue();
+ public LIRSuites getDefaultLIRSuites() {
+ return defaultLIRSuites.getValue();
}
- public LowLevelSuites createLowLevelSuites() {
- return Suites.createDefaultLowLevelSuites();
+ public LIRSuites createLIRSuites() {
+ return Suites.createDefaultLIRSuites();
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -78,8 +78,7 @@
@Override
protected void run(StructuredGraph graph, HighTierContext context) {
- new Instance(context.getMetaAccess(), context.getStampProvider(), context.getAssumptions(), null, context.getConstantReflection(), graphBuilderConfig, graphBuilderPlugins,
- context.getOptimisticOptimizations()).run(graph);
+ new Instance(context.getMetaAccess(), context.getStampProvider(), null, context.getConstantReflection(), graphBuilderConfig, graphBuilderPlugins, context.getOptimisticOptimizations()).run(graph);
}
public GraphBuilderConfiguration getGraphBuilderConfig() {
@@ -102,7 +101,6 @@
private final GraphBuilderPlugins graphBuilderPlugins;
private final OptimisticOptimizations optimisticOpts;
private final StampProvider stampProvider;
- private final Assumptions assumptions;
private final ConstantReflectionProvider constantReflection;
private final SnippetReflectionProvider snippetReflectionProvider;
@@ -113,22 +111,21 @@
return currentGraph;
}
- public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, Assumptions assumptions, SnippetReflectionProvider snippetReflectionProvider,
- ConstantReflectionProvider constantReflection, GraphBuilderConfiguration graphBuilderConfig, GraphBuilderPlugins graphBuilderPlugins, OptimisticOptimizations optimisticOpts) {
+ public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, SnippetReflectionProvider snippetReflectionProvider, ConstantReflectionProvider constantReflection,
+ GraphBuilderConfiguration graphBuilderConfig, GraphBuilderPlugins graphBuilderPlugins, OptimisticOptimizations optimisticOpts) {
this.graphBuilderConfig = graphBuilderConfig;
this.optimisticOpts = optimisticOpts;
this.metaAccess = metaAccess;
this.stampProvider = stampProvider;
- this.assumptions = assumptions;
this.graphBuilderPlugins = graphBuilderPlugins;
this.constantReflection = constantReflection;
this.snippetReflectionProvider = snippetReflectionProvider;
assert metaAccess != null;
}
- public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, Assumptions assumptions, ConstantReflectionProvider constantReflection,
- GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) {
- this(metaAccess, stampProvider, assumptions, null, constantReflection, graphBuilderConfig, null, optimisticOpts);
+ public Instance(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, GraphBuilderConfiguration graphBuilderConfig,
+ OptimisticOptimizations optimisticOpts) {
+ this(metaAccess, stampProvider, null, constantReflection, graphBuilderConfig, null, optimisticOpts);
}
@Override
@@ -836,7 +833,7 @@
InvokeKind invokeKind = initialInvokeKind;
if (initialInvokeKind.isIndirect()) {
ResolvedJavaType contextType = this.frameState.method.getDeclaringClass();
- ResolvedJavaMethod specialCallTarget = MethodCallTargetNode.findSpecialCallTarget(initialInvokeKind, args[0], initialTargetMethod, assumptions, contextType);
+ ResolvedJavaMethod specialCallTarget = MethodCallTargetNode.findSpecialCallTarget(initialInvokeKind, args[0], initialTargetMethod, contextType);
if (specialCallTarget != null) {
invokeKind = InvokeKind.Special;
targetMethod = specialCallTarget;
@@ -973,6 +970,11 @@
}
calleeBeforeUnwindNode.setNext(handleException(calleeUnwindValue, bci()));
}
+
+ // Record method dependency in the graph
+ if (currentGraph.isMethodRecordingEnabled()) {
+ currentGraph.getMethods().add(targetMethod);
+ }
}
protected MethodCallTargetNode createMethodCallTarget(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args, JavaType returnType) {
@@ -1691,7 +1693,7 @@
}
public Assumptions getAssumptions() {
- return assumptions;
+ return currentGraph.getAssumptions();
}
public void push(Kind kind, ValueNode value) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugin.java Thu Feb 12 20:47:20 2015 +0100
@@ -27,7 +27,6 @@
*
* Concrete plugins implement one of the sub-interfaces of this interface.
*
- * @see GraphBuilderPluginsProvider
* @see GraphBuilderPlugins
* @see GraphBuilderPlugins.Registration
*/
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugins.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugins.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPlugins.java Thu Feb 12 20:47:20 2015 +0100
@@ -296,4 +296,6 @@
* @return the plugin associated with {@code method} or {@code null} if none exists
*/
InvocationPlugin lookupInvocation(ResolvedJavaMethod method);
+
+ DefaultGraphBuilderPlugins copy();
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPluginsProvider.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPluginsProvider.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.java;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-
-/**
- * Interface for providers of {@link GraphBuilderPlugin}s.
- */
-public interface GraphBuilderPluginsProvider extends Service {
- /**
- * Registers the plugins provided by this object.
- */
- void registerPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins);
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/StandardGraphBuilderPlugins.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/StandardGraphBuilderPlugins.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.java;
+
+import static com.oracle.graal.java.GraphBuilderContext.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.java.GraphBuilderPlugins.InvocationPlugin;
+import com.oracle.graal.java.GraphBuilderPlugins.Registration;
+import com.oracle.graal.java.GraphBuilderPlugins.Registration.Receiver;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.java.*;
+
+/**
+ * Provider of non-runtime specific {@link GraphBuilderPlugin}s.
+ */
+public class StandardGraphBuilderPlugins {
+ public static void registerPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
+ Registration r = new Registration(plugins, metaAccess, Object.class);
+ r.register1("", Receiver.class, new InvocationPlugin() {
+ public boolean apply(GraphBuilderContext builder, ValueNode object) {
+ if (RegisterFinalizerNode.mayHaveFinalizer(object, builder.getAssumptions())) {
+ builder.append(new RegisterFinalizerNode(object));
+ }
+ return true;
+ }
+ });
+
+ for (Kind kind : Kind.values()) {
+ if (kind.isPrimitive() && kind != Kind.Void) {
+ new BoxPlugin(kind).register(metaAccess, plugins);
+ new UnboxPlugin(kind).register(metaAccess, plugins);
+ }
+ }
+
+ GraalDirectivePlugins.registerPlugins(metaAccess, plugins);
+ }
+
+ static class BoxPlugin implements InvocationPlugin {
+
+ private final Kind kind;
+
+ BoxPlugin(Kind kind) {
+ this.kind = kind;
+ }
+
+ public boolean apply(GraphBuilderContext builder, ValueNode value) {
+ ResolvedJavaType resultType = builder.getMetaAccess().lookupJavaType(kind.toBoxedJavaClass());
+ builder.push(Kind.Object, builder.append(new BoxNode(value, resultType, kind)));
+ return true;
+ }
+
+ void register(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
+ ResolvedJavaMethod method = Registration.resolve(metaAccess, kind.toBoxedJavaClass(), "valueOf", kind.toJavaClass());
+ plugins.register(method, this);
+ }
+ }
+
+ static class UnboxPlugin implements InvocationPlugin {
+
+ private final Kind kind;
+
+ UnboxPlugin(Kind kind) {
+ this.kind = kind;
+ }
+
+ public boolean apply(GraphBuilderContext builder, ValueNode value) {
+ ValueNode valueNode = UnboxNode.create(builder.getMetaAccess(), builder.getConstantReflection(), nullCheckedValue(builder, value), kind);
+ builder.push(kind.getStackKind(), builder.append(valueNode));
+ return true;
+ }
+
+ void register(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
+ String name = kind.toJavaClass().getSimpleName() + "Value";
+ ResolvedJavaMethod method = Registration.resolve(metaAccess, kind.toBoxedJavaClass(), name);
+ plugins.register(method, this);
+ }
+ }
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.java/src/com/oracle/graal/java/StandardGraphBuilderPluginsProvider.java
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/StandardGraphBuilderPluginsProvider.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.java;
-
-import static com.oracle.graal.java.GraphBuilderContext.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
-import com.oracle.graal.java.GraphBuilderPlugins.InvocationPlugin;
-import com.oracle.graal.java.GraphBuilderPlugins.Registration;
-import com.oracle.graal.java.GraphBuilderPlugins.Registration.Receiver;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.java.*;
-
-/**
- * Provider of non-runtime specific {@link GraphBuilderPlugin}s.
- */
-@ServiceProvider(GraphBuilderPluginsProvider.class)
-public class StandardGraphBuilderPluginsProvider implements GraphBuilderPluginsProvider {
- public void registerPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
- Registration r = new Registration(plugins, metaAccess, Object.class);
- r.register1("", Receiver.class, new InvocationPlugin() {
- public boolean apply(GraphBuilderContext builder, ValueNode object) {
- if (RegisterFinalizerNode.mayHaveFinalizer(object, builder.getAssumptions())) {
- builder.append(new RegisterFinalizerNode(object));
- }
- return true;
- }
- });
-
- for (Kind kind : Kind.values()) {
- if (kind.isPrimitive() && kind != Kind.Void) {
- new BoxPlugin(kind).register(metaAccess, plugins);
- new UnboxPlugin(kind).register(metaAccess, plugins);
- }
- }
-
- GraalDirectivePlugins.registerPlugins(metaAccess, plugins);
- }
-
- static class BoxPlugin implements InvocationPlugin {
-
- private final Kind kind;
-
- BoxPlugin(Kind kind) {
- this.kind = kind;
- }
-
- public boolean apply(GraphBuilderContext builder, ValueNode value) {
- ResolvedJavaType resultType = builder.getMetaAccess().lookupJavaType(kind.toBoxedJavaClass());
- builder.push(Kind.Object, builder.append(new BoxNode(value, resultType, kind)));
- return true;
- }
-
- void register(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
- ResolvedJavaMethod method = Registration.resolve(metaAccess, kind.toBoxedJavaClass(), "valueOf", kind.toJavaClass());
- plugins.register(method, this);
- }
- }
-
- static class UnboxPlugin implements InvocationPlugin {
-
- private final Kind kind;
-
- UnboxPlugin(Kind kind) {
- this.kind = kind;
- }
-
- public boolean apply(GraphBuilderContext builder, ValueNode value) {
- ValueNode valueNode = UnboxNode.create(builder.getMetaAccess(), builder.getConstantReflection(), nullCheckedValue(builder, value), kind);
- builder.push(kind.getStackKind(), builder.append(valueNode));
- return true;
- }
-
- void register(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
- String name = kind.toJavaClass().getSimpleName() + "Value";
- ResolvedJavaMethod method = Registration.resolve(metaAccess, kind.toBoxedJavaClass(), name);
- plugins.register(method, this);
- }
- }
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -32,6 +32,7 @@
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
/**
* Base class for the JTT tests.
@@ -56,8 +57,8 @@
}
@Override
- protected StructuredGraph parseEager(ResolvedJavaMethod m) {
- StructuredGraph graph = super.parseEager(m);
+ protected StructuredGraph parseEager(ResolvedJavaMethod m, AllowAssumptions allowAssumptions) {
+ StructuredGraph graph = super.parseEager(m, allowAssumptions);
if (argsToBind != null) {
Object receiver = isStatic(m.getModifiers()) ? null : this;
Object[] args = argsWithReceiver(receiver, argsToBind);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java Thu Feb 12 20:47:20 2015 +0100
@@ -35,7 +35,7 @@
/**
* This class performs basic optimizations on the control flow graph after LIR generation.
*/
-public final class ControlFlowOptimizer extends LowLevelLowTierPhase {
+public final class ControlFlowOptimizer extends LIRLowTierPhase {
/**
* Performs control flow optimizations on the given LIR graph.
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Thu Feb 12 20:47:20 2015 +0100
@@ -48,7 +48,7 @@
* Because this optimization works best when a block contains only a few moves, it has a huge impact
* on the number of blocks that are totally empty.
*/
-public final class EdgeMoveOptimizer extends LowLevelLowTierPhase {
+public final class EdgeMoveOptimizer extends LIRLowTierPhase {
@Override
protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java Thu Feb 12 20:47:20 2015 +0100
@@ -31,7 +31,7 @@
import com.oracle.graal.lir.gen.*;
import com.oracle.graal.lir.phases.*;
-public final class NullCheckOptimizer extends LowLevelLowTierPhase {
+public final class NullCheckOptimizer extends LIRLowTierPhase {
@Override
protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Thu Feb 12 20:47:20 2015 +0100
@@ -41,7 +41,7 @@
/**
* Removes move instructions, where the destination value is already in place.
*/
-public final class RedundantMoveElimination extends LowLevelLowTierPhase {
+public final class RedundantMoveElimination extends LIRLowTierPhase {
@Override
protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -29,7 +29,7 @@
import com.oracle.graal.lir.gen.*;
import com.oracle.graal.lir.phases.*;
-public final class LinearScanPhase extends LowLevelMidTierPhase {
+public final class LinearScanPhase extends LIRMidTierPhase {
@Override
protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Thu Feb 12 20:47:20 2015 +0100
@@ -42,7 +42,7 @@
* Mark all live references for a frame state. The frame state use this information to build the OOP
* maps.
*/
-public final class LocationMarker extends LowLevelMidTierPhase {
+public final class LocationMarker extends LIRMidTierPhase {
public static class Options {
// @formatter:off
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Thu Feb 12 20:47:20 2015 +0100
@@ -47,12 +47,12 @@
* a constant, which is potentially scheduled into a block with high probability, with one or more
* definitions in blocks with a lower probability.
*/
-public final class ConstantLoadOptimization extends LowLevelHighTierPhase {
+public final class ConstantLoadOptimization extends LIRHighTierPhase {
public static class Options {
// @formatter:off
@Option(help = "Enable constant load optimization.", type = OptionType.Debug)
- public static final OptionValue ConstantLoadOptimization = new OptionValue<>(true);
+ public static final OptionValue LIROptConstantLoadOptimization = new OptionValue<>(true);
// @formatter:on
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTier.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTier.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import com.oracle.graal.lir.constopt.*;
+import com.oracle.graal.lir.phases.LIRHighTierPhase.*;
+
+public class LIRHighTier extends LIRPhaseSuite {
+ public LIRHighTier() {
+ if (ConstantLoadOptimization.Options.LIROptConstantLoadOptimization.getValue()) {
+ appendPhase(new ConstantLoadOptimization());
+ }
+ }
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTierPhase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTierPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.common.cfg.*;
+import com.oracle.graal.lir.gen.*;
+
+public abstract class LIRHighTierPhase extends LIRPhase {
+
+ public static final class LIRHighTierContext {
+ private final LIRGeneratorTool lirGen;
+
+ public LIRHighTierContext(LIRGeneratorTool lirGen) {
+ this.lirGen = lirGen;
+ }
+
+ }
+
+ @Override
+ protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRHighTierContext context) {
+ run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context.lirGen);
+ }
+
+ protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen);
+
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTier.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTier.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.phases.LIRLowTierPhase.*;
+import com.oracle.graal.options.*;
+
+public class LIRLowTier extends LIRPhaseSuite {
+ public static class Options {
+ // @formatter:off
+ @Option(help = "", type = OptionType.Debug)
+ public static final OptionValue LIROptEdgeMoveOptimizer = new OptionValue<>(true);
+ @Option(help = "", type = OptionType.Debug)
+ public static final OptionValue LIROptControlFlowOptmizer = new OptionValue<>(true);
+ @Option(help = "", type = OptionType.Debug)
+ public static final OptionValue LIROptRedundantMoveElimination = new OptionValue<>(true);
+ @Option(help = "", type = OptionType.Debug)
+ public static final OptionValue LIROptNullCheckOptimizer = new OptionValue<>(true);
+ // @formatter:on
+ }
+
+ public LIRLowTier() {
+ if (Options.LIROptEdgeMoveOptimizer.getValue()) {
+ appendPhase(new EdgeMoveOptimizer());
+ }
+ if (Options.LIROptControlFlowOptmizer.getValue()) {
+ appendPhase(new ControlFlowOptimizer());
+ }
+ if (Options.LIROptRedundantMoveElimination.getValue()) {
+ appendPhase(new RedundantMoveElimination());
+ }
+ if (Options.LIROptNullCheckOptimizer.getValue()) {
+ appendPhase(new NullCheckOptimizer());
+ }
+ }
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTierPhase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTierPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.common.cfg.*;
+import com.oracle.graal.lir.gen.*;
+
+public abstract class LIRLowTierPhase extends LIRPhase {
+
+ public static final class LIRLowTierContext {
+ }
+
+ @Override
+ protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRLowTierContext context) {
+ run(target, lirGenRes, codeEmittingOrder, linearScanOrder);
+ }
+
+ protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder);
+
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTier.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTier.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import com.oracle.graal.lir.alloc.lsra.*;
+import com.oracle.graal.lir.phases.LIRMidTierPhase.*;
+import com.oracle.graal.lir.stackslotalloc.*;
+
+public class LIRMidTier extends LIRPhaseSuite {
+ public LIRMidTier() {
+ appendPhase(new LinearScanPhase());
+
+ // build frame map
+ if (LSStackSlotAllocator.Options.LIROptLSStackSlotAllocator.getValue()) {
+ appendPhase(new LSStackSlotAllocator());
+ } else {
+ appendPhase(new SimpleStackSlotAllocator());
+ }
+ // currently we mark locations only if we do register allocation
+ appendPhase(new LocationMarker());
+ }
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTierPhase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTierPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.common.cfg.*;
+import com.oracle.graal.lir.gen.*;
+
+public abstract class LIRMidTierPhase extends LIRPhase {
+
+ public static final class LIRMidTierContext {
+ }
+
+ @Override
+ protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRMidTierContext context) {
+ run(target, lirGenRes, codeEmittingOrder, linearScanOrder);
+ }
+
+ protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder);
+
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import java.util.*;
+import java.util.regex.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.common.cfg.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
+import com.oracle.graal.debug.DebugMemUseTracker.Closeable;
+import com.oracle.graal.debug.internal.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.gen.*;
+
+/**
+ * Base class for all {@link LIR low-level} phases. Subclasses should be stateless. There will be
+ * one global instance for each phase that is shared for all compilations.
+ */
+public abstract class LIRPhase {
+
+ private static final int PHASE_DUMP_LEVEL = 2;
+
+ private CharSequence name;
+
+ /**
+ * Records time spent within {@link #apply}.
+ */
+ private final DebugTimer timer;
+
+ /**
+ * Records memory usage within {@link #apply}.
+ */
+ private final DebugMemUseTracker memUseTracker;
+
+ private static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+");
+
+ private static boolean checkName(String name) {
+ assert name == null || NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name;
+ return true;
+ }
+
+ public LIRPhase() {
+ timer = Debug.timer("LIRPhaseTime_%s", getClass());
+ memUseTracker = Debug.memUseTracker("LIRPhaseMemUse_%s", getClass());
+ }
+
+ protected LIRPhase(String name) {
+ assert checkName(name);
+ this.name = name;
+ timer = Debug.timer("LIRPhaseTime_%s", getClass());
+ memUseTracker = Debug.memUseTracker("LIRPhaseMemUse_%s", getClass());
+ }
+
+ public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) {
+ apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, true);
+ }
+
+ public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context, boolean dumpLIR) {
+ try (TimerCloseable a = timer.start(); Scope s = Debug.scope(getName(), this); Closeable c = memUseTracker.start()) {
+ run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
+ if (dumpLIR && Debug.isDumpEnabled(PHASE_DUMP_LEVEL)) {
+ Debug.dump(PHASE_DUMP_LEVEL, lirGenRes.getLIR(), "After phase %s", getName());
+ }
+ } catch (Throwable e) {
+ throw Debug.handle(e);
+ }
+ }
+
+ protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context);
+
+ protected CharSequence createName() {
+ String className = LIRPhase.this.getClass().getName();
+ String s = className.substring(className.lastIndexOf(".") + 1); // strip the package name
+ if (s.endsWith("Phase")) {
+ s = s.substring(0, s.length() - "Phase".length());
+ }
+ return s;
+ }
+
+ public final CharSequence getName() {
+ if (name == null) {
+ name = createName();
+ }
+ return name;
+ }
+
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.common.cfg.*;
+import com.oracle.graal.lir.gen.*;
+
+public abstract class LIRPhaseSuite extends LIRPhase {
+ private final List> phases;
+
+ public LIRPhaseSuite() {
+ phases = new ArrayList<>();
+ }
+
+ /**
+ * Add a new phase at the beginning of this suite.
+ */
+ public final void prependPhase(LIRPhase phase) {
+ phases.add(0, phase);
+ }
+
+ /**
+ * Add a new phase at the end of this suite.
+ */
+ public final void appendPhase(LIRPhase phase) {
+ phases.add(phase);
+ }
+
+ public final ListIterator> findPhase(Class extends LIRPhase> phaseClass) {
+ ListIterator> it = phases.listIterator();
+ if (findNextPhase(it, phaseClass)) {
+ return it;
+ } else {
+ return null;
+ }
+ }
+
+ public static boolean findNextPhase(ListIterator> it, Class extends LIRPhase> phaseClass) {
+ while (it.hasNext()) {
+ LIRPhase phase = it.next();
+ if (phaseClass.isInstance(phase)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) {
+ for (LIRPhase phase : phases) {
+ phase.apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
+ }
+ }
+
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java Thu Feb 12 20:47:20 2015 +0100
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.lir.phases;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.gen.*;
+import com.oracle.graal.lir.phases.LIRHighTierPhase.LIRHighTierContext;
+import com.oracle.graal.lir.phases.LIRLowTierPhase.LIRLowTierContext;
+import com.oracle.graal.lir.phases.LIRMidTierPhase.LIRMidTierContext;
+
+public class LIRSuites {
+
+ private final LIRPhaseSuite highTier;
+ private final LIRPhaseSuite midTier;
+ private final LIRPhaseSuite lowTier;
+
+ public LIRSuites(LIRPhaseSuite highTier, LIRPhaseSuite midTier, LIRPhaseSuite lowTier) {
+ this.highTier = highTier;
+ this.midTier = midTier;
+ this.lowTier = lowTier;
+ }
+
+ /**
+ * {@link LIRHighTierPhase}s are executed between {@link LIR} generation and register
+ * allocation.
+ *
+ * {@link LIRHighTierPhase Implementers} can create new {@link LIRGeneratorTool#newVariable
+ * variables}, {@link LIRGenerationResult#getFrameMap stack slots} and
+ * {@link LIRGenerationResult#getFrameMapBuilder virtual stack slots}.
+ */
+ public LIRPhaseSuite getHighTier() {
+ return highTier;
+ }
+
+ /**
+ * {@link LIRMidTierPhase}s are responsible for register allocation and translating
+ * {@link VirtualStackSlot}s into {@link StackSlot}s.
+ *
+ * After the {@link LIRMidTier} there should be no more {@link Variable}s and
+ * {@link VirtualStackSlot}s.
+ */
+ public LIRPhaseSuite getMidTier() {
+ return midTier;
+ }
+
+ /**
+ * {@link LIRLowTierPhase}s are executed after register allocation and before machine code
+ * generation.
+ *
+ * A {@link LIRLowTierPhase} must not introduce new {@link Variable}s, {@link VirtualStackSlot}s
+ * or {@link StackSlot}s.
+ */
+ public LIRPhaseSuite getLowTier() {
+ return lowTier;
+ }
+
+}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTier.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTier.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import com.oracle.graal.lir.constopt.*;
-import com.oracle.graal.lir.phases.LowLevelHighTierPhase.*;
-
-public class LowLevelHighTier extends LowLevelPhaseSuite {
- public LowLevelHighTier() {
- if (ConstantLoadOptimization.Options.ConstantLoadOptimization.getValue()) {
- appendPhase(new ConstantLoadOptimization());
- }
- }
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTierPhase.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTierPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.lir.gen.*;
-
-public abstract class LowLevelHighTierPhase extends LowLevelPhase {
-
- public static final class LowLevelHighTierContext {
- private final LIRGeneratorTool lirGen;
-
- public LowLevelHighTierContext(LIRGeneratorTool lirGen) {
- this.lirGen = lirGen;
- }
-
- }
-
- @Override
- protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LowLevelHighTierContext context) {
- run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context.lirGen);
- }
-
- protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen);
-
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTier.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTier.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.phases.LowLevelLowTierPhase.*;
-
-public class LowLevelLowTier extends LowLevelPhaseSuite {
- public LowLevelLowTier() {
- appendPhase(new EdgeMoveOptimizer());
- appendPhase(new ControlFlowOptimizer());
- appendPhase(new RedundantMoveElimination());
- appendPhase(new NullCheckOptimizer());
- }
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTierPhase.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTierPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.lir.gen.*;
-
-public abstract class LowLevelLowTierPhase extends LowLevelPhase {
-
- public static final class LowLevelLowTierContext {
- }
-
- @Override
- protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LowLevelLowTierContext context) {
- run(target, lirGenRes, codeEmittingOrder, linearScanOrder);
- }
-
- protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder);
-
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTier.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTier.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import com.oracle.graal.lir.alloc.lsra.*;
-import com.oracle.graal.lir.phases.LowLevelMidTierPhase.*;
-import com.oracle.graal.lir.stackslotalloc.*;
-
-public class LowLevelMidTier extends LowLevelPhaseSuite {
- public LowLevelMidTier() {
- appendPhase(new LinearScanPhase());
-
- // build frame map
- if (LSStackSlotAllocator.Options.LSStackSlotAllocation.getValue()) {
- appendPhase(new LSStackSlotAllocator());
- } else {
- appendPhase(new SimpleStackSlotAllocator());
- }
- // currently we mark locations only if we do register allocation
- appendPhase(new LocationMarker());
- }
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTierPhase.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTierPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.lir.gen.*;
-
-public abstract class LowLevelMidTierPhase extends LowLevelPhase {
-
- public static final class LowLevelMidTierContext {
- }
-
- @Override
- protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LowLevelMidTierContext context) {
- run(target, lirGenRes, codeEmittingOrder, linearScanOrder);
- }
-
- protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder);
-
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhase.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import java.util.*;
-import java.util.regex.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.debug.DebugMemUseTracker.Closeable;
-import com.oracle.graal.debug.internal.*;
-import com.oracle.graal.lir.*;
-import com.oracle.graal.lir.gen.*;
-
-/**
- * Base class for all {@link LIR low-level} phases. Subclasses should be stateless. There will be
- * one global instance for each phase that is shared for all compilations.
- */
-public abstract class LowLevelPhase {
-
- private static final int PHASE_DUMP_LEVEL = 2;
-
- private CharSequence name;
-
- /**
- * Records time spent within {@link #apply}.
- */
- private final DebugTimer timer;
-
- /**
- * Records memory usage within {@link #apply}.
- */
- private final DebugMemUseTracker memUseTracker;
-
- private static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+");
-
- private static boolean checkName(String name) {
- assert name == null || NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name;
- return true;
- }
-
- public LowLevelPhase() {
- timer = Debug.timer("LowLevelPhaseTime_%s", getClass());
- memUseTracker = Debug.memUseTracker("LowLevelPhaseMemUse_%s", getClass());
- }
-
- protected LowLevelPhase(String name) {
- assert checkName(name);
- this.name = name;
- timer = Debug.timer("LowLevelPhaseTime_%s", getClass());
- memUseTracker = Debug.memUseTracker("LowLevelPhaseMemUse_%s", getClass());
- }
-
- public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) {
- apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, true);
- }
-
- public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context, boolean dumpLIR) {
- try (TimerCloseable a = timer.start(); Scope s = Debug.scope(getName(), this); Closeable c = memUseTracker.start()) {
- run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
- if (dumpLIR && Debug.isDumpEnabled(PHASE_DUMP_LEVEL)) {
- Debug.dump(PHASE_DUMP_LEVEL, lirGenRes.getLIR(), "After phase %s", getName());
- }
- } catch (Throwable e) {
- throw Debug.handle(e);
- }
- }
-
- protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context);
-
- protected CharSequence createName() {
- String className = LowLevelPhase.this.getClass().getName();
- String s = className.substring(className.lastIndexOf(".") + 1); // strip the package name
- if (s.endsWith("Phase")) {
- s = s.substring(0, s.length() - "Phase".length());
- }
- return s;
- }
-
- public final CharSequence getName() {
- if (name == null) {
- name = createName();
- }
- return name;
- }
-
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhaseSuite.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhaseSuite.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.lir.gen.*;
-
-public abstract class LowLevelPhaseSuite extends LowLevelPhase {
- private final List> phases;
-
- public LowLevelPhaseSuite() {
- phases = new ArrayList<>();
- }
-
- /**
- * Add a new phase at the beginning of this suite.
- */
- public final void prependPhase(LowLevelPhase phase) {
- phases.add(0, phase);
- }
-
- /**
- * Add a new phase at the end of this suite.
- */
- public final void appendPhase(LowLevelPhase phase) {
- phases.add(phase);
- }
-
- public final ListIterator> findPhase(Class extends LowLevelPhase> phaseClass) {
- ListIterator> it = phases.listIterator();
- if (findNextPhase(it, phaseClass)) {
- return it;
- } else {
- return null;
- }
- }
-
- public static boolean findNextPhase(ListIterator> it, Class extends LowLevelPhase> phaseClass) {
- while (it.hasNext()) {
- LowLevelPhase phase = it.next();
- if (phaseClass.isInstance(phase)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) {
- for (LowLevelPhase phase : phases) {
- phase.apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
- }
- }
-
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelSuites.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelSuites.java Thu Feb 12 20:46:56 2015 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.lir.phases;
-
-import com.oracle.graal.lir.phases.LowLevelHighTierPhase.LowLevelHighTierContext;
-import com.oracle.graal.lir.phases.LowLevelLowTierPhase.LowLevelLowTierContext;
-import com.oracle.graal.lir.phases.LowLevelMidTierPhase.LowLevelMidTierContext;
-
-public class LowLevelSuites {
-
- private final LowLevelPhaseSuite highTier;
- private final LowLevelPhaseSuite midTier;
- private final LowLevelPhaseSuite lowTier;
-
- public LowLevelSuites(LowLevelPhaseSuite highTier, LowLevelPhaseSuite midTier, LowLevelPhaseSuite lowTier) {
- this.highTier = highTier;
- this.midTier = midTier;
- this.lowTier = lowTier;
- }
-
- public LowLevelPhaseSuite getHighTier() {
- return highTier;
- }
-
- public LowLevelPhaseSuite getMidTier() {
- return midTier;
- }
-
- public LowLevelPhaseSuite getLowTier() {
- return lowTier;
- }
-
-}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Thu Feb 12 20:47:20 2015 +0100
@@ -51,12 +51,12 @@
* {@link OperandFlag#UNINITIALIZED}. Otherwise the stack slot might be reused and its content
* destroyed.
*/
-public final class LSStackSlotAllocator extends LowLevelMidTierPhase implements StackSlotAllocator {
+public final class LSStackSlotAllocator extends LIRMidTierPhase implements StackSlotAllocator {
public static class Options {
// @formatter:off
@Option(help = "Use linear scan stack slot allocation.", type = OptionType.Debug)
- public static final OptionValue LSStackSlotAllocation = new OptionValue<>(true);
+ public static final OptionValue LIROptLSStackSlotAllocator = new OptionValue<>(true);
// @formatter:on
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Thu Feb 12 20:47:20 2015 +0100
@@ -36,7 +36,7 @@
import com.oracle.graal.lir.gen.*;
import com.oracle.graal.lir.phases.*;
-public class SimpleStackSlotAllocator extends LowLevelMidTierPhase implements StackSlotAllocator {
+public class SimpleStackSlotAllocator extends LIRMidTierPhase implements StackSlotAllocator {
@Override
protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopEx.java Thu Feb 12 20:47:20 2015 +0100
@@ -233,26 +233,23 @@
return data;
}
- public NodeBitMap nodesInLoopFrom(AbstractBeginNode point, AbstractBeginNode until) {
+ public NodeBitMap nodesInLoopBranch(AbstractBeginNode branch) {
Collection blocks = new LinkedList<>();
Collection exits = new LinkedList<>();
Queue work = new LinkedList<>();
ControlFlowGraph cfg = loopsData().controlFlowGraph();
- work.add(cfg.blockFor(point));
- Block untilBlock = until != null ? cfg.blockFor(until) : null;
+ work.add(cfg.blockFor(branch));
while (!work.isEmpty()) {
Block b = work.remove();
- if (b == untilBlock) {
- continue;
- }
if (loop().getExits().contains(b)) {
exits.add((LoopExitNode) b.getBeginNode());
- } else if (loop().getBlocks().contains(b)) {
+ } else {
+ assert loop().getBlocks().contains(b);
blocks.add(b.getBeginNode());
work.addAll(b.getDominated());
}
}
- return LoopFragment.computeNodes(point.graph(), blocks, exits);
+ return LoopFragment.computeNodes(branch.graph(), blocks, exits);
}
public Map getInductionVariables() {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopPolicies.java
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopPolicies.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopPolicies.java Thu Feb 12 20:47:20 2015 +0100
@@ -30,10 +30,19 @@
import com.oracle.graal.debug.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.VirtualState.VirtualClosure;
import com.oracle.graal.nodes.cfg.*;
import com.oracle.graal.nodes.debug.*;
+import com.oracle.graal.options.*;
public abstract class LoopPolicies {
+ @Option(help = "", type = OptionType.Expert) public static final OptionValue LoopUnswitchMaxIncrease = new OptionValue<>(500);
+ @Option(help = "", type = OptionType.Expert) public static final OptionValue LoopUnswitchTrivial = new OptionValue<>(10);
+ @Option(help = "", type = OptionType.Expert) public static final OptionValue LoopUnswitchFrequencyBoost = new OptionValue<>(10.0);
+
+ @Option(help = "", type = OptionType.Expert) public static final OptionValue FullUnrollMaxNodes = new OptionValue<>(300);
+ @Option(help = "", type = OptionType.Expert) public static final OptionValue FullUnrollMaxIterations = new OptionValue<>(600);
+ @Option(help = "", type = OptionType.Expert) public static final OptionValue ExactFullUnrollMaxNodes = new OptionValue<>(1200);
private LoopPolicies() {
// does not need to be instantiated
@@ -82,31 +91,57 @@
}
public static boolean shouldTryUnswitch(LoopEx loop) {
- return loop.loopBegin().unswitches() <= LoopMaxUnswitch.getValue();
+ LoopBeginNode loopBegin = loop.loopBegin();
+ double loopFrequency = loopBegin.loopFrequency();
+ if (loopFrequency <= 1.0) {
+ return false;
+ }
+ return loopBegin.unswitches() <= LoopMaxUnswitch.getValue();
+ }
+
+ private static final class CountingClosure implements VirtualClosure {
+ int count;
+
+ public void apply(VirtualState node) {
+ count++;
+ }
+ }
+
+ private static class IsolatedInitialization {
+ static final DebugMetric UNSWITCH_SPLIT_WITH_PHIS = Debug.metric("UnswitchSplitWithPhis");
}
public static boolean shouldUnswitch(LoopEx loop, List controlSplits) {
- int loopTotal = loop.size();
int inBranchTotal = 0;
- double maxProbability = 0;
+ int phis = 0;
for (ControlSplitNode controlSplit : controlSplits) {
- Block postDomBlock = loop.loopsData().controlFlowGraph().blockFor(controlSplit).getPostdominator();
- AbstractBeginNode postDom = postDomBlock != null ? postDomBlock.getBeginNode() : null;
for (Node successor : controlSplit.successors()) {
AbstractBeginNode branch = (AbstractBeginNode) successor;
// this may count twice because of fall-through in switches
- inBranchTotal += loop.nodesInLoopFrom(branch, postDom).count();
- double probability = controlSplit.probability(branch);
- if (probability > maxProbability) {
- maxProbability = probability;
- }
+ inBranchTotal += loop.nodesInLoopBranch(branch).count();
+ }
+ Block postDomBlock = loop.loopsData().controlFlowGraph().blockFor(controlSplit).getPostdominator();
+ if (postDomBlock != null) {
+ IsolatedInitialization.UNSWITCH_SPLIT_WITH_PHIS.increment();
+ phis += ((MergeNode) postDomBlock.getBeginNode()).phis().count();
}
}
- int netDiff = loopTotal - (inBranchTotal);
- double uncertainty = 1 - maxProbability;
- int maxDiff = LoopUnswitchMaxIncrease.getValue() + (int) (LoopUnswitchUncertaintyBoost.getValue() * loop.loopBegin().loopFrequency() * uncertainty);
- Debug.log("shouldUnswitch(%s, %s) : delta=%d, max=%d, %.2f%% inside of branches", loop, controlSplits, netDiff, maxDiff, (double) (inBranchTotal) / loopTotal * 100);
- return netDiff <= maxDiff;
+
+ CountingClosure stateNodesCount = new CountingClosure();
+ double loopFrequency = loop.loopBegin().loopFrequency();
+ int maxDiff = LoopUnswitchTrivial.getValue() + (int) (LoopUnswitchFrequencyBoost.getValue() * (loopFrequency - 1.0 + phis));
+
+ maxDiff = Math.min(maxDiff, LoopUnswitchMaxIncrease.getValue());
+ int remainingGraphSpace = MaximumDesiredSize.getValue() - loop.loopBegin().graph().getNodeCount();
+ maxDiff = Math.min(maxDiff, remainingGraphSpace);
+
+ loop.loopBegin().stateAfter().applyToVirtual(stateNodesCount);
+ int loopTotal = loop.size() - loop.loopBegin().phis().count() - stateNodesCount.count - 1;
+ int actualDiff = loopTotal - inBranchTotal;
+
+ Debug.log("shouldUnswitch(%s, %s) : delta=%d (%.2f%% inside of branches), max=%d, f=%.2f, phis=%d -> %b", loop, controlSplits, actualDiff, (double) (inBranchTotal) / loopTotal * 100, maxDiff,
+ loopFrequency, phis, actualDiff <= maxDiff);
+ return actualDiff <= maxDiff;
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopTransformations.java Thu Feb 12 20:47:20 2015 +0100
@@ -37,22 +37,13 @@
public abstract class LoopTransformations {
- private static final int UNROLL_LIMIT = FullUnrollMaxNodes.getValue() * 2;
-
private LoopTransformations() {
// does not need to be instantiated
}
- public static void invert(LoopEx loop, FixedNode point) {
- LoopFragmentInsideBefore head = loop.insideBefore(point);
- LoopFragmentInsideBefore duplicate = head.duplicate();
- head.disconnect();
- head.insertBefore(loop);
- duplicate.appendInside(loop);
- }
-
public static void peel(LoopEx loop) {
loop.inside().duplicate().insertBefore(loop);
+ loop.loopBegin().setLoopFrequency(Math.max(0.0, loop.loopBegin().loopFrequency() - 1));
}
public static void fullUnroll(LoopEx loop, PhaseContext context, CanonicalizerPhase canonicalizer) {
@@ -66,7 +57,7 @@
canonicalizer.applyIncremental(graph, context, mark);
loopBegin.removeDeadPhis();
loop.invalidateFragments();
- if (iterations++ > UNROLL_LIMIT || graph.getNodeCount() > MaximumDesiredSize.getValue() * 3) {
+ if (iterations++ > LoopPolicies.FullUnrollMaxIterations.getValue() || graph.getNodeCount() > MaximumDesiredSize.getValue() * 3) {
throw new BailoutException("FullUnroll : Graph seems to grow out of proportion");
}
}
@@ -121,27 +112,6 @@
// TODO (gd) probabilities need some amount of fixup.. (probably also in other transforms)
}
- public static void unroll(LoopEx loop, int factor) {
- assert loop.isCounted();
- if (factor > 0) {
- throw new UnsupportedOperationException();
- }
- // TODO (gd) implement counted loop
- LoopFragmentWhole main = loop.whole();
- LoopFragmentWhole prologue = main.duplicate();
- prologue.insertBefore(loop);
- // CountedLoopBeginNode counted = prologue.countedLoop();
- // StructuredGraph graph = (StructuredGraph) counted.graph();
- // ValueNode tripCountPrologue = counted.tripCount();
- // ValueNode tripCountMain = counted.tripCount();
- // graph.replaceFloating(tripCountPrologue, "tripCountPrologue % factor");
- // graph.replaceFloating(tripCountMain, "tripCountMain - (tripCountPrologue % factor)");
- LoopFragmentInside inside = loop.inside();
- for (int i = 0; i < factor; i++) {
- inside.duplicate().appendInside(loop);
- }
- }
-
public static List findUnswitchable(LoopEx loop) {
List controls = null;
ValueNode invariantValue = null;
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopUnswitchingPhase.java
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopUnswitchingPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/phases/LoopUnswitchingPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -34,6 +34,7 @@
private static final DebugMetric UNSWITCHED = Debug.metric("Unswitched");
private static final DebugMetric UNSWITCH_CANDIDATES = Debug.metric("UnswitchCandidates");
+ private static final DebugMetric UNSWITCH_EARLY_REJECTS = Debug.metric("UnswitchEarlyRejects");
@Override
protected void run(StructuredGraph graph) {
@@ -57,6 +58,8 @@
break;
}
}
+ } else {
+ UNSWITCH_EARLY_REJECTS.increment();
}
}
} while (unswitched);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodeinfo.processor/src/com/oracle/graal/nodeinfo/processor/GraphNodeVerifier.java
--- a/graal/com.oracle.graal.nodeinfo.processor/src/com/oracle/graal/nodeinfo/processor/GraphNodeVerifier.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodeinfo.processor/src/com/oracle/graal/nodeinfo/processor/GraphNodeVerifier.java Thu Feb 12 20:47:20 2015 +0100
@@ -117,7 +117,7 @@
List extends AnnotationMirror> annotations = field.getAnnotationMirrors();
- boolean isNonOptionalInput = findAnnotationMirror(annotations, Input) != null;
+ boolean isNonOptionalInput = findAnnotationMirror(annotations, Input.asType()) != null;
boolean isOptionalInput = findAnnotationMirror(annotations, OptionalInput) != null;
boolean isSuccessor = findAnnotationMirror(annotations, Successor) != null;
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java
--- a/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/IntegerStampTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -31,6 +31,7 @@
import com.oracle.graal.compiler.common.type.ArithmeticOpTable.ShiftOp;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
/**
* This class tests that integer stamps are created correctly for constants.
@@ -45,7 +46,7 @@
@Before
public void before() {
- graph = new StructuredGraph();
+ graph = new StructuredGraph(AllowAssumptions.YES);
}
@Test
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/LoopPhiCanonicalizerTest.java
--- a/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/LoopPhiCanonicalizerTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/LoopPhiCanonicalizerTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -27,6 +27,7 @@
import com.oracle.graal.compiler.test.*;
import com.oracle.graal.graph.iterators.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
import com.oracle.graal.phases.common.*;
import com.oracle.graal.phases.tiers.*;
@@ -56,10 +57,10 @@
@Test
public void test() {
- StructuredGraph graph = parseEager("loopSnippet");
+ StructuredGraph graph = parseEager("loopSnippet", AllowAssumptions.YES);
NodePredicate loopPhis = node -> node instanceof PhiNode && ((PhiNode) node).merge() instanceof LoopBeginNode;
- PhaseContext context = new PhaseContext(getProviders(), null);
+ PhaseContext context = new PhaseContext(getProviders());
Assert.assertEquals(5, graph.getNodes().filter(loopPhis).count());
new CanonicalizerPhase(false).apply(graph, context);
Assert.assertEquals(2, graph.getNodes().filter(loopPhis).count());
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/NegateNodeCanonicalizationTest.java
--- a/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/NegateNodeCanonicalizationTest.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes.test/src/com/oracle/graal/nodes/test/NegateNodeCanonicalizationTest.java Thu Feb 12 20:47:20 2015 +0100
@@ -29,6 +29,7 @@
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
/**
* This class tests that the canonicalization for constant negate nodes cover all cases.
@@ -39,7 +40,7 @@
@Before
public void before() {
- graph = new StructuredGraph();
+ graph = new StructuredGraph(AllowAssumptions.YES);
}
@Test
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -189,6 +189,10 @@
return;
}
+ if (splitIfAtPhi(tool)) {
+ return;
+ }
+
if (falseSuccessor().hasNoUsages() && (!(falseSuccessor() instanceof LoopExitNode)) && falseSuccessor().next() instanceof IfNode) {
AbstractBeginNode intermediateBegin = falseSuccessor();
IfNode nextIf = (IfNode) intermediateBegin.next();
@@ -602,6 +606,137 @@
}
/**
+ * Take an if that is immediately dominated by a merge with a single phi and split off any paths
+ * where the test would be statically decidable creating a new merge below the approriate side
+ * of the IfNode. Any undecidable tests will continue to use the original IfNode.
+ *
+ * @param tool
+ */
+ @SuppressWarnings("unchecked")
+ private boolean splitIfAtPhi(SimplifierTool tool) {
+ if (!(predecessor() instanceof MergeNode)) {
+ return false;
+ }
+ MergeNode merge = (MergeNode) predecessor();
+ if (merge.forwardEndCount() == 1) {
+ // Don't bother.
+ return false;
+ }
+ if (merge.usages().count() != 1 || merge.phis().count() != 1) {
+ return false;
+ }
+ if (merge.stateAfter() != null) {
+ /* We'll get the chance to simplify this after frame state assignment. */
+ return false;
+ }
+ PhiNode phi = merge.phis().first();
+ if (phi.usages().count() != 1 || condition().usages().count() != 1) {
+ /*
+ * For simplicity the below code assumes assumes the phi goes dead at the end so skip
+ * this case.
+ */
+ return false;
+ }
+
+ if (condition() instanceof Canonicalizable.Unary>) {
+ Canonicalizable.Unary> unary = (Canonicalizable.Unary>) condition();
+ if (unary.getValue() != phi) {
+ return false;
+ }
+ } else if (condition() instanceof Canonicalizable.Binary>) {
+ Canonicalizable.Binary> binary = (Canonicalizable.Binary>) condition();
+ if (binary.getX() != phi && binary.getY() != phi) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ /*
+ * We could additionally filter for the case that at least some of the Phi inputs or one of
+ * the condition inputs are constants but there are cases where a non-constant is
+ * simplifiable, usually where the stamp allows the question to be answered.
+ */
+
+ /* Each successor of the if gets a new merge if needed. */
+ MergeNode trueMerge = null;
+ MergeNode falseMerge = null;
+ assert merge.stateAfter() == null;
+
+ for (AbstractEndNode end : merge.forwardEnds().snapshot()) {
+ Node value = phi.valueAt(end);
+ Node result = null;
+ if (condition() instanceof Canonicalizable.Binary>) {
+ Canonicalizable.Binary compare = (Canonicalizable.Binary) condition;
+ if (compare.getX() == phi) {
+ result = compare.canonical(tool, value, compare.getY());
+ } else {
+ result = compare.canonical(tool, compare.getX(), value);
+ }
+ } else {
+ assert condition() instanceof Canonicalizable.Unary>;
+ Canonicalizable.Unary compare = (Canonicalizable.Unary) condition;
+ result = compare.canonical(tool, value);
+ }
+ if (result instanceof LogicConstantNode) {
+ merge.removeEnd(end);
+ if (((LogicConstantNode) result).getValue()) {
+ if (trueMerge == null) {
+ trueMerge = insertMerge(trueSuccessor());
+ }
+ trueMerge.addForwardEnd(end);
+ } else {
+ if (falseMerge == null) {
+ falseMerge = insertMerge(falseSuccessor());
+ }
+ falseMerge.addForwardEnd(end);
+ }
+ }
+ }
+
+ cleanupMerge(tool, merge);
+ cleanupMerge(tool, trueMerge);
+ cleanupMerge(tool, falseMerge);
+
+ return true;
+ }
+
+ private void cleanupMerge(SimplifierTool tool, MergeNode merge) {
+ if (merge != null && merge.isAlive()) {
+ if (merge.forwardEndCount() == 0) {
+ GraphUtil.killCFG(merge, tool);
+ } else if (merge.forwardEndCount() == 1) {
+ graph().reduceTrivialMerge(merge);
+ }
+ }
+ }
+
+ private MergeNode insertMerge(AbstractBeginNode begin) {
+ MergeNode merge = graph().add(new MergeNode());
+ if (!begin.anchored().isEmpty()) {
+ Object before = null;
+ before = begin.anchored().snapshot();
+ begin.replaceAtUsages(InputType.Guard, merge);
+ begin.replaceAtUsages(InputType.Anchor, merge);
+ assert begin.anchored().isEmpty() : before + " " + begin.anchored().snapshot();
+ }
+
+ AbstractBeginNode theBegin = begin;
+ if (begin instanceof LoopExitNode) {
+ // Insert an extra begin to make it easier.
+ theBegin = graph().add(new BeginNode());
+ begin.replaceAtPredecessor(theBegin);
+ theBegin.setNext(begin);
+ }
+ FixedNode next = theBegin.next();
+ next.replaceAtPredecessor(merge);
+ theBegin.setNext(graph().add(new EndNode()));
+ merge.addForwardEnd((EndNode) theBegin.next());
+ merge.setNext(next);
+ return merge;
+ }
+
+ /**
* Tries to connect code that initializes a variable directly with the successors of an if
* construct that switches on the variable. For example, the pseudo code below:
*
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Thu Feb 12 20:47:20 2015 +0100
@@ -25,6 +25,8 @@
import java.util.*;
import java.util.concurrent.atomic.*;
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.Assumptions.Assumption;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.graph.*;
@@ -80,6 +82,17 @@
}
}
+ /**
+ * Constants denoting whether or not {@link Assumption}s can be made while processing a graph.
+ */
+ public enum AllowAssumptions {
+ YES,
+ NO;
+ public static AllowAssumptions from(boolean flag) {
+ return flag ? YES : NO;
+ }
+ }
+
public static final int INVOCATION_ENTRY_BCI = -1;
public static final long INVALID_GRAPH_ID = -1;
@@ -94,35 +107,46 @@
private boolean hasValueProxies = true;
/**
+ * The assumptions made while constructing and transforming this graph.
+ */
+ private final Assumptions assumptions;
+
+ /**
+ * The methods whose bytecodes are used while constructing this graph.
+ */
+ private Set methods = new HashSet<>();
+
+ /**
* Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start()
* start} node.
*/
- public StructuredGraph() {
- this(null, null);
+ public StructuredGraph(AllowAssumptions allowAssumptions) {
+ this(null, null, allowAssumptions);
}
/**
* Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start()
* start} node.
*/
- public StructuredGraph(String name, ResolvedJavaMethod method) {
- this(name, method, uniqueGraphIds.incrementAndGet(), INVOCATION_ENTRY_BCI);
+ public StructuredGraph(String name, ResolvedJavaMethod method, AllowAssumptions allowAssumptions) {
+ this(name, method, uniqueGraphIds.incrementAndGet(), INVOCATION_ENTRY_BCI, allowAssumptions);
}
- public StructuredGraph(ResolvedJavaMethod method) {
- this(null, method, uniqueGraphIds.incrementAndGet(), INVOCATION_ENTRY_BCI);
+ public StructuredGraph(ResolvedJavaMethod method, AllowAssumptions allowAssumptions) {
+ this(null, method, uniqueGraphIds.incrementAndGet(), INVOCATION_ENTRY_BCI, allowAssumptions);
}
- public StructuredGraph(ResolvedJavaMethod method, int entryBCI) {
- this(null, method, uniqueGraphIds.incrementAndGet(), entryBCI);
+ public StructuredGraph(ResolvedJavaMethod method, int entryBCI, AllowAssumptions allowAssumptions) {
+ this(null, method, uniqueGraphIds.incrementAndGet(), entryBCI, allowAssumptions);
}
- private StructuredGraph(String name, ResolvedJavaMethod method, long graphId, int entryBCI) {
+ private StructuredGraph(String name, ResolvedJavaMethod method, long graphId, int entryBCI, AllowAssumptions allowAssumptions) {
super(name);
this.setStart(add(new StartNode()));
this.method = method;
this.graphId = graphId;
this.entryBCI = entryBCI;
+ this.assumptions = allowAssumptions == AllowAssumptions.YES ? new Assumptions() : null;
}
public Stamp getReturnStamp() {
@@ -196,7 +220,17 @@
}
public StructuredGraph copy(String newName, ResolvedJavaMethod newMethod) {
- StructuredGraph copy = new StructuredGraph(newName, newMethod, graphId, entryBCI);
+ return copy(newName, newMethod, AllowAssumptions.from(assumptions != null), isMethodRecordingEnabled());
+ }
+
+ public StructuredGraph copy(String newName, ResolvedJavaMethod newMethod, AllowAssumptions allowAssumptions, boolean enableMethodRecording) {
+ StructuredGraph copy = new StructuredGraph(newName, newMethod, graphId, entryBCI, allowAssumptions);
+ if (allowAssumptions == AllowAssumptions.YES && assumptions != null) {
+ copy.assumptions.record(assumptions);
+ }
+ if (!enableMethodRecording) {
+ copy.disableMethodRecording();
+ }
copy.setGuardsStage(getGuardsStage());
copy.isAfterFloatingReadPhase = isAfterFloatingReadPhase;
copy.hasValueProxies = hasValueProxies;
@@ -467,4 +501,37 @@
assert !state : "cannot 'unapply' value proxy removal on graph";
hasValueProxies = state;
}
+
+ /**
+ * Gets the object for recording assumptions while constructing of this graph.
+ *
+ * @return {@code null} if assumptions cannot be made for this graph
+ */
+ public Assumptions getAssumptions() {
+ return assumptions;
+ }
+
+ /**
+ * Disables recording of method used while constructing this graph. This can be done at most
+ * once and must be done before any methods are recorded.
+ */
+ public void disableMethodRecording() {
+ assert methods != null : "cannot disable method recording more than once";
+ assert methods.isEmpty() : "cannot disable method recording once methods have been recorded";
+ methods = null;
+ }
+
+ public boolean isMethodRecordingEnabled() {
+ return methods != null;
+ }
+
+ /**
+ * Gets the methods whose bytecodes are used while constructing this graph.
+ *
+ * @return {@code null} if method recording has been {@linkplain #disableMethodRecording()
+ * disabled}
+ */
+ public Set getMethods() {
+ return methods;
+ }
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/ControlFlowGraph.java Thu Feb 12 20:47:20 2015 +0100
@@ -275,7 +275,7 @@
if (sux.loop != loop) {
AbstractBeginNode begin = sux.getBeginNode();
if (!(begin instanceof LoopExitNode && ((LoopExitNode) begin).loopBegin() == loopBegin)) {
- Debug.log("Unexpected loop exit with %s, including whole branch in the loop", sux);
+ Debug.log(3, "Unexpected loop exit with %s, including whole branch in the loop", sux);
unexpected.add(sux);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -73,10 +73,10 @@
ResolvedJavaType exactType;
if (objectStamp.isExactType()) {
exactType = objectStamp.type();
- } else if (objectStamp.type() != null && tool.assumptions().useOptimisticAssumptions()) {
+ } else if (objectStamp.type() != null && graph().getAssumptions() != null) {
exactType = objectStamp.type().findUniqueConcreteSubtype();
if (exactType != null) {
- tool.assumptions().recordConcreteSubtype(objectStamp.type(), exactType);
+ graph().getAssumptions().recordConcreteSubtype(objectStamp.type(), exactType);
}
} else {
exactType = null;
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadMethodNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,6 +22,7 @@
*/
package com.oracle.graal.nodes.extended;
+import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.graph.*;
@@ -68,10 +69,11 @@
if (StampTool.isExactType(object)) {
return resolveExactMethod(tool, type);
}
- if (type != null && tool.assumptions().useOptimisticAssumptions()) {
+ Assumptions assumptions = graph().getAssumptions();
+ if (type != null && assumptions != null) {
ResolvedJavaMethod resolvedMethod = type.findUniqueConcreteMethod(method);
if (resolvedMethod != null && !type.isInterface() && method.getDeclaringClass().isAssignableFrom(type)) {
- tool.assumptions().recordConcreteMethod(method, type, resolvedMethod);
+ assumptions.recordConcreteMethod(method, type, resolvedMethod);
return ConstantNode.forConstant(stamp(), resolvedMethod.getEncoding(), tool.getMetaAccess());
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,6 +26,7 @@
import static com.oracle.graal.api.meta.DeoptimizationReason.*;
import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
+import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.api.meta.ProfilingInfo.TriState;
import com.oracle.graal.compiler.common.type.*;
@@ -157,11 +158,12 @@
return synonym;
}
- if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) {
+ Assumptions assumptions = graph().getAssumptions();
+ if (assumptions != null) {
ResolvedJavaType exactType = type.findUniqueConcreteSubtype();
if (exactType != null && !exactType.equals(type)) {
// Propagate more precise type information to usages of the checkcast.
- tool.assumptions().recordConcreteSubtype(type, exactType);
+ assumptions.recordConcreteSubtype(type, exactType);
return new CheckCastNode(exactType, object, profile, forStoreCheck);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,6 +22,7 @@
*/
package com.oracle.graal.nodes.java;
+import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.graph.spi.*;
@@ -77,12 +78,13 @@
if (result != null) {
return result;
}
- if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) {
+ Assumptions assumptions = graph().getAssumptions();
+ if (assumptions != null) {
ResolvedJavaType exact = stampType.findUniqueConcreteSubtype();
if (exact != null) {
result = checkInstanceOf(forValue, exact, objectStamp.nonNull(), true);
if (result != null) {
- tool.assumptions().recordConcreteSubtype(stampType, exact);
+ assumptions.recordConcreteSubtype(stampType, exact);
return result;
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -94,7 +94,7 @@
}
}
- public static ResolvedJavaMethod findSpecialCallTarget(InvokeKind invokeKind, ValueNode receiver, ResolvedJavaMethod targetMethod, Assumptions assumptions, ResolvedJavaType contextType) {
+ public static ResolvedJavaMethod findSpecialCallTarget(InvokeKind invokeKind, ValueNode receiver, ResolvedJavaMethod targetMethod, ResolvedJavaType contextType) {
if (invokeKind.isDirect()) {
return null;
}
@@ -119,7 +119,8 @@
if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || StampTool.isExactType(receiver) || type.isArray())) {
return resolvedMethod;
}
- if (assumptions != null && assumptions.useOptimisticAssumptions()) {
+ Assumptions assumptions = receiver.graph().getAssumptions();
+ if (assumptions != null) {
ResolvedJavaType uniqueConcreteType = type.findUniqueConcreteSubtype();
if (uniqueConcreteType != null) {
ResolvedJavaMethod methodFromUniqueType = uniqueConcreteType.resolveConcreteMethod(targetMethod, contextType);
@@ -144,7 +145,7 @@
public void simplify(SimplifierTool tool) {
// attempt to devirtualize the call
ResolvedJavaType contextType = (invoke().stateAfter() == null && invoke().stateDuring() == null) ? null : invoke().getContextType();
- ResolvedJavaMethod specialCallTarget = findSpecialCallTarget(invokeKind, receiver(), targetMethod, tool.assumptions(), contextType);
+ ResolvedJavaMethod specialCallTarget = findSpecialCallTarget(invokeKind, receiver(), targetMethod, contextType);
if (specialCallTarget != null) {
this.setTargetMethod(specialCallTarget);
setInvokeKind(InvokeKind.Special);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java Thu Feb 12 20:47:20 2015 +0100
@@ -67,7 +67,7 @@
} else if (objectStamp.type() != null && !objectStamp.type().hasFinalizableSubclass()) {
// if either the declared type of receiver or the holder
// can be assumed to have no finalizers
- if (assumptions.useOptimisticAssumptions()) {
+ if (assumptions != null) {
assumptions.recordNoFinalizableSubclassAssumption(objectStamp.type());
return false;
}
@@ -80,7 +80,7 @@
if (!(forValue.stamp() instanceof ObjectStamp)) {
return this;
}
- if (!mayHaveFinalizer(forValue, tool.assumptions())) {
+ if (!mayHaveFinalizer(forValue, graph().getAssumptions())) {
return null;
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,7 +22,6 @@
*/
package com.oracle.graal.nodes.spi;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.nodes.*;
import com.oracle.graal.nodes.extended.*;
@@ -43,8 +42,6 @@
GuardingNode createGuard(FixedNode before, LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated);
- Assumptions assumptions();
-
/**
* Gets the closest fixed node preceding the node currently being lowered.
*/
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java Thu Feb 12 20:47:20 2015 +0100
@@ -25,7 +25,6 @@
import java.lang.reflect.*;
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.api.replacements.*;
import com.oracle.graal.nodes.*;
@@ -83,11 +82,6 @@
Class extends FixedWithNextNode> getMacroSubstitution(ResolvedJavaMethod method);
/**
- * Gets the assumptions with which replacement graphs are preprocessed.
- */
- Assumptions getAssumptions();
-
- /**
* Registers all the {@linkplain MethodSubstitution method} and {@linkplain MacroSubstitution
* macro} substitutions defined by a given class.
*
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
@@ -35,7 +34,7 @@
/**
* This tool can be used to query the current state (normal/virtualized/re-materialized) of values
* and to describe the actions that would be taken for this state.
- *
+ *
* See also {@link Virtualizable}.
*/
public interface VirtualizerTool {
@@ -52,15 +51,9 @@
ConstantReflectionProvider getConstantReflectionProvider();
/**
- * @return the {@link Assumptions} associated with the current compilation, which can be used to
- * make type assumptions during virtualization.
- */
- Assumptions getAssumptions();
-
- /**
* This method should be used to query the maximum size of virtualized objects before attempting
* virtualization.
- *
+ *
* @return the maximum number of entries for virtualized objects.
*/
int getMaximumEntryCount();
@@ -69,7 +62,7 @@
/**
* Introduces a new virtual object to the current state.
- *
+ *
* @param virtualObject the new virtual object.
* @param entryState the initial state of the virtual object's fields.
* @param locks the initial locking depths.
@@ -79,7 +72,7 @@
/**
* Queries the current state of the given value: if it is virtualized (thread-local and the
* compiler knows all entries) or not.
- *
+ *
* @param value the value whose state should be queried.
* @return the {@link State} representing the value if it has been virtualized at some point,
* null otherwise.
@@ -88,7 +81,7 @@
/**
* Sets the entry (field or array element) with the given index in the virtualized object.
- *
+ *
* @param state the state.
* @param index the index to be set.
* @param value the new value for the given index.
@@ -102,7 +95,7 @@
* Replacements via {@link #replaceWithValue(ValueNode)} are not immediately committed. This
* method can be used to determine if a value was replaced by another one (e.g., a load field by
* the loaded value).
- *
+ *
* @param original the original input value.
* @return the replacement value, or the original value if there is no replacement.
*/
@@ -112,14 +105,14 @@
/**
* Deletes the current node and replaces it with the given virtualized object.
- *
+ *
* @param virtual the virtualized object that should replace the current node.
*/
void replaceWithVirtual(VirtualObjectNode virtual);
/**
* Deletes the current node and replaces it with the given value.
- *
+ *
* @param replacement the value that should replace the current node.
*/
void replaceWithValue(ValueNode replacement);
@@ -131,7 +124,7 @@
/**
* Replaces an input of the current node.
- *
+ *
* @param oldInput the old input value.
* @param replacement the new input value.
*/
@@ -140,7 +133,7 @@
/**
* Adds the given node to the graph.This action will only be performed when, and if, the changes
* are committed.
- *
+ *
* @param node the node to add.
*/
void addNode(ValueNode node);
@@ -148,7 +141,7 @@
/**
* This method performs either {@link #replaceWithValue(ValueNode)} or
* {@link #replaceWithVirtual(VirtualObjectNode)}, depending on the given value.
- *
+ *
* @param value the replacement value
*/
void replaceWith(ValueNode value);
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/GraphUtil.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.graph.iterators.*;
@@ -473,22 +472,16 @@
}
private static final class DefaultSimplifierTool implements SimplifierTool {
- private final Assumptions assumptions;
private final MetaAccessProvider metaAccess;
private final ConstantReflectionProvider constantReflection;
private final boolean canonicalizeReads;
- public DefaultSimplifierTool(Assumptions assumptions, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, boolean canonicalizeReads) {
- this.assumptions = assumptions;
+ public DefaultSimplifierTool(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, boolean canonicalizeReads) {
this.metaAccess = metaAccess;
this.constantReflection = constantReflection;
this.canonicalizeReads = canonicalizeReads;
}
- public Assumptions assumptions() {
- return assumptions;
- }
-
public MetaAccessProvider getMetaAccess() {
return metaAccess;
}
@@ -517,7 +510,7 @@
}
}
- public static SimplifierTool getDefaultSimplifier(Assumptions assumptions, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, boolean canonicalizeReads) {
- return new DefaultSimplifierTool(assumptions, metaAccess, constantReflection, canonicalizeReads);
+ public static SimplifierTool getDefaultSimplifier(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, boolean canonicalizeReads) {
+ return new DefaultSimplifierTool(metaAccess, constantReflection, canonicalizeReads);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -22,12 +22,13 @@
*/
package com.oracle.graal.phases.common;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.debug.*;
import com.oracle.graal.debug.Debug.Scope;
import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Graph.*;
+import com.oracle.graal.graph.Graph.Mark;
+import com.oracle.graal.graph.Graph.NodeEventListener;
+import com.oracle.graal.graph.Graph.NodeEventScope;
import com.oracle.graal.graph.spi.*;
import com.oracle.graal.nodeinfo.*;
import com.oracle.graal.nodes.*;
@@ -394,15 +395,6 @@
GraphUtil.killCFG(branch, this);
}
- /**
- * @return an object that can be used for recording assumptions or {@code null} if
- * assumptions are not allowed in the current context.
- */
- @Override
- public Assumptions assumptions() {
- return context.getAssumptions();
- }
-
@Override
public MetaAccessProvider getMetaAccess() {
return context.getMetaAccess();
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConvertDeoptimizeToGuardPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -49,7 +49,7 @@
*
*/
public class ConvertDeoptimizeToGuardPhase extends Phase {
- private SimplifierTool simplifierTool = GraphUtil.getDefaultSimplifier(null, null, null, false);
+ private SimplifierTool simplifierTool = GraphUtil.getDefaultSimplifier(null, null, false);
private static AbstractBeginNode findBeginNode(FixedNode startNode) {
return GraphUtil.predecessorIterable(startNode).filter(AbstractBeginNode.class).first();
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,7 +26,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.type.*;
import com.oracle.graal.graph.Graph.Mark;
@@ -120,11 +119,6 @@
return createGuard(before, condition, deoptReason, action, false);
}
- @Override
- public Assumptions assumptions() {
- return context.getAssumptions();
- }
-
public StampProvider getStampProvider() {
return context.getStampProvider();
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java Thu Feb 12 20:47:20 2015 +0100
@@ -27,9 +27,8 @@
import com.oracle.graal.nodes.*;
import com.oracle.graal.options.*;
import com.oracle.graal.phases.common.*;
-import com.oracle.graal.phases.common.inlining.policy.GreedyInliningPolicy;
-import com.oracle.graal.phases.common.inlining.policy.InliningPolicy;
-import com.oracle.graal.phases.common.inlining.walker.InliningData;
+import com.oracle.graal.phases.common.inlining.policy.*;
+import com.oracle.graal.phases.common.inlining.walker.*;
import com.oracle.graal.phases.tiers.*;
public class InliningPhase extends AbstractInliningPhase {
@@ -93,5 +92,4 @@
assert data.inliningDepth() == 0;
assert data.graphCount() == 0;
}
-
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java Thu Feb 12 20:47:20 2015 +0100
@@ -114,7 +114,15 @@
public static void logNotInlinedMethod(Invoke invoke, String msg) {
if (shouldLogInliningDecision()) {
- String methodString = invoke.toString() + (invoke.callTarget() == null ? " callTarget=null" : invoke.callTarget().targetName());
+ String methodString = invoke.toString();
+ if (invoke.callTarget() == null) {
+ methodString += " callTarget=null";
+ } else {
+ String targetName = invoke.callTarget().targetName();
+ if (!methodString.endsWith(targetName)) {
+ methodString += " " + targetName;
+ }
+ }
logInliningDecision(methodString, false, msg, new Object[0]);
}
}
@@ -355,6 +363,21 @@
invokeNode.replaceAtUsages(null);
GraphUtil.killCFG(invokeNode);
+ // Copy assumptions from inlinee to caller
+ Assumptions assumptions = graph.getAssumptions();
+ if (assumptions != null) {
+ if (inlineGraph.getAssumptions() != null) {
+ assumptions.record(inlineGraph.getAssumptions());
+ }
+ } else {
+ assert inlineGraph.getAssumptions() == null : "cannot inline graph which makes assumptions into a graph that doesn't: " + inlineGraph + " -> " + graph;
+ }
+
+ // Copy method dependencies from inlinee to caller
+ if (inlineGraph.isMethodRecordingEnabled() && graph.isMethodRecordingEnabled()) {
+ graph.getMethods().addAll(inlineGraph.getMethods());
+ }
+
return duplicates;
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/AbstractInlineInfo.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/AbstractInlineInfo.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/AbstractInlineInfo.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,16 +24,13 @@
import java.util.*;
-import com.oracle.graal.api.code.Assumptions;
-import com.oracle.graal.api.meta.ResolvedJavaMethod;
+import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.common.CanonicalizerPhase;
-import com.oracle.graal.phases.common.inlining.InliningUtil;
-import com.oracle.graal.phases.common.inlining.info.elem.Inlineable;
-import com.oracle.graal.phases.common.inlining.info.elem.InlineableMacroNode;
-import com.oracle.graal.phases.common.inlining.info.elem.InlineableGraph;
-import com.oracle.graal.phases.tiers.HighTierContext;
+import com.oracle.graal.phases.common.*;
+import com.oracle.graal.phases.common.inlining.*;
+import com.oracle.graal.phases.common.inlining.info.elem.*;
+import com.oracle.graal.phases.tiers.*;
public abstract class AbstractInlineInfo implements InlineInfo {
@@ -53,7 +50,7 @@
return invoke;
}
- protected static Collection inline(Invoke invoke, ResolvedJavaMethod concrete, Inlineable inlineable, Assumptions assumptions, boolean receiverNullCheck) {
+ protected static Collection inline(Invoke invoke, ResolvedJavaMethod concrete, Inlineable inlineable, boolean receiverNullCheck) {
List canonicalizeNodes = new ArrayList<>();
if (inlineable instanceof InlineableGraph) {
StructuredGraph calleeGraph = ((InlineableGraph) inlineable).getGraph();
@@ -68,7 +65,10 @@
}
InliningUtil.InlinedBytecodes.add(concrete.getCodeSize());
- assumptions.recordMethodContents(concrete);
+ StructuredGraph graph = invoke.asNode().graph();
+ if (graph.isMethodRecordingEnabled()) {
+ graph.getMethods().add(concrete);
+ }
return canonicalizeNodes;
}
@@ -83,9 +83,9 @@
}
}
- public final void populateInlinableElements(HighTierContext context, Assumptions calleeAssumptions, CanonicalizerPhase canonicalizer) {
+ public final void populateInlinableElements(HighTierContext context, StructuredGraph caller, CanonicalizerPhase canonicalizer) {
for (int i = 0; i < numberOfMethods(); i++) {
- Inlineable elem = Inlineable.getInlineableElement(methodAt(i), invoke, context.replaceAssumptions(calleeAssumptions), canonicalizer);
+ Inlineable elem = Inlineable.getInlineableElement(methodAt(i), invoke, context, canonicalizer);
setInlinableElement(i, elem);
}
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/AssumptionInlineInfo.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/AssumptionInlineInfo.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/AssumptionInlineInfo.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.code.Assumptions.Assumption;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
@@ -47,14 +46,14 @@
}
@Override
- public Collection inline(Providers providers, Assumptions assumptions) {
- assumptions.record(takenAssumption);
- return super.inline(providers, assumptions);
+ public Collection inline(Providers providers) {
+ invoke.asNode().graph().getAssumptions().record(takenAssumption);
+ return super.inline(providers);
}
@Override
- public void tryToDevirtualizeInvoke(Providers providers, Assumptions assumptions) {
- assumptions.record(takenAssumption);
+ public void tryToDevirtualizeInvoke(Providers providers) {
+ invoke.asNode().graph().getAssumptions().record(takenAssumption);
InliningUtil.replaceInvokeCallTarget(invoke, graph(), InvokeKind.Special, concrete);
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/ExactInlineInfo.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/ExactInlineInfo.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/ExactInlineInfo.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
@@ -52,12 +51,12 @@
}
@Override
- public Collection inline(Providers providers, Assumptions assumptions) {
- return inline(invoke, concrete, inlineableElement, assumptions, !suppressNullCheck);
+ public Collection inline(Providers providers) {
+ return inline(invoke, concrete, inlineableElement, !suppressNullCheck);
}
@Override
- public void tryToDevirtualizeInvoke(Providers providers, Assumptions assumptions) {
+ public void tryToDevirtualizeInvoke(Providers providers) {
// nothing todo, can already be bound statically
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/InlineInfo.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/InlineInfo.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/InlineInfo.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.graph.*;
import com.oracle.graal.nodes.*;
@@ -74,16 +73,16 @@
*
* @return a collection of nodes that need to be canonicalized after the inlining
*/
- Collection inline(Providers providers, Assumptions assumptions);
+ Collection inline(Providers providers);
/**
* Try to make the call static bindable to avoid interface and virtual method calls.
*/
- void tryToDevirtualizeInvoke(Providers providers, Assumptions assumptions);
+ void tryToDevirtualizeInvoke(Providers providers);
boolean shouldInline();
- void populateInlinableElements(HighTierContext context, Assumptions calleeAssumptions, CanonicalizerPhase canonicalizer);
+ void populateInlinableElements(HighTierContext context, StructuredGraph caller, CanonicalizerPhase canonicalizer);
int determineNodeCount();
}
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/MultiTypeGuardInlineInfo.java Thu Feb 12 20:47:20 2015 +0100
@@ -26,7 +26,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
import com.oracle.graal.compiler.common.calc.*;
@@ -142,11 +141,11 @@
}
@Override
- public Collection inline(Providers providers, Assumptions assumptions) {
+ public Collection inline(Providers providers) {
if (hasSingleMethod()) {
- return inlineSingleMethod(graph(), providers.getMetaAccess(), assumptions, providers.getStampProvider());
+ return inlineSingleMethod(graph(), providers.getMetaAccess(), providers.getStampProvider());
} else {
- return inlineMultipleMethods(graph(), providers, assumptions);
+ return inlineMultipleMethods(graph(), providers);
}
}
@@ -167,7 +166,7 @@
return notRecordedTypeProbability > 0;
}
- private Collection inlineMultipleMethods(StructuredGraph graph, Providers providers, Assumptions assumptions) {
+ private Collection inlineMultipleMethods(StructuredGraph graph, Providers providers) {
int numberOfMethods = concretes.size();
FixedNode continuation = invoke.next();
@@ -276,7 +275,7 @@
if (opportunities > 0) {
metricInliningTailDuplication.increment();
Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities);
- PhaseContext phaseContext = new PhaseContext(providers, assumptions);
+ PhaseContext phaseContext = new PhaseContext(providers);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!ImmutableCode.getValue());
TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, phaseContext, canonicalizer);
}
@@ -286,7 +285,7 @@
// do the actual inlining for every invoke
for (int i = 0; i < numberOfMethods; i++) {
Invoke invokeForInlining = (Invoke) successors[i].next();
- canonicalizeNodes.addAll(inline(invokeForInlining, methodAt(i), inlineableElementAt(i), assumptions, false));
+ canonicalizeNodes.addAll(inline(invokeForInlining, methodAt(i), inlineableElementAt(i), false));
}
if (returnValuePhi != null) {
canonicalizeNodes.add(returnValuePhi);
@@ -327,7 +326,7 @@
return result;
}
- private Collection inlineSingleMethod(StructuredGraph graph, MetaAccessProvider metaAccess, Assumptions assumptions, StampProvider stampProvider) {
+ private Collection inlineSingleMethod(StructuredGraph graph, MetaAccessProvider metaAccess, StampProvider stampProvider) {
assert concretes.size() == 1 && inlineableElements.length == 1 && ptypes.size() > 1 && !shouldFallbackToInvoke() && notRecordedTypeProbability == 0;
AbstractBeginNode calleeEntryNode = graph.add(new BeginNode());
@@ -338,7 +337,7 @@
calleeEntryNode.setNext(invoke.asNode());
- return inline(invoke, methodAt(0), inlineableElementAt(0), assumptions, false);
+ return inline(invoke, methodAt(0), inlineableElementAt(0), false);
}
private boolean createDispatchOnTypeBeforeInvoke(StructuredGraph graph, AbstractBeginNode[] successors, boolean invokeIsOnlySuccessor, MetaAccessProvider metaAccess, StampProvider stampProvider) {
@@ -511,7 +510,7 @@
}
@Override
- public void tryToDevirtualizeInvoke(Providers providers, Assumptions assumptions) {
+ public void tryToDevirtualizeInvoke(Providers providers) {
if (hasSingleMethod()) {
devirtualizeWithTypeSwitch(graph(), InvokeKind.Special, concretes.get(0), providers.getMetaAccess(), providers.getStampProvider());
} else {
diff -r fcefaa7f103d -r 57c53b1044a7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java Thu Feb 12 20:46:56 2015 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/info/TypeGuardInlineInfo.java Thu Feb 12 20:47:20 2015 +0100
@@ -24,7 +24,6 @@
import java.util.*;
-import com.oracle.graal.api.code.*;
import com.oracle.graal.api.meta.*;
import com.oracle.graal.compiler.common.calc.*;
import com.oracle.graal.graph.*;
@@ -90,13 +89,13 @@
}
@Override
- public Collection inline(Providers providers, Assumptions assumptions) {
+ public Collection