Commit f12bdb27 authored by antonm@chromium.org's avatar antonm@chromium.org

Improved version of LookupForRead (tnx to Kasper) + some faster paths.

1) add no GC check;
2) do not use recursion;

Review URL: http://codereview.chromium.org/155141

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2462 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 36b69749
...@@ -273,28 +273,39 @@ static bool HasInterceptorGetter(JSObject* object) { ...@@ -273,28 +273,39 @@ static bool HasInterceptorGetter(JSObject* object) {
static void LookupForRead(Object* object, static void LookupForRead(Object* object,
String* name, String* name,
LookupResult* lookup) { LookupResult* lookup) {
object->Lookup(name, lookup); AssertNoAllocation no_gc; // pointers must stay valid
if (lookup->IsNotFound() || lookup->type() != INTERCEPTOR) {
return; // Skip all the objects with named interceptors, but
} // without actual getter.
while (true) {
object->Lookup(name, lookup);
// Besides normal conditions (property not found or it's not
// an interceptor), bail out of lookup is not cacheable: we won't
// be able to IC it anyway and regular lookup should work fine.
if (lookup->IsNotFound() || lookup->type() != INTERCEPTOR ||
!lookup->IsCacheable()) {
return;
}
JSObject* holder = lookup->holder(); JSObject* holder = lookup->holder();
if (HasInterceptorGetter(holder)) { if (HasInterceptorGetter(holder)) {
return; return;
} }
// There is no getter, just skip it and lookup down the proto chain holder->LocalLookupRealNamedProperty(name, lookup);
holder->LocalLookupRealNamedProperty(name, lookup); if (lookup->IsValid()) {
if (lookup->IsValid()) { ASSERT(lookup->type() != INTERCEPTOR);
return; return;
} }
Object* proto = holder->GetPrototype(); Object* proto = holder->GetPrototype();
if (proto == Heap::null_value()) { if (proto->IsNull()) {
return; lookup->NotFound();
} return;
}
LookupForRead(proto, name, lookup); object = proto;
}
} }
......
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