changeset 10050:55bf0dc8e281

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 14 Jun 2013 16:28:10 +0200
parents ec8dd267d882 (diff) 0b30da13d86b (current diff)
children 215a4291e387
files
diffstat 13 files changed, 52 insertions(+), 139 deletions(-) [+]
line wrap: on
line diff
--- 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);
 
--- 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);
--- 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;
--- 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);
         }
--- 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<Node> nodes) {
+    public void addAll(Iterable<? extends Node> nodes) {
         for (Node node : nodes) {
             this.add(node);
         }
--- 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;
--- 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
--- 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) {
--- 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<State> {
-
-        private FrameState lastFrameState;
-
-        public State(FrameState lastFrameState) {
-            this.lastFrameState = lastFrameState;
-        }
-
-        @Override
-        public boolean merge(MergeNode merge, List<State> 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<State> loopEndStates) {
-        }
-
-        @Override
-        public void afterSplit(AbstractBeginNode node) {
-        }
-
-        @Override
-        public State clone() {
-            return new State(lastFrameState);
-        }
-    }
-
-    public static class CullFrameStates extends PostOrderNodeIterator<State> {
-
-        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;
-                }
-            }
-        }
-    }
-
-}
--- 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);
         }
--- 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<Boolean> ConditionalElimination = new OptionValue<>(true);
     @Option(help = "")
-    public static final OptionValue<Boolean> CullFrameStates = new OptionValue<>(false);
-    @Option(help = "")
     public static final OptionValue<Boolean> UseProfilingInformation = new OptionValue<>(true);
     @Option(help = "")
            static final OptionValue<Boolean> RemoveNeverExecutedCode = new OptionValue<>(true);
--- 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<BlockT> 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<BlockT> 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<BlockT> states) {
             newState = getInitialState();
             newState.meetAliases(states);
+            mergeEffects.clear();
+            afterMergeEffects.clear();
+        }
+
+        @SuppressWarnings("unused")
+        protected void commitEnds(List<BlockT> states) {
         }
     }
 }
--- 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: