changeset 12635:ba6593e52d22

Truffle-DSL: fixed additional wrong @SlowPath usage on generic. (GRAAL-490 #resolve)
author Christian Humer <christian.humer@gmail.com>
date Mon, 28 Oct 2013 11:06:51 +0100
parents 595f01abb887
children 748b8381b171
files graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathTest.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java
diffstat 3 files changed, 30 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathTest.java	Sun Oct 27 19:59:00 2013 +0100
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/SlowPathTest.java	Mon Oct 28 11:06:51 2013 +0100
@@ -28,6 +28,7 @@
 import com.oracle.truffle.api.dsl.*;
 import com.oracle.truffle.api.dsl.test.SlowPathTestFactory.SlowPathOnGeneric0Factory;
 import com.oracle.truffle.api.dsl.test.SlowPathTestFactory.SlowPathOnGeneric1Factory;
+import com.oracle.truffle.api.dsl.test.SlowPathTestFactory.SlowPathOnGeneric2Factory;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.nodes.*;
@@ -69,4 +70,27 @@
 
     }
 
+    @Test
+    public void testSlowPathOnGeneric2() throws NoSuchMethodException, SecurityException {
+        Node node = SlowPathOnGeneric2Factory.create(null);
+        Assert.assertNull(node.getClass().getSuperclass().getDeclaredMethod("executeGeneric0", VirtualFrame.class, Object.class).getAnnotation(SlowPath.class));
+    }
+
+    @NodeChild
+    abstract static class SlowPathOnGeneric2 extends ValueNode {
+
+        @Specialization(order = 0)
+        @SuppressWarnings("unused")
+        Object doObject0(int value0) {
+            throw new AssertionError();
+        }
+
+        @Specialization(order = 1)
+        @SuppressWarnings("unused")
+        Object doObject1(VirtualFrame frame, String value0) {
+            throw new AssertionError();
+        }
+
+    }
+
 }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Sun Oct 27 19:59:00 2013 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Oct 28 11:06:51 2013 +0100
@@ -1377,10 +1377,10 @@
             TypeMirror genericReturnType = node.getGenericSpecialization().getReturnType().getType();
             CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED), genericReturnType, EXECUTE_GENERIC_NAME);
 
-            if (!node.getGenericSpecialization().hasFrame(getContext())) {
+            if (!node.needsFrame(getContext())) {
                 method.getAnnotationMirrors().add(new CodeAnnotationMirror(getContext().getTruffleTypes().getSlowPath()));
             }
-            addInternalValueParameters(method, node.getGenericSpecialization(), node.needsFrame(), false);
+            addInternalValueParameters(method, node.getGenericSpecialization(), node.needsFrame(getContext()), false);
             final CodeTreeBuilder builder = method.createBuilder();
 
             builder.tree(createExecuteTree(builder, node.getGenericSpecialization(), group, false, new CodeBlock<SpecializationData>() {
@@ -1803,7 +1803,7 @@
             }
             if (current.isGeneric()) {
                 builder.startReturn().tree(replace).string(".").startCall(EXECUTE_GENERIC_NAME);
-                addInternalValueParameterNames(builder, source, current, null, current.getNode().needsFrame(), true, null);
+                addInternalValueParameterNames(builder, source, current, null, current.getNode().needsFrame(getContext()), true, null);
                 builder.end().end();
             } else if (current.getMethod() == null) {
                 if (replaceCall != null) {
@@ -2968,7 +2968,7 @@
                 emitEncounteredSynthetic(builder, specialization);
             } else if (specialization.isGeneric()) {
                 returnBuilder.startCall("super", EXECUTE_GENERIC_NAME);
-                addInternalValueParameterNames(returnBuilder, specialization, specialization, null, node.needsFrame(), true, null);
+                addInternalValueParameterNames(returnBuilder, specialization, specialization, null, node.needsFrame(getContext()), true, null);
                 returnBuilder.end();
             } else {
                 returnBuilder.tree(createTemplateMethodCall(returnBuilder, null, specialization, specialization, null));
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java	Sun Oct 27 19:59:00 2013 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java	Mon Oct 28 11:06:51 2013 +0100
@@ -78,12 +78,12 @@
         this.assumptions = splitSource.assumptions;
     }
 
-    public boolean needsFrame() {
+    public boolean needsFrame(ProcessorContext context) {
         for (SpecializationData specialization : specializations) {
             if (!specialization.isReachable()) {
                 continue;
             }
-            if (specialization.findParameter("frameValue") != null) {
+            if (specialization.hasFrame(context)) {
                 return true;
             }
         }