Mercurial > hg > graal-jvmci-8
comparison 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 |
comparison
equal
deleted
inserted
replaced
16820:0370880ac9ce | 16821:224a89858453 |
---|---|
2615 | 2615 |
2616 protected void createExecuteMethods(SpecializationData specialization) { | 2616 protected void createExecuteMethods(SpecializationData specialization) { |
2617 NodeData node = specialization.getNode(); | 2617 NodeData node = specialization.getNode(); |
2618 CodeTypeElement clazz = getElement(); | 2618 CodeTypeElement clazz = getElement(); |
2619 | 2619 |
2620 List<ExecutableTypeData> primaryExecutes = null; | |
2621 int lastEvaluatedCount = -1; | |
2622 | |
2620 for (ExecutableTypeData execType : node.getExecutableTypes()) { | 2623 for (ExecutableTypeData execType : node.getExecutableTypes()) { |
2621 if (execType.isFinal()) { | 2624 if (execType.isFinal()) { |
2622 continue; | 2625 continue; |
2623 } | 2626 } |
2624 CodeExecutableElement executeMethod = createExecutableTypeOverride(execType, true); | 2627 if (execType.getEvaluatedCount() != lastEvaluatedCount) { |
2625 clazz.add(executeMethod); | 2628 lastEvaluatedCount = execType.getEvaluatedCount(); |
2626 CodeTreeBuilder builder = executeMethod.getBuilder(); | 2629 primaryExecutes = findFunctionalExecutableType(specialization, lastEvaluatedCount); |
2627 CodeTree result = createExecuteBody(builder, specialization, execType); | 2630 } |
2631 | |
2632 CodeTreeBuilder builder = new CodeTreeBuilder(null); | |
2633 builder.getTree().setEnclosingElement(execType.getMessageElement()); | |
2634 | |
2635 CodeTree result = createExecuteBody(builder, specialization, execType, primaryExecutes); | |
2628 if (result != null) { | 2636 if (result != null) { |
2629 builder.tree(result); | 2637 CodeExecutableElement method = createExecutableTypeOverride(execType, true); |
2630 } else { | 2638 method.createBuilder().tree(result); |
2631 clazz.remove(executeMethod); | 2639 clazz.add(method); |
2632 } | 2640 } |
2633 } | 2641 } |
2634 } | 2642 } |
2635 | 2643 |
2636 protected void createCachedExecuteMethods(SpecializationData specialization) { | 2644 protected void createCachedExecuteMethods(SpecializationData specialization) { |
2682 builder.tree(createDeoptimize(builder)); | 2690 builder.tree(createDeoptimize(builder)); |
2683 } | 2691 } |
2684 return builder.getRoot(); | 2692 return builder.getRoot(); |
2685 } | 2693 } |
2686 | 2694 |
2687 private CodeTree createExecuteBody(CodeTreeBuilder parent, SpecializationData specialization, ExecutableTypeData execType) { | 2695 private CodeTree createExecuteBody(CodeTreeBuilder parent, SpecializationData specialization, ExecutableTypeData execType, List<ExecutableTypeData> primaryExecutes) { |
2688 CodeTreeBuilder builder = new CodeTreeBuilder(parent); | 2696 CodeTreeBuilder builder = new CodeTreeBuilder(parent); |
2689 | |
2690 List<ExecutableTypeData> primaryExecutes = findFunctionalExecutableType(specialization, execType.getEvaluatedCount()); | |
2691 | 2697 |
2692 if (primaryExecutes.contains(execType) || primaryExecutes.isEmpty()) { | 2698 if (primaryExecutes.contains(execType) || primaryExecutes.isEmpty()) { |
2693 builder.tree(createFunctionalExecute(builder, specialization, execType)); | 2699 builder.tree(createFunctionalExecute(builder, specialization, execType)); |
2694 } else if (needsCastingExecuteMethod(execType)) { | 2700 } else if (needsCastingExecuteMethod(execType)) { |
2695 assert !primaryExecutes.isEmpty(); | 2701 assert !primaryExecutes.isEmpty(); |
2776 TypeData primaryType = specialization.getReturnType().getTypeSystemType(); | 2782 TypeData primaryType = specialization.getReturnType().getTypeSystemType(); |
2777 List<ExecutableTypeData> otherTypes = specialization.getNode().getExecutableTypes(evaluatedCount); | 2783 List<ExecutableTypeData> otherTypes = specialization.getNode().getExecutableTypes(evaluatedCount); |
2778 | 2784 |
2779 List<ExecutableTypeData> filteredTypes = new ArrayList<>(); | 2785 List<ExecutableTypeData> filteredTypes = new ArrayList<>(); |
2780 for (ExecutableTypeData compareType : otherTypes) { | 2786 for (ExecutableTypeData compareType : otherTypes) { |
2781 if (!ElementUtils.typeEquals(compareType.getType().getPrimitiveType(), primaryType.getPrimitiveType())) { | 2787 if (ElementUtils.typeEquals(compareType.getType().getPrimitiveType(), primaryType.getPrimitiveType())) { |
2782 continue; | 2788 filteredTypes.add(compareType); |
2783 } | 2789 } |
2784 filteredTypes.add(compareType); | |
2785 } | 2790 } |
2786 | 2791 |
2787 // no direct matches found use generic where the type is Object | 2792 // no direct matches found use generic where the type is Object |
2788 if (filteredTypes.isEmpty()) { | 2793 if (filteredTypes.isEmpty()) { |
2789 for (ExecutableTypeData compareType : otherTypes) { | 2794 for (ExecutableTypeData compareType : otherTypes) { |