Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { |
|
Emily Fortuna
2017/04/05 19:56:37
thank you for writing out this comment. it helps.
| |
| 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 // visitBasicBlockAndSuccessors(graph.entry); | |
| 116 // } | |
| 117 // } | |
| 118 // visitBasicBlockAndSuccessors(graph.entry); | |
| 119 | |
| 120 _Frame frame = new _Frame(null); | |
| 121 frame.block = graph.entry; | |
| 122 frame.index = 0; | |
| 123 | |
| 124 visitBasicBlock(frame.block); | |
| 125 | |
| 126 while (frame != null) { | |
| 127 HBasicBlock block = frame.block; | |
| 128 int index = frame.index; | |
| 129 if (index < block.dominatedBlocks.length) { | |
| 130 frame.index = index + 1; | |
| 131 frame = frame.next ??= new _Frame(frame); | |
| 132 frame.block = block.dominatedBlocks[index]; | |
| 133 frame.index = 0; | |
| 134 visitBasicBlock(frame.block); | |
| 135 continue; | |
| 113 } | 136 } |
| 137 frame = frame.previous; | |
| 114 } | 138 } |
| 115 | |
| 116 visitBasicBlockAndSuccessors(graph.entry); | |
| 117 } | 139 } |
| 118 | 140 |
| 119 visitPostDominatorTree(HGraph graph) { | 141 visitPostDominatorTree(HGraph graph) { |
| 120 void visitBasicBlockAndSuccessors(HBasicBlock block) { | 142 // Recusion free version of: |
| 121 List dominated = block.dominatedBlocks; | 143 // |
| 122 for (int i = dominated.length - 1; i >= 0; i--) { | 144 // void visitBasicBlockAndSuccessors(HBasicBlock block) { |
| 123 visitBasicBlockAndSuccessors(dominated[i]); | 145 // List dominated = block.dominatedBlocks; |
| 146 // for (int i = dominated.length - 1; i >= 0; i--) { | |
| 147 // visitBasicBlockAndSuccessors(dominated[i]); | |
| 148 // } | |
| 149 // visitBasicBlock(block); | |
| 150 // } | |
| 151 // visitBasicBlockAndSuccessors(graph.entry); | |
| 152 | |
| 153 _Frame frame = new _Frame(null); | |
| 154 frame.block = graph.entry; | |
| 155 frame.index = frame.block.dominatedBlocks.length; | |
| 156 | |
| 157 while (frame != null) { | |
| 158 HBasicBlock block = frame.block; | |
| 159 int index = frame.index; | |
| 160 if (index > 0) { | |
| 161 frame.index = index - 1; | |
| 162 frame = frame.next ??= new _Frame(frame); | |
| 163 frame.block = block.dominatedBlocks[index - 1]; | |
| 164 frame.index = frame.block.dominatedBlocks.length; | |
| 165 continue; | |
| 124 } | 166 } |
| 125 visitBasicBlock(block); | 167 visitBasicBlock(block); |
| 168 frame = frame.previous; | |
| 126 } | 169 } |
| 127 | |
| 128 visitBasicBlockAndSuccessors(graph.entry); | |
| 129 } | 170 } |
| 130 | 171 |
| 131 visitBasicBlock(HBasicBlock block); | 172 visitBasicBlock(HBasicBlock block); |
| 132 } | 173 } |
| 133 | 174 |
| 175 class _Frame { | |
| 176 final _Frame previous; | |
| 177 _Frame next; | |
| 178 HBasicBlock block; | |
| 179 int index; | |
| 180 _Frame(this.previous); | |
| 181 } | |
| 182 | |
| 134 abstract class HInstructionVisitor extends HGraphVisitor { | 183 abstract class HInstructionVisitor extends HGraphVisitor { |
| 135 HBasicBlock currentBlock; | 184 HBasicBlock currentBlock; |
| 136 | 185 |
| 137 visitInstruction(HInstruction node); | 186 visitInstruction(HInstruction node); |
| 138 | 187 |
| 139 visitBasicBlock(HBasicBlock node) { | 188 visitBasicBlock(HBasicBlock node) { |
| 140 void visitInstructionList(HInstructionList list) { | 189 void visitInstructionList(HInstructionList list) { |
| 141 HInstruction instruction = list.first; | 190 HInstruction instruction = list.first; |
| 142 while (instruction != null) { | 191 while (instruction != null) { |
| 143 visitInstruction(instruction); | 192 visitInstruction(instruction); |
| (...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3394 // ignore: MISSING_RETURN | 3443 // ignore: MISSING_RETURN |
| 3395 String get kindAsString { | 3444 String get kindAsString { |
| 3396 switch (kind) { | 3445 switch (kind) { |
| 3397 case TypeInfoExpressionKind.COMPLETE: | 3446 case TypeInfoExpressionKind.COMPLETE: |
| 3398 return 'COMPLETE'; | 3447 return 'COMPLETE'; |
| 3399 case TypeInfoExpressionKind.INSTANCE: | 3448 case TypeInfoExpressionKind.INSTANCE: |
| 3400 return 'INSTANCE'; | 3449 return 'INSTANCE'; |
| 3401 } | 3450 } |
| 3402 } | 3451 } |
| 3403 } | 3452 } |
| OLD | NEW |