comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java @ 11320:80de3bbfa8b9

Truffle-DSL: fixed inconsistent children for polymorphic -> generic rewrites. (GRAAL-425)
author Christian Humer <christian.humer@gmail.com>
date Fri, 16 Aug 2013 14:00:17 +0200
parents 7fc3e1fb3965
children efe58aa92f86
comparison
equal deleted inserted replaced
11310:9f317a663366 11320:80de3bbfa8b9
1767 NodeData node = current.getNode(); 1767 NodeData node = current.getNode();
1768 1768
1769 CodeTreeBuilder builder = parent.create(); 1769 CodeTreeBuilder builder = parent.create();
1770 builder.declaration(getContext().getTruffleTypes().getNode(), "root", currentNode); 1770 builder.declaration(getContext().getTruffleTypes().getNode(), "root", currentNode);
1771 builder.startIf().string(currentNode).string(".next0 != null").end().startBlock(); 1771 builder.startIf().string(currentNode).string(".next0 != null").end().startBlock();
1772 /*
1773 * Communicates to the caller of executeAndSpecialize that it was rewritten to generic.
1774 * Its important that this is used instead of the currentNode since the caller is this.
1775 * CurrentNode may not be this anymore at this place.
1776 */
1777 builder.statement("this.next0 = null");
1772 builder.tree(createFindRoot(builder, node, false)); 1778 builder.tree(createFindRoot(builder, node, false));
1773 builder.end(); 1779 builder.end();
1774 builder.end(); 1780 builder.end();
1775 builder.tree(createGenericInvoke(builder, source, current, createReplaceCall(builder, current, "root", "(" + baseClassName(node) + ") root", null), null)); 1781 builder.tree(createGenericInvoke(builder, source, current, createReplaceCall(builder, current, "root", "(" + baseClassName(node) + ") root", null), null));
1776 return builder.getRoot(); 1782 return builder.getRoot();
2500 builder.tree(createFindRoot(builder, node, true)); 2506 builder.tree(createFindRoot(builder, node, true));
2501 builder.newLine(); 2507 builder.newLine();
2502 2508
2503 builder.startIf().string("depth > ").string(String.valueOf(node.getPolymorphicDepth())).end(); 2509 builder.startIf().string("depth > ").string(String.valueOf(node.getPolymorphicDepth())).end();
2504 builder.startBlock(); 2510 builder.startBlock();
2505 String message = ("Polymorphic limit reached (" + node.getPolymorphicDepth() + ")"); 2511 String message = "Polymorphic limit reached (" + node.getPolymorphicDepth() + ")";
2512 String castRoot = "(" + baseClassName(node) + ") root";
2506 builder.tree(createGenericInvoke(builder, node.getGenericPolymorphicSpecialization(), node.getGenericSpecialization(), 2513 builder.tree(createGenericInvoke(builder, node.getGenericPolymorphicSpecialization(), node.getGenericSpecialization(),
2507 createReplaceCall(builder, node.getGenericSpecialization(), "root", "this", message), null)); 2514 createReplaceCall(builder, node.getGenericSpecialization(), "root", castRoot, message), null));
2508 builder.end(); 2515 builder.end();
2509 2516
2510 builder.startElseBlock(); 2517 builder.startElseBlock();
2511 builder.startStatement().startCall("setNext0"); 2518 builder.startStatement().startCall("setNext0");
2512 builder.startNew(nodeSpecializationClassName(node.getUninitializedSpecialization())).string("this").end(); 2519 builder.startNew(nodeSpecializationClassName(node.getUninitializedSpecialization())).string("this").end();
2519 specializeCall.startGroup().doubleQuote("Uninitialized polymorphic (").string(" + depth + ").doubleQuote("/" + node.getPolymorphicDepth() + ")").end(); 2526 specializeCall.startGroup().doubleQuote("Uninitialized polymorphic (").string(" + depth + ").doubleQuote("/" + node.getPolymorphicDepth() + ")").end();
2520 specializeCall.end().end(); 2527 specializeCall.end().end();
2521 2528
2522 builder.declaration(node.getGenericSpecialization().getReturnType().getType(), "result", specializeCall.getRoot()); 2529 builder.declaration(node.getGenericSpecialization().getReturnType().getType(), "result", specializeCall.getRoot());
2523 2530
2531 builder.startIf().string("this.next0 != null").end().startBlock();
2524 builder.startStatement().string("(").cast(nodePolymorphicClassName(node, node.getGenericPolymorphicSpecialization())).string("root).optimizeTypes()").end(); 2532 builder.startStatement().string("(").cast(nodePolymorphicClassName(node, node.getGenericPolymorphicSpecialization())).string("root).optimizeTypes()").end();
2533 builder.end();
2525 2534
2526 if (Utils.isVoid(builder.findMethod().getReturnType())) { 2535 if (Utils.isVoid(builder.findMethod().getReturnType())) {
2527 builder.returnStatement(); 2536 builder.returnStatement();
2528 } else { 2537 } else {
2529 builder.startReturn().string("result").end(); 2538 builder.startReturn().string("result").end();