Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1062)

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10693059: remove HIf.hasElse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 final JavaScriptBackend backend; 6 final JavaScriptBackend backend;
7 SsaCodeGeneratorTask(JavaScriptBackend backend) 7 SsaCodeGeneratorTask(JavaScriptBackend backend)
8 : this.backend = backend, 8 : this.backend = backend,
9 super(backend.compiler); 9 super(backend.compiler);
10 String get name() => 'SSA code generator'; 10 String get name() => 'SSA code generator';
(...skipping 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 // The subgraph traversal never reached it, so we visit it here 1696 // The subgraph traversal never reached it, so we visit it here
1697 // instead. 1697 // instead.
1698 visitBasicBlock(joinBlock); 1698 visitBasicBlock(joinBlock);
1699 } 1699 }
1700 1700
1701 // Visit all the dominated blocks that are not part of the then or else 1701 // Visit all the dominated blocks that are not part of the then or else
1702 // branches, and is not the join block. 1702 // branches, and is not the join block.
1703 // Depending on how the then/else branches terminate 1703 // Depending on how the then/else branches terminate
1704 // (e.g., return/throw/break) there can be any number of these. 1704 // (e.g., return/throw/break) there can be any number of these.
1705 List<HBasicBlock> dominated = node.block.dominatedBlocks; 1705 List<HBasicBlock> dominated = node.block.dominatedBlocks;
1706 for (int i = node.hasElse ? 2 : 1; i < dominated.length; i++) { 1706 for (int i = 2; i < dominated.length; i++) {
1707 visitBasicBlock(dominated[i]); 1707 visitBasicBlock(dominated[i]);
1708 } 1708 }
1709 } 1709 }
1710 1710
1711 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { 1711 visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
1712 beginExpression(JSPrecedence.CALL_PRECEDENCE); 1712 beginExpression(JSPrecedence.CALL_PRECEDENCE);
1713 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); 1713 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE);
1714 buffer.add('.'); 1714 buffer.add('.');
1715 // Avoid adding the generative constructor name to the list of 1715 // Avoid adding the generative constructor name to the list of
1716 // seen selectors. 1716 // seen selectors.
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 void handleLoopCondition(HLoopBranch node) { 3041 void handleLoopCondition(HLoopBranch node) {
3042 buffer.add('if (!'); 3042 buffer.add('if (!');
3043 use(node.inputs[0], JSPrecedence.PREFIX_PRECEDENCE); 3043 use(node.inputs[0], JSPrecedence.PREFIX_PRECEDENCE);
3044 buffer.add(') break ${currentLabel()};\n'); 3044 buffer.add(') break ${currentLabel()};\n');
3045 } 3045 }
3046 3046
3047 void generateIf(HIf node, HIfBlockInformation info) { 3047 void generateIf(HIf node, HIfBlockInformation info) {
3048 HStatementInformation thenGraph = info.thenGraph; 3048 HStatementInformation thenGraph = info.thenGraph;
3049 HStatementInformation elseGraph = info.elseGraph; 3049 HStatementInformation elseGraph = info.elseGraph;
3050 bool thenHasGuards = thenGraph.start.hasGuards(); 3050 bool thenHasGuards = thenGraph.start.hasGuards();
3051 bool elseHasGuards = node.hasElse && elseGraph.start.hasGuards(); 3051 bool elseHasGuards = elseGraph.start.hasGuards();
3052 bool hasGuards = thenHasGuards || elseHasGuards; 3052 bool hasGuards = thenHasGuards || elseHasGuards;
3053 if (!hasGuards) return super.generateIf(node, info); 3053 if (!hasGuards) return super.generateIf(node, info);
3054 3054
3055 int elseKind = analyzeGraphForCodegen(elseGraph); 3055 int elseKind = analyzeGraphForCodegen(elseGraph);
3056 bool emptyElse = !node.hasElse || elseKind == SsaCodeGenerator.EMPTY; 3056 bool emptyElse = elseKind == SsaCodeGenerator.EMPTY;
3057 3057
3058 startBailoutCase(thenGraph.start.guards, 3058 startBailoutCase(thenGraph.start.guards,
3059 node.hasElse ? elseGraph.start.guards : const <HTypeGuard>[]); 3059 emptyElse ? const <HTypeGuard>[] : elseGraph.start.guards);
3060 3060
3061 addIndented('if ('); 3061 addIndented('if (');
3062 int precedence = JSPrecedence.EXPRESSION_PRECEDENCE; 3062 int precedence = JSPrecedence.EXPRESSION_PRECEDENCE;
3063 // TODO(ngeoffray): Put the condition initialization in the 3063 // TODO(ngeoffray): Put the condition initialization in the
3064 // [setup] buffer. 3064 // [setup] buffer.
3065 List<HTypeGuard> guards = node.thenBlock.guards; 3065 List<HTypeGuard> guards = node.thenBlock.guards;
3066 for (int i = 0, len = guards.length; i < len; i++) { 3066 for (int i = 0, len = guards.length; i < len; i++) {
3067 buffer.add('state == ${guards[i].state} || '); 3067 buffer.add('state == ${guards[i].state} || ');
3068 } 3068 }
3069 buffer.add('(state == 0 && '); 3069 buffer.add('(state == 0 && ');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3103 startBailoutSwitch(); 3103 startBailoutSwitch();
3104 } 3104 }
3105 } 3105 }
3106 3106
3107 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 3107 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
3108 if (labeledBlockInfo.body.start.hasGuards()) { 3108 if (labeledBlockInfo.body.start.hasGuards()) {
3109 endBailoutSwitch(); 3109 endBailoutSwitch();
3110 } 3110 }
3111 } 3111 }
3112 } 3112 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698