| 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 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/cha.h" | 7 #include "vm/cha.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" |
| 10 #include "vm/il_printer.h" | 10 #include "vm/il_printer.h" |
| 11 #include "vm/object_store.h" | 11 #include "vm/object_store.h" |
| 12 #include "vm/parser.h" | 12 #include "vm/parser.h" |
| 13 #include "vm/scopes.h" | 13 #include "vm/scopes.h" |
| 14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 DECLARE_FLAG(bool, eliminate_type_checks); | 18 DECLARE_FLAG(bool, eliminate_type_checks); |
| 19 DECLARE_FLAG(bool, enable_type_checks); | 19 DECLARE_FLAG(bool, enable_type_checks); |
| 20 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); | 20 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); |
| 21 DECLARE_FLAG(bool, trace_type_check_elimination); | 21 DECLARE_FLAG(bool, trace_type_check_elimination); |
| 22 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis."); | 22 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis."); |
| 23 DEFINE_FLAG(bool, use_unboxed_doubles, true, "Try unboxing double values."); | |
| 24 | 23 |
| 25 void FlowGraphOptimizer::ApplyICData() { | 24 void FlowGraphOptimizer::ApplyICData() { |
| 26 VisitBlocks(); | 25 VisitBlocks(); |
| 27 } | 26 } |
| 28 | 27 |
| 29 | 28 |
| 30 void FlowGraphOptimizer::OptimizeComputations() { | 29 void FlowGraphOptimizer::OptimizeComputations() { |
| 31 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 30 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 32 BlockEntryInstr* entry = block_order_[i]; | 31 BlockEntryInstr* entry = block_order_[i]; |
| 33 entry->Accept(this); | 32 entry->Accept(this); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 } else { | 442 } else { |
| 444 return false; | 443 return false; |
| 445 } | 444 } |
| 446 break; | 445 break; |
| 447 default: | 446 default: |
| 448 UNREACHABLE(); | 447 UNREACHABLE(); |
| 449 }; | 448 }; |
| 450 | 449 |
| 451 ASSERT(comp->ArgumentCount() == 2); | 450 ASSERT(comp->ArgumentCount() == 2); |
| 452 if (operands_type == kDoubleCid) { | 451 if (operands_type == kDoubleCid) { |
| 453 if (FLAG_use_unboxed_doubles) { | 452 Value* left = comp->ArgumentAt(0)->value(); |
| 454 Value* left = comp->ArgumentAt(0)->value(); | 453 Value* right = comp->ArgumentAt(1)->value(); |
| 455 Value* right = comp->ArgumentAt(1)->value(); | |
| 456 | 454 |
| 457 // Check that either left or right are not a smi. Result or a | 455 // Check that either left or right are not a smi. Result or a |
| 458 // binary operation with two smis is a smi not a double. | 456 // binary operation with two smis is a smi not a double. |
| 459 InsertBefore(instr, | 457 InsertBefore(instr, |
| 460 new CheckEitherNonSmiComp(left->Copy(), | 458 new CheckEitherNonSmiComp(left->Copy(), |
| 461 right->Copy(), | 459 right->Copy(), |
| 462 comp), | 460 comp), |
| 463 instr->env(), | 461 instr->env(), |
| 464 BindInstr::kUnused); | 462 BindInstr::kUnused); |
| 465 | 463 |
| 466 UnboxedDoubleBinaryOpComp* double_bin_op = | 464 UnboxedDoubleBinaryOpComp* double_bin_op = |
| 467 new UnboxedDoubleBinaryOpComp(op_kind, | 465 new UnboxedDoubleBinaryOpComp(op_kind, |
| 468 left->Copy(), | 466 left->Copy(), |
| 469 right->Copy(), | 467 right->Copy(), |
| 470 comp); | 468 comp); |
| 471 instr->set_computation(double_bin_op); | 469 instr->set_computation(double_bin_op); |
| 472 | 470 |
| 473 RemovePushArguments(comp); | 471 RemovePushArguments(comp); |
| 474 } else { | |
| 475 BinaryDoubleOpComp* double_bin_op = new BinaryDoubleOpComp(op_kind, comp); | |
| 476 instr->set_computation(double_bin_op); | |
| 477 } | |
| 478 } else if (operands_type == kMintCid) { | 472 } else if (operands_type == kMintCid) { |
| 479 Value* left = comp->ArgumentAt(0)->value(); | 473 Value* left = comp->ArgumentAt(0)->value(); |
| 480 Value* right = comp->ArgumentAt(1)->value(); | 474 Value* right = comp->ArgumentAt(1)->value(); |
| 481 BinaryMintOpComp* bin_op = new BinaryMintOpComp(op_kind, | 475 BinaryMintOpComp* bin_op = new BinaryMintOpComp(op_kind, |
| 482 comp, | 476 comp, |
| 483 left, | 477 left, |
| 484 right); | 478 right); |
| 485 instr->set_computation(bin_op); | 479 instr->set_computation(bin_op); |
| 486 RemovePushArguments(comp); | 480 RemovePushArguments(comp); |
| 487 } else { | 481 } else { |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. | 1199 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. |
| 1206 OptimizeRecursive(child, &child_map); | 1200 OptimizeRecursive(child, &child_map); |
| 1207 } else { | 1201 } else { |
| 1208 OptimizeRecursive(child, map); // Reuse map for the last child. | 1202 OptimizeRecursive(child, map); // Reuse map for the last child. |
| 1209 } | 1203 } |
| 1210 } | 1204 } |
| 1211 } | 1205 } |
| 1212 | 1206 |
| 1213 | 1207 |
| 1214 } // namespace dart | 1208 } // namespace dart |
| OLD | NEW |