Index: src/types-inl.h |
diff --git a/src/types-inl.h b/src/types-inl.h |
index ad1107b68cb0c3421c19f8343745268b3ff842d8..6f3f6704b573d058fc57c795f9b22beaf75622c6 100644 |
--- a/src/types-inl.h |
+++ b/src/types-inl.h |
@@ -13,6 +13,34 @@ |
namespace v8 { |
namespace internal { |
+// -------------------------------------------------------------------------- // |
+// TypeImpl |
+ |
+template<class Config> |
+typename TypeImpl<Config>::template Iterator<i::Map> |
+TypeImpl<Config>::Classes() { |
+ if (this->IsBitset()) return Iterator<i::Map>(); |
+ return Iterator<i::Map>(Config::handle(this)); |
+} |
+ |
+ |
+template<class Config> |
+typename TypeImpl<Config>::template Iterator<i::Object> |
+TypeImpl<Config>::Constants() { |
+ if (this->IsBitset()) return Iterator<i::Object>(); |
+ return Iterator<i::Object>(Config::handle(this)); |
+} |
+ |
+ |
+template<class Config> |
+TypeImpl<Config>* TypeImpl<Config>::cast(typename Config::Base* object) { |
+ TypeImpl* t = static_cast<TypeImpl*>(object); |
+ ASSERT(t->IsBitset() || t->IsClass() || t->IsConstant() || |
+ t->IsUnion() || t->IsArray() || t->IsFunction()); |
+ return t; |
+} |
+ |
+ |
template<class Config> |
bool TypeImpl<Config>::NowContains(i::Object* value) { |
DisallowHeapAllocation no_allocation; |
@@ -27,33 +55,44 @@ bool TypeImpl<Config>::NowContains(i::Object* value) { |
} |
+// -------------------------------------------------------------------------- // |
+// ZoneTypeConfig |
+ |
// static |
-Type* ZoneTypeConfig::handle(Type* type) { |
+template<class T> |
+T* ZoneTypeConfig::handle(T* type) { |
return type; |
} |
// static |
+template<class T> |
+T* ZoneTypeConfig::cast(Type* type) { |
+ return static_cast<T*>(type); |
+} |
+ |
+ |
+// static |
bool ZoneTypeConfig::is_bitset(Type* type) { |
return reinterpret_cast<intptr_t>(type) & 1; |
} |
// static |
-bool ZoneTypeConfig::is_struct(Type* type) { |
- return !is_bitset(type); |
+bool ZoneTypeConfig::is_struct(Type* type, int tag) { |
+ return !is_bitset(type) && struct_tag(as_struct(type)) == tag; |
} |
// static |
bool ZoneTypeConfig::is_class(Type* type) { |
- return is_struct(type) && struct_tag(as_struct(type)) == Type::kClassTag; |
+ return is_struct(type, Type::StructuralType::kClassTag); |
} |
// static |
bool ZoneTypeConfig::is_constant(Type* type) { |
- return is_struct(type) && struct_tag(as_struct(type)) == Type::kConstantTag; |
+ return is_struct(type, Type::StructuralType::kConstantTag); |
} |
@@ -66,7 +105,7 @@ int ZoneTypeConfig::as_bitset(Type* type) { |
// static |
ZoneTypeConfig::Struct* ZoneTypeConfig::as_struct(Type* type) { |
- ASSERT(is_struct(type)); |
+ ASSERT(!is_bitset(type)); |
return reinterpret_cast<Struct*>(type); |
} |
@@ -107,7 +146,7 @@ ZoneTypeConfig::Type* ZoneTypeConfig::from_struct(Struct* structured) { |
// static |
ZoneTypeConfig::Type* ZoneTypeConfig::from_class( |
i::Handle<i::Map> map, int lub, Zone* zone) { |
- Struct* structured = struct_create(Type::kClassTag, 2, zone); |
+ Struct* structured = struct_create(Type::StructuralType::kClassTag, 2, zone); |
structured[2] = from_bitset(lub); |
structured[3] = map.location(); |
return from_struct(structured); |
@@ -117,7 +156,8 @@ ZoneTypeConfig::Type* ZoneTypeConfig::from_class( |
// static |
ZoneTypeConfig::Type* ZoneTypeConfig::from_constant( |
i::Handle<i::Object> value, int lub, Zone* zone) { |
- Struct* structured = struct_create(Type::kConstantTag, 2, zone); |
+ Struct* structured = |
+ struct_create(Type::StructuralType::kConstantTag, 2, zone); |
structured[2] = from_bitset(lub); |
structured[3] = value.location(); |
return from_struct(structured); |
@@ -174,15 +214,25 @@ int ZoneTypeConfig::lub_bitset(Type* type) { |
return as_bitset(struct_get(as_struct(type), 0)); |
} |
+ |
// -------------------------------------------------------------------------- // |
+// HeapTypeConfig |
// static |
-i::Handle<HeapTypeConfig::Type> HeapTypeConfig::handle(Type* type) { |
+template<class T> |
+i::Handle<T> HeapTypeConfig::handle(T* type) { |
return i::handle(type, i::HeapObject::cast(type)->GetIsolate()); |
} |
// static |
+template<class T> |
+i::Handle<T> HeapTypeConfig::cast(i::Handle<Type> type) { |
+ return i::Handle<T>::cast(type); |
+} |
+ |
+ |
+// static |
bool HeapTypeConfig::is_bitset(Type* type) { |
return type->IsSmi(); |
} |
@@ -201,14 +251,14 @@ bool HeapTypeConfig::is_constant(Type* type) { |
// static |
-bool HeapTypeConfig::is_struct(Type* type) { |
- return type->IsFixedArray(); |
+bool HeapTypeConfig::is_struct(Type* type, int tag) { |
+ return type->IsFixedArray() && struct_tag(as_struct(type)) == tag; |
} |
// static |
int HeapTypeConfig::as_bitset(Type* type) { |
- return Smi::cast(type)->value(); |
+ return i::Smi::cast(type)->value(); |
} |