changeset 11508:bb39b1bce748

Merge.
author Christian Humer <christian.humer@gmail.com>
date Mon, 02 Sep 2013 15:27:20 +0200
parents d6a5ab791b0d (diff) fc3a6fb4cf3d (current diff)
children dcaf879d4a7e
files
diffstat 5 files changed, 81 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardsTest.java	Mon Sep 02 14:15:41 2013 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/GuardsTest.java	Mon Sep 02 15:27:20 2013 +0200
@@ -34,11 +34,15 @@
 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.GuardWithBoxedPrimitiveFactory;
 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.GuardWithObjectFactory;
 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.InvocationGuardFactory;
+import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestAbstractGuard1Factory;
 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve1Factory;
 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve2Factory;
 import com.oracle.truffle.api.dsl.test.GuardsTestFactory.TestGuardResolve3Factory;
 import com.oracle.truffle.api.dsl.test.NodeContainerTest.Str;
 import com.oracle.truffle.api.dsl.test.NodeContainerTest.StrBase;
+import com.oracle.truffle.api.dsl.test.TypeSystemTest.Abstract;
+import com.oracle.truffle.api.dsl.test.TypeSystemTest.BExtendsAbstract;
+import com.oracle.truffle.api.dsl.test.TypeSystemTest.CExtendsAbstract;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 
@@ -271,4 +275,43 @@
         }
     }
 
+    @NodeChild("expression")
+    public abstract static class TestGuardResolve4 extends ValueNode {
+
+        boolean guard(StrBase primitive) {
+            return false;
+        }
+
+        @Specialization(guards = "guard")
+        int doSpecialized(Str value0) {
+            return 42;
+        }
+    }
+
+    @Test
+    public void testAbstractGuard1() {
+        TestRootNode<?> root = createRoot(TestAbstractGuard1Factory.getInstance());
+
+        assertEquals(BExtendsAbstract.INSTANCE, executeWith(root, BExtendsAbstract.INSTANCE));
+        assertEquals(CExtendsAbstract.INSTANCE, executeWith(root, CExtendsAbstract.INSTANCE));
+    }
+
+    @NodeChild("expression")
+    public abstract static class TestAbstractGuard1 extends ValueNode {
+
+        boolean guard(Abstract value0) {
+            return true;
+        }
+
+        @Specialization(order = 1, guards = "guard")
+        BExtendsAbstract doSpecialized1(BExtendsAbstract value0) {
+            return value0;
+        }
+
+        @Specialization(order = 2, guards = "guard")
+        CExtendsAbstract doSpecialized2(CExtendsAbstract value0) {
+            return value0;
+        }
+    }
+
 }
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java	Mon Sep 02 14:15:41 2013 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java	Mon Sep 02 15:27:20 2013 +0200
@@ -30,7 +30,7 @@
 
 public class TypeSystemTest {
 
-    @TypeSystem({int.class, boolean.class, String.class, Str.class, CallTarget.class, Object[].class})
+    @TypeSystem({int.class, boolean.class, String.class, Str.class, CallTarget.class, BExtendsAbstract.class, CExtendsAbstract.class, Abstract.class, Object[].class})
     static class SimpleTypes {
 
         static int intCheck;
@@ -73,6 +73,14 @@
             return SimpleTypesGen.SIMPLETYPES.expectObjectArray(execute(frame));
         }
 
+        public BExtendsAbstract executeBExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException {
+            return SimpleTypesGen.SIMPLETYPES.expectBExtendsAbstract(execute(frame));
+        }
+
+        public CExtendsAbstract executeCExtendsAbstract(VirtualFrame frame) throws UnexpectedResultException {
+            return SimpleTypesGen.SIMPLETYPES.expectCExtendsAbstract(execute(frame));
+        }
+
         public abstract Object execute(VirtualFrame frame);
 
         @Override
@@ -154,4 +162,18 @@
 
     }
 
+    abstract static class Abstract {
+    }
+
+    static final class BExtendsAbstract extends Abstract {
+
+        static final BExtendsAbstract INSTANCE = new BExtendsAbstract();
+
+    }
+
+    static final class CExtendsAbstract extends Abstract {
+
+        static final CExtendsAbstract INSTANCE = new CExtendsAbstract();
+    }
+
 }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Sep 02 14:15:41 2013 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Sep 02 15:27:20 2013 +0200
@@ -2392,15 +2392,13 @@
         }
 
         private CodeTree createExecuteBody(CodeTreeBuilder parent, SpecializationData specialization, ExecutableTypeData execType) {
-            TypeData primaryType = specialization.getReturnType().getTypeSystemType();
-
             CodeTreeBuilder builder = new CodeTreeBuilder(parent);
 
             List<ExecutableTypeData> primaryExecutes = findFunctionalExecutableType(specialization, execType.getEvaluatedCount());
 
             if (primaryExecutes.contains(execType) || primaryExecutes.isEmpty()) {
                 builder.tree(createFunctionalExecute(builder, specialization, execType));
-            } else if (needsCastingExecuteMethod(execType, primaryType)) {
+            } else if (needsCastingExecuteMethod(execType)) {
                 assert !primaryExecutes.isEmpty();
                 builder.tree(createCastingExecute(builder, specialization, execType, primaryExecutes.get(0)));
             } else {
@@ -2431,13 +2429,10 @@
             return method;
         }
 
-        private boolean needsCastingExecuteMethod(ExecutableTypeData execType, TypeData primaryType) {
+        private boolean needsCastingExecuteMethod(ExecutableTypeData execType) {
             if (execType.isAbstract()) {
                 return true;
             }
-            if (Utils.isPrimitiveOrVoid(primaryType.getPrimitiveType()) && Utils.isPrimitiveOrVoid(execType.getType().getPrimitiveType())) {
-                return true;
-            }
             if (execType.getType().isGeneric()) {
                 return true;
             }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java	Mon Sep 02 14:15:41 2013 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java	Mon Sep 02 15:27:20 2013 +0200
@@ -396,11 +396,13 @@
                 nodeChild.addError("The @%s of the node and the @%s of the @%s does not match. %s != %s. ", TypeSystem.class.getSimpleName(), TypeSystem.class.getSimpleName(),
                                 NodeChild.class.getSimpleName(), Utils.getSimpleName(node.getTypeSystem().getTemplateType()), Utils.getSimpleName(fieldNodeData.getTypeSystem().getTemplateType()));
             }
-            List<ExecutableTypeData> types = nodeChild.findGenericExecutableTypes(context);
-            if (types.isEmpty()) {
-                AnnotationValue executeWithValue = Utils.getAnnotationValue(nodeChild.getMessageAnnotation(), "executeWith");
-                nodeChild.addError(executeWithValue, "No generic execute method found with %s evaluated arguments for node type %s.", nodeChild.getExecuteWith().size(),
-                                Utils.getSimpleName(nodeChild.getNodeType()));
+            if (fieldNodeData != null) {
+                List<ExecutableTypeData> types = nodeChild.findGenericExecutableTypes(context);
+                if (types.isEmpty()) {
+                    AnnotationValue executeWithValue = Utils.getAnnotationValue(nodeChild.getMessageAnnotation(), "executeWith");
+                    nodeChild.addError(executeWithValue, "No generic execute method found with %s evaluated arguments for node type %s.", nodeChild.getExecuteWith().size(),
+                                    Utils.getSimpleName(nodeChild.getNodeType()));
+                }
             }
         }
     }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/SpecializationGroup.java	Mon Sep 02 14:15:41 2013 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/SpecializationGroup.java	Mon Sep 02 15:27:20 2013 +0200
@@ -119,6 +119,11 @@
         if (previous == null || previous.getGuards().size() != elseConnectedGuards.size() + 1) {
             return null;
         }
+
+        if (elseConnectedGuards.contains(guard)) {
+            return guard;
+        }
+
         GuardData previousGuard = previous.getGuards().get(elseConnectedGuards.size());
         if (guard.getMethod().equals(previousGuard.getMethod()) && guard.isNegated() != previousGuard.isNegated()) {
             return guard;
@@ -212,7 +217,7 @@
             int signatureIndex = 0;
             for (ActualParameter parameter : guardMatch.getParameters()) {
                 signatureIndex++;
-                if (parameter.getSpecification().isSignature()) {
+                if (!parameter.getSpecification().isSignature()) {
                     continue;
                 }