| 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/flow_graph_builder.h" | 7 #include "vm/flow_graph_builder.h" |
| 8 #include "vm/il_printer.h" | 8 #include "vm/il_printer.h" |
| 9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if ((ic_data.NumberOfChecks() == 0) || !HasOneTarget(ic_data)) { | 371 if ((ic_data.NumberOfChecks() == 0) || !HasOneTarget(ic_data)) { |
| 372 // No type feedback collected. | 372 // No type feedback collected. |
| 373 return false; | 373 return false; |
| 374 } | 374 } |
| 375 Function& target = Function::Handle(); | 375 Function& target = Function::Handle(); |
| 376 GrowableArray<intptr_t> class_ids; | 376 GrowableArray<intptr_t> class_ids; |
| 377 ic_data.GetCheckAt(0, &class_ids, &target); | 377 ic_data.GetCheckAt(0, &class_ids, &target); |
| 378 MethodRecognizer::Kind recognized_kind = | 378 MethodRecognizer::Kind recognized_kind = |
| 379 MethodRecognizer::RecognizeKind(target); | 379 MethodRecognizer::RecognizeKind(target); |
| 380 | 380 |
| 381 intptr_t from_class_id; | 381 if ((recognized_kind == MethodRecognizer::kDoubleToDouble) && |
| 382 if (recognized_kind == MethodRecognizer::kDoubleToDouble) { | 382 (class_ids[0] == kDoubleCid)) { |
| 383 from_class_id = kDoubleCid; | 383 DoubleToDoubleComp* d2d_comp = |
| 384 } else if (recognized_kind == MethodRecognizer::kIntegerToDouble) { | 384 new DoubleToDoubleComp(comp->ArgumentAt(0)->value(), comp); |
| 385 from_class_id = kSmiCid; | 385 instr->set_computation(d2d_comp); |
| 386 } else { | 386 RemovePushArguments(comp); |
| 387 return false; | 387 return true; |
| 388 } | 388 } |
| 389 | 389 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
| 390 if (class_ids[0] != from_class_id) { | 390 (class_ids[0] == kSmiCid)) { |
| 391 return false; | 391 SmiToDoubleComp* s2d_comp = new SmiToDoubleComp(comp); |
| 392 instr->set_computation(s2d_comp); |
| 393 // Pushed arguments are not removed because SmiToDouble is implemented |
| 394 // as a call. |
| 395 return true; |
| 392 } | 396 } |
| 393 ToDoubleComp* coerce = new ToDoubleComp( | 397 return false; |
| 394 comp->ArgumentAt(0)->value(), from_class_id, comp); | |
| 395 instr->set_computation(coerce); | |
| 396 RemovePushArguments(comp); | |
| 397 return true; | |
| 398 } | 398 } |
| 399 | 399 |
| 400 | 400 |
| 401 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp, | 401 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp, |
| 402 BindInstr* instr) { | 402 BindInstr* instr) { |
| 403 if (comp->HasICData() && (comp->ic_data()->NumberOfChecks() > 0)) { | 403 if (comp->HasICData() && (comp->ic_data()->NumberOfChecks() > 0)) { |
| 404 const Token::Kind op_kind = comp->token_kind(); | 404 const Token::Kind op_kind = comp->token_kind(); |
| 405 if (Token::IsBinaryToken(op_kind) && | 405 if (Token::IsBinaryToken(op_kind) && |
| 406 TryReplaceWithBinaryOp(instr, comp, op_kind)) { | 406 TryReplaceWithBinaryOp(instr, comp, op_kind)) { |
| 407 return; | 407 return; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 LocationSummary* locs = it.Current()->locs(); | 718 LocationSummary* locs = it.Current()->locs(); |
| 719 if ((locs != NULL) && locs->contains_call()) { | 719 if ((locs != NULL) && locs->contains_call()) { |
| 720 is_leaf_ = false; | 720 is_leaf_ = false; |
| 721 return; | 721 return; |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 } | 725 } |
| 726 | 726 |
| 727 } // namespace dart | 727 } // namespace dart |
| OLD | NEW |