| 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/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2620 } else { | 2620 } else { |
| 2621 call_with_checks = true; | 2621 call_with_checks = true; |
| 2622 } | 2622 } |
| 2623 PolymorphicInstanceCallInstr* call = | 2623 PolymorphicInstanceCallInstr* call = |
| 2624 new PolymorphicInstanceCallInstr(instr, unary_checks, | 2624 new PolymorphicInstanceCallInstr(instr, unary_checks, |
| 2625 call_with_checks); | 2625 call_with_checks); |
| 2626 instr->ReplaceWith(call, current_iterator()); | 2626 instr->ReplaceWith(call, current_iterator()); |
| 2627 } | 2627 } |
| 2628 } | 2628 } |
| 2629 | 2629 |
| 2630 | |
| 2631 void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* call) { | 2630 void FlowGraphOptimizer::VisitStaticCall(StaticCallInstr* call) { |
| 2632 MethodRecognizer::Kind recognized_kind = | 2631 MethodRecognizer::Kind recognized_kind = |
| 2633 MethodRecognizer::RecognizeKind(call->function()); | 2632 MethodRecognizer::RecognizeKind(call->function()); |
| 2634 if (recognized_kind == MethodRecognizer::kMathSqrt) { | 2633 if ((recognized_kind == MethodRecognizer::kMathSqrt) || |
| 2635 MathSqrtInstr* sqrt = | 2634 (recognized_kind == MethodRecognizer::kMathSin) || |
| 2636 new MathSqrtInstr(new Value(call->ArgumentAt(0)), call->deopt_id()); | 2635 (recognized_kind == MethodRecognizer::kMathCos)) { |
| 2637 ReplaceCall(call, sqrt); | 2636 if ((recognized_kind == MethodRecognizer::kMathSqrt) || |
| 2637 FlowGraphCompiler::SupportsInlinedTrigonometrics()) { |
| 2638 MathUnaryInstr* math_unary = |
| 2639 new MathUnaryInstr(recognized_kind, |
| 2640 new Value(call->ArgumentAt(0)), |
| 2641 call->deopt_id()); |
| 2642 ReplaceCall(call, math_unary); |
| 2643 } |
| 2638 } else if ((recognized_kind == MethodRecognizer::kFloat32x4Zero) || | 2644 } else if ((recognized_kind == MethodRecognizer::kFloat32x4Zero) || |
| 2639 (recognized_kind == MethodRecognizer::kFloat32x4Splat) || | 2645 (recognized_kind == MethodRecognizer::kFloat32x4Splat) || |
| 2640 (recognized_kind == MethodRecognizer::kFloat32x4Constructor)) { | 2646 (recognized_kind == MethodRecognizer::kFloat32x4Constructor)) { |
| 2641 TryInlineFloat32x4Constructor(call, recognized_kind); | 2647 TryInlineFloat32x4Constructor(call, recognized_kind); |
| 2642 } else if (recognized_kind == MethodRecognizer::kUint32x4BoolConstructor) { | 2648 } else if (recognized_kind == MethodRecognizer::kUint32x4BoolConstructor) { |
| 2643 TryInlineUint32x4Constructor(call, recognized_kind); | 2649 TryInlineUint32x4Constructor(call, recognized_kind); |
| 2644 } else if (recognized_kind == MethodRecognizer::kObjectConstructor) { | 2650 } else if (recognized_kind == MethodRecognizer::kObjectConstructor) { |
| 2645 // Remove the original push arguments. | 2651 // Remove the original push arguments. |
| 2646 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { | 2652 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { |
| 2647 PushArgumentInstr* push = call->PushArgumentAt(i); | 2653 PushArgumentInstr* push = call->PushArgumentAt(i); |
| (...skipping 3814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6462 Uint32x4ToFloat32x4Instr* instr) { | 6468 Uint32x4ToFloat32x4Instr* instr) { |
| 6463 SetValue(instr, non_constant_); | 6469 SetValue(instr, non_constant_); |
| 6464 } | 6470 } |
| 6465 | 6471 |
| 6466 | 6472 |
| 6467 void ConstantPropagator::VisitBinaryUint32x4Op(BinaryUint32x4OpInstr* instr) { | 6473 void ConstantPropagator::VisitBinaryUint32x4Op(BinaryUint32x4OpInstr* instr) { |
| 6468 SetValue(instr, non_constant_); | 6474 SetValue(instr, non_constant_); |
| 6469 } | 6475 } |
| 6470 | 6476 |
| 6471 | 6477 |
| 6472 void ConstantPropagator::VisitMathSqrt(MathSqrtInstr* instr) { | 6478 void ConstantPropagator::VisitMathUnary(MathUnaryInstr* instr) { |
| 6473 const Object& value = instr->value()->definition()->constant_value(); | 6479 const Object& value = instr->value()->definition()->constant_value(); |
| 6474 if (IsNonConstant(value)) { | 6480 if (IsNonConstant(value)) { |
| 6475 SetValue(instr, non_constant_); | 6481 SetValue(instr, non_constant_); |
| 6476 } else if (IsConstant(value)) { | 6482 } else if (IsConstant(value)) { |
| 6477 // TODO(kmillikin): Handle sqrt. | 6483 // TODO(kmillikin): Handle Math's unary operations (sqrt, cos, sin). |
| 6478 SetValue(instr, non_constant_); | 6484 SetValue(instr, non_constant_); |
| 6479 } | 6485 } |
| 6480 } | 6486 } |
| 6481 | 6487 |
| 6482 | 6488 |
| 6483 void ConstantPropagator::VisitMathMinMax(MathMinMaxInstr* instr) { | 6489 void ConstantPropagator::VisitMathMinMax(MathMinMaxInstr* instr) { |
| 6484 const Object& left = instr->left()->definition()->constant_value(); | 6490 const Object& left = instr->left()->definition()->constant_value(); |
| 6485 const Object& right = instr->right()->definition()->constant_value(); | 6491 const Object& right = instr->right()->definition()->constant_value(); |
| 6486 if (IsNonConstant(left) || IsNonConstant(right)) { | 6492 if (IsNonConstant(left) || IsNonConstant(right)) { |
| 6487 SetValue(instr, non_constant_); | 6493 SetValue(instr, non_constant_); |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7405 } | 7411 } |
| 7406 | 7412 |
| 7407 // Insert materializations at environment uses. | 7413 // Insert materializations at environment uses. |
| 7408 for (intptr_t i = 0; i < exits.length(); i++) { | 7414 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7409 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); | 7415 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); |
| 7410 } | 7416 } |
| 7411 } | 7417 } |
| 7412 | 7418 |
| 7413 | 7419 |
| 7414 } // namespace dart | 7420 } // namespace dart |
| OLD | NEW |