Revision: 23202
Author: [email protected]
Date: Tue Aug 19 14:58:41 2014 UTC
Log: Get rid of LookupRealNamedProperty and
LookupRealNamedPropertyInPrototypes and update clients
BUG=
[email protected]
Review URL: https://codereview.chromium.org/481043002
http://code.google.com/p/v8/source/detail?r=23202
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/src/api.cc Tue Aug 19 12:08:46 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Tue Aug 19 14:58:41 2014 UTC
@@ -3564,24 +3564,12 @@
}
-static Local<Value> GetPropertyByLookup(i::Isolate* isolate,
- i::Handle<i::JSObject> receiver,
- i::Handle<i::String> name,
- i::LookupResult* lookup) {
- if (!lookup->IsProperty()) {
- // No real property was found.
- return Local<Value>();
- }
-
- // If the property being looked up is a callback, it can throw
- // an exception.
- EXCEPTION_PREAMBLE(isolate);
- i::LookupIterator it(receiver, name,
- i::Handle<i::JSReceiver>(lookup->holder(), isolate),
- i::LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR);
+static Local<Value> GetPropertyByLookup(i::LookupIterator* it) {
+ // If the property being looked up is a callback, it can throw an
exception.
+ EXCEPTION_PREAMBLE(it->isolate());
i::Handle<i::Object> result;
- has_pending_exception = !i::Object::GetProperty(&it).ToHandle(&result);
- EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
+ has_pending_exception = !i::Object::GetProperty(it).ToHandle(&result);
+ EXCEPTION_BAILOUT_CHECK(it->isolate(), Local<Value>());
return Utils::ToLocal(result);
}
@@ -3596,9 +3584,11 @@
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> 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<Value>();
+ i::LookupIterator it(i::PrototypeIterator::GetCurrent(iter), key_obj,
+ i::LookupIterator::CHECK_DERIVED_PROPERTY);
+ return GetPropertyByLookup(&it);
}
@@ -3609,9 +3599,9 @@
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> 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 @@
i::Handle<i::String> 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<i::String>(name));
- }
+ i::LookupIterator it(func, property_name,
+ i::LookupIterator::CHECK_DERIVED_PROPERTY);
+
+ i::Handle<i::Object> value =
+ i::JSObject::GetDataProperty(func, property_name);
+ if (value->IsString()) {
+ i::Handle<i::String> name = i::Handle<i::String>::cast(value);
+ if (name->length() > 0) return Utils::ToLocal(name);
}
+
return ToApiHandle<Primitive>(isolate->factory()->undefined_value());
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Tue Aug 19 10:56:49 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Tue Aug 19 14:58:41 2014 UTC
@@ -138,6 +138,34 @@
}
return it->factory()->undefined_value();
}
+
+
+Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
+ Handle<Name> 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) {
@@ -628,22 +656,6 @@
DCHECK(!value->IsPropertyCell() && !value->IsCell());
return value;
}
-
-
-Handle<Object> JSObject::GetNormalizedProperty(Handle<JSObject> object,
- const LookupResult* result)
{
- DCHECK(!object->HasFastProperties());
- Isolate* isolate = object->GetIsolate();
- Handle<Object> value(
- object->property_dictionary()->ValueAt(result->GetDictionaryEntry()),
- isolate);
- if (object->IsGlobalObject()) {
- value = handle(Handle<PropertyCell>::cast(value)->value(), isolate);
- DCHECK(!value->IsTheHole());
- }
- DCHECK(!value->IsPropertyCell() && !value->IsCell());
- return value;
-}
void JSObject::SetNormalizedProperty(Handle<JSObject> object,
@@ -3417,37 +3429,6 @@
result->NotFound();
}
-
-
-void JSObject::LookupRealNamedProperty(Handle<Name> name,
- LookupResult* result) {
- DisallowHeapAllocation no_gc;
- LookupOwnRealNamedProperty(name, result);
- if (result->IsFound()) return;
-
- LookupRealNamedPropertyInPrototypes(name, result);
-}
-
-
-void JSObject::LookupRealNamedPropertyInPrototypes(Handle<Name> 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<bool> JSProxy::HasPropertyWithHandler(Handle<JSProxy> proxy,
@@ -5669,41 +5650,6 @@
DCHECK(!copy.ToHandle(&for_assert) |
| !for_assert.is_identical_to(object));
return copy;
}
-
-
-Handle<Object> JSObject::GetDataProperty(Handle<JSObject> object,
- Handle<Name> key) {
- Isolate* isolate = object->GetIsolate();
- LookupResult lookup(isolate);
- {
- DisallowHeapAllocation no_allocation;
- object->LookupRealNamedProperty(key, &lookup);
- }
- Handle<Object> result = isolate->factory()->undefined_value();
- if (lookup.IsFound() && !lookup.IsTransition()) {
- switch (lookup.type()) {
- case NORMAL:
- result = GetNormalizedProperty(
- Handle<JSObject>(lookup.holder(), isolate), &lookup);
- break;
- case FIELD:
- result = FastPropertyAt(Handle<JSObject>(lookup.holder(), isolate),
- lookup.representation(),
- lookup.GetFieldIndex());
- break;
- case CONSTANT:
- result = Handle<Object>(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:
=======================================
--- /branches/bleeding_edge/src/objects.h Tue Aug 19 10:56:49 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Tue Aug 19 14:58:41 2014 UTC
@@ -2157,8 +2157,6 @@
// 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<Object> GetNormalizedProperty(Handle<JSObject> 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 @@
// The following lookup functions skip interceptors.
void LookupOwnRealNamedProperty(Handle<Name> name, LookupResult* result);
- void LookupRealNamedProperty(Handle<Name> name, LookupResult* result);
- void LookupRealNamedPropertyInPrototypes(Handle<Name> name,
- LookupResult* result);
// Returns the number of properties on this object filtering out
properties
// with the specified attributes (ignoring interceptors).
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.