| 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_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| 11 #include "vm/flow_graph_compiler.h" | 11 #include "vm/flow_graph_compiler.h" |
| 12 #include "vm/locations.h" | 12 #include "vm/locations.h" |
| 13 #include "vm/object.h" | 13 #include "vm/object.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/os.h" | 15 #include "vm/os.h" |
| 16 #include "vm/scopes.h" | 16 #include "vm/scopes.h" |
| 17 #include "vm/stub_code.h" | 17 #include "vm/stub_code.h" |
| 18 #include "vm/symbols.h" | 18 #include "vm/symbols.h" |
| 19 | 19 |
| 20 namespace dart { | 20 namespace dart { |
| 21 | 21 |
| 22 DECLARE_FLAG(bool, enable_type_checks); | 22 DECLARE_FLAG(bool, enable_type_checks); |
| 23 | 23 |
| 24 |
| 25 intptr_t Computation::Hashcode() const { |
| 26 intptr_t result = computation_kind(); |
| 27 for (intptr_t i = 0; i < InputCount(); ++i) { |
| 28 UseVal* val = InputAt(i)->AsUse(); |
| 29 intptr_t j = val != NULL |
| 30 ? val->definition()->ssa_temp_index() |
| 31 : -1; |
| 32 result = result * 31 + j; |
| 33 } |
| 34 return result; |
| 35 } |
| 36 |
| 37 |
| 38 bool Computation::Equals(Computation* other) const { |
| 39 if (computation_kind() != other->computation_kind()) return false; |
| 40 for (intptr_t i = 0; i < InputCount(); ++i) { |
| 41 if (!InputAt(i)->Equals(other->InputAt(i))) return false; |
| 42 } |
| 43 return AttributesEqual(other); |
| 44 } |
| 45 |
| 46 |
| 47 bool CheckClassComp::AttributesEqual(Computation* other) const { |
| 48 CheckClassComp* other_check = other->AsCheckClass(); |
| 49 if (other_check == NULL) return false; |
| 50 if (ic_data()->NumberOfChecks() != other->ic_data()->NumberOfChecks()) { |
| 51 return false; |
| 52 } |
| 53 for (intptr_t i = 0; i < ic_data()->NumberOfChecks(); ++i) { |
| 54 // TODO(fschneider): Make sure ic_data are sorted to hit more cases. |
| 55 if (ic_data()->GetReceiverClassIdAt(i) != |
| 56 other->ic_data()->GetReceiverClassIdAt(i)) { |
| 57 return false; |
| 58 } |
| 59 } |
| 60 return true; |
| 61 } |
| 62 |
| 63 |
| 24 UseVal::UseVal(Definition* definition) | 64 UseVal::UseVal(Definition* definition) |
| 25 : definition_(definition), next_use_(NULL), previous_use_(NULL) { | 65 : definition_(definition), next_use_(NULL), previous_use_(NULL) { |
| 26 AddToUseList(); | 66 AddToUseList(); |
| 27 } | 67 } |
| 28 | 68 |
| 29 | 69 |
| 30 void UseVal::SetDefinition(Definition* definition) { | 70 void UseVal::SetDefinition(Definition* definition) { |
| 31 ASSERT(definition != NULL); | 71 ASSERT(definition != NULL); |
| 32 RemoveFromUseList(); | 72 RemoveFromUseList(); |
| 33 definition_ = definition; | 73 definition_ = definition; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 next_instr->set_previous(prev_instr); | 210 next_instr->set_previous(prev_instr); |
| 171 // Reset successor and previous instruction to indicate | 211 // Reset successor and previous instruction to indicate |
| 172 // that the instruction is removed from the graph. | 212 // that the instruction is removed from the graph. |
| 173 set_previous(NULL); | 213 set_previous(NULL); |
| 174 set_next(NULL); | 214 set_next(NULL); |
| 175 ASSERT(!IsDefinition() || AsDefinition()->use_list() == NULL); | 215 ASSERT(!IsDefinition() || AsDefinition()->use_list() == NULL); |
| 176 return return_previous ? prev_instr : next_instr; | 216 return return_previous ? prev_instr : next_instr; |
| 177 } | 217 } |
| 178 | 218 |
| 179 | 219 |
| 220 void BindInstr::InsertBefore(BindInstr* next) { |
| 221 ASSERT(previous_ == NULL); |
| 222 ASSERT(next_ == NULL); |
| 223 next_ = next; |
| 224 previous_ = next->previous_; |
| 225 next->previous_ = this; |
| 226 previous_->next_ = this; |
| 227 } |
| 228 |
| 229 |
| 180 void ForwardInstructionIterator::RemoveCurrentFromGraph() { | 230 void ForwardInstructionIterator::RemoveCurrentFromGraph() { |
| 181 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. | 231 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. |
| 182 } | 232 } |
| 183 | 233 |
| 184 | 234 |
| 185 // Default implementation of visiting basic blocks. Can be overridden. | 235 // Default implementation of visiting basic blocks. Can be overridden. |
| 186 void FlowGraphVisitor::VisitBlocks() { | 236 void FlowGraphVisitor::VisitBlocks() { |
| 187 ASSERT(current_iterator_ == NULL); | 237 ASSERT(current_iterator_ == NULL); |
| 188 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 238 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 189 BlockEntryInstr* entry = block_order_[i]; | 239 BlockEntryInstr* entry = block_order_[i]; |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 RawAbstractType* DoubleToDoubleComp::CompileType() const { | 1008 RawAbstractType* DoubleToDoubleComp::CompileType() const { |
| 959 return Type::DoubleInterface(); | 1009 return Type::DoubleInterface(); |
| 960 } | 1010 } |
| 961 | 1011 |
| 962 | 1012 |
| 963 RawAbstractType* SmiToDoubleComp::CompileType() const { | 1013 RawAbstractType* SmiToDoubleComp::CompileType() const { |
| 964 return Type::DoubleInterface(); | 1014 return Type::DoubleInterface(); |
| 965 } | 1015 } |
| 966 | 1016 |
| 967 | 1017 |
| 1018 RawAbstractType* CheckClassComp::CompileType() const { |
| 1019 return AbstractType::null(); |
| 1020 } |
| 1021 |
| 1022 |
| 968 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and | 1023 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and |
| 969 // PrepareEntry). Only assembly code that can be shared across all architectures | 1024 // PrepareEntry). Only assembly code that can be shared across all architectures |
| 970 // can be used. Machine specific register allocation and code generation | 1025 // can be used. Machine specific register allocation and code generation |
| 971 // is located in intermediate_language_<arch>.cc | 1026 // is located in intermediate_language_<arch>.cc |
| 972 | 1027 |
| 973 | 1028 |
| 974 // True iff. the arguments to a call will be properly pushed and can | 1029 // True iff. the arguments to a call will be properly pushed and can |
| 975 // be popped after the call. | 1030 // be popped after the call. |
| 976 template <typename T> static bool VerifyCallComputation(T* comp) { | 1031 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 977 // Argument values should be consecutive temps. | 1032 // Argument values should be consecutive temps. |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 if (compiler->is_ssa()) { | 1490 if (compiler->is_ssa()) { |
| 1436 ASSERT(locs()->in(0).IsRegister()); | 1491 ASSERT(locs()->in(0).IsRegister()); |
| 1437 __ PushRegister(locs()->in(0).reg()); | 1492 __ PushRegister(locs()->in(0).reg()); |
| 1438 } | 1493 } |
| 1439 } | 1494 } |
| 1440 | 1495 |
| 1441 | 1496 |
| 1442 #undef __ | 1497 #undef __ |
| 1443 | 1498 |
| 1444 } // namespace dart | 1499 } // namespace dart |
| OLD | NEW |