diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java @ 20999:ef2825da2e43

Truffle-DSL: fixed generation of unused synthetic execute methods.
author Christian Humer <christian.humer@gmail.com>
date Thu, 16 Apr 2015 17:30:43 +0200
parents 6361fa2e3321
children 986f1c0d6f55
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java	Thu Apr 16 21:29:56 2015 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java	Thu Apr 16 17:30:43 2015 +0200
@@ -211,22 +211,46 @@
             }
         }
 
-        for (ExecutableTypeData execType : usedTypes) {
-            if (!singleSpecializable && execType.getMethod() == null) {
-                continue;
-            }
-            clazz.add(createExecutableTypeOverride(usedTypes, execType));
-        }
-
         clazz.add(createGetCostMethod());
 
         avoidFindbugsProblems(clazz);
 
         if (singleSpecializable) {
+            SpecializationData specialization = reachableSpecializations.iterator().next();
+
+            for (ExecutableTypeData execType : usedTypes) {
+                if (execType.getMethod() == null) {
+                    boolean foundDelegate = false;
+                    for (ExecutableTypeData type : usedTypes) {
+                        if (type == execType) {
+                            continue;
+                        }
+                        if (findFastPathDelegate(specialization.getReturnType().getType(), type, usedTypes) == execType) {
+                            foundDelegate = true;
+                            break;
+                        }
+                    }
+                    // just exclude synthetic execute methods that were not delegated to
+                    if (!foundDelegate) {
+                        continue;
+                    }
+                }
+
+                clazz.add(createExecutableTypeOverride(usedTypes, execType));
+            }
+
             if (node.needsRewrites(context)) {
                 clazz.add(createUnsupportedMethod());
             }
         } else {
+
+            for (ExecutableTypeData execType : usedTypes) {
+                if (execType.getMethod() == null) {
+                    continue;
+                }
+                clazz.add(createExecutableTypeOverride(usedTypes, execType));
+            }
+
             clazz.getImplements().add(getType(SpecializedNode.class));
             clazz.add(createMethodGetSpecializationNode());
             clazz.add(createDeepCopyMethod());
@@ -242,7 +266,7 @@
             }
         }
 
-        for (TypeMirror type : ElementUtils.uniqueSortedTypes(expectedTypes)) {
+        for (TypeMirror type : ElementUtils.uniqueSortedTypes(expectedTypes, false)) {
             if (!typeSystem.hasType(type)) {
                 clazz.addOptional(TypeSystemCodeGenerator.createExpectMethod(PRIVATE, typeSystem, context.getType(Object.class), type));
             }