| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <iomanip> | 5 #include <iomanip> |
| 6 | 6 |
| 7 #include "src/types.h" | 7 #include "src/types.h" |
| 8 | 8 |
| 9 #include "src/handles-inl.h" | 9 #include "src/handles-inl.h" |
| 10 #include "src/ostreams.h" | 10 #include "src/ostreams.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // a bitset. | 139 // a bitset. |
| 140 int bitset = type->AsUnion()->Get(0)->BitsetLub(); | 140 int bitset = type->AsUnion()->Get(0)->BitsetLub(); |
| 141 for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) { | 141 for (int i = 0, n = type->AsUnion()->Length(); i < n; ++i) { |
| 142 // Other elements only contribute their semantic part. | 142 // Other elements only contribute their semantic part. |
| 143 bitset |= SEMANTIC(type->AsUnion()->Get(i)->BitsetLub()); | 143 bitset |= SEMANTIC(type->AsUnion()->Get(i)->BitsetLub()); |
| 144 } | 144 } |
| 145 return bitset; | 145 return bitset; |
| 146 } | 146 } |
| 147 if (type->IsConstant()) return type->AsConstant()->Lub(); | 147 if (type->IsConstant()) return type->AsConstant()->Lub(); |
| 148 if (type->IsRange()) return type->AsRange()->Lub(); | 148 if (type->IsRange()) return type->AsRange()->Lub(); |
| 149 if (type->IsContext()) return kOtherInternal & kTaggedPointer; | |
| 150 if (type->IsArray()) return kOtherObject; | 149 if (type->IsArray()) return kOtherObject; |
| 151 if (type->IsFunction()) return kFunction; | 150 if (type->IsFunction()) return kFunction; |
| 152 if (type->IsTuple()) return kOtherInternal; | 151 if (type->IsTuple()) return kOtherInternal; |
| 153 UNREACHABLE(); | 152 UNREACHABLE(); |
| 154 return kNone; | 153 return kNone; |
| 155 } | 154 } |
| 156 | 155 |
| 157 Type::bitset BitsetType::Lub(i::Map* map) { | 156 Type::bitset BitsetType::Lub(i::Map* map) { |
| 158 DisallowHeapAllocation no_allocation; | 157 DisallowHeapAllocation no_allocation; |
| 159 switch (map->instance_type()) { | 158 switch (map->instance_type()) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 404 |
| 406 // ----------------------------------------------------------------------------- | 405 // ----------------------------------------------------------------------------- |
| 407 // Predicates. | 406 // Predicates. |
| 408 | 407 |
| 409 bool Type::SimplyEquals(Type* that) { | 408 bool Type::SimplyEquals(Type* that) { |
| 410 DisallowHeapAllocation no_allocation; | 409 DisallowHeapAllocation no_allocation; |
| 411 if (this->IsConstant()) { | 410 if (this->IsConstant()) { |
| 412 return that->IsConstant() | 411 return that->IsConstant() |
| 413 && *this->AsConstant()->Value() == *that->AsConstant()->Value(); | 412 && *this->AsConstant()->Value() == *that->AsConstant()->Value(); |
| 414 } | 413 } |
| 415 if (this->IsContext()) { | |
| 416 return that->IsContext() | |
| 417 && this->AsContext()->Outer()->Equals(that->AsContext()->Outer()); | |
| 418 } | |
| 419 if (this->IsArray()) { | 414 if (this->IsArray()) { |
| 420 return that->IsArray() | 415 return that->IsArray() |
| 421 && this->AsArray()->Element()->Equals(that->AsArray()->Element()); | 416 && this->AsArray()->Element()->Equals(that->AsArray()->Element()); |
| 422 } | 417 } |
| 423 if (this->IsFunction()) { | 418 if (this->IsFunction()) { |
| 424 if (!that->IsFunction()) return false; | 419 if (!that->IsFunction()) return false; |
| 425 FunctionType* this_fun = this->AsFunction(); | 420 FunctionType* this_fun = this->AsFunction(); |
| 426 FunctionType* that_fun = that->AsFunction(); | 421 FunctionType* that_fun = that->AsFunction(); |
| 427 if (this_fun->Arity() != that_fun->Arity() || | 422 if (this_fun->Arity() != that_fun->Arity() || |
| 428 !this_fun->Result()->Equals(that_fun->Result()) || | 423 !this_fun->Result()->Equals(that_fun->Result()) || |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 BitsetType::Print(os, SEMANTIC(this->AsBitset())); | 1095 BitsetType::Print(os, SEMANTIC(this->AsBitset())); |
| 1101 } else if (this->IsConstant()) { | 1096 } else if (this->IsConstant()) { |
| 1102 os << "Constant(" << Brief(*this->AsConstant()->Value()) << ")"; | 1097 os << "Constant(" << Brief(*this->AsConstant()->Value()) << ")"; |
| 1103 } else if (this->IsRange()) { | 1098 } else if (this->IsRange()) { |
| 1104 std::ostream::fmtflags saved_flags = os.setf(std::ios::fixed); | 1099 std::ostream::fmtflags saved_flags = os.setf(std::ios::fixed); |
| 1105 std::streamsize saved_precision = os.precision(0); | 1100 std::streamsize saved_precision = os.precision(0); |
| 1106 os << "Range(" << this->AsRange()->Min() << ", " << this->AsRange()->Max() | 1101 os << "Range(" << this->AsRange()->Min() << ", " << this->AsRange()->Max() |
| 1107 << ")"; | 1102 << ")"; |
| 1108 os.flags(saved_flags); | 1103 os.flags(saved_flags); |
| 1109 os.precision(saved_precision); | 1104 os.precision(saved_precision); |
| 1110 } else if (this->IsContext()) { | |
| 1111 os << "Context("; | |
| 1112 this->AsContext()->Outer()->PrintTo(os, dim); | |
| 1113 os << ")"; | |
| 1114 } else if (this->IsUnion()) { | 1105 } else if (this->IsUnion()) { |
| 1115 os << "("; | 1106 os << "("; |
| 1116 for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) { | 1107 for (int i = 0, n = this->AsUnion()->Length(); i < n; ++i) { |
| 1117 Type* type_i = this->AsUnion()->Get(i); | 1108 Type* type_i = this->AsUnion()->Get(i); |
| 1118 if (i > 0) os << " | "; | 1109 if (i > 0) os << " | "; |
| 1119 type_i->PrintTo(os, dim); | 1110 type_i->PrintTo(os, dim); |
| 1120 } | 1111 } |
| 1121 os << ")"; | 1112 os << ")"; |
| 1122 } else if (this->IsArray()) { | 1113 } else if (this->IsArray()) { |
| 1123 os << "Array("; | 1114 os << "Array("; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; | 1166 return i::SmiValuesAre31Bits() ? kUnsigned30 : kUnsigned31; |
| 1176 } | 1167 } |
| 1177 | 1168 |
| 1178 // ----------------------------------------------------------------------------- | 1169 // ----------------------------------------------------------------------------- |
| 1179 // Instantiations. | 1170 // Instantiations. |
| 1180 | 1171 |
| 1181 template class Type::Iterator<i::Object>; | 1172 template class Type::Iterator<i::Object>; |
| 1182 | 1173 |
| 1183 } // namespace internal | 1174 } // namespace internal |
| 1184 } // namespace v8 | 1175 } // namespace v8 |
| OLD | NEW |