| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 bool FlowGraphOptimizer::TryReplaceWithUnaryOp(BindInstr* instr, | 411 bool FlowGraphOptimizer::TryReplaceWithUnaryOp(BindInstr* instr, |
| 412 InstanceCallComp* comp, | 412 InstanceCallComp* comp, |
| 413 Token::Kind op_kind) { | 413 Token::Kind op_kind) { |
| 414 if (comp->ic_data()->NumberOfChecks() != 1) { | 414 if (comp->ic_data()->NumberOfChecks() != 1) { |
| 415 // TODO(srdjan): Not yet supported. | 415 // TODO(srdjan): Not yet supported. |
| 416 return false; | 416 return false; |
| 417 } | 417 } |
| 418 ASSERT(comp->ArgumentCount() == 1); | 418 ASSERT(comp->ArgumentCount() == 1); |
| 419 Computation* unary_op = NULL; | 419 Computation* unary_op = NULL; |
| 420 if (HasOneSmi(*comp->ic_data())) { | 420 if (HasOneSmi(*comp->ic_data())) { |
| 421 unary_op = new UnarySmiOpComp(op_kind, comp, comp->ArgumentAt(0)->value()); | 421 Value* value = comp->ArgumentAt(0)->value(); |
| 422 InsertBefore(instr, |
| 423 new CheckSmiComp(value->CopyValue(), comp), |
| 424 instr->env(), |
| 425 BindInstr::kUnused); |
| 426 unary_op = new UnarySmiOpComp(op_kind, |
| 427 (op_kind == Token::kNEGATE) ? comp : NULL, |
| 428 value); |
| 422 } else if (HasOneDouble(*comp->ic_data()) && (op_kind == Token::kNEGATE)) { | 429 } else if (HasOneDouble(*comp->ic_data()) && (op_kind == Token::kNEGATE)) { |
| 423 unary_op = new NumberNegateComp(comp, comp->ArgumentAt(0)->value()); | 430 unary_op = new NumberNegateComp(comp, comp->ArgumentAt(0)->value()); |
| 424 } | 431 } |
| 425 if (unary_op == NULL) return false; | 432 if (unary_op == NULL) return false; |
| 426 | 433 |
| 427 unary_op->set_ic_data(comp->ic_data()); | 434 unary_op->set_ic_data(comp->ic_data()); |
| 428 instr->set_computation(unary_op); | 435 instr->set_computation(unary_op); |
| 429 RemovePushArguments(comp); | 436 RemovePushArguments(comp); |
| 430 return true; | 437 return true; |
| 431 } | 438 } |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. | 1059 DirectChainedHashMap<BindInstr*> child_map(*map); // Copy map. |
| 1053 OptimizeRecursive(child, &child_map); | 1060 OptimizeRecursive(child, &child_map); |
| 1054 } else { | 1061 } else { |
| 1055 OptimizeRecursive(child, map); // Reuse map for the last child. | 1062 OptimizeRecursive(child, map); // Reuse map for the last child. |
| 1056 } | 1063 } |
| 1057 } | 1064 } |
| 1058 } | 1065 } |
| 1059 | 1066 |
| 1060 | 1067 |
| 1061 } // namespace dart | 1068 } // namespace dart |
| OLD | NEW |