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

Side by Side Diff: pkg/compiler/lib/src/ssa/nodes.dart

Issue 2799603003: dart2js: make dominator tree traversals nonrecursive (Closed)
Patch Set: fix comment Created 3 years, 8 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
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../common/backend_api.dart' show BackendClasses; 7 import '../common/backend_api.dart' show BackendClasses;
8 import '../compiler.dart' show Compiler; 8 import '../compiler.dart' show Compiler;
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 R visitTypeKnown(HTypeKnown node); 98 R visitTypeKnown(HTypeKnown node);
99 R visitYield(HYield node); 99 R visitYield(HYield node);
100 100
101 R visitTypeInfoReadRaw(HTypeInfoReadRaw node); 101 R visitTypeInfoReadRaw(HTypeInfoReadRaw node);
102 R visitTypeInfoReadVariable(HTypeInfoReadVariable node); 102 R visitTypeInfoReadVariable(HTypeInfoReadVariable node);
103 R visitTypeInfoExpression(HTypeInfoExpression node); 103 R visitTypeInfoExpression(HTypeInfoExpression node);
104 } 104 }
105 105
106 abstract class HGraphVisitor { 106 abstract class HGraphVisitor {
107 visitDominatorTree(HGraph graph) { 107 visitDominatorTree(HGraph graph) {
108 void visitBasicBlockAndSuccessors(HBasicBlock block) { 108 // Recursion free version of:
109 visitBasicBlock(block); 109 //
110 List dominated = block.dominatedBlocks; 110 // void visitBasicBlockAndSuccessors(HBasicBlock block) {
111 for (int i = 0; i < dominated.length; i++) { 111 // visitBasicBlock(block);
112 visitBasicBlockAndSuccessors(dominated[i]); 112 // List dominated = block.dominatedBlocks;
113 // for (int i = 0; i < dominated.length; i++) {
114 // visitBasicBlockAndSuccessors(dominated[i]);
115 // }
116 // }
117 // visitBasicBlockAndSuccessors(graph.entry);
118
119 _Frame frame = new _Frame(null);
120 frame.block = graph.entry;
121 frame.index = 0;
122
123 visitBasicBlock(frame.block);
124
125 while (frame != null) {
126 HBasicBlock block = frame.block;
127 int index = frame.index;
128 if (index < block.dominatedBlocks.length) {
129 frame.index = index + 1;
130 frame = frame.next ??= new _Frame(frame);
131 frame.block = block.dominatedBlocks[index];
132 frame.index = 0;
133 visitBasicBlock(frame.block);
134 continue;
113 } 135 }
136 frame = frame.previous;
114 } 137 }
115
116 visitBasicBlockAndSuccessors(graph.entry);
117 } 138 }
118 139
119 visitPostDominatorTree(HGraph graph) { 140 visitPostDominatorTree(HGraph graph) {
120 void visitBasicBlockAndSuccessors(HBasicBlock block) { 141 // Recusion free version of:
121 List dominated = block.dominatedBlocks; 142 //
122 for (int i = dominated.length - 1; i >= 0; i--) { 143 // void visitBasicBlockAndSuccessors(HBasicBlock block) {
123 visitBasicBlockAndSuccessors(dominated[i]); 144 // List dominated = block.dominatedBlocks;
145 // for (int i = dominated.length - 1; i >= 0; i--) {
146 // visitBasicBlockAndSuccessors(dominated[i]);
147 // }
148 // visitBasicBlock(block);
149 // }
150 // visitBasicBlockAndSuccessors(graph.entry);
151
152 _Frame frame = new _Frame(null);
153 frame.block = graph.entry;
154 frame.index = frame.block.dominatedBlocks.length;
155
156 while (frame != null) {
157 HBasicBlock block = frame.block;
158 int index = frame.index;
159 if (index > 0) {
160 frame.index = index - 1;
161 frame = frame.next ??= new _Frame(frame);
162 frame.block = block.dominatedBlocks[index - 1];
163 frame.index = frame.block.dominatedBlocks.length;
164 continue;
124 } 165 }
125 visitBasicBlock(block); 166 visitBasicBlock(block);
167 frame = frame.previous;
126 } 168 }
127
128 visitBasicBlockAndSuccessors(graph.entry);
129 } 169 }
130 170
131 visitBasicBlock(HBasicBlock block); 171 visitBasicBlock(HBasicBlock block);
132 } 172 }
133 173
174 class _Frame {
175 final _Frame previous;
176 _Frame next;
177 HBasicBlock block;
178 int index;
179 _Frame(this.previous);
180 }
181
134 abstract class HInstructionVisitor extends HGraphVisitor { 182 abstract class HInstructionVisitor extends HGraphVisitor {
135 HBasicBlock currentBlock; 183 HBasicBlock currentBlock;
136 184
137 visitInstruction(HInstruction node); 185 visitInstruction(HInstruction node);
138 186
139 visitBasicBlock(HBasicBlock node) { 187 visitBasicBlock(HBasicBlock node) {
140 void visitInstructionList(HInstructionList list) { 188 void visitInstructionList(HInstructionList list) {
141 HInstruction instruction = list.first; 189 HInstruction instruction = list.first;
142 while (instruction != null) { 190 while (instruction != null) {
143 visitInstruction(instruction); 191 visitInstruction(instruction);
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3394 // ignore: MISSING_RETURN 3442 // ignore: MISSING_RETURN
3395 String get kindAsString { 3443 String get kindAsString {
3396 switch (kind) { 3444 switch (kind) {
3397 case TypeInfoExpressionKind.COMPLETE: 3445 case TypeInfoExpressionKind.COMPLETE:
3398 return 'COMPLETE'; 3446 return 'COMPLETE';
3399 case TypeInfoExpressionKind.INSTANCE: 3447 case TypeInfoExpressionKind.INSTANCE:
3400 return 'INSTANCE'; 3448 return 'INSTANCE';
3401 } 3449 }
3402 } 3450 }
3403 } 3451 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698