| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 bool Computation::Equals(Computation* other) const { | 38 bool Computation::Equals(Computation* other) const { |
| 39 if (computation_kind() != other->computation_kind()) return false; | 39 if (computation_kind() != other->computation_kind()) return false; |
| 40 for (intptr_t i = 0; i < InputCount(); ++i) { | 40 for (intptr_t i = 0; i < InputCount(); ++i) { |
| 41 if (!InputAt(i)->Equals(other->InputAt(i))) return false; | 41 if (!InputAt(i)->Equals(other->InputAt(i))) return false; |
| 42 } | 42 } |
| 43 return AttributesEqual(other); | 43 return AttributesEqual(other); |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 bool UseVal::AttributesEqual(Computation* other) const { | 47 bool UseVal::Equals(Value* other) const { |
| 48 return other->IsUse() | 48 return other->IsUse() |
| 49 && definition() == other->AsUse()->definition(); | 49 && definition() == other->AsUse()->definition(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 bool ConstantVal::AttributesEqual(Computation* other) const { | 53 bool ConstantVal::Equals(Value* other) const { |
| 54 return other->IsConstant() | 54 return other->IsConstant() |
| 55 && value().raw() == other->AsConstant()->value().raw(); | 55 && value().raw() == other->AsConstant()->value().raw(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 |
| 59 bool CheckClassComp::AttributesEqual(Computation* other) const { | 59 bool CheckClassComp::AttributesEqual(Computation* other) const { |
| 60 CheckClassComp* other_check = other->AsCheckClass(); | 60 CheckClassComp* other_check = other->AsCheckClass(); |
| 61 if (other_check == NULL) return false; | 61 if (other_check == NULL) return false; |
| 62 if (ic_data()->NumberOfChecks() != other->ic_data()->NumberOfChecks()) { | 62 if (ic_data()->NumberOfChecks() != other->ic_data()->NumberOfChecks()) { |
| 63 return false; | 63 return false; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 AddToUseList(); | 86 AddToUseList(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 // Returns true if the value represents a constant. | 90 // Returns true if the value represents a constant. |
| 91 bool UseVal::BindsToConstant() const { | 91 bool UseVal::BindsToConstant() const { |
| 92 BindInstr* bind = definition()->AsBind(); | 92 BindInstr* bind = definition()->AsBind(); |
| 93 if (bind == NULL) { | 93 if (bind == NULL) { |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 return bind->computation()->AsConstant() != NULL; | 96 return bind->computation()->AsMaterialize() != NULL; |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 // Returns true if the value represents constant null. | 100 // Returns true if the value represents constant null. |
| 101 bool UseVal::BindsToConstantNull() const { | 101 bool UseVal::BindsToConstantNull() const { |
| 102 BindInstr* bind = definition()->AsBind(); | 102 BindInstr* bind = definition()->AsBind(); |
| 103 if (bind == NULL) { | 103 if (bind == NULL) { |
| 104 return false; | 104 return false; |
| 105 } | 105 } |
| 106 ConstantVal* constant = bind->computation()->AsConstant(); | 106 MaterializeComp* constant = bind->computation()->AsMaterialize(); |
| 107 if (constant != NULL) { | 107 if (constant != NULL) { |
| 108 return constant->value().IsNull(); | 108 return constant->constant_val()->value().IsNull(); |
| 109 } | 109 } |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 const Object& UseVal::BoundConstant() const { | 114 const Object& UseVal::BoundConstant() const { |
| 115 ASSERT(BindsToConstant()); | 115 ASSERT(BindsToConstant()); |
| 116 BindInstr* bind = definition()->AsBind(); | 116 BindInstr* bind = definition()->AsBind(); |
| 117 ASSERT(bind != NULL); | 117 ASSERT(bind != NULL); |
| 118 ConstantVal* constant = bind->computation()->AsConstant(); | 118 MaterializeComp* constant = bind->computation()->AsMaterialize(); |
| 119 ASSERT(constant != NULL); | 119 ASSERT(constant != NULL); |
| 120 return constant->value(); | 120 return constant->constant_val()->value(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 void UseVal::RemoveFromUseList() { | 124 void UseVal::RemoveFromUseList() { |
| 125 ASSERT(definition_ != NULL); | 125 ASSERT(definition_ != NULL); |
| 126 if (next_use_ != NULL) { | 126 if (next_use_ != NULL) { |
| 127 next_use_->previous_use_ = previous_use_; | 127 next_use_->previous_use_ = previous_use_; |
| 128 } | 128 } |
| 129 if (previous_use_ != NULL) { | 129 if (previous_use_ != NULL) { |
| 130 previous_use_->next_use_ = next_use_; | 130 previous_use_->next_use_ = next_use_; |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 definition()->SetPropagatedType(type); | 714 definition()->SetPropagatedType(type); |
| 715 return type.raw(); | 715 return type.raw(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 | 718 |
| 719 intptr_t UseVal::ResultCid() const { | 719 intptr_t UseVal::ResultCid() const { |
| 720 return definition()->GetPropagatedCid(); | 720 return definition()->GetPropagatedCid(); |
| 721 } | 721 } |
| 722 | 722 |
| 723 | 723 |
| 724 |
| 725 RawAbstractType* MaterializeComp::CompileType() const { |
| 726 return constant_val()->CompileType(); |
| 727 } |
| 728 |
| 729 |
| 730 intptr_t MaterializeComp::ResultCid() const { |
| 731 return constant_val()->ResultCid(); |
| 732 } |
| 733 |
| 734 |
| 724 RawAbstractType* AssertAssignableComp::CompileType() const { | 735 RawAbstractType* AssertAssignableComp::CompileType() const { |
| 725 const AbstractType& value_compile_type = | 736 const AbstractType& value_compile_type = |
| 726 AbstractType::Handle(value()->CompileType()); | 737 AbstractType::Handle(value()->CompileType()); |
| 727 if (!value_compile_type.IsNull() && | 738 if (!value_compile_type.IsNull() && |
| 728 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { | 739 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { |
| 729 return value_compile_type.raw(); | 740 return value_compile_type.raw(); |
| 730 } | 741 } |
| 731 return dst_type().raw(); | 742 return dst_type().raw(); |
| 732 } | 743 } |
| 733 | 744 |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 token_pos(), | 1357 token_pos(), |
| 1347 try_index(), | 1358 try_index(), |
| 1348 function(), | 1359 function(), |
| 1349 ArgumentCount(), | 1360 ArgumentCount(), |
| 1350 argument_names(), | 1361 argument_names(), |
| 1351 locs()->stack_bitmap()); | 1362 locs()->stack_bitmap()); |
| 1352 __ Bind(&done); | 1363 __ Bind(&done); |
| 1353 } | 1364 } |
| 1354 | 1365 |
| 1355 | 1366 |
| 1356 LocationSummary* UseVal::MakeLocationSummary() const { | |
| 1357 return NULL; | |
| 1358 } | |
| 1359 | |
| 1360 | |
| 1361 void UseVal::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 1362 UNIMPLEMENTED(); | |
| 1363 } | |
| 1364 | |
| 1365 | |
| 1366 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 1367 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 1367 if (!is_eliminated()) { | 1368 if (!is_eliminated()) { |
| 1368 compiler->GenerateAssertAssignable(deopt_id(), | 1369 compiler->GenerateAssertAssignable(deopt_id(), |
| 1369 token_pos(), | 1370 token_pos(), |
| 1370 try_index(), | 1371 try_index(), |
| 1371 dst_type(), | 1372 dst_type(), |
| 1372 dst_name(), | 1373 dst_name(), |
| 1373 locs()->stack_bitmap()); | 1374 locs()->stack_bitmap()); |
| 1374 } | 1375 } |
| 1375 ASSERT(locs()->in(0).reg() == locs()->out().reg()); | 1376 ASSERT(locs()->in(0).reg() == locs()->out().reg()); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 // TODO(fschneider): Avoid special-casing for SSA mode here. | 1506 // TODO(fschneider): Avoid special-casing for SSA mode here. |
| 1506 if (compiler->is_ssa()) { | 1507 if (compiler->is_ssa()) { |
| 1507 ASSERT(locs()->in(0).IsRegister()); | 1508 ASSERT(locs()->in(0).IsRegister()); |
| 1508 __ PushRegister(locs()->in(0).reg()); | 1509 __ PushRegister(locs()->in(0).reg()); |
| 1509 } | 1510 } |
| 1510 } | 1511 } |
| 1511 | 1512 |
| 1512 | 1513 |
| 1513 // Helper to either use the constant value of a definition or the definition. | 1514 // Helper to either use the constant value of a definition or the definition. |
| 1514 static Value* UseDefinition(Definition* defn) { | 1515 static Value* UseDefinition(Definition* defn) { |
| 1515 if (defn->IsBind() && defn->AsBind()->computation()->IsConstant()) { | 1516 if (defn->IsBind() && defn->AsBind()->computation()->IsMaterialize()) { |
| 1516 return defn->AsBind()->computation()->AsConstant(); | 1517 return defn->AsBind()->computation()->AsMaterialize()->constant_val(); |
| 1517 } else { | 1518 } else { |
| 1518 return new UseVal(defn); | 1519 return new UseVal(defn); |
| 1519 } | 1520 } |
| 1520 } | 1521 } |
| 1521 | 1522 |
| 1522 | 1523 |
| 1523 Environment::Environment(const GrowableArray<Definition*>& definitions, | 1524 Environment::Environment(const GrowableArray<Definition*>& definitions, |
| 1524 intptr_t fixed_parameter_count) | 1525 intptr_t fixed_parameter_count) |
| 1525 : values_(definitions.length()), | 1526 : values_(definitions.length()), |
| 1526 locations_(NULL), | 1527 locations_(NULL), |
| 1527 fixed_parameter_count_(fixed_parameter_count) { | 1528 fixed_parameter_count_(fixed_parameter_count) { |
| 1528 for (intptr_t i = 0; i < definitions.length(); ++i) { | 1529 for (intptr_t i = 0; i < definitions.length(); ++i) { |
| 1529 values_.Add(UseDefinition(definitions[i])); | 1530 values_.Add(UseDefinition(definitions[i])); |
| 1530 } | 1531 } |
| 1531 } | 1532 } |
| 1532 | 1533 |
| 1533 | 1534 |
| 1534 #undef __ | 1535 #undef __ |
| 1535 | 1536 |
| 1536 } // namespace dart | 1537 } // namespace dart |
| OLD | NEW |