# HG changeset patch # User Tom Rodriguez # Date 1390523757 28800 # Node ID 978587c9137375de930fc94725842b7323a32242 # Parent d96dbd96bb4518c80714c4b1633f84aae2d1aedc# Parent bfd61161d75233becf9b6d2fe4de85268a63e890 Merge diff -r bfd61161d752 -r 978587c91373 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 Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Jan 23 16:35:57 2014 -0800 @@ -138,6 +138,7 @@ public static T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target, GraphCache cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, boolean withScope, T compilationResult, CompilationResultBuilderFactory factory) { + assert !graph.isFrozen(); try (Scope s0 = withScope ? Debug.scope("GraalCompiler", graph, providers.getCodeCache()) : null) { Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); LIR lir = null; diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Thu Jan 23 16:35:57 2014 -0800 @@ -75,6 +75,12 @@ NodeChangedListener usagesDroppedToZeroListener; private final HashMap cachedNodes = new HashMap<>(); + /* + * Indicates that the graph should no longer be modified. Frozen graphs can be used my multiple + * threads so it's only safe to read them. + */ + private boolean isFrozen = false; + private static final class CacheEntry { private final Node node; @@ -761,6 +767,7 @@ } void register(Node node) { + assert !isFrozen(); assert node.id() == Node.INITIAL_ID; if (nodes.length == nodesSize) { nodes = Arrays.copyOf(nodes, (nodesSize * 2) + 1); @@ -812,6 +819,7 @@ } void unregister(Node node) { + assert !isFrozen(); assert !node.isDeleted() : "cannot delete a node twice! node=" + node; logNodeDeleted(node); nodes[node.id] = null; @@ -896,4 +904,12 @@ public Map addDuplicates(Iterable newNodes, final Graph oldGraph, int estimatedNodeCount, DuplicationReplacement replacements) { return NodeClass.addGraphDuplicate(this, oldGraph, estimatedNodeCount, newNodes, replacements); } + + public boolean isFrozen() { + return isFrozen; + } + + public void freeze() { + this.isFrozen = true; + } } diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Thu Jan 23 16:35:57 2014 -0800 @@ -488,6 +488,7 @@ * this node to newSuccessor's predecessors. */ protected void updatePredecessor(Node oldSuccessor, Node newSuccessor) { + assert graph == null || !graph.isFrozen(); if (oldSuccessor != newSuccessor) { if (oldSuccessor != null) { assert assertTrue(oldSuccessor.predecessor == this, "wrong predecessor in old successor (%s): %s", oldSuccessor, oldSuccessor.predecessor); @@ -517,6 +518,7 @@ } private boolean checkReplaceWith(Node other) { + assert assertTrue(graph == null || !graph.isFrozen(), "cannot modify frozen graph"); assert assertFalse(other == this, "cannot replace a node with itself"); assert assertFalse(isDeleted(), "cannot replace deleted node"); assert assertTrue(other == null || !other.isDeleted(), "cannot replace with deleted node %s", other); @@ -574,6 +576,7 @@ public void clearInputs() { assert assertFalse(isDeleted(), "cannot clear inputs of deleted node"); + assert graph == null || !graph.isFrozen(); for (Node input : inputs()) { if (input.recordsUsages()) { diff -r bfd61161d752 -r 978587c91373 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 Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Thu Jan 23 16:35:57 2014 -0800 @@ -172,6 +172,7 @@ return Boolean.valueOf(true); } + @Ignore("ImmutableCode override may not work reliably in non-hosted mode") @Test public void testBoxedBooleanAOT() { StructuredGraph result = compile("getBoxedBoolean", true); diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Thu Jan 23 16:35:57 2014 -0800 @@ -115,6 +115,7 @@ ResolvedJavaMethod installedCodeOwner = getMetaAccess().lookupJavaMethod(method); StructuredGraph graph = getReplacements().getMethodSubstitution(installedCodeOwner); if (graph != null) { + graph = graph.copy(); Assert.assertNotNull(getCode(installedCodeOwner, graph, true)); atLeastOneCompiled = true; } else { diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Thu Jan 23 16:35:57 2014 -0800 @@ -857,7 +857,7 @@ @Override public String toString() { - return MetaUtil.format("%H.%n(%p)", method()) + remainingInvokes; + return (graph != null ? MetaUtil.format("%H.%n(%p)", method()) : "") + remainingInvokes; } } diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Jan 23 16:35:57 2014 -0800 @@ -135,7 +135,9 @@ if (graph == null) { graphs.putIfAbsent(substitute, makeGraph(substitute, original, substitute, inliningPolicy(substitute), FrameStateProcessing.None)); graph = graphs.get(substitute); + graph.freeze(); } + assert graph.isFrozen(); return graph; } diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerAddExactNode.java Thu Jan 23 16:35:57 2014 -0800 @@ -84,8 +84,12 @@ } @NodeIntrinsic - public static native int addExact(int a, int b); + public static int addExact(int a, int b) { + return ExactMath.addExact(a, b); + } @NodeIntrinsic - public static native long addExact(long a, long b); + public static long addExact(long a, long b) { + return ExactMath.addExact(a, b); + } } diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerMulExactNode.java Thu Jan 23 16:35:57 2014 -0800 @@ -80,8 +80,12 @@ } @NodeIntrinsic - public static native int multiplyExact(int a, int b); + public static int multiplyExact(int a, int b) { + return ExactMath.multiplyExact(a, b); + } @NodeIntrinsic - public static native long multiplyExact(long a, long b); + public static long multiplyExact(long a, long b) { + return ExactMath.multiplyExact(a, b); + } } diff -r bfd61161d752 -r 978587c91373 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java Fri Jan 24 00:52:06 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerSubExactNode.java Thu Jan 23 16:35:57 2014 -0800 @@ -84,8 +84,12 @@ } @NodeIntrinsic - public static native int subtractExact(int a, int b); + public static int subtractExact(int a, int b) { + return ExactMath.subtractExact(a, b); + } @NodeIntrinsic - public static native long subtractExact(long a, long b); + public static long subtractExact(long a, long b) { + return ExactMath.subtractExact(a, b); + } }