| 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 | 10 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if ((ic_data.NumberOfChecks() == 0) || !HasOneTarget(ic_data)) { | 381 if ((ic_data.NumberOfChecks() == 0) || !HasOneTarget(ic_data)) { |
| 382 // No type feedback collected. | 382 // No type feedback collected. |
| 383 return; | 383 return; |
| 384 } | 384 } |
| 385 Function& target = Function::Handle(); | 385 Function& target = Function::Handle(); |
| 386 GrowableArray<const Class*> classes; | 386 GrowableArray<const Class*> classes; |
| 387 ic_data.GetCheckAt(0, &classes, &target); | 387 ic_data.GetCheckAt(0, &classes, &target); |
| 388 ASSERT(classes.length() == 1); | 388 ASSERT(classes.length() == 1); |
| 389 MethodRecognizer::Kind recognized_kind = | 389 MethodRecognizer::Kind recognized_kind = |
| 390 MethodRecognizer::RecognizeKind(target); | 390 MethodRecognizer::RecognizeKind(target); |
| 391 |
| 392 ObjectKind from_kind; |
| 391 if (recognized_kind == MethodRecognizer::kDoubleToDouble) { | 393 if (recognized_kind == MethodRecognizer::kDoubleToDouble) { |
| 392 // TODO(srdjan): Implement. | 394 from_kind = kDouble; |
| 395 } else if (recognized_kind == MethodRecognizer::kIntegerToDouble) { |
| 396 from_kind = kSmi; |
| 397 } else { |
| 398 return; |
| 393 } | 399 } |
| 394 if (recognized_kind == MethodRecognizer::kIntegerToDouble) { | 400 |
| 395 // TODO(srdjan): Implement. | 401 if (classes[0]->id() != from_kind) { |
| 402 return; |
| 396 } | 403 } |
| 404 |
| 405 ToDoubleComp* coerce = new ToDoubleComp( |
| 406 comp->InputAt(0), from_kind, comp); |
| 407 coerce->set_instr(comp->instr()); |
| 408 comp->instr()->replace_computation(coerce); |
| 397 } | 409 } |
| 398 | 410 |
| 399 | 411 |
| 400 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp) { | 412 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp) { |
| 401 if (comp->HasICData()) { | 413 if (comp->HasICData()) { |
| 402 const String& function_name = comp->function_name(); | 414 const String& function_name = comp->function_name(); |
| 403 Token::Kind op_kind = Token::GetBinaryOp(function_name); | 415 Token::Kind op_kind = Token::GetBinaryOp(function_name); |
| 404 if (op_kind != Token::kILLEGAL) { | 416 if (op_kind != Token::kILLEGAL) { |
| 405 TryReplaceWithBinaryOp(comp, op_kind); | 417 TryReplaceWithBinaryOp(comp, op_kind); |
| 406 return; | 418 return; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 instr->computation()->Accept(this); | 526 instr->computation()->Accept(this); |
| 515 } | 527 } |
| 516 | 528 |
| 517 | 529 |
| 518 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { | 530 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { |
| 519 instr->computation()->Accept(this); | 531 instr->computation()->Accept(this); |
| 520 } | 532 } |
| 521 | 533 |
| 522 | 534 |
| 523 } // namespace dart | 535 } // namespace dart |
| OLD | NEW |