diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ParameterSpec.java @ 16820:0370880ac9ce

Truffle-DSL: better caching for type checks.
author Christian Humer <christian.humer@gmail.com>
date Wed, 13 Aug 2014 18:06:26 +0200
parents 23415229349b
children 2db61eddcb97
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ParameterSpec.java	Wed Aug 13 18:06:18 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/ParameterSpec.java	Wed Aug 13 18:06:26 2014 +0200
@@ -34,6 +34,7 @@
 
     private final String name;
     private final List<TypeMirror> allowedTypes;
+    private final Set<String> allowedTypesIdentifier;
 
     /** Type is bound to local final variable. */
     private boolean local;
@@ -43,22 +44,24 @@
     private NodeExecutionData execution;
     private TypeDef typeDefinition;
 
-    public ParameterSpec(String name, List<TypeMirror> allowedTypes) {
+    public ParameterSpec(String name, List<TypeMirror> allowedTypes, Set<String> typeIdentifiers) {
         this.name = name;
         this.allowedTypes = allowedTypes;
+        this.allowedTypesIdentifier = typeIdentifiers;
     }
 
     public ParameterSpec(String name, TypeMirror type) {
-        this(name, Arrays.asList(type));
+        this(name, Arrays.asList(type), new HashSet<>(Arrays.asList(ElementUtils.getUniqueIdentifier(type))));
     }
 
-    public ParameterSpec(ParameterSpec o, List<TypeMirror> allowedTypes) {
+    public ParameterSpec(ParameterSpec o, List<TypeMirror> allowedTypes, Set<String> typeIdentifiers) {
         this.name = o.name;
         this.local = o.local;
         this.typeDefinition = o.typeDefinition;
         this.execution = o.execution;
         this.signature = o.signature;
         this.allowedTypes = allowedTypes;
+        this.allowedTypesIdentifier = typeIdentifiers;
     }
 
     public NodeExecutionData getExecution() {
@@ -103,12 +106,7 @@
     }
 
     public boolean matches(TypeMirror actualType) {
-        for (TypeMirror mirror : allowedTypes) {
-            if (ElementUtils.typeEquals(actualType, mirror)) {
-                return true;
-            }
-        }
-        return false;
+        return allowedTypesIdentifier.contains(ElementUtils.getUniqueIdentifier(actualType));
     }
 
     @Override