Get rid of LookupRealNamedProperty and LookupRealNamedPropertyInPrototypes and update...
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Aug 2014 14:58:41 +0000 (14:58 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 19 Aug 2014 14:58:41 +0000 (14:58 +0000)
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
src/objects.cc
src/objects.h

index 35a7e5f..9b57b36 100644 (file)
@@ -3564,24 +3564,12 @@ bool v8::Object::HasIndexedLookupInterceptor() {
 }
 
 
-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 @@ Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
   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 @@ Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
   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 @@ Handle<Value> Function::GetDisplayName() const {
   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());
 }
 
index 307bcbf..ac4982d 100644 (file)
@@ -140,6 +140,34 @@ MaybeHandle<Object> Object::GetProperty(LookupIterator* it) {
 }
 
 
+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) {
   if (IsSmi()) {
     *value = Smi::cast(this)->value();
@@ -630,22 +658,6 @@ Object* JSObject::GetNormalizedProperty(const LookupResult* result) {
 }
 
 
-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,
                                      Handle<Name> name,
                                      Handle<Object> value,
@@ -3419,37 +3431,6 @@ void JSObject::LookupOwnRealNamedProperty(Handle<Name> name,
 }
 
 
-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,
                                             Handle<Name> name) {
   Isolate* isolate = proxy->GetIsolate();
@@ -5671,41 +5652,6 @@ MaybeHandle<JSObject> JSObject::DeepCopy(
 }
 
 
-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:
 // - This object and all prototypes has an enum cache (which means that
 //   it is no proxy, has no interceptors and needs no access checks).
index d009416..af1152d 100644 (file)
@@ -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<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 @@ class JSObject: public JSReceiver {
 
   // 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).