Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java @ 7794:b891ec348f8a
Made the usage of generic types more flexible for short circuits and generic specializations.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 15 Feb 2013 19:32:58 +0100 |
parents | 3cec97eb3b5f |
children | 6e4fb0ccebb1 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java Fri Feb 15 16:48:22 2013 +0100 +++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java Fri Feb 15 19:32:58 2013 +0100 @@ -126,34 +126,17 @@ return executableTypes; } - public ExecutableTypeData findGenericExecutableType(ProcessorContext context) { + public ExecutableTypeData findGenericExecutableType(ProcessorContext context, TypeData type) { List<ExecutableTypeData> types = findGenericExecutableTypes(context); - if (types.isEmpty()) { - return null; - } else if (types.size() == 1) { - return types.get(0); - } else if (types.size() == 2) { - if (types.get(0).getType().isVoid()) { - return types.get(1); - } else if (types.get(1).getType().isVoid()) { - return types.get(0); + for (ExecutableTypeData availableType : types) { + if (Utils.typeEquals(availableType.getType().getBoxedType(), type.getBoxedType())) { + return availableType; } } - - ExecutableTypeData execType = null; - for (ExecutableTypeData type : types) { - TypeData returnType = type.getReturnType().getActualTypeData(getTypeSystem()); - if (returnType.isGeneric()) { - if (execType != null) { - return null; - } - execType = type; - } - } - return execType; + return null; } - private List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) { + public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) { List<ExecutableTypeData> types = new ArrayList<>(); for (ExecutableTypeData type : executableTypes) { if (!type.hasUnexpectedValue(context)) {