Commit e78783a3 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Introduce Type::IsCurrently

R=verwaest@chromium.org
BUG=

Review URL: https://codereview.chromium.org/83003003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18015 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6a4d5b42
......@@ -783,7 +783,7 @@ void CallICBase::UpdateCaches(LookupResult* lookup,
: 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);
}
......@@ -1148,7 +1148,7 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
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);
}
......@@ -1609,7 +1609,7 @@ void StoreIC::UpdateCaches(LookupResult* lookup,
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);
}
......
......@@ -244,7 +244,7 @@ int Type::GlbBitset() {
// 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 ||
......@@ -297,6 +297,14 @@ bool Type::SlowIs(Type* that) {
}
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.
......
......@@ -153,13 +153,18 @@ class Type : public Object {
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(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment