: Handle<JSObject>(JSObject::cast(object->GetPrototype(isolate())),
isolate());
- PatchCache(handle(Type::CurrentOf(cache_object), isolate()), name, code);
+ PatchCache(handle(Type::OfCurrently(cache_object), isolate()), name, code);
TRACE_IC("CallIC", name);
}
code = ComputeHandler(lookup, object, name);
}
- PatchCache(handle(Type::CurrentOf(object), isolate()), name, code);
+ PatchCache(handle(Type::OfCurrently(object), isolate()), name, code);
TRACE_IC("LoadIC", name);
}
Handle<Code> code = ComputeHandler(lookup, receiver, name, value);
- PatchCache(handle(Type::CurrentOf(receiver), isolate()), name, code);
+ PatchCache(handle(Type::OfCurrently(receiver), isolate()), name, code);
TRACE_IC("StoreIC", name);
}
// Most precise _current_ type of a value (usually its class).
-Type* Type::CurrentOf(Handle<i::Object> value) {
+Type* Type::OfCurrently(Handle<i::Object> value) {
if (value->IsSmi()) return Smi();
i::Map* map = i::HeapObject::cast(*value)->map();
if (map->instance_type() == HEAP_NUMBER_TYPE ||
}
+bool Type::IsCurrently(Type* that) {
+ return this->Is(that) ||
+ (this->is_constant() && that->is_class() &&
+ this->as_constant()->IsHeapObject() &&
+ i::HeapObject::cast(*this->as_constant())->map() == *that->as_class());
+}
+
+
// Check this overlaps that.
bool Type::Maybe(Type* that) {
// Fast path for bitsets.
static Type* Of(Handle<i::Object> value) {
return from_bitset(LubBitset(*value));
}
- static Type* CurrentOf(Handle<i::Object> value);
- bool Is(Type* that) { return (this == that) ? true : SlowIs(that); }
+ bool Is(Type* that) { return this == that || SlowIs(that); }
bool Is(Handle<Type> that) { return this->Is(*that); }
bool Maybe(Type* that);
bool Maybe(Handle<Type> that) { return this->Maybe(*that); }
+ // State-dependent versions of Of and Is that consider subtyping between
+ // a constant and its map class.
+ static Type* OfCurrently(Handle<i::Object> value);
+ bool IsCurrently(Type* that);
+ bool IsCurrently(Handle<Type> that) { return this->IsCurrently(*that); }
+
bool IsClass() { return is_class(); }
bool IsConstant() { return is_constant(); }
Handle<i::Map> AsClass() { return as_class(); }