# HG changeset patch # User Lukas Stadler # Date 1371220090 -7200 # Node ID 55bf0dc8e28109bc2ef68f76f4f88c291ff0e2b6 # Parent ec8dd267d882febb654c1ec2a130665cc85d0b1e# Parent 0b30da13d86b4d29f81b7873feadfd343fd45fe2 Merge diff -r 0b30da13d86b -r 55bf0dc8e281 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 Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Fri Jun 14 16:28:10 2013 +0200 @@ -310,7 +310,6 @@ HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); new PartialEscapePhase(false, new CanonicalizerPhase(true)).apply(graph, context); - new CullFrameStatesPhase().apply(graph); } private void compareGraphs(final String snippet, final String referenceSnippet) { @@ -335,7 +334,6 @@ canonicalizer.apply(graph, context); new PartialEscapePhase(false, canonicalizer).apply(graph, context); - new CullFrameStatesPhase().apply(graph); new DeadCodeEliminationPhase().apply(graph); canonicalizer.apply(graph, context); diff -r 0b30da13d86b -r 55bf0dc8e281 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 Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/StampCanonicalizerTest.java Fri Jun 14 16:28:10 2013 +0200 @@ -96,6 +96,17 @@ testZeroReturn("divStamp2"); } + public static int distinctMask(int a, int b) { + int x = a & 0xaaaa; + int y = (b & 0x5555) | 0x1; + return x == y ? 1 : 0; + } + + @Test + public void testDistinctMask() { + testZeroReturn("distinctMask"); + } + private void testZeroReturn(String methodName) { StructuredGraph graph = parse(methodName); new CanonicalizerPhase.Instance(runtime(), new Assumptions(false), true).apply(graph); diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Fri Jun 14 16:28:10 2013 +0200 @@ -168,7 +168,9 @@ canonicalizer.apply(graph, context); new PartialEscapePhase(false, canonicalizer).apply(graph, context); - new CullFrameStatesPhase().apply(graph); + for (MergeNode merge : graph.getNodes(MergeNode.class)) { + merge.setStateAfter(null); + } new DeadCodeEliminationPhase().apply(graph); canonicalizer.apply(graph, context); return graph; diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Fri Jun 14 16:28:10 2013 +0200 @@ -60,10 +60,6 @@ } appendPhase(new RemoveValueProxyPhase()); - if (CullFrameStates.getValue()) { - appendPhase(new CullFrameStatesPhase()); - } - if (OptCanonicalizer.getValue()) { appendPhase(canonicalizer); } diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeFlood.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeFlood.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeFlood.java Fri Jun 14 16:28:10 2013 +0200 @@ -43,7 +43,7 @@ } } - public void addAll(Iterable nodes) { + public void addAll(Iterable nodes) { for (Node node : nodes) { this.add(node); } diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Fri Jun 14 16:28:10 2013 +0200 @@ -64,7 +64,7 @@ return graph.unique(new IndexedLocationNode(identity, kind, displacement, index, indexScaling)); } - private IndexedLocationNode(LocationIdentity identity, Kind kind, long displacement, ValueNode index, int indexScaling) { + public IndexedLocationNode(LocationIdentity identity, Kind kind, long displacement, ValueNode index, int indexScaling) { super(StampFactory.extension()); assert kind != Kind.Illegal && kind != Kind.Void; this.valueKind = kind; diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java Fri Jun 14 16:28:10 2013 +0200 @@ -129,7 +129,15 @@ @Override public boolean alwaysDistinct(Stamp otherStamp) { IntegerStamp other = (IntegerStamp) otherStamp; - return lowerBound > other.upperBound || upperBound < other.lowerBound; + if (lowerBound > other.upperBound || upperBound < other.lowerBound) { + return true; + } else { + if ((mask & other.mask) == 0) { + // zero is the only common value if the masks don't overlap => check for non-zero + return lowerBound > 0 || upperBound < 0 || other.lowerBound > 0 || other.upperBound < 0; + } + return false; + } } @Override diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java Fri Jun 14 16:28:10 2013 +0200 @@ -101,6 +101,10 @@ private static final long LONG_SIGN_BIT = 0x8000000000000000L; private static Stamp stampForMask(Kind kind, long mask) { + return stampForMask(kind, mask, 0); + } + + private static Stamp stampForMask(Kind kind, long mask, long alwaysSetBits) { long lowerBound; long upperBound; if (kind == Kind.Int && (mask & INTEGER_SIGN_BIT) != 0) { @@ -112,7 +116,7 @@ lowerBound = Long.MIN_VALUE; upperBound = mask ^ LONG_SIGN_BIT; } else { - lowerBound = 0; + lowerBound = alwaysSetBits; upperBound = mask; } return StampFactory.forInteger(kind, lowerBound, upperBound, mask); @@ -127,7 +131,11 @@ public static Stamp or(IntegerStamp stamp1, IntegerStamp stamp2) { Kind kind = stamp1.kind(); long mask = stamp1.mask() | stamp2.mask(); - return stampForMask(kind, mask); + if (stamp1.lowerBound() >= 0 && stamp2.lowerBound() >= 0) { + return stampForMask(kind, mask, stamp1.lowerBound() | stamp2.lowerBound()); + } else { + return stampForMask(kind, mask); + } } public static Stamp xor(IntegerStamp stamp1, IntegerStamp stamp2) { diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CullFrameStatesPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CullFrameStatesPhase.java Fri Jun 14 15:01:20 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2012, 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.phases.common; - -import java.util.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.util.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.phases.graph.*; - -/** - * This phase culls unused FrameStates from the graph. It does a post order iteration over the - * graph, and - */ -public class CullFrameStatesPhase extends Phase { - - private static final DebugMetric metricFrameStatesCulled = Debug.metric("FrameStatesCulled"); - private static final DebugMetric metricNodesRemoved = Debug.metric("NodesRemoved"); - private static final DebugMetric metricMergesTraversed = Debug.metric("MergesTraversed"); - - @Override - protected void run(StructuredGraph graph) { - int initialNodes = graph.getNodeCount(); - new CullFrameStates(graph.start(), new State(null)).apply(); - metricNodesRemoved.add(initialNodes - graph.getNodeCount()); - } - - public static class State implements MergeableState { - - private FrameState lastFrameState; - - public State(FrameState lastFrameState) { - this.lastFrameState = lastFrameState; - } - - @Override - public boolean merge(MergeNode merge, List withStates) { - FrameState stateAfter = merge.stateAfter(); - if (merge instanceof LoopBeginNode) { - if (stateAfter != null) { - lastFrameState = stateAfter; - } - return true; - } - metricMergesTraversed.increment(); - if (stateAfter != null) { - for (State other : withStates) { - if (other.lastFrameState != lastFrameState) { - lastFrameState = stateAfter; - return true; - } - } - metricFrameStatesCulled.increment(); - merge.setStateAfter(null); - if (stateAfter.usages().isEmpty()) { - GraphUtil.killWithUnusedFloatingInputs(stateAfter); - } - } - return true; - } - - @Override - public void loopBegin(LoopBeginNode loopBegin) { - } - - @Override - public void loopEnds(LoopBeginNode loopBegin, List loopEndStates) { - } - - @Override - public void afterSplit(AbstractBeginNode node) { - } - - @Override - public State clone() { - return new State(lastFrameState); - } - } - - public static class CullFrameStates extends PostOrderNodeIterator { - - public CullFrameStates(FixedNode start, State initialState) { - super(start, initialState); - } - - @Override - protected void node(FixedNode node) { - if (node instanceof StateSplit) { - FrameState stateAfter = ((StateSplit) node).stateAfter(); - if (stateAfter != null) { - state.lastFrameState = stateAfter; - } - } - } - } - -} diff -r 0b30da13d86b -r 55bf0dc8e281 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 Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Fri Jun 14 16:28:10 2013 +0200 @@ -312,9 +312,6 @@ new CanonicalizerPhase.Instance(runtime, assumptions, !AOTCompilation.getValue()).apply(newGraph); } - if (CullFrameStates.getValue()) { - new CullFrameStatesPhase().apply(newGraph); - } if (CacheGraphs.getValue() && cache != null) { cache.put(newGraph.copy(), hasMatureProfilingInfo); } diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Fri Jun 14 16:28:10 2013 +0200 @@ -198,8 +198,6 @@ @Option(help = "") public static final OptionValue ConditionalElimination = new OptionValue<>(true); @Option(help = "") - public static final OptionValue CullFrameStates = new OptionValue<>(false); - @Option(help = "") public static final OptionValue UseProfilingInformation = new OptionValue<>(true); @Option(help = "") static final OptionValue RemoveNeverExecutedCode = new OptionValue<>(true); diff -r 0b30da13d86b -r 55bf0dc8e281 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java Fri Jun 14 15:01:20 2013 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java Fri Jun 14 16:28:10 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.virtual.phases.ea; +import static com.oracle.graal.phases.GraalOptions.*; + import java.util.*; import com.oracle.graal.debug.*; @@ -82,7 +84,9 @@ @Override protected Void processBlock(Block block, Void currentState) { apply(blockEffects.get(block), block); - Debug.dump(graph, "after processing block %s", block); + if (TraceEscapeAnalysis.getValue()) { + Debug.dump(graph, "after processing block %s", block); + } return currentState; } @@ -109,7 +113,7 @@ @Override protected BlockT processBlock(Block block, BlockT state) { - VirtualUtil.trace("\nBlock: %s (", block); + VirtualUtil.trace("\nBlock: %s, preds: %s, succ: %s (", block, block.getPredecessors(), block.getSuccessors()); GraphEffectList effects = blockEffects.get(block); FixedWithNextNode lastFixedNode = null; @@ -130,6 +134,7 @@ assert blockEffects.get(merge).isEmpty(); MergeProcessor processor = createMergeProcessor(merge); processor.merge(states); + processor.commitEnds(states); blockEffects.get(merge).addAll(processor.mergeEffects); blockEffects.get(merge).addAll(processor.afterMergeEffects); return processor.newState; @@ -138,7 +143,7 @@ @Override protected final List processLoop(Loop loop, BlockT initialState) { BlockT loopEntryState = initialState; - BlockT lastMergedState = initialState; + BlockT lastMergedState = cloneState(initialState); MergeProcessor mergeProcessor = createMergeProcessor(loop.header); for (int iteration = 0; iteration < 10; iteration++) { LoopInfo info = ReentrantBlockIterator.processLoop(this, loop, cloneState(lastMergedState)); @@ -154,6 +159,8 @@ Debug.log("%s", lastMergedState); if (mergeProcessor.newState.equivalentTo(lastMergedState)) { + mergeProcessor.commitEnds(states); + blockEffects.get(loop.header).insertAll(mergeProcessor.mergeEffects, 0); loopMergeEffects.put(loop, mergeProcessor.afterMergeEffects); @@ -198,6 +205,12 @@ protected void merge(List states) { newState = getInitialState(); newState.meetAliases(states); + mergeEffects.clear(); + afterMergeEffects.clear(); + } + + @SuppressWarnings("unused") + protected void commitEnds(List states) { } } } diff -r 0b30da13d86b -r 55bf0dc8e281 mxtool/mx.py --- a/mxtool/mx.py Fri Jun 14 15:01:20 2013 +0200 +++ b/mxtool/mx.py Fri Jun 14 16:28:10 2013 +0200 @@ -2652,6 +2652,7 @@ shutil.rmtree(join(p.dir, 'nbproject'), ignore_errors=True) rm(join(p.dir, '.classpath')) rm(join(p.dir, '.project')) + rm(join(p.dir, '.factorypath')) rm(join(p.dir, 'build.xml')) rm(join(p.dir, 'eclipse-build.xml')) try: