| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 return; | 600 return; |
| 601 } | 601 } |
| 602 const intptr_t kMaxChecks = 4; | 602 const intptr_t kMaxChecks = 4; |
| 603 if (comp->ic_data()->NumberOfChecks() <= kMaxChecks) { | 603 if (comp->ic_data()->NumberOfChecks() <= kMaxChecks) { |
| 604 const ICData& unary_checks = | 604 const ICData& unary_checks = |
| 605 ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks()); | 605 ICData::ZoneHandle(comp->ic_data()->AsUnaryClassChecks()); |
| 606 bool call_with_checks; | 606 bool call_with_checks; |
| 607 // TODO(srdjan): Add check class comp for mixed smi/non-smi. | 607 // TODO(srdjan): Add check class comp for mixed smi/non-smi. |
| 608 if (HasOneTarget(unary_checks) && | 608 if (HasOneTarget(unary_checks) && |
| 609 (unary_checks.GetReceiverClassIdAt(0) != kSmiCid)) { | 609 (unary_checks.GetReceiverClassIdAt(0) != kSmiCid)) { |
| 610 Value* value = comp->ArgumentAt(0)->value()->CopyValue(); | |
| 611 // Type propagation has not run yet, we cannot eliminate the check. | 610 // Type propagation has not run yet, we cannot eliminate the check. |
| 612 CheckClassComp* check = new CheckClassComp(value, comp); | 611 AddCheckClass(instr, comp, comp->ArgumentAt(0)->value()->CopyValue()); |
| 613 check->set_ic_data(&unary_checks); | |
| 614 InsertBefore(instr, check, instr->env(), BindInstr::kUnused); | |
| 615 // Call can still deoptimize, do not detach environment from instr. | 612 // Call can still deoptimize, do not detach environment from instr. |
| 616 call_with_checks = false; | 613 call_with_checks = false; |
| 617 } else { | 614 } else { |
| 618 call_with_checks = true; | 615 call_with_checks = true; |
| 619 } | 616 } |
| 620 PolymorphicInstanceCallComp* call = | 617 PolymorphicInstanceCallComp* call = |
| 621 new PolymorphicInstanceCallComp(comp, call_with_checks); | 618 new PolymorphicInstanceCallComp(comp, call_with_checks); |
| 622 call->set_ic_data(&unary_checks); | 619 call->set_ic_data(&unary_checks); |
| 623 instr->set_computation(call); | 620 instr->set_computation(call); |
| 624 } | 621 } |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. | 1049 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. |
| 1053 OptimizeRecursive(child, &child_map); | 1050 OptimizeRecursive(child, &child_map); |
| 1054 } else { | 1051 } else { |
| 1055 OptimizeRecursive(child, map); // Reuse map for the last child. | 1052 OptimizeRecursive(child, map); // Reuse map for the last child. |
| 1056 } | 1053 } |
| 1057 } | 1054 } |
| 1058 } | 1055 } |
| 1059 | 1056 |
| 1060 | 1057 |
| 1061 } // namespace dart | 1058 } // namespace dart |
| OLD | NEW |