Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java @ 16821:224a89858453
Truffle-DSL: cache primary executes
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 13 Aug 2014 18:06:26 +0200 |
parents | e2ebaf1e1b74 |
children | 84f1c44b5e9b |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java Wed Aug 13 18:06:26 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeCodeGenerator.java Wed Aug 13 18:06:26 2014 +0200 @@ -2617,18 +2617,26 @@ NodeData node = specialization.getNode(); CodeTypeElement clazz = getElement(); + List<ExecutableTypeData> primaryExecutes = null; + int lastEvaluatedCount = -1; + for (ExecutableTypeData execType : node.getExecutableTypes()) { if (execType.isFinal()) { continue; } - CodeExecutableElement executeMethod = createExecutableTypeOverride(execType, true); - clazz.add(executeMethod); - CodeTreeBuilder builder = executeMethod.getBuilder(); - CodeTree result = createExecuteBody(builder, specialization, execType); + if (execType.getEvaluatedCount() != lastEvaluatedCount) { + lastEvaluatedCount = execType.getEvaluatedCount(); + primaryExecutes = findFunctionalExecutableType(specialization, lastEvaluatedCount); + } + + CodeTreeBuilder builder = new CodeTreeBuilder(null); + builder.getTree().setEnclosingElement(execType.getMessageElement()); + + CodeTree result = createExecuteBody(builder, specialization, execType, primaryExecutes); if (result != null) { - builder.tree(result); - } else { - clazz.remove(executeMethod); + CodeExecutableElement method = createExecutableTypeOverride(execType, true); + method.createBuilder().tree(result); + clazz.add(method); } } } @@ -2684,11 +2692,9 @@ return builder.getRoot(); } - private CodeTree createExecuteBody(CodeTreeBuilder parent, SpecializationData specialization, ExecutableTypeData execType) { + private CodeTree createExecuteBody(CodeTreeBuilder parent, SpecializationData specialization, ExecutableTypeData execType, List<ExecutableTypeData> primaryExecutes) { 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)) { @@ -2778,10 +2784,9 @@ List<ExecutableTypeData> filteredTypes = new ArrayList<>(); for (ExecutableTypeData compareType : otherTypes) { - if (!ElementUtils.typeEquals(compareType.getType().getPrimitiveType(), primaryType.getPrimitiveType())) { - continue; + if (ElementUtils.typeEquals(compareType.getType().getPrimitiveType(), primaryType.getPrimitiveType())) { + filteredTypes.add(compareType); } - filteredTypes.add(compareType); } // no direct matches found use generic where the type is Object