| 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #define DEFINE_ACCEPT(ShortName) \ | 70 #define DEFINE_ACCEPT(ShortName) \ |
| 71 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ | 71 void ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ |
| 72 visitor->Visit##ShortName(this); \ | 72 visitor->Visit##ShortName(this); \ |
| 73 } | 73 } |
| 74 | 74 |
| 75 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT) | 75 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT) |
| 76 | 76 |
| 77 #undef DEFINE_ACCEPT | 77 #undef DEFINE_ACCEPT |
| 78 | 78 |
| 79 | 79 |
| 80 void ForwardInstructionIterator::RemoveCurrentFromGraph() { | 80 Instruction* Instruction::RemoveFromGraph(bool return_previous) { |
| 81 ASSERT(!current_->IsBlockEntry()); | 81 ASSERT(!IsBlockEntry()); |
| 82 ASSERT(!current_->IsBranch()); | 82 ASSERT(!IsBranch()); |
| 83 ASSERT(!current_->IsThrow()); | 83 ASSERT(!IsThrow()); |
| 84 ASSERT(!current_->IsReturn()); | 84 ASSERT(!IsReturn()); |
| 85 ASSERT(!current_->IsReThrow()); | 85 ASSERT(!IsReThrow()); |
| 86 ASSERT(current_->previous() != NULL); | 86 ASSERT(!IsGoto()); |
| 87 ASSERT(current_ != block_entry_->last_instruction()); | 87 ASSERT(previous() != NULL); |
| 88 Instruction* prev = current_->previous(); | 88 Instruction* prev_instr = previous(); |
| 89 Instruction* next = current_->next(); | 89 Instruction* next_instr = next(); |
| 90 ASSERT(next != NULL); | 90 ASSERT(next_instr != NULL); |
| 91 ASSERT(!next->IsBlockEntry()); | 91 ASSERT(!next_instr->IsBlockEntry()); |
| 92 prev->set_next(next); | 92 prev_instr->set_next(next_instr); |
| 93 next->set_previous(prev); | 93 next_instr->set_previous(prev_instr); |
| 94 // Reset successor and previous instruction to indicate | 94 // Reset successor and previous instruction to indicate |
| 95 // that the instruction is removed from the graph. | 95 // that the instruction is removed from the graph. |
| 96 current_->set_previous(NULL); | 96 set_previous(NULL); |
| 97 current_->set_next(NULL); | 97 set_next(NULL); |
| 98 current_ = prev; | 98 return return_previous ? prev_instr : next_instr; |
| 99 } |
| 100 |
| 101 |
| 102 void ForwardInstructionIterator::RemoveCurrentFromGraph() { |
| 103 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. |
| 99 } | 104 } |
| 100 | 105 |
| 101 | 106 |
| 102 // Default implementation of visiting basic blocks. Can be overridden. | 107 // Default implementation of visiting basic blocks. Can be overridden. |
| 103 void FlowGraphVisitor::VisitBlocks() { | 108 void FlowGraphVisitor::VisitBlocks() { |
| 104 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 109 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 105 BlockEntryInstr* entry = block_order_[i]; | 110 BlockEntryInstr* entry = block_order_[i]; |
| 106 entry->Accept(this); | 111 entry->Accept(this); |
| 107 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 112 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 108 it.Current()->Accept(this); | 113 it.Current()->Accept(this); |
| 109 } | 114 } |
| 110 } | 115 } |
| 111 } | 116 } |
| 112 | 117 |
| 113 | 118 |
| 114 intptr_t InstanceCallComp::InputCount() const { | |
| 115 return ArgumentCount(); | |
| 116 } | |
| 117 | |
| 118 | |
| 119 intptr_t AllocateObjectComp::InputCount() const { | 119 intptr_t AllocateObjectComp::InputCount() const { |
| 120 return arguments().length(); | 120 return arguments().length(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 intptr_t AllocateObjectWithBoundsCheckComp::InputCount() const { | 124 intptr_t AllocateObjectWithBoundsCheckComp::InputCount() const { |
| 125 return arguments().length(); | 125 return arguments().length(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 __ Drop(argument_count); | 1153 __ Drop(argument_count); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 | 1156 |
| 1157 LocationSummary* InstanceCallComp::MakeLocationSummary() const { | 1157 LocationSummary* InstanceCallComp::MakeLocationSummary() const { |
| 1158 return MakeCallSummary(); | 1158 return MakeCallSummary(); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 | 1161 |
| 1162 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1162 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1163 ASSERT(VerifyCallComputation(this)); | |
| 1164 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, | 1163 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 1165 cid(), | 1164 cid(), |
| 1166 token_pos(), | 1165 token_pos(), |
| 1167 try_index()); | 1166 try_index()); |
| 1168 compiler->GenerateInstanceCall(cid(), | 1167 compiler->GenerateInstanceCall(cid(), |
| 1169 token_pos(), | 1168 token_pos(), |
| 1170 try_index(), | 1169 try_index(), |
| 1171 function_name(), | 1170 function_name(), |
| 1172 ArgumentCount(), | 1171 ArgumentCount(), |
| 1173 argument_names(), | 1172 argument_names(), |
| 1174 checked_argument_count()); | 1173 checked_argument_count()); |
| 1175 } | 1174 } |
| 1176 | 1175 |
| 1177 | 1176 |
| 1178 bool InstanceCallComp::VerifyComputation() { | |
| 1179 return VerifyCallComputation(this); | |
| 1180 } | |
| 1181 | |
| 1182 | |
| 1183 LocationSummary* StaticCallComp::MakeLocationSummary() const { | 1177 LocationSummary* StaticCallComp::MakeLocationSummary() const { |
| 1184 return MakeCallSummary(); | 1178 return MakeCallSummary(); |
| 1185 } | 1179 } |
| 1186 | 1180 |
| 1187 | 1181 |
| 1188 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1182 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1189 Label done; | 1183 Label done; |
| 1190 if (recognized() == MethodRecognizer::kMathSqrt) { | 1184 if (recognized() == MethodRecognizer::kMathSqrt) { |
| 1191 compiler->GenerateInlinedMathSqrt(&done); | 1185 compiler->GenerateInlinedMathSqrt(&done); |
| 1192 // Falls through to static call when operand type is not double or smi. | 1186 // Falls through to static call when operand type is not double or smi. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 if (compiler->is_ssa()) { | 1336 if (compiler->is_ssa()) { |
| 1343 ASSERT(locs()->in(0).IsRegister()); | 1337 ASSERT(locs()->in(0).IsRegister()); |
| 1344 __ PushRegister(locs()->in(0).reg()); | 1338 __ PushRegister(locs()->in(0).reg()); |
| 1345 } | 1339 } |
| 1346 } | 1340 } |
| 1347 | 1341 |
| 1348 | 1342 |
| 1349 #undef __ | 1343 #undef __ |
| 1350 | 1344 |
| 1351 } // namespace dart | 1345 } // namespace dart |
| OLD | NEW |