Reviewers: Jakob,

Message:
PTAL

Description:
Use LookupIterator in SetAccessor / DefineAccessor and remove
"search_hidden_prototypes" from LookupOwn

BUG=

Please review this at https://codereview.chromium.org/468163002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+17, -25 lines):
  M src/lookup.h
  M src/objects.h
  M src/objects.cc


Index: src/lookup.h
diff --git a/src/lookup.h b/src/lookup.h
index 7727ca57dc083289f361a27fcbc4acf81480bd45..53f1a686828fd0c2d035a4164c8e2668ec4b2063 100644
--- a/src/lookup.h
+++ b/src/lookup.h
@@ -143,6 +143,7 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
     return property_details_;
   }
bool IsConfigurable() const { return !property_details().IsDontDelete(); }
+  bool IsReadOnly() const { return property_details().IsReadOnly(); }
   Representation representation() const {
     return property_details().representation();
   }
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 2526152b8903d4a3d605b663885ef7d3ef091dbd..06e4db5ff60294d01ba37742d37320d604d3f9e5 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5792,8 +5792,7 @@ int Map::NextFreePropertyIndex() {
 }


-void JSReceiver::LookupOwn(
- Handle<Name> name, LookupResult* result, bool search_hidden_prototypes) {
+void JSReceiver::LookupOwn(Handle<Name> name, LookupResult* result) {
   DisallowHeapAllocation no_gc;
   DCHECK(name->IsName());

@@ -5801,8 +5800,7 @@ void JSReceiver::LookupOwn(
     PrototypeIterator iter(GetIsolate(), this);
     if (iter.IsAtEnd()) return result->NotFound();
     DCHECK(iter.GetCurrent()->IsJSGlobalObject());
-    return JSReceiver::cast(iter.GetCurrent())
-        ->LookupOwn(name, result, search_hidden_prototypes);
+    return JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result);
   }

   if (IsJSProxy()) {
@@ -5826,14 +5824,6 @@ void JSReceiver::LookupOwn(
   }

   js_object->LookupOwnRealNamedProperty(name, result);
- if (result->IsFound() || name->IsOwn() || !search_hidden_prototypes) return;
-
-  PrototypeIterator iter(GetIsolate(), js_object);
-  if (!iter.GetCurrent()->IsJSReceiver()) return;
-  JSReceiver* receiver = JSReceiver::cast(iter.GetCurrent());
-  if (receiver->map()->is_hidden_prototype()) {
-    receiver->LookupOwn(name, result, search_hidden_prototypes);
-  }
 }


@@ -5843,7 +5833,7 @@ void JSReceiver::Lookup(Handle<Name> name, LookupResult* result) {
   for (PrototypeIterator iter(GetIsolate(), this,
                               PrototypeIterator::START_AT_RECEIVER);
        !iter.IsAtEnd(); iter.Advance()) {
-    JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result, false);
+    JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result);
     if (result->IsFound()) return;
     if (name->IsOwn()) {
       result->NotFound();
@@ -6369,12 +6359,13 @@ MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object,
             Object::GetElement(isolate, object, index).ToHandleChecked();
       }
     } else {
-      LookupResult lookup(isolate);
-      object->LookupOwn(name, &lookup, true);
-      preexists = lookup.IsProperty();
-      if (preexists && lookup.IsDataProperty()) {
-        old_value =
-            Object::GetPropertyOrElement(object, name).ToHandleChecked();
+      LookupIterator it(object, name,
+                        LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+      CHECK(GetPropertyAttributes(&it).has_value);
+      preexists = it.IsFound();
+      if (preexists && (it.property_kind() == LookupIterator::DATA ||
+                        it.GetAccessors()->IsAccessorInfo())) {
+        old_value = GetProperty(&it).ToHandleChecked();
       }
     }
   }
@@ -6564,11 +6555,12 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
     SetElementCallback(object, index, info, info->property_attributes());
   } else {
     // Lookup the name.
-    LookupResult result(isolate);
-    object->LookupOwn(name, &result, true);
+    LookupIterator it(object, name,
+                      LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+    CHECK(GetPropertyAttributes(&it).has_value);
     // ES5 forbids turning a property into an accessor if it's not
- // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5). - if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) {
+    // configurable. See 8.6.1 (Table 5).
+    if (it.IsFound() && (it.IsReadOnly() || !it.IsConfigurable())) {
       return factory->undefined_value();
     }

Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 953e58d03d44c1dc24facca8488eea4597970361..bbbfe59c40057aaeb60048ddb514fe22e2d6f6d9 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2010,8 +2010,7 @@ class JSReceiver: public HeapObject {

   // Lookup a property.  If found, the result is valid and has
   // detailed information.
-  void LookupOwn(Handle<Name> name, LookupResult* result,
-                 bool search_hidden_prototypes = false);
+  void LookupOwn(Handle<Name> name, LookupResult* result);
   void Lookup(Handle<Name> name, LookupResult* result);

   enum KeyCollectionType { OWN_ONLY, INCLUDE_PROTOS };


--
--
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.

Reply via email to