changeset 18576:487c792de3dc

Merge.
author Doug Simon <doug.simon@oracle.com>
date Sun, 30 Nov 2014 00:17:21 +0000
parents 351cc8ee5e3f (current diff) a65c1032f400 (diff)
children c296b906b9eb
files
diffstat 10 files changed, 100 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/AMD64AllocatorTest.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/AMD64AllocatorTest.java	Sun Nov 30 00:17:21 2014 +0000
@@ -38,7 +38,7 @@
 
     @Test
     public void test1() {
-        test("test1snippet", 3, 1, 0);
+        testAllocation("test1snippet", 3, 1, 0);
     }
 
     public static long test1snippet(long x) {
@@ -47,7 +47,7 @@
 
     @Test
     public void test2() {
-        test("test2snippet", 3, 0, 0);
+        testAllocation("test2snippet", 3, 0, 0);
     }
 
     public static long test2snippet(long x) {
@@ -57,7 +57,7 @@
     @Ignore
     @Test
     public void test3() {
-        test("test3snippet", 4, 1, 0);
+        testAllocation("test3snippet", 4, 1, 0);
     }
 
     public static long test3snippet(long x) {
--- a/graal/com.oracle.graal.compiler.sparc.test/src/com/oracle/graal/compiler/sparc/test/SPARCAllocatorTest.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.compiler.sparc.test/src/com/oracle/graal/compiler/sparc/test/SPARCAllocatorTest.java	Sun Nov 30 00:17:21 2014 +0000
@@ -38,7 +38,7 @@
 
     @Test
     public void test1() {
-        test("test1snippet", 1, 0, 0);
+        testAllocation("test1snippet", 1, 0, 0);
     }
 
     public static long test1snippet(long x) {
@@ -47,7 +47,7 @@
 
     @Test
     public void test2() {
-        test("test2snippet", 2, 1, 0);
+        testAllocation("test2snippet", 2, 1, 0);
     }
 
     public static long test2snippet(long x) {
@@ -56,7 +56,7 @@
 
     @Test
     public void test3() {
-        test("test3snippet", 3, 1, 0);
+        testAllocation("test3snippet", 3, 1, 0);
     }
 
     public static long test3snippet(long x) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Sun Nov 30 00:17:21 2014 +0000
@@ -22,34 +22,25 @@
  */
 package com.oracle.graal.compiler.test.backend;
 
-import static com.oracle.graal.api.code.CodeUtil.*;
-import static com.oracle.graal.compiler.common.GraalOptions.*;
-
 import java.util.*;
 
 import org.junit.*;
 
 import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.CallingConvention.Type;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.common.cfg.*;
-import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.MoveOp;
-import com.oracle.graal.lir.gen.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.schedule.*;
 
-public class AllocatorTest extends GraalCompilerTest {
+public class AllocatorTest extends BackendTest {
 
-    protected void test(String snippet, final int expectedRegisters, final int expectedRegRegMoves, final int expectedSpillMoves) {
+    protected void testAllocation(String snippet, final int expectedRegisters, final int expectedRegRegMoves, final int expectedSpillMoves) {
         final StructuredGraph graph = parseEager(snippet);
         try (Scope s = Debug.scope("AllocatorTest", graph, graph.method(), getCodeCache())) {
-            final RegisterStats stats = getRegisterStats(graph);
+            final RegisterStats stats = new RegisterStats(getLIRGenerationResult(graph).getLIR());
             try (Scope s2 = Debug.scope("Assertions", stats.lir)) {
                 Assert.assertEquals("register count", expectedRegisters, stats.registers.size());
                 Assert.assertEquals("reg-reg moves", expectedRegRegMoves, stats.regRegMoves);
@@ -104,20 +95,4 @@
             }
         }
     }
-
-    private RegisterStats getRegisterStats(final StructuredGraph graph) {
-        final Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
-
-        SchedulePhase schedule = null;
-        try (Scope s = Debug.scope("FrontEnd")) {
-            schedule = GraalCompiler.emitFrontEnd(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
-                            graph.method().getProfilingInfo(), null, getSuites());
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
-
-        CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
-        LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null);
-        return new RegisterStats(lirGen.getLIR());
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java	Sun Nov 30 00:17:21 2014 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2014, 2014, 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.backend;
+
+import static com.oracle.graal.api.code.CodeUtil.*;
+import static com.oracle.graal.compiler.common.GraalOptions.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.CallingConvention.Type;
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.test.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.Debug.Scope;
+import com.oracle.graal.lir.gen.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.schedule.*;
+
+public abstract class BackendTest extends GraalCompilerTest {
+
+    public BackendTest() {
+        super();
+    }
+
+    public BackendTest(Class<? extends Architecture> arch) {
+        super(arch);
+    }
+
+    protected LIRGenerationResult getLIRGenerationResult(final StructuredGraph graph) {
+        final Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
+
+        SchedulePhase schedule = null;
+        try (Scope s = Debug.scope("FrontEnd")) {
+            schedule = GraalCompiler.emitFrontEnd(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
+                            graph.method().getProfilingInfo(), null, getSuites());
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
+
+        CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
+        LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null);
+        return lirGen;
+    }
+
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java	Sun Nov 30 00:17:21 2014 +0000
@@ -151,7 +151,7 @@
 
         ResolvedJavaType type = parameterTypes[index];
         if (!checkValidCache(type, accessingClass)) {
-            type = (ResolvedJavaType) runtime.lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, true);
+            type = (ResolvedJavaType) runtime.lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false);
             parameterTypes[index] = type;
         }
         return type;
@@ -176,7 +176,7 @@
             return getUnresolvedOrPrimitiveType(runtime, returnType);
         }
         if (!checkValidCache(returnTypeCache, accessingClass)) {
-            returnTypeCache = (ResolvedJavaType) runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, true);
+            returnTypeCache = (ResolvedJavaType) runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false);
         }
         return returnTypeCache;
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleNode.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleNode.java	Sun Nov 30 00:17:21 2014 +0000
@@ -57,7 +57,7 @@
     protected MethodHandleNode(Invoke invoke) {
         super(invoke);
 
-        CallTargetNode callTarget = invoke.callTarget();
+        MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
 
         // See if we need to save some replacement method data.
         if (callTarget instanceof SelfReplacingMethodCallTargetNode) {
@@ -237,6 +237,7 @@
      */
     private InvokeNode createTargetInvokeNode(ResolvedJavaMethod target, IntrinsicMethod intrinsicMethod) {
         InvokeKind targetInvokeKind = target.isStatic() ? InvokeKind.Static : InvokeKind.Special;
+        JavaType targetReturnType = target.getSignature().getReturnType(null);
 
         // MethodHandleLinkTo* nodes have a trailing MemberName argument which
         // needs to be popped.
@@ -257,12 +258,12 @@
         }
 
         // If there is already replacement information, use that instead.
-        CallTargetNode callTarget;
+        MethodCallTargetNode callTarget;
         if (replacementTargetMethod == null) {
-            callTarget = SelfReplacingMethodCallTargetNode.create(targetInvokeKind, target, targetArguments, getTargetMethod(), originalArguments, getReturnType());
+            callTarget = SelfReplacingMethodCallTargetNode.create(targetInvokeKind, target, targetArguments, targetReturnType, getTargetMethod(), originalArguments, getReturnType());
         } else {
             ValueNode[] args = replacementArguments.toArray(new ValueNode[replacementArguments.size()]);
-            callTarget = SelfReplacingMethodCallTargetNode.create(targetInvokeKind, target, targetArguments, replacementTargetMethod, args, replacementReturnType);
+            callTarget = SelfReplacingMethodCallTargetNode.create(targetInvokeKind, target, targetArguments, targetReturnType, replacementTargetMethod, args, replacementReturnType);
         }
         graph().add(callTarget);
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/Invoke.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/Invoke.java	Sun Nov 30 00:17:21 2014 +0000
@@ -109,8 +109,7 @@
     default Stamp uncheckedStamp() {
         if (callTarget() instanceof MethodCallTargetNode) {
             MethodCallTargetNode methodCallTargetNode = (MethodCallTargetNode) callTarget();
-            JavaType returnType = methodCallTargetNode.targetMethod().getSignature().getReturnType(getContextType());
-            return UncheckedInterfaceProvider.uncheckedOrNull(returnType, asNode().stamp());
+            return UncheckedInterfaceProvider.uncheckedOrNull(methodCallTargetNode.returnType(), asNode().stamp());
         }
         return null;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/DynamicNewArrayNode.java	Sun Nov 30 00:17:21 2014 +0000
@@ -63,13 +63,21 @@
         return elementType;
     }
 
+    protected NewArrayNode forConstantType(ResolvedJavaType type) {
+        ValueNode len = length();
+        NewArrayNode ret = graph().add(NewArrayNode.create(type, len.isAlive() ? len : graph().addOrUniqueWithInputs(len), fillContents()));
+        if (stateBefore() != null) {
+            ret.setStateBefore(stateBefore());
+        }
+        return ret;
+    }
+
     @Override
     public void simplify(SimplifierTool tool) {
         if (isAlive() && elementType.isConstant()) {
             ResolvedJavaType javaType = tool.getConstantReflection().asJavaType(elementType.asConstant());
             if (javaType != null && !javaType.equals(tool.getMetaAccess().lookupJavaType(void.class))) {
-                ValueNode len = length();
-                NewArrayNode newArray = graph().add(NewArrayNode.create(javaType, len.isAlive() ? len : graph().addOrUniqueWithInputs(len), fillContents()));
+                NewArrayNode newArray = forConstantType(javaType);
                 List<Node> snapshot = inputs().snapshot();
                 graph().replaceFixedWithFixed(this, newArray);
                 for (Node input : snapshot) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java	Sun Nov 30 00:17:21 2014 +0000
@@ -24,7 +24,6 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
@@ -38,21 +37,21 @@
  * inlined.
  */
 @NodeInfo
-public class SelfReplacingMethodCallTargetNode extends CallTargetNode implements Lowerable {
+public class SelfReplacingMethodCallTargetNode extends MethodCallTargetNode implements Lowerable {
 
     // Replacement method data
     protected final ResolvedJavaMethod replacementTargetMethod;
     protected final JavaType replacementReturnType;
     @Input NodeInputList<ValueNode> replacementArguments;
 
-    public static SelfReplacingMethodCallTargetNode create(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, ResolvedJavaMethod replacementTargetMethod,
-                    ValueNode[] replacementArguments, JavaType replacementReturnType) {
-        return new SelfReplacingMethodCallTargetNode(invokeKind, targetMethod, arguments, replacementTargetMethod, replacementArguments, replacementReturnType);
+    public static SelfReplacingMethodCallTargetNode create(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType,
+                    ResolvedJavaMethod replacementTargetMethod, ValueNode[] replacementArguments, JavaType replacementReturnType) {
+        return new SelfReplacingMethodCallTargetNode(invokeKind, targetMethod, arguments, returnType, replacementTargetMethod, replacementArguments, replacementReturnType);
     }
 
-    protected SelfReplacingMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, ResolvedJavaMethod replacementTargetMethod,
+    protected SelfReplacingMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod replacementTargetMethod,
                     ValueNode[] replacementArguments, JavaType replacementReturnType) {
-        super(arguments, targetMethod, invokeKind);
+        super(invokeKind, targetMethod, arguments, returnType);
         this.replacementTargetMethod = replacementTargetMethod;
         this.replacementReturnType = replacementReturnType;
         this.replacementArguments = new NodeInputList<>(this, replacementArguments);
@@ -84,22 +83,4 @@
     public void generate(NodeLIRBuilderTool gen) {
         throw GraalInternalError.shouldNotReachHere("should have replaced itself");
     }
-
-    @Override
-    public Stamp returnStamp() {
-        Kind returnKind = targetMethod().getSignature().getReturnKind();
-        if (returnKind == Kind.Object && replacementReturnType instanceof ResolvedJavaType) {
-            return StampFactory.declared((ResolvedJavaType) replacementReturnType);
-        } else {
-            return StampFactory.forKind(returnKind);
-        }
-    }
-
-    @Override
-    public String targetName() {
-        if (targetMethod() == null) {
-            return "??Invalid!";
-        }
-        return targetMethod().format("%h.%n");
-    }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CounterAndTimeBasedCompilationPolicy.java	Thu Nov 27 12:37:05 2014 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/CounterAndTimeBasedCompilationPolicy.java	Sun Nov 30 00:17:21 2014 +0000
@@ -31,7 +31,7 @@
     @Override
     public boolean shouldCompile(CompilationProfile profile, CompilerOptions options) {
         if (super.shouldCompile(profile, options)) {
-            long threshold = TruffleTimeThreshold.getValue() * 1_000_000L;
+            long threshold = TruffleTimeThreshold.getValue();
 
             if (options instanceof GraalCompilerOptions) {
                 threshold = Math.max(threshold, ((GraalCompilerOptions) options).getMinTimeThreshold());
@@ -42,7 +42,7 @@
                 throw new AssertionError();
             }
             long timeElapsed = System.nanoTime() - time;
-            if (timeElapsed > threshold) {
+            if (timeElapsed > threshold * 1_000_000) {
                 profile.deferCompilation();
                 return false;
             }