| 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 BailoutInfo { | 5 class BailoutInfo { |
| 6 int instructionId; | 6 int instructionId; |
| 7 int bailoutId; | 7 int bailoutId; |
| 8 BailoutInfo(this.instructionId, this.bailoutId); | 8 BailoutInfo(this.instructionId, this.bailoutId); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 | 311 |
| 312 void visitBasicBlock(HBasicBlock block) { | 312 void visitBasicBlock(HBasicBlock block) { |
| 313 // Abort traversal if we are leaving the currently active sub-graph. | 313 // Abort traversal if we are leaving the currently active sub-graph. |
| 314 if (!subGraph.contains(block)) return; | 314 if (!subGraph.contains(block)) return; |
| 315 | 315 |
| 316 if (block.isLoopHeader()) { | 316 if (block.isLoopHeader()) { |
| 317 blocks.addLast(block); | 317 blocks.addLast(block); |
| 318 } else if (block.isLabeledBlock() && blocks.last() !== block) { | 318 } else if (block.isLabeledBlock() && blocks.last() !== block) { |
| 319 HLabeledBlockInformation info = block.blockInformation; | 319 HLabeledBlockInformation info = block.blockInformation.body; |
| 320 visitStatements(info.body); | 320 visitStatements(info.body); |
| 321 return; | 321 return; |
| 322 } | 322 } |
| 323 | 323 |
| 324 HInstruction instruction = block.first; | 324 HInstruction instruction = block.first; |
| 325 while (instruction != null) { | 325 while (instruction != null) { |
| 326 instruction.accept(this); | 326 instruction.accept(this); |
| 327 instruction = instruction.next; | 327 instruction = instruction.next; |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 void visitStatements(HStatementInformation info) { | 331 void visitStatements(HStatementInformation info) { |
| 332 assert(info is HSubGraphBlockInformation); | 332 assert(info is HSubGraphBlockInformation); |
| 333 HSubGraphBlockInformation graph = info; | 333 HSubGraphBlockInformation graph = info; |
| 334 visitSubGraph(graph.subGraph); | 334 visitSubGraph(graph.subGraph); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void visitSubGraph(SubGraph graph) { | 337 void visitSubGraph(SubGraph graph) { |
| 338 SubGraph oldSubGraph = subGraph; | 338 SubGraph oldSubGraph = subGraph; |
| 339 subGraph = graph; | 339 subGraph = graph; |
| 340 HBasicBlock start = graph.start; | 340 HBasicBlock start = graph.start; |
| 341 blocks.addLast(start); | 341 blocks.addLast(start); |
| 342 visitBasicBlock(start); | 342 visitBasicBlock(start); |
| 343 blocks.removeLast(); | 343 blocks.removeLast(); |
| 344 subGraph = oldSubGraph; | 344 subGraph = oldSubGraph; |
| 345 | 345 |
| 346 if (start.isLabeledBlock()) { | 346 if (start.isLabeledBlock()) { |
| 347 HLabeledBlockInformation info = start.blockInformation; | 347 HBasicBlock continuation = start.blockInformation.continuation; |
| 348 if (info.joinBlock !== null) { | 348 if (continuation !== null) { |
| 349 visitBasicBlock(info.joinBlock); | 349 visitBasicBlock(continuation); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 void visitIf(HIf instruction) { | 354 void visitIf(HIf instruction) { |
| 355 int preVisitedBlocks = 0; | 355 int preVisitedBlocks = 0; |
| 356 HIfBlockInformation info = instruction.blockInformation; | 356 HIfBlockInformation info = instruction.blockInformation.body; |
| 357 visitStatements(info.thenGraph); | 357 visitStatements(info.thenGraph); |
| 358 preVisitedBlocks++; | 358 preVisitedBlocks++; |
| 359 if (instruction.hasElse) { | 359 if (instruction.hasElse) { |
| 360 visitStatements(info.elseGraph); | 360 visitStatements(info.elseGraph); |
| 361 preVisitedBlocks++; | 361 preVisitedBlocks++; |
| 362 } | 362 } |
| 363 | 363 |
| 364 if (info.joinBlock !== null | 364 HBasicBlock joinBlock = instruction.joinBlock; |
| 365 && info.joinBlock.dominator !== instruction.block) { | 365 if (joinBlock !== null |
| 366 && joinBlock.dominator !== instruction.block) { |
| 366 // The join block is dominated by a block in one of the branches. | 367 // The join block is dominated by a block in one of the branches. |
| 367 // The subgraph traversal never reached it, so we visit it here | 368 // The subgraph traversal never reached it, so we visit it here |
| 368 // instead. | 369 // instead. |
| 369 visitBasicBlock(info.joinBlock); | 370 visitBasicBlock(joinBlock); |
| 370 } | 371 } |
| 371 | 372 |
| 372 // Visit all the dominated blocks that are not part of the then or else | 373 // Visit all the dominated blocks that are not part of the then or else |
| 373 // branches, and is not the join block. | 374 // branches, and is not the join block. |
| 374 // Depending on how the then/else branches terminate | 375 // Depending on how the then/else branches terminate |
| 375 // (e.g., return/throw/break) there can be any number of these. | 376 // (e.g., return/throw/break) there can be any number of these. |
| 376 List<HBasicBlock> dominated = instruction.block.dominatedBlocks; | 377 List<HBasicBlock> dominated = instruction.block.dominatedBlocks; |
| 377 int dominatedCount = dominated.length; | 378 int dominatedCount = dominated.length; |
| 378 for (int i = preVisitedBlocks; i < dominatedCount; i++) { | 379 for (int i = preVisitedBlocks; i < dominatedCount; i++) { |
| 379 HBasicBlock dominatedBlock = dominated[i]; | 380 HBasicBlock dominatedBlock = dominated[i]; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 410 } | 411 } |
| 411 } | 412 } |
| 412 } | 413 } |
| 413 | 414 |
| 414 visitTypeGuard(HTypeGuard guard) { | 415 visitTypeGuard(HTypeGuard guard) { |
| 415 blocks.forEach((HBasicBlock block) { | 416 blocks.forEach((HBasicBlock block) { |
| 416 block.guards.add(guard); | 417 block.guards.add(guard); |
| 417 }); | 418 }); |
| 418 } | 419 } |
| 419 } | 420 } |
| OLD | NEW |