changeset 19102:026749fff52c

Merge
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Tue, 03 Feb 2015 17:15:44 +0100
parents 212299803bf6 (current diff) 71302ef5f55a (diff)
children ccabd82be35c f92ea2a54112
files
diffstat 4 files changed, 121 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/SchedulingTest.java	Tue Feb 03 17:15:44 2015 +0100
@@ -0,0 +1,72 @@
+/*
+ * 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.compiler.test;
+
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.graph.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.cfg.*;
+import com.oracle.graal.nodes.util.*;
+import com.oracle.graal.phases.schedule.*;
+import com.oracle.graal.phases.schedule.SchedulePhase.SchedulingStrategy;
+
+public class SchedulingTest extends GraphScheduleTest {
+
+    public static int testValueProxyInputsSnippet(int s) {
+        int i = 0;
+        while (true) {
+            i++;
+            int v = i - s * 2;
+            if (i == s) {
+                return v;
+            }
+        }
+    }
+
+    @Test
+    public void testValueProxyInputs() {
+        StructuredGraph graph = parseEager("testValueProxyInputsSnippet");
+        for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
+            fs.replaceAtUsages(null);
+            GraphUtil.killWithUnusedFloatingInputs(fs);
+        }
+        SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST);
+        schedule.apply(graph);
+        NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock();
+        assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1);
+        LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first();
+        List<ValueNode> list = schedule.nodesFor(nodeToBlock.get(loopExit));
+        for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
+            if (!(node instanceof AddNode)) {
+                assertTrue(nodeToBlock.get(node) == nodeToBlock.get(loopExit));
+                assertTrue(list.indexOf(node) < list.indexOf(loopExit));
+            }
+        }
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java	Tue Feb 03 17:03:19 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java	Tue Feb 03 17:15:44 2015 +0100
@@ -37,11 +37,13 @@
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.replacements.*;
+import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.HeapAccess.BarrierType;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.debug.*;
 import com.oracle.graal.nodes.extended.*;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.replacements.nodes.*;
 
@@ -108,17 +110,24 @@
     public static final ArrayList<AtomicLong> staticCounters = new ArrayList<>();
 
     @SuppressFBWarnings(value = "AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION", justification = "concurrent abstraction calls are in synchronized block")
-    private static int getIndex(DynamicCounterNode counter) {
+    private static int getIndex(DynamicCounterNode counter, StructuredGraph currentGraph) {
         if (!enabled) {
             throw new GraalInternalError("counter nodes shouldn't exist when counters are not enabled: " + counter.getGroup() + ", " + counter.getName());
         }
         String name;
         String group = counter.getGroup();
         if (counter.isWithContext()) {
-            StructuredGraph graph = counter.graph();
-            name = counter.getName() + " @ " + graph.graphId() + ":" + (graph.method() == null ? "" : graph.method().format("%h.%n"));
-            if (graph.name != null) {
-                name += " (" + graph.name + ")";
+            name = counter.getName() + " @ ";
+            if (currentGraph.method() != null) {
+                StackTraceElement stackTraceElement = currentGraph.method().asStackTraceElement(0);
+                if (stackTraceElement != null) {
+                    name += " " + stackTraceElement.toString();
+                } else {
+                    name += currentGraph.method().format("%h.%n");
+                }
+            }
+            if (currentGraph.name != null) {
+                name += " (" + currentGraph.name + ")";
             }
             name += "#" + group;
 
@@ -374,20 +383,41 @@
         }
     }
 
+    private static final LocationIdentity COUNTER_ARRAY_LOCATION = NamedLocationIdentity.mutable("COUNTER_ARRAY_LOCATION");
     private static final LocationIdentity COUNTER_LOCATION = NamedLocationIdentity.mutable("COUNTER_LOCATION");
 
+    @NodeInfo(nameTemplate = "CounterIndex")
+    private static class CounterIndexNode extends FloatingNode implements LIRLowerable {
+
+        protected final Object counter;
+        protected final int countersSize;
+
+        protected CounterIndexNode(Stamp stamp, DynamicCounterNode counter, int countersSize) {
+            super(stamp);
+            this.countersSize = countersSize;
+            this.counter = counter;
+        }
+
+        @Override
+        public void generate(NodeLIRBuilderTool generator) {
+            int index = BenchmarkCounters.getIndex((DynamicCounterNode) counter, graph());
+            if (index >= countersSize) {
+                throw new GraalInternalError("too many counters, reduce number of counters or increase -XX:GraalCounterSize=... (current value: " + countersSize + ")");
+            }
+
+            generator.setResult(this, JavaConstant.forIntegerKind(getKind(), index));
+        }
+    }
+
     public static void lower(DynamicCounterNode counter, HotSpotRegistersProvider registers, HotSpotVMConfig config, Kind wordKind) {
         StructuredGraph graph = counter.graph();
 
         ReadRegisterNode thread = graph.add(new ReadRegisterNode(registers.getThreadRegister(), wordKind, true, false));
 
-        int index = BenchmarkCounters.getIndex(counter);
-        if (index >= config.graalCountersSize) {
-            throw new GraalInternalError("too many counters, reduce number of counters or increase -XX:GraalCounterSize=... (current value: " + config.graalCountersSize + ")");
-        }
-        ConstantLocationNode arrayLocation = graph.unique(new ConstantLocationNode(COUNTER_LOCATION, config.graalCountersThreadOffset));
+        CounterIndexNode index = graph.unique(new CounterIndexNode(StampFactory.forKind(wordKind), counter, config.graalCountersSize));
+        ConstantLocationNode arrayLocation = graph.unique(new ConstantLocationNode(COUNTER_ARRAY_LOCATION, config.graalCountersThreadOffset));
         ReadNode readArray = graph.add(new ReadNode(thread, arrayLocation, StampFactory.forKind(wordKind), BarrierType.NONE));
-        ConstantLocationNode location = graph.unique(new ConstantLocationNode(COUNTER_LOCATION, Unsafe.ARRAY_LONG_INDEX_SCALE * index));
+        IndexedLocationNode location = graph.unique(new IndexedLocationNode(COUNTER_LOCATION, 0, index, Unsafe.ARRAY_LONG_INDEX_SCALE));
         ReadNode read = graph.add(new ReadNode(readArray, location, StampFactory.forKind(Kind.Long), BarrierType.NONE));
         AddNode add = graph.unique(new AddNode(read, counter.getIncrement()));
         WriteNode write = graph.add(new WriteNode(readArray, add, location, BarrierType.NONE));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Tue Feb 03 17:03:19 2015 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSnippetReflectionProvider.java	Tue Feb 03 17:15:44 2015 +0100
@@ -41,12 +41,18 @@
 
     @Override
     public Object asObject(ResolvedJavaType type, JavaConstant constant) {
+        if (constant.isNull()) {
+            return null;
+        }
         HotSpotObjectConstant hsConstant = (HotSpotObjectConstant) constant;
         return hsConstant.asObject(type);
     }
 
     @Override
     public <T> T asObject(Class<T> type, JavaConstant constant) {
+        if (constant.isNull()) {
+            return null;
+        }
         HotSpotObjectConstant hsConstant = (HotSpotObjectConstant) constant;
         return hsConstant.asObject(type);
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategyNew.java	Tue Feb 03 17:03:19 2015 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/DefaultTruffleSplittingStrategyNew.java	Tue Feb 03 17:15:44 2015 +0100
@@ -38,14 +38,14 @@
     public DefaultTruffleSplittingStrategyNew(OptimizedDirectCallNode call) {
         this.call = call;
         this.splitStart = TruffleCompilerOptions.TruffleSplittingStartCallCount.getValue();
-        this.splittingEnabled = isSplittingEnabled();
+        this.splittingEnabled = isSplittingEnabled(call);
         this.argumentStamp = DefaultTruffleStamp.getInstance();
         if (TruffleCompilerOptions.TruffleSplittingAggressive.getValue()) {
             splittingForced = true;
         }
     }
 
-    private boolean isSplittingEnabled() {
+    private static boolean isSplittingEnabled(OptimizedDirectCallNode call) {
         if (!TruffleCompilerOptions.TruffleSplitting.getValue()) {
             return false;
         }