if (current_type->IsClass() && current_type->AsClass()->is_deprecated()) {
// Filter out deprecated maps to ensure their instances get migrated.
++deprecated_types;
- } else if (type->IsCurrently(current_type)) {
+ } else if (type->NowIs(current_type)) {
// If the receiver type is already in the polymorphic IC, this indicates
// there was a prototoype chain failure. In that case, just overwrite the
// handler.
number_of_valid_types++;
if (handler_to_overwrite >= 0) {
handlers.Set(handler_to_overwrite, code);
- if (!type->IsCurrently(types.at(handler_to_overwrite))) {
+ if (!type->NowIs(types.at(handler_to_overwrite))) {
types.Set(handler_to_overwrite, type);
}
} else {
Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) {
return object->IsJSGlobalObject()
? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate)
- : HeapType::OfCurrently(object, isolate);
+ : HeapType::NowOf(object, isolate);
}
#ifndef V8_TYPES_INL_H_
#define V8_TYPES_INL_H_
+#include "types.h"
+
#include "factory.h"
#include "handles-inl.h"
-#include "types.h"
namespace v8 {
namespace internal {
return static_cast<int>(tagged_get<intptr_t>(as_tagged(type), 0));
}
+// -------------------------------------------------------------------------- //
// static
i::Handle<HeapTypeConfig::Type> HeapTypeConfig::handle(Type* type) {
// Most precise _current_ type of a value (usually its class).
template<class Config>
-typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::OfCurrently(
+typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf(
i::Handle<i::Object> value, Region* region) {
if (value->IsSmi() ||
i::HeapObject::cast(*value)->map()->instance_type() == HEAP_NUMBER_TYPE ||
template<class Config>
-bool TypeImpl<Config>::IsCurrently(TypeImpl* that) {
+bool TypeImpl<Config>::NowIs(TypeImpl* that) {
return this->Is(that) ||
(this->IsConstant() && that->IsClass() &&
this->AsConstant()->IsHeapObject() &&
}
+template<class Config>
+bool TypeImpl<Config>::Contains(i::Object* value) {
+ if (this->IsConstant()) {
+ return *this->AsConstant() == value;
+ }
+ return Config::from_bitset(LubBitset(value))->Is(this);
+}
+
+
+template<class Config>
+bool TypeImpl<Config>::NowContains(i::Object* value) {
+ return this->Contains(value) ||
+ (this->IsClass() && value->IsHeapObject() &&
+ *this->AsClass() == i::HeapObject::cast(value)->map());
+}
+
+
template<class Config>
bool TypeImpl<Config>::InUnion(UnionedHandle unioned, int current_size) {
ASSERT(!this->IsUnion());
bool Is(TypeImpl* that) { return this == that || this->SlowIs(that); }
template<class TypeHandle>
bool Is(TypeHandle that) { return this->Is(*that); }
+
bool Maybe(TypeImpl* that);
template<class TypeHandle>
bool Maybe(TypeHandle that) { return this->Maybe(*that); }
+ // Equivalent to Constant(value)->Is(this), but avoiding allocation.
+ bool Contains(i::Object* val);
+ bool Contains(i::Handle<i::Object> val) { return this->Contains(*val); }
+
// State-dependent versions of Of and Is that consider subtyping between
// a constant and its map class.
- static TypeHandle OfCurrently(i::Handle<i::Object> value, Region* region);
- bool IsCurrently(TypeImpl* that);
+ static TypeHandle NowOf(i::Handle<i::Object> value, Region* region);
+ bool NowIs(TypeImpl* that);
template<class TypeHandle>
- bool IsCurrently(TypeHandle that) { return this->IsCurrently(*that); }
+ bool NowIs(TypeHandle that) { return this->NowIs(*that); }
+ bool NowContains(i::Object* val);
+ bool NowContains(i::Handle<i::Object> val) { return this->NowContains(*val); }
bool IsClass() { return Config::is_class(this); }
bool IsConstant() { return Config::is_constant(this); }
static inline Tagged* tagged_create(Tag tag, int size, Zone* zone);
static inline void tagged_shrink(Tagged* tagged, int size);
static inline Tag tagged_tag(Tagged* tagged);
- template<class T>
- static inline T tagged_get(Tagged* tagged, int i);
- template<class T>
- static inline void tagged_set(Tagged* tagged, int i, T value);
+ template<class T> static inline T tagged_get(Tagged* tagged, int i);
+ template<class T> static inline void tagged_set(Tagged* tagged, int i, T val);
static inline int tagged_length(Tagged* tagged);
public:
static inline int lub_bitset(Type* type);
};
+typedef TypeImpl<ZoneTypeConfig> Type;
+
// Heap-allocated types are either smis for bitsets, maps for classes, boxes for
// constants, or fixed arrays for unions.
static inline int lub_bitset(Type* type);
};
-typedef TypeImpl<ZoneTypeConfig> Type;
typedef TypeImpl<HeapTypeConfig> HeapType;
Effect AstTyper::ObservedOnStack(Object* value) {
- Type* lower = Type::OfCurrently(handle(value, isolate()), zone());
+ Type* lower = Type::NowOf(handle(value, isolate()), zone());
return Effect(Bounds(lower, Type::Any(zone())));
}