diff graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java @ 8251:cb70ed101b5f

Added automatic generation of generic specialization which throws unsupported operation if reached.
author Christian Humer <christian.humer@gmail.com>
date Wed, 13 Mar 2013 11:32:43 +0100
parents c4c3f50fa9c2
children 0905d796944a
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java	Tue Mar 12 11:38:52 2013 +0100
+++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java	Wed Mar 13 11:32:43 2013 +0100
@@ -68,14 +68,7 @@
         this.guards = copy.guards;
         this.executableTypes = copy.executableTypes;
         this.shortCircuits = copy.shortCircuits;
-
-        List<NodeFieldData> fieldsCopy = new ArrayList<>();
-        for (NodeFieldData field : copy.fields) {
-            NodeFieldData newField = new NodeFieldData(field);
-            newField.setNode(this);
-            fieldsCopy.add(newField);
-        }
-        this.fields = fieldsCopy;
+        this.fields = copy.fields;
     }
 
     public ParameterSpec getInstanceParameterSpec() {
@@ -186,6 +179,14 @@
         return null;
     }
 
+    public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) {
+        List<ExecutableTypeData> types = findGenericExecutableTypes(context);
+        if (!types.isEmpty()) {
+            return types.get(0);
+        }
+        return null;
+    }
+
     public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) {
         List<ExecutableTypeData> types = new ArrayList<>();
         for (ExecutableTypeData type : executableTypes) {
@@ -250,18 +251,13 @@
 
     public boolean needsRewrites(ProcessorContext context) {
         boolean needsRewrites = false;
-        for (NodeFieldData field : getFields()) {
-            if (field.getExecutionKind() == ExecutionKind.DEFAULT || field.getExecutionKind() == ExecutionKind.SHORT_CIRCUIT) {
-                if (!field.getNodeData().hasUnexpectedExecutableTypes(context)) {
-                    continue;
-                }
 
+        for (SpecializationData specialization : getSpecializations()) {
+            if (specialization.hasRewrite(context)) {
                 needsRewrites = true;
                 break;
             }
         }
-
-        needsRewrites &= specializations.size() >= 2;
         return needsRewrites;
     }