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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 String generate(WorkItem work, HGraph graph) { | 9 String generate(WorkItem work, HGraph graph) { |
| 10 return measure(() { | 10 return measure(() { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 int oldPrecedence = this.expectedPrecedence; | 242 int oldPrecedence = this.expectedPrecedence; |
| 243 this.expectedPrecedence = expectedPrecedence; | 243 this.expectedPrecedence = expectedPrecedence; |
| 244 node.accept(this); | 244 node.accept(this); |
| 245 this.expectedPrecedence = oldPrecedence; | 245 this.expectedPrecedence = oldPrecedence; |
| 246 } | 246 } |
| 247 | 247 |
| 248 void handleLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 248 void handleLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 249 addIndentation(); | 249 addIndentation(); |
| 250 for (LabelElement label in labeledBlockInfo.labels) { | 250 for (LabelElement label in labeledBlockInfo.labels) { |
| 251 if (labeledBlockInfo.isContinue) { | 251 if (labeledBlockInfo.isContinue) { |
| 252 addContinueLabel(label); | 252 if (label.isContinueTarget) { |
| 253 addContinueLabel(label); | |
| 254 buffer.add(':'); | |
| 255 } | |
| 253 } else { | 256 } else { |
| 254 addBreakLabel(label); | 257 if (label.isBreakTarget) { |
| 258 addBreakLabel(label); | |
| 259 buffer.add(':'); | |
| 260 } | |
| 255 } | 261 } |
| 256 buffer.add(':'); | |
| 257 } | 262 } |
| 258 TargetElement target = labeledBlockInfo.target; | 263 TargetElement target = labeledBlockInfo.target; |
| 259 if (target.isSwitch) { | 264 if (target.isSwitch) { |
| 260 addImplicitBreakLabel(target); | 265 addImplicitBreakLabel(target); |
| 261 buffer.add(@':'); | 266 buffer.add(':'); |
| 262 } | 267 } |
| 263 if (labeledBlockInfo.isContinue) { | 268 if (labeledBlockInfo.isContinue) { |
| 264 addImplicitContinueLabel(target); | 269 addImplicitContinueLabel(target); |
| 265 buffer.add(':'); | 270 buffer.add(':'); |
| 266 } | 271 } |
| 267 buffer.add('{\n'); | 272 buffer.add('{\n'); |
| 268 indent++; | 273 indent++; |
| 269 | 274 |
| 270 visitSubGraph(labeledBlockInfo.body); | 275 visitSubGraph(labeledBlockInfo.body); |
| 271 | 276 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 289 // don't handle it again. | 294 // don't handle it again. |
| 290 if (node.hasLabeledBlockInformation() && | 295 if (node.hasLabeledBlockInformation() && |
| 291 node.labeledBlockInformation !== currentBlockInformation) { | 296 node.labeledBlockInformation !== currentBlockInformation) { |
| 292 HLabeledBlockInformation oldBlockInformation = currentBlockInformation; | 297 HLabeledBlockInformation oldBlockInformation = currentBlockInformation; |
| 293 currentBlockInformation = node.labeledBlockInformation; | 298 currentBlockInformation = node.labeledBlockInformation; |
| 294 handleLabeledBlock(currentBlockInformation); | 299 handleLabeledBlock(currentBlockInformation); |
| 295 currentBlockInformation = oldBlockInformation; | 300 currentBlockInformation = oldBlockInformation; |
| 296 return; | 301 return; |
| 297 } | 302 } |
| 298 | 303 |
| 299 currentBlock = node; | |
| 300 if (node.isLoopHeader()) { | 304 if (node.isLoopHeader()) { |
| 301 // While loop will be closed by the conditional loop-branch. | 305 // While loop will be closed by the conditional loop-branch. |
| 302 // TODO(floitsch): HACK HACK HACK. | 306 // TODO(floitsch): HACK HACK HACK. |
| 303 beginLoop(node); | 307 beginLoop(node); |
| 304 } | 308 } |
| 309 | |
| 310 currentBlock = node; | |
|
ngeoffray
2012/03/21 12:23:23
Why this change? I actually think we should get ri
Lasse Reichstein Nielsen
2012/03/21 12:33:26
Hmm, is it even safe?
I hadn't noticed that curren
| |
| 305 HInstruction instruction = node.first; | 311 HInstruction instruction = node.first; |
| 306 while (instruction != null) { | 312 while (instruction != null) { |
| 307 if (instruction is HGoto || instruction is HExit || instruction is HTry) { | 313 if (instruction is HGoto || instruction is HExit || instruction is HTry) { |
| 308 visit(instruction, JSPrecedence.STATEMENT_PRECEDENCE); | 314 visit(instruction, JSPrecedence.STATEMENT_PRECEDENCE); |
| 309 return; | 315 return; |
| 310 } else if (!instruction.generateAtUseSite()) { | 316 } else if (!instruction.generateAtUseSite()) { |
| 311 if (instruction is !HIf && instruction is !HBailoutTarget) { | 317 if (instruction is !HIf && instruction is !HBailoutTarget) { |
| 312 addIndentation(); | 318 addIndentation(); |
| 313 } | 319 } |
| 314 if (instruction.usedBy.isEmpty() || instruction is HLocal) { | 320 if (instruction.usedBy.isEmpty() || instruction is HLocal) { |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1484 startBailoutSwitch(); | 1490 startBailoutSwitch(); |
| 1485 } | 1491 } |
| 1486 } | 1492 } |
| 1487 | 1493 |
| 1488 void endElse(HIf node) { | 1494 void endElse(HIf node) { |
| 1489 if (node.elseBlock.hasBailouts()) { | 1495 if (node.elseBlock.hasBailouts()) { |
| 1490 endBailoutSwitch(); | 1496 endBailoutSwitch(); |
| 1491 } | 1497 } |
| 1492 } | 1498 } |
| 1493 } | 1499 } |
| OLD | NEW |