changeset 16058:45bd621d9bb9

Merge
author Miguel Garcia <miguel.m.garcia@oracle.com>
date Fri, 06 Jun 2014 12:16:45 +0200
parents 83efd0e68a4a (current diff) 87e11e4c031f (diff)
children bab1a955411e
files
diffstat 6 files changed, 155 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Fri Jun 06 11:47:56 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Fri Jun 06 12:16:45 2014 +0200
@@ -651,7 +651,7 @@
                 MidTierContext midContext = new MidTierContext(getProviders(), assumptions, 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.MID_TIER).apply(graph, midContext);
+                new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, midContext);
 
                 SchedulePhase schedule = new SchedulePhase(schedulingStrategy, memsched);
                 schedule.apply(graph);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/NestedLoop_EA.java	Fri Jun 06 12:16:45 2014 +0200
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, 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.jtt.optimize;
+
+import java.util.*;
+
+import org.junit.*;
+
+import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.jtt.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.virtual.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.common.*;
+import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.virtual.phases.ea.*;
+
+public class NestedLoop_EA extends JTTTest {
+
+    @Override
+    protected Suites createSuites() {
+        Suites suites = super.createSuites();
+        ListIterator<BasePhase<? super HighTierContext>> position = suites.getHighTier().findPhase(PartialEscapePhase.class);
+        CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!GraalOptions.ImmutableCode.getValue());
+        // incremental canonicalizer of PEA is missing some important canonicalization (TODO?)
+        position.add(canonicalizer);
+        position.add(new PartialEscapePhase(true, canonicalizer));
+        return suites;
+    }
+
+    static class Frame {
+        Object objects[] = new Object[10];
+    }
+
+    final static int RESULT_SLOT = 0;
+    final static int K_SLOT = 1;
+    final static int I_SLOT = 2;
+    final static int ARG_SLOT = 3;
+    final static int STACK_BASE = 4;
+
+    static class Pointer {
+        public int sp = STACK_BASE;
+    }
+
+    public static int simpleLoop(int arg) {
+        Frame f = new Frame();
+        Pointer p = new Pointer();
+        f.objects[ARG_SLOT] = arg;
+        f.objects[RESULT_SLOT] = 0;
+        f.objects[K_SLOT] = 0;
+        for (; (int) f.objects[K_SLOT] < (int) f.objects[ARG_SLOT];) {
+
+            f.objects[RESULT_SLOT] = (int) f.objects[RESULT_SLOT] + 5;
+
+            f.objects[++p.sp] = f.objects[K_SLOT];
+            f.objects[++p.sp] = 1;
+            int result = (int) f.objects[p.sp] + (int) f.objects[p.sp - 1];
+            p.sp--;
+            f.objects[p.sp] = result;
+            f.objects[K_SLOT] = (int) f.objects[p.sp];
+            p.sp--;
+        }
+        return (int) f.objects[RESULT_SLOT];
+    }
+
+    @Test
+    public void run0() throws Throwable {
+        runTest("simpleLoop", 5);
+    }
+
+    public static int nestedLoop(int arg) {
+        Frame f = new Frame();
+        Pointer p = new Pointer();
+        f.objects[ARG_SLOT] = arg;
+        f.objects[RESULT_SLOT] = 0;
+        f.objects[K_SLOT] = 0;
+        for (; (int) f.objects[K_SLOT] < (int) f.objects[ARG_SLOT];) {
+
+            f.objects[I_SLOT] = 0;
+            for (; (int) f.objects[I_SLOT] < (int) f.objects[ARG_SLOT];) {
+                f.objects[RESULT_SLOT] = (int) f.objects[RESULT_SLOT] + 5;
+
+                f.objects[++p.sp] = f.objects[I_SLOT];
+                f.objects[++p.sp] = 1;
+                int result = (int) f.objects[p.sp] + (int) f.objects[p.sp - 1];
+                p.sp--;
+                f.objects[p.sp] = result;
+                f.objects[I_SLOT] = (int) f.objects[p.sp];
+                p.sp--;
+            }
+
+            f.objects[++p.sp] = f.objects[K_SLOT];
+            f.objects[++p.sp] = 1;
+            int result = (int) f.objects[p.sp] + (int) f.objects[p.sp - 1];
+            p.sp--;
+            f.objects[p.sp] = result;
+            f.objects[K_SLOT] = (int) f.objects[p.sp];
+            p.sp--;
+        }
+        return (int) f.objects[RESULT_SLOT];
+    }
+
+    @Test
+    public void run1() throws Throwable {
+        runTest("nestedLoop", 5);
+    }
+
+    @Override
+    protected boolean checkHighTierGraph(StructuredGraph graph) {
+        assert graph.getNodes().filter(CommitAllocationNode.class).count() == 0 : "all allocations should be virtualized";
+        return true;
+    }
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerAssertsSubstitutions.java	Fri Jun 06 11:47:56 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerAssertsSubstitutions.java	Fri Jun 06 12:16:45 2014 +0200
@@ -33,6 +33,9 @@
     @MacroSubstitution(macro = NeverPartOfCompilationNode.class, isStatic = true)
     public static native void neverPartOfCompilation();
 
+    @MacroSubstitution(macro = NeverPartOfCompilationNode.class, isStatic = true)
+    public static native void neverPartOfCompilation(String message);
+
     @MacroSubstitution(macro = CompilationConstantNode.class, isStatic = true)
     public static native boolean compilationConstant(boolean value);
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java	Fri Jun 06 11:47:56 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerAsserts.java	Fri Jun 06 12:16:45 2014 +0200
@@ -29,7 +29,7 @@
  * either executed in the interpreter or in the compiled code. The assertions are checked during
  * code generation and the Truffle compiler produces for failing assertions a stack trace that
  * identifies the code position of the assertion in the context of the current compilation.
- * 
+ *
  */
 public class CompilerAsserts {
 
@@ -42,9 +42,12 @@
     public static void neverPartOfCompilation() {
     }
 
+    public static void neverPartOfCompilation(@SuppressWarnings("unused") String message) {
+    }
+
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -54,7 +57,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -64,7 +67,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -74,7 +77,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -84,7 +87,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -94,7 +97,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -104,7 +107,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -114,7 +117,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
@@ -124,7 +127,7 @@
 
     /**
      * Assertion that the corresponding value is reduced to a constant during compilation.
-     * 
+     *
      * @param value the value that must be constant during compilation
      * @return the value given as parameter
      */
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java	Fri Jun 06 11:47:56 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java	Fri Jun 06 12:16:45 2014 +0200
@@ -57,6 +57,7 @@
     }
 
     public FrameSlot addFrameSlot(Object identifier, FrameSlotKind kind) {
+        CompilerAsserts.neverPartOfCompilation("interpreter-only.  includes hashmap operations.");
         assert !identifierToSlotMap.containsKey(identifier);
         FrameSlot slot = new FrameSlot(this, identifier, slots.size(), kind);
         slots.add(slot);
@@ -87,6 +88,7 @@
     }
 
     public void removeFrameSlot(Object identifier) {
+        CompilerAsserts.neverPartOfCompilation("interpreter-only.  includes hashmap operations.");
         assert identifierToSlotMap.containsKey(identifier);
         slots.remove(identifierToSlotMap.get(identifier));
         identifierToSlotMap.remove(identifier);
@@ -104,7 +106,7 @@
 
     /**
      * Retrieve the list of all the identifiers associated with this frame descriptor.
-     * 
+     *
      * @return the list of all the identifiers in this frame descriptor
      */
     public Set<Object> getIdentifiers() {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java	Fri Jun 06 11:47:56 2014 +0200
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameSlot.java	Fri Jun 06 12:16:45 2014 +0200
@@ -25,6 +25,7 @@
 package com.oracle.truffle.api.frame;
 
 import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
 
 /**
  * A slot in a frame that can store a value of a given type.
@@ -34,7 +35,7 @@
     private final FrameDescriptor descriptor;
     private final Object identifier;
     private final int index;
-    @com.oracle.truffle.api.CompilerDirectives.CompilationFinal private FrameSlotKind kind;
+    @CompilationFinal private FrameSlotKind kind;
 
     public FrameSlot(FrameDescriptor descriptor, Object identifier, int index, FrameSlotKind kind) {
         this.descriptor = descriptor;