| 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/cha.h" | 7 #include "vm/cha.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" |
| 10 #include "vm/il_printer.h" | 10 #include "vm/il_printer.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 return; | 531 return; |
| 532 } | 532 } |
| 533 if ((op_kind == Token::kSET) && TryInlineInstanceSetter(instr, comp)) { | 533 if ((op_kind == Token::kSET) && TryInlineInstanceSetter(instr, comp)) { |
| 534 return; | 534 return; |
| 535 } | 535 } |
| 536 if (TryInlineInstanceMethod(instr, comp)) { | 536 if (TryInlineInstanceMethod(instr, comp)) { |
| 537 return; | 537 return; |
| 538 } | 538 } |
| 539 const intptr_t kMaxChecks = 4; | 539 const intptr_t kMaxChecks = 4; |
| 540 if (comp->ic_data()->NumberOfChecks() <= kMaxChecks) { | 540 if (comp->ic_data()->NumberOfChecks() <= kMaxChecks) { |
| 541 PolymorphicInstanceCallComp* call = new PolymorphicInstanceCallComp(comp); | |
| 542 const ICData& unary_checks = | 541 const ICData& unary_checks = |
| 543 ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks()); | 542 ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks()); |
| 543 bool call_with_checks; |
| 544 // TODO(srdjan): Add check class comp for mixed smi/non-smi. |
| 545 if (HasOneTarget(unary_checks) && |
| 546 (unary_checks.GetReceiverClassIdAt(0) != kSmiCid)) { |
| 547 Value* value = comp->ArgumentAt(0)->value()->CopyValue(); |
| 548 // Type propagation has not run yet, we cannot eliminate the check. |
| 549 CheckClassComp* check = new CheckClassComp(value, comp); |
| 550 check->set_ic_data(&unary_checks); |
| 551 InsertCheckBefore(instr, check, instr->env()->Copy()); |
| 552 // Call can still deoptimize, do not detach environment from instr. |
| 553 call_with_checks = false; |
| 554 } else { |
| 555 call_with_checks = true; |
| 556 } |
| 557 PolymorphicInstanceCallComp* call = |
| 558 new PolymorphicInstanceCallComp(comp, call_with_checks); |
| 544 call->set_ic_data(&unary_checks); | 559 call->set_ic_data(&unary_checks); |
| 545 instr->set_computation(call); | 560 instr->set_computation(call); |
| 546 } | 561 } |
| 547 } | 562 } |
| 548 // An instance call without ICData should continue calling via IC calls | 563 // An instance call without ICData should continue calling via IC calls |
| 549 // which should trigger reoptimization of optimized code. | 564 // which should trigger reoptimization of optimized code. |
| 550 } | 565 } |
| 551 | 566 |
| 552 | 567 |
| 553 void FlowGraphOptimizer::VisitStaticCall(StaticCallComp* comp, | 568 void FlowGraphOptimizer::VisitStaticCall(StaticCallComp* comp, |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 OS::Print("Replacing v%d with v%d\n", | 986 OS::Print("Replacing v%d with v%d\n", |
| 972 instr->ssa_temp_index(), | 987 instr->ssa_temp_index(), |
| 973 result->ssa_temp_index()); | 988 result->ssa_temp_index()); |
| 974 } | 989 } |
| 975 } | 990 } |
| 976 } | 991 } |
| 977 } | 992 } |
| 978 | 993 |
| 979 | 994 |
| 980 } // namespace dart | 995 } // namespace dart |
| OLD | NEW |