| 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/jit_optimizer.h" | 5 #include "vm/jit_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return; // No information about receiver was infered. | 242 return; // No information about receiver was infered. |
| 243 } | 243 } |
| 244 | 244 |
| 245 const ICData& ic_data = TrySpecializeICData(call->ic_data(), receiver_cid); | 245 const ICData& ic_data = TrySpecializeICData(call->ic_data(), receiver_cid); |
| 246 if (ic_data.raw() == call->ic_data().raw()) { | 246 if (ic_data.raw() == call->ic_data().raw()) { |
| 247 // No specialization. | 247 // No specialization. |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 | 250 |
| 251 const bool with_checks = false; | 251 const bool with_checks = false; |
| 252 const bool complete = false; |
| 252 PolymorphicInstanceCallInstr* specialized = | 253 PolymorphicInstanceCallInstr* specialized = |
| 253 new(Z) PolymorphicInstanceCallInstr(call->instance_call(), | 254 new(Z) PolymorphicInstanceCallInstr(call->instance_call(), |
| 254 ic_data, | 255 ic_data, |
| 255 with_checks); | 256 with_checks, |
| 257 complete); |
| 256 call->ReplaceWith(specialized, current_iterator()); | 258 call->ReplaceWith(specialized, current_iterator()); |
| 257 } | 259 } |
| 258 | 260 |
| 259 | 261 |
| 260 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) { | 262 static BinarySmiOpInstr* AsSmiShiftLeftInstruction(Definition* d) { |
| 261 BinarySmiOpInstr* instr = d->AsBinarySmiOp(); | 263 BinarySmiOpInstr* instr = d->AsBinarySmiOp(); |
| 262 if ((instr != NULL) && (instr->op_kind() == Token::kSHL)) { | 264 if ((instr != NULL) && (instr->op_kind() == Token::kSHL)) { |
| 263 return instr; | 265 return instr; |
| 264 } | 266 } |
| 265 return NULL; | 267 return NULL; |
| (...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2748 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target); | 2750 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target); |
| 2749 has_one_target = !polymorphic_target; | 2751 has_one_target = !polymorphic_target; |
| 2750 } | 2752 } |
| 2751 | 2753 |
| 2752 if (has_one_target) { | 2754 if (has_one_target) { |
| 2753 RawFunction::Kind function_kind = | 2755 RawFunction::Kind function_kind = |
| 2754 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); | 2756 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); |
| 2755 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { | 2757 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { |
| 2756 PolymorphicInstanceCallInstr* call = | 2758 PolymorphicInstanceCallInstr* call = |
| 2757 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, | 2759 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, |
| 2758 /* call_with_checks = */ false); | 2760 /* call_with_checks = */ false, |
| 2761 /* complete = */ false); |
| 2759 instr->ReplaceWith(call, current_iterator()); | 2762 instr->ReplaceWith(call, current_iterator()); |
| 2760 return; | 2763 return; |
| 2761 } | 2764 } |
| 2762 } | 2765 } |
| 2763 | 2766 |
| 2764 if ((unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) || | 2767 if ((unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks) || |
| 2765 (has_one_target && is_dense)) { | 2768 (has_one_target && is_dense)) { |
| 2766 bool call_with_checks; | 2769 bool call_with_checks; |
| 2767 if (has_one_target && FLAG_polymorphic_with_deopt) { | 2770 if (has_one_target && FLAG_polymorphic_with_deopt) { |
| 2768 // Type propagation has not run yet, we cannot eliminate the check. | 2771 // Type propagation has not run yet, we cannot eliminate the check. |
| 2769 AddReceiverCheck(instr); | 2772 AddReceiverCheck(instr); |
| 2770 // Call can still deoptimize, do not detach environment from instr. | 2773 // Call can still deoptimize, do not detach environment from instr. |
| 2771 call_with_checks = false; | 2774 call_with_checks = false; |
| 2772 } else { | 2775 } else { |
| 2773 call_with_checks = true; | 2776 call_with_checks = true; |
| 2774 } | 2777 } |
| 2775 PolymorphicInstanceCallInstr* call = | 2778 PolymorphicInstanceCallInstr* call = |
| 2776 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, | 2779 new(Z) PolymorphicInstanceCallInstr(instr, unary_checks, |
| 2777 call_with_checks); | 2780 call_with_checks, |
| 2781 /* complete = */ false); |
| 2778 instr->ReplaceWith(call, current_iterator()); | 2782 instr->ReplaceWith(call, current_iterator()); |
| 2779 } | 2783 } |
| 2780 } | 2784 } |
| 2781 | 2785 |
| 2782 | 2786 |
| 2783 void JitOptimizer::VisitStaticCall(StaticCallInstr* call) { | 2787 void JitOptimizer::VisitStaticCall(StaticCallInstr* call) { |
| 2784 if (!CanUnboxDouble()) { | 2788 if (!CanUnboxDouble()) { |
| 2785 return; | 2789 return; |
| 2786 } | 2790 } |
| 2787 MethodRecognizer::Kind recognized_kind = | 2791 MethodRecognizer::Kind recognized_kind = |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3125 | 3129 |
| 3126 // Discard the environment from the original instruction because the store | 3130 // Discard the environment from the original instruction because the store |
| 3127 // can't deoptimize. | 3131 // can't deoptimize. |
| 3128 instr->RemoveEnvironment(); | 3132 instr->RemoveEnvironment(); |
| 3129 ReplaceCall(instr, store); | 3133 ReplaceCall(instr, store); |
| 3130 return true; | 3134 return true; |
| 3131 } | 3135 } |
| 3132 | 3136 |
| 3133 | 3137 |
| 3134 } // namespace dart | 3138 } // namespace dart |
| OLD | NEW |