| 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 21 matching lines...) Expand all Loading... |
| 32 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 32 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 33 Instruction* instr = block_order_[i]->Accept(this); | 33 Instruction* instr = block_order_[i]->Accept(this); |
| 34 // Compile all successors until an exit, branch, or a block entry. | 34 // Compile all successors until an exit, branch, or a block entry. |
| 35 while ((instr != NULL) && !instr->IsBlockEntry()) { | 35 while ((instr != NULL) && !instr->IsBlockEntry()) { |
| 36 instr = instr->Accept(this); | 36 instr = instr->Accept(this); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 static Token::Kind GetBinaryOp(const String& name) { | |
| 43 if (name.Length() == 1) { | |
| 44 switch (name.CharAt(0)) { | |
| 45 case '+' : return Token::kADD; | |
| 46 default: return Token::kILLEGAL; | |
| 47 } | |
| 48 } | |
| 49 return Token::kILLEGAL; | |
| 50 } | |
| 51 | |
| 52 | |
| 53 static bool ICDataHasTwoReceiverClasses(const ICData& ic_data, | 42 static bool ICDataHasTwoReceiverClasses(const ICData& ic_data, |
| 54 const Class& cls1, | 43 const Class& cls1, |
| 55 const Class& cls2) { | 44 const Class& cls2) { |
| 56 ASSERT(!cls1.IsNull() && !cls2.IsNull()); | 45 ASSERT(!cls1.IsNull() && !cls2.IsNull()); |
| 57 if (ic_data.num_args_tested() != 2) { | 46 if (ic_data.num_args_tested() != 2) { |
| 58 return false; | 47 return false; |
| 59 } | 48 } |
| 60 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { | 49 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { |
| 61 GrowableArray<const Class*> classes; | 50 GrowableArray<const Class*> classes; |
| 62 Function& target = Function::Handle(); | 51 Function& target = Function::Handle(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 | 63 |
| 75 static bool HasTwoSmi(const ICData& ic_data) { | 64 static bool HasTwoSmi(const ICData& ic_data) { |
| 76 const Class& smi_class = | 65 const Class& smi_class = |
| 77 Class::Handle(Isolate::Current()->object_store()->smi_class()); | 66 Class::Handle(Isolate::Current()->object_store()->smi_class()); |
| 78 return ICDataHasTwoReceiverClasses(ic_data, smi_class, smi_class); | 67 return ICDataHasTwoReceiverClasses(ic_data, smi_class, smi_class); |
| 79 } | 68 } |
| 80 | 69 |
| 81 | 70 |
| 82 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp) { | 71 void FlowGraphOptimizer::VisitInstanceCall(InstanceCallComp* comp) { |
| 83 if ((comp->ic_data() != NULL) && (!comp->ic_data()->IsNull())) { | 72 if ((comp->ic_data() != NULL) && (!comp->ic_data()->IsNull())) { |
| 84 Token::Kind op_kind = GetBinaryOp(comp->function_name()); | 73 Token::Kind op_kind = Token::GetBinaryOp(comp->function_name()); |
| 85 if (op_kind == Token::kILLEGAL) { | 74 if (op_kind == Token::kILLEGAL) { |
| 86 // Not a recognized binary operation. | 75 // Not a recognized binary operation. |
| 87 return; | 76 return; |
| 88 } | 77 } |
| 89 if (comp->ic_data()->NumberOfChecks() != 1) { | 78 if (comp->ic_data()->NumberOfChecks() != 1) { |
| 90 // TODO(srdjan): Not yet supported. | 79 // TODO(srdjan): Not yet supported. |
| 91 return; | 80 return; |
| 92 } | 81 } |
| 93 if (!HasTwoSmi(*comp->ic_data())) { | 82 if (!HasTwoSmi(*comp->ic_data())) { |
| 94 // TODO(srdjan): Not yet supported. | 83 // TODO(srdjan): Not yet supported. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 110 instr->computation()->Accept(this); | 99 instr->computation()->Accept(this); |
| 111 } | 100 } |
| 112 | 101 |
| 113 | 102 |
| 114 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { | 103 void FlowGraphOptimizer::VisitBind(BindInstr* instr) { |
| 115 instr->computation()->Accept(this); | 104 instr->computation()->Accept(this); |
| 116 } | 105 } |
| 117 | 106 |
| 118 | 107 |
| 119 } // namespace dart | 108 } // namespace dart |
| OLD | NEW |