Chromium Code Reviews| 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; | |
|
srdjan
2012/08/17 22:30:22
Weird indentation.
Florian Schneider
2012/08/20 12:09:37
Done.
| |
| 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 | |
|
srdjan
2012/08/17 22:30:22
One line too much
Florian Schneider
2012/08/20 12:09:37
Done.
| |
| 46 | |
| 47 | |
| 48 bool CheckClassComp::AttributesEqual(Computation* other) const { | |
| 49 CheckClassComp* other_check = other->AsCheckClass(); | |
| 50 if (other_check == NULL) return false; | |
| 51 if (ic_data()->NumberOfChecks() != other->ic_data()->NumberOfChecks()) { | |
| 52 return false; | |
| 53 } | |
| 54 for (intptr_t i = 0; i < ic_data()->NumberOfChecks(); ++i) { | |
| 55 // TODO(fschneider): Make sure ic_data are sorted to hit more cases. | |
| 56 if (ic_data()->GetReceiverClassIdAt(i) != | |
| 57 other->ic_data()->GetReceiverClassIdAt(i)) { | |
| 58 return false; | |
| 59 } | |
| 60 } | |
|
srdjan
2012/08/17 22:30:22
You may want to move this loop and tests into clas
| |
| 61 return true; | |
| 62 } | |
| 63 | |
| 64 | |
| 24 UseVal::UseVal(Definition* definition) | 65 UseVal::UseVal(Definition* definition) |
| 25 : definition_(definition), next_use_(NULL), previous_use_(NULL) { | 66 : definition_(definition), next_use_(NULL), previous_use_(NULL) { |
| 26 AddToUseList(); | 67 AddToUseList(); |
| 27 } | 68 } |
| 28 | 69 |
| 29 | 70 |
| 30 void UseVal::SetDefinition(Definition* definition) { | 71 void UseVal::SetDefinition(Definition* definition) { |
| 31 ASSERT(definition != NULL); | 72 ASSERT(definition != NULL); |
| 32 RemoveFromUseList(); | 73 RemoveFromUseList(); |
| 33 definition_ = definition; | 74 definition_ = definition; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 next_instr->set_previous(prev_instr); | 211 next_instr->set_previous(prev_instr); |
| 171 // Reset successor and previous instruction to indicate | 212 // Reset successor and previous instruction to indicate |
| 172 // that the instruction is removed from the graph. | 213 // that the instruction is removed from the graph. |
| 173 set_previous(NULL); | 214 set_previous(NULL); |
| 174 set_next(NULL); | 215 set_next(NULL); |
| 175 ASSERT(!IsDefinition() || AsDefinition()->use_list() == NULL); | 216 ASSERT(!IsDefinition() || AsDefinition()->use_list() == NULL); |
| 176 return return_previous ? prev_instr : next_instr; | 217 return return_previous ? prev_instr : next_instr; |
| 177 } | 218 } |
| 178 | 219 |
| 179 | 220 |
| 221 void Instruction::InsertBefore(Instruction* next) { | |
| 222 ASSERT(previous_ == NULL); | |
| 223 ASSERT(next_ == NULL); | |
| 224 ASSERT(IsBind()); | |
|
srdjan
2012/08/17 22:30:22
Why don't you put this method in BindInstr then?
Florian Schneider
2012/08/20 12:09:37
Done.
| |
| 225 ASSERT(!next->IsBlockEntry()); | |
| 226 next_ = next; | |
| 227 previous_ = next->previous_; | |
| 228 next->previous_ = this; | |
| 229 previous_->next_ = this; | |
| 230 } | |
| 231 | |
| 232 | |
| 180 void ForwardInstructionIterator::RemoveCurrentFromGraph() { | 233 void ForwardInstructionIterator::RemoveCurrentFromGraph() { |
| 181 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. | 234 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. |
| 182 } | 235 } |
| 183 | 236 |
| 184 | 237 |
| 185 // Default implementation of visiting basic blocks. Can be overridden. | 238 // Default implementation of visiting basic blocks. Can be overridden. |
| 186 void FlowGraphVisitor::VisitBlocks() { | 239 void FlowGraphVisitor::VisitBlocks() { |
| 187 ASSERT(current_iterator_ == NULL); | 240 ASSERT(current_iterator_ == NULL); |
| 188 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 241 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 189 BlockEntryInstr* entry = block_order_[i]; | 242 BlockEntryInstr* entry = block_order_[i]; |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 958 RawAbstractType* DoubleToDoubleComp::CompileType() const { | 1011 RawAbstractType* DoubleToDoubleComp::CompileType() const { |
| 959 return Type::DoubleInterface(); | 1012 return Type::DoubleInterface(); |
| 960 } | 1013 } |
| 961 | 1014 |
| 962 | 1015 |
| 963 RawAbstractType* SmiToDoubleComp::CompileType() const { | 1016 RawAbstractType* SmiToDoubleComp::CompileType() const { |
| 964 return Type::DoubleInterface(); | 1017 return Type::DoubleInterface(); |
| 965 } | 1018 } |
| 966 | 1019 |
| 967 | 1020 |
| 1021 RawAbstractType* CheckClassComp::CompileType() const { | |
| 1022 return AbstractType::null(); | |
| 1023 } | |
| 1024 | |
| 1025 | |
| 968 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and | 1026 // Shared code generation methods (EmitNativeCode, MakeLocationSummary, and |
| 969 // PrepareEntry). Only assembly code that can be shared across all architectures | 1027 // PrepareEntry). Only assembly code that can be shared across all architectures |
| 970 // can be used. Machine specific register allocation and code generation | 1028 // can be used. Machine specific register allocation and code generation |
| 971 // is located in intermediate_language_<arch>.cc | 1029 // is located in intermediate_language_<arch>.cc |
| 972 | 1030 |
| 973 | 1031 |
| 974 // True iff. the arguments to a call will be properly pushed and can | 1032 // True iff. the arguments to a call will be properly pushed and can |
| 975 // be popped after the call. | 1033 // be popped after the call. |
| 976 template <typename T> static bool VerifyCallComputation(T* comp) { | 1034 template <typename T> static bool VerifyCallComputation(T* comp) { |
| 977 // Argument values should be consecutive temps. | 1035 // Argument values should be consecutive temps. |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1435 if (compiler->is_ssa()) { | 1493 if (compiler->is_ssa()) { |
| 1436 ASSERT(locs()->in(0).IsRegister()); | 1494 ASSERT(locs()->in(0).IsRegister()); |
| 1437 __ PushRegister(locs()->in(0).reg()); | 1495 __ PushRegister(locs()->in(0).reg()); |
| 1438 } | 1496 } |
| 1439 } | 1497 } |
| 1440 | 1498 |
| 1441 | 1499 |
| 1442 #undef __ | 1500 #undef __ |
| 1443 | 1501 |
| 1444 } // namespace dart | 1502 } // namespace dart |
| OLD | NEW |