| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 #include "vm/branch_optimizer.h" | 5 #include "vm/branch_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/flow_graph.h" | 7 #include "vm/flow_graph.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // These are the branches produced by inlining in a test context. Also, | 40 // These are the branches produced by inlining in a test context. Also, |
| 41 // the phi has no other uses so they can simply be eliminated. The block | 41 // the phi has no other uses so they can simply be eliminated. The block |
| 42 // has no other phis and no instructions intervening between the phi and | 42 // has no other phis and no instructions intervening between the phi and |
| 43 // branch so the block can simply be eliminated. | 43 // branch so the block can simply be eliminated. |
| 44 BranchInstr* branch = block->last_instruction()->AsBranch(); | 44 BranchInstr* branch = block->last_instruction()->AsBranch(); |
| 45 ASSERT(branch != NULL); | 45 ASSERT(branch != NULL); |
| 46 ComparisonInstr* comparison = branch->comparison(); | 46 ComparisonInstr* comparison = branch->comparison(); |
| 47 if (comparison->InputCount() != 2) { | 47 if (comparison->InputCount() != 2) { |
| 48 return false; | 48 return false; |
| 49 } | 49 } |
| 50 if (comparison->CanDeoptimize() || comparison->MayThrow()) { |
| 51 return false; |
| 52 } |
| 50 Value* left = comparison->left(); | 53 Value* left = comparison->left(); |
| 51 PhiInstr* phi = left->definition()->AsPhi(); | 54 PhiInstr* phi = left->definition()->AsPhi(); |
| 52 Value* right = comparison->right(); | 55 Value* right = comparison->right(); |
| 53 ConstantInstr* constant = | 56 ConstantInstr* constant = |
| 54 (right == NULL) ? NULL : right->definition()->AsConstant(); | 57 (right == NULL) ? NULL : right->definition()->AsConstant(); |
| 55 return (phi != NULL) && | 58 return (phi != NULL) && |
| 56 (constant != NULL) && | 59 (constant != NULL) && |
| 57 (phi->GetBlock() == block) && | 60 (phi->GetBlock() == block) && |
| 58 PhiHasSingleUse(phi, left) && | 61 PhiHasSingleUse(phi, left) && |
| 59 (block->next() == branch) && | 62 (block->next() == branch) && |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 if (changed) { | 352 if (changed) { |
| 350 // We may have changed the block order and the dominator tree. | 353 // We may have changed the block order and the dominator tree. |
| 351 flow_graph->DiscoverBlocks(); | 354 flow_graph->DiscoverBlocks(); |
| 352 GrowableArray<BitVector*> dominance_frontier; | 355 GrowableArray<BitVector*> dominance_frontier; |
| 353 flow_graph->ComputeDominators(&dominance_frontier); | 356 flow_graph->ComputeDominators(&dominance_frontier); |
| 354 } | 357 } |
| 355 } | 358 } |
| 356 | 359 |
| 357 | 360 |
| 358 } // namespace dart | 361 } // namespace dart |
| OLD | NEW |