| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 return false; | 437 return false; |
| 438 } | 438 } |
| 439 ToDoubleComp* coerce = new ToDoubleComp( | 439 ToDoubleComp* coerce = new ToDoubleComp( |
| 440 comp->InputAt(0), from_kind, comp); | 440 comp->InputAt(0), from_kind, comp); |
| 441 coerce->set_instr(comp->instr()); | 441 coerce->set_instr(comp->instr()); |
| 442 comp->instr()->replace_computation(coerce); | 442 comp->instr()->replace_computation(coerce); |
| 443 return true; | 443 return true; |
| 444 } | 444 } |
| 445 | 445 |
| 446 | 446 |
| 447 |
| 448 |
| 447 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp) { | 449 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp) { |
| 448 if (comp->HasICData() && (comp->ic_data()->NumberOfChecks() > 0)) { | 450 if (comp->HasICData() && (comp->ic_data()->NumberOfChecks() > 0)) { |
| 449 const String& function_name = comp->function_name(); | 451 const Token::Kind op_kind = comp->token_kind(); |
| 450 Token::Kind op_kind = Token::GetBinaryOp(function_name); | 452 if (Token::IsBinaryToken(op_kind) && |
| 451 if ((op_kind != Token::kILLEGAL) && TryReplaceWithBinaryOp(comp, op_kind)) { | 453 TryReplaceWithBinaryOp(comp, op_kind)) { |
| 452 return; | 454 return; |
| 453 } | 455 } |
| 454 op_kind = Token::GetUnaryOp(function_name); | 456 if (Token::IsUnaryToken(op_kind) && TryReplaceWithUnaryOp(comp, op_kind)) { |
| 455 if ((op_kind != Token::kILLEGAL) && TryReplaceWithUnaryOp(comp, op_kind)) { | |
| 456 return; | 457 return; |
| 457 } | 458 } |
| 458 if ((Field::IsGetterName(function_name)) && TryInlineInstanceGetter(comp)) { | 459 if ((op_kind == Token::kGET) && TryInlineInstanceGetter(comp)) { |
| 459 return; | 460 return; |
| 460 } | 461 } |
| 461 if (TryInlineInstanceMethod(comp)) { | 462 if (TryInlineInstanceMethod(comp)) { |
| 462 return; | 463 return; |
| 463 } | 464 } |
| 464 const intptr_t kMaxChecks = 4; | 465 const intptr_t kMaxChecks = 4; |
| 465 if (comp->ic_data()->num_args_tested() <= kMaxChecks) { | 466 if (comp->ic_data()->num_args_tested() <= kMaxChecks) { |
| 466 ZoneGrowableArray<intptr_t>* class_ids = | 467 ZoneGrowableArray<intptr_t>* class_ids = |
| 467 new ZoneGrowableArray<intptr_t>(); | 468 new ZoneGrowableArray<intptr_t>(); |
| 468 ZoneGrowableArray<Function*>* targets = | 469 ZoneGrowableArray<Function*>* targets = |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 instr->computation()->Accept(this); | 642 instr->computation()->Accept(this); |
| 642 } | 643 } |
| 643 | 644 |
| 644 | 645 |
| 645 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { | 646 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { |
| 646 instr->computation()->Accept(this); | 647 instr->computation()->Accept(this); |
| 647 } | 648 } |
| 648 | 649 |
| 649 | 650 |
| 650 } // namespace dart | 651 } // namespace dart |
| OLD | NEW |