| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 DEFINE_FLAG(int, getter_setter_ratio, 13, | 27 DEFINE_FLAG(int, getter_setter_ratio, 13, |
| 28 "Ratio of getter/setter usage used for double field unboxing heuristics"); | 28 "Ratio of getter/setter usage used for double field unboxing heuristics"); |
| 29 DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination."); | 29 DEFINE_FLAG(bool, load_cse, true, "Use redundant load elimination."); |
| 30 DEFINE_FLAG(bool, dead_store_elimination, true, "Eliminate dead stores"); | 30 DEFINE_FLAG(bool, dead_store_elimination, true, "Eliminate dead stores"); |
| 31 DEFINE_FLAG(int, max_polymorphic_checks, 4, | 31 DEFINE_FLAG(int, max_polymorphic_checks, 4, |
| 32 "Maximum number of polymorphic check, otherwise it is megamorphic."); | 32 "Maximum number of polymorphic check, otherwise it is megamorphic."); |
| 33 DEFINE_FLAG(int, max_equality_polymorphic_checks, 32, | 33 DEFINE_FLAG(int, max_equality_polymorphic_checks, 32, |
| 34 "Maximum number of polymorphic checks in equality operator," | 34 "Maximum number of polymorphic checks in equality operator," |
| 35 " otherwise use megamorphic dispatch."); | 35 " otherwise use megamorphic dispatch."); |
| 36 DEFINE_FLAG(bool, merge_sin_cos, true, "Merge sin/cos into sincos"); |
| 36 DEFINE_FLAG(bool, trace_load_optimization, false, | 37 DEFINE_FLAG(bool, trace_load_optimization, false, |
| 37 "Print live sets for load optimization pass."); | 38 "Print live sets for load optimization pass."); |
| 38 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); | 39 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); |
| 39 DEFINE_FLAG(bool, truncating_left_shift, true, | 40 DEFINE_FLAG(bool, truncating_left_shift, true, |
| 40 "Optimize left shift to truncate if possible"); | 41 "Optimize left shift to truncate if possible"); |
| 41 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis."); | 42 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis."); |
| 42 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_IA32) | 43 #if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_IA32) |
| 43 DEFINE_FLAG(bool, trace_smi_widening, false, "Trace Smi->Int32 widening pass."); | 44 DEFINE_FLAG(bool, trace_smi_widening, false, "Trace Smi->Int32 widening pass."); |
| 44 #endif | 45 #endif |
| 45 DECLARE_FLAG(bool, enable_type_checks); | 46 DECLARE_FLAG(bool, enable_type_checks); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 break; | 430 break; |
| 430 } | 431 } |
| 431 } | 432 } |
| 432 } | 433 } |
| 433 } | 434 } |
| 434 | 435 |
| 435 | 436 |
| 436 // Tries to merge MathUnary operations, in this case sinus and cosinus. | 437 // Tries to merge MathUnary operations, in this case sinus and cosinus. |
| 437 void FlowGraphOptimizer::TryMergeMathUnary( | 438 void FlowGraphOptimizer::TryMergeMathUnary( |
| 438 GrowableArray<MathUnaryInstr*>* merge_candidates) { | 439 GrowableArray<MathUnaryInstr*>* merge_candidates) { |
| 439 if (!FlowGraphCompiler::SupportsSinCos() || !CanUnboxDouble()) { | 440 if (!FlowGraphCompiler::SupportsSinCos() || !CanUnboxDouble() || |
| 441 !FLAG_merge_sin_cos) { |
| 440 return; | 442 return; |
| 441 } | 443 } |
| 442 if (merge_candidates->length() < 2) { | 444 if (merge_candidates->length() < 2) { |
| 443 // Need at least a SIN and a COS. | 445 // Need at least a SIN and a COS. |
| 444 return; | 446 return; |
| 445 } | 447 } |
| 446 for (intptr_t i = 0; i < merge_candidates->length(); i++) { | 448 for (intptr_t i = 0; i < merge_candidates->length(); i++) { |
| 447 MathUnaryInstr* curr_instr = (*merge_candidates)[i]; | 449 MathUnaryInstr* curr_instr = (*merge_candidates)[i]; |
| 448 if (curr_instr == NULL) { | 450 if (curr_instr == NULL) { |
| 449 // Instruction was merged already. | 451 // Instruction was merged already. |
| 450 continue; | 452 continue; |
| 451 } | 453 } |
| 452 const intptr_t kind = curr_instr->kind(); | 454 const intptr_t kind = curr_instr->kind(); |
| 453 ASSERT((kind == MathUnaryInstr::kSin) || | 455 ASSERT((kind == MathUnaryInstr::kSin) || |
| 454 (kind == MathUnaryInstr::kCos)); | 456 (kind == MathUnaryInstr::kCos)); |
| 455 // Check if there is sin/cos binop with same inputs. | 457 // Check if there is sin/cos binop with same inputs. |
| 456 const intptr_t other_kind = (kind == MethodRecognizer::kMathSin) ? | 458 const intptr_t other_kind = (kind == MathUnaryInstr::kSin) ? |
| 457 MethodRecognizer::kMathCos : MethodRecognizer::kMathSin; | 459 MathUnaryInstr::kCos : MathUnaryInstr::kSin; |
| 458 Definition* def = curr_instr->value()->definition(); | 460 Definition* def = curr_instr->value()->definition(); |
| 459 for (intptr_t k = i + 1; k < merge_candidates->length(); k++) { | 461 for (intptr_t k = i + 1; k < merge_candidates->length(); k++) { |
| 460 MathUnaryInstr* other_op = (*merge_candidates)[k]; | 462 MathUnaryInstr* other_op = (*merge_candidates)[k]; |
| 461 // 'other_op' can be NULL if it was already merged. | 463 // 'other_op' can be NULL if it was already merged. |
| 462 if ((other_op != NULL) && (other_op->kind() == other_kind) && | 464 if ((other_op != NULL) && (other_op->kind() == other_kind) && |
| 463 (other_op->value()->definition() == def)) { | 465 (other_op->value()->definition() == def)) { |
| 464 (*merge_candidates)[k] = NULL; // Clear it. | 466 (*merge_candidates)[k] = NULL; // Clear it. |
| 465 ASSERT(curr_instr->HasUses()); | 467 ASSERT(curr_instr->HasUses()); |
| 466 AppendExtractNthOutputForMerged(curr_instr, | 468 AppendExtractNthOutputForMerged(curr_instr, |
| 467 MergedMathInstr::OutputIndexOf(kind), | 469 MergedMathInstr::OutputIndexOf(kind), |
| (...skipping 8140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8608 | 8610 |
| 8609 // Insert materializations at environment uses. | 8611 // Insert materializations at environment uses. |
| 8610 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { | 8612 for (intptr_t i = 0; i < exits_collector_.exits().length(); i++) { |
| 8611 CreateMaterializationAt( | 8613 CreateMaterializationAt( |
| 8612 exits_collector_.exits()[i], alloc, *slots); | 8614 exits_collector_.exits()[i], alloc, *slots); |
| 8613 } | 8615 } |
| 8614 } | 8616 } |
| 8615 | 8617 |
| 8616 | 8618 |
| 8617 } // namespace dart | 8619 } // namespace dart |
| OLD | NEW |