From f268f02092548026a141680f9299e88506a59812 Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Tue, 19 Aug 2014 14:58:41 +0000 Subject: [PATCH] Get rid of LookupRealNamedProperty and LookupRealNamedPropertyInPrototypes and update clients BUG= R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/481043002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23202 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 53 ++++++++++++--------------- src/objects.cc | 110 +++++++++++++++------------------------------------------ src/objects.h | 5 --- 3 files changed, 50 insertions(+), 118 deletions(-) diff --git a/src/api.cc b/src/api.cc index 35a7e5f..9b57b36 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3564,24 +3564,12 @@ bool v8::Object::HasIndexedLookupInterceptor() { } -static Local GetPropertyByLookup(i::Isolate* isolate, - i::Handle receiver, - i::Handle name, - i::LookupResult* lookup) { - if (!lookup->IsProperty()) { - // No real property was found. - return Local(); - } - - // If the property being looked up is a callback, it can throw - // an exception. - EXCEPTION_PREAMBLE(isolate); - i::LookupIterator it(receiver, name, - i::Handle(lookup->holder(), isolate), - i::LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR); +static Local GetPropertyByLookup(i::LookupIterator* it) { + // If the property being looked up is a callback, it can throw an exception. + EXCEPTION_PREAMBLE(it->isolate()); i::Handle result; - has_pending_exception = !i::Object::GetProperty(&it).ToHandle(&result); - EXCEPTION_BAILOUT_CHECK(isolate, Local()); + has_pending_exception = !i::Object::GetProperty(it).ToHandle(&result); + EXCEPTION_BAILOUT_CHECK(it->isolate(), Local()); return Utils::ToLocal(result); } @@ -3596,9 +3584,11 @@ Local v8::Object::GetRealNamedPropertyInPrototypeChain( ENTER_V8(isolate); i::Handle self_obj = Utils::OpenHandle(this); i::Handle key_obj = Utils::OpenHandle(*key); - i::LookupResult lookup(isolate); - self_obj->LookupRealNamedPropertyInPrototypes(key_obj, &lookup); - return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); + i::PrototypeIterator iter(isolate, self_obj); + if (iter.IsAtEnd()) return Local(); + i::LookupIterator it(i::PrototypeIterator::GetCurrent(iter), key_obj, + i::LookupIterator::CHECK_DERIVED_PROPERTY); + return GetPropertyByLookup(&it); } @@ -3609,9 +3599,9 @@ Local v8::Object::GetRealNamedProperty(Handle key) { ENTER_V8(isolate); i::Handle self_obj = Utils::OpenHandle(this); i::Handle key_obj = Utils::OpenHandle(*key); - i::LookupResult lookup(isolate); - self_obj->LookupRealNamedProperty(key_obj, &lookup); - return GetPropertyByLookup(isolate, self_obj, key_obj, &lookup); + i::LookupIterator it(self_obj, key_obj, + i::LookupIterator::CHECK_DERIVED_PROPERTY); + return GetPropertyByLookup(&it); } @@ -4065,15 +4055,16 @@ Handle Function::GetDisplayName() const { i::Handle property_name = isolate->factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("displayName")); - i::LookupResult lookup(isolate); - func->LookupRealNamedProperty(property_name, &lookup); - if (lookup.IsFound()) { - i::Object* value = lookup.GetLazyValue(); - if (value && value->IsString()) { - i::String* name = i::String::cast(value); - if (name->length() > 0) return Utils::ToLocal(i::Handle(name)); - } + i::LookupIterator it(func, property_name, + i::LookupIterator::CHECK_DERIVED_PROPERTY); + + i::Handle value = + i::JSObject::GetDataProperty(func, property_name); + if (value->IsString()) { + i::Handle name = i::Handle::cast(value); + if (name->length() > 0) return Utils::ToLocal(name); } + return ToApiHandle(isolate->factory()->undefined_value()); } diff --git a/src/objects.cc b/src/objects.cc index 307bcbf..ac4982d 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -140,6 +140,34 @@ MaybeHandle Object::GetProperty(LookupIterator* it) { } +Handle JSObject::GetDataProperty(Handle object, + Handle key) { + LookupIterator it(object, key, LookupIterator::CHECK_DERIVED_PROPERTY); + for (; it.IsFound(); it.Next()) { + switch (it.state()) { + case LookupIterator::NOT_FOUND: + case LookupIterator::ACCESS_CHECK: + case LookupIterator::INTERCEPTOR: + UNREACHABLE(); + case LookupIterator::JSPROXY: + return it.isolate()->factory()->undefined_value(); + case LookupIterator::PROPERTY: + if (!it.HasProperty()) continue; + switch (it.property_kind()) { + case LookupIterator::DATA: + return it.GetDataValue(); + case LookupIterator::ACCESSOR: + // TODO(verwaest): For now this doesn't call into + // ExecutableAccessorInfo, since clients don't need it. Update once + // relevant. + return it.isolate()->factory()->undefined_value(); + } + } + } + return it.isolate()->factory()->undefined_value(); +} + + bool Object::ToInt32(int32_t* value) { if (IsSmi()) { *value = Smi::cast(this)->value(); @@ -630,22 +658,6 @@ Object* JSObject::GetNormalizedProperty(const LookupResult* result) { } -Handle JSObject::GetNormalizedProperty(Handle object, - const LookupResult* result) { - DCHECK(!object->HasFastProperties()); - Isolate* isolate = object->GetIsolate(); - Handle value( - object->property_dictionary()->ValueAt(result->GetDictionaryEntry()), - isolate); - if (object->IsGlobalObject()) { - value = handle(Handle::cast(value)->value(), isolate); - DCHECK(!value->IsTheHole()); - } - DCHECK(!value->IsPropertyCell() && !value->IsCell()); - return value; -} - - void JSObject::SetNormalizedProperty(Handle object, Handle name, Handle value, @@ -3419,37 +3431,6 @@ void JSObject::LookupOwnRealNamedProperty(Handle name, } -void JSObject::LookupRealNamedProperty(Handle name, - LookupResult* result) { - DisallowHeapAllocation no_gc; - LookupOwnRealNamedProperty(name, result); - if (result->IsFound()) return; - - LookupRealNamedPropertyInPrototypes(name, result); -} - - -void JSObject::LookupRealNamedPropertyInPrototypes(Handle name, - LookupResult* result) { - if (name->IsOwn()) { - result->NotFound(); - return; - } - - DisallowHeapAllocation no_gc; - Isolate* isolate = GetIsolate(); - for (PrototypeIterator iter(isolate, this); !iter.IsAtEnd(); iter.Advance()) { - if (iter.GetCurrent()->IsJSProxy()) { - return result->HandlerResult(JSProxy::cast(iter.GetCurrent())); - } - JSObject::cast(iter.GetCurrent())->LookupOwnRealNamedProperty(name, result); - DCHECK(!(result->IsFound() && result->type() == INTERCEPTOR)); - if (result->IsFound()) return; - } - result->NotFound(); -} - - Maybe JSProxy::HasPropertyWithHandler(Handle proxy, Handle name) { Isolate* isolate = proxy->GetIsolate(); @@ -5671,41 +5652,6 @@ MaybeHandle JSObject::DeepCopy( } -Handle JSObject::GetDataProperty(Handle object, - Handle key) { - Isolate* isolate = object->GetIsolate(); - LookupResult lookup(isolate); - { - DisallowHeapAllocation no_allocation; - object->LookupRealNamedProperty(key, &lookup); - } - Handle result = isolate->factory()->undefined_value(); - if (lookup.IsFound() && !lookup.IsTransition()) { - switch (lookup.type()) { - case NORMAL: - result = GetNormalizedProperty( - Handle(lookup.holder(), isolate), &lookup); - break; - case FIELD: - result = FastPropertyAt(Handle(lookup.holder(), isolate), - lookup.representation(), - lookup.GetFieldIndex()); - break; - case CONSTANT: - result = Handle(lookup.GetConstant(), isolate); - break; - case CALLBACKS: - case HANDLER: - case INTERCEPTOR: - break; - case NONEXISTENT: - UNREACHABLE(); - } - } - return result; -} - - // Tests for the fast common case for property enumeration: // - This object and all prototypes has an enum cache (which means that // it is no proxy, has no interceptors and needs no access checks). diff --git a/src/objects.h b/src/objects.h index d009416..af1152d 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2157,8 +2157,6 @@ class JSObject: public JSReceiver { // Retrieve a value in a normalized object given a lookup result. // Handles the special representation of JS global objects. Object* GetNormalizedProperty(const LookupResult* result); - static Handle GetNormalizedProperty(Handle object, - const LookupResult* result); // Sets the property value in a normalized object given (key, value, details). // Handles the special representation of JS global objects. @@ -2376,9 +2374,6 @@ class JSObject: public JSReceiver { // The following lookup functions skip interceptors. void LookupOwnRealNamedProperty(Handle name, LookupResult* result); - void LookupRealNamedProperty(Handle name, LookupResult* result); - void LookupRealNamedPropertyInPrototypes(Handle name, - LookupResult* result); // Returns the number of properties on this object filtering out properties // with the specified attributes (ignoring interceptors). -- 2.7.4