Minor cleanup and optimisation of element methods.
authorrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 12 Nov 2012 11:08:34 +0000 (11:08 +0000)
committerrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 12 Nov 2012 11:08:34 +0000 (11:08 +0000)
R=verwaest@chromium.org
BUG=

Review URL: https://codereview.chromium.org/11365175

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12927 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/elements.cc
src/objects-inl.h
src/objects.cc
src/objects.h

index 89d3a7b93c85aa6a508bda421baca5fdccac7428..8cb48c6ad8a418e3640b82d2d796b191eddc9a7a 100644 (file)
@@ -528,9 +528,8 @@ class ElementsAccessorBase : public ElementsAccessor {
                              JSObject* holder,
                              uint32_t key,
                              BackingStore* backing_store) {
-    MaybeObject* element =
-        ElementsAccessorSubclass::GetImpl(receiver, holder, key, backing_store);
-    return !element->IsTheHole();
+    return ElementsAccessorSubclass::GetAttributesImpl(
+        receiver, holder, key, backing_store) != ABSENT;
   }
 
   virtual bool HasElement(Object* receiver,
index 71a169bb71970e9dfe1a72997c9fcce90835559c..d5815f2ecffa12f71ad39ab5a89c21088d92bf4e 100644 (file)
@@ -5046,7 +5046,11 @@ PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) {
 
 
 PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) {
-  return GetElementAttributeWithReceiver(this, index, true);
+  if (IsJSProxy()) {
+    return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index);
+  }
+  return JSObject::cast(this)->GetElementAttributeWithReceiver(
+      this, index, true);
 }
 
 
@@ -5074,7 +5078,8 @@ bool JSReceiver::HasElement(uint32_t index) {
   if (IsJSProxy()) {
     return JSProxy::cast(this)->HasElementWithHandler(index);
   }
-  return JSObject::cast(this)->GetElementAttribute(index) != ABSENT;
+  return JSObject::cast(this)->GetElementAttributeWithReceiver(
+      this, index, true) != ABSENT;
 }
 
 
@@ -5082,17 +5087,8 @@ bool JSReceiver::HasLocalElement(uint32_t index) {
   if (IsJSProxy()) {
     return JSProxy::cast(this)->HasElementWithHandler(index);
   }
-  return JSObject::cast(this)->GetLocalElementAttribute(index) != ABSENT;
-}
-
-
-PropertyAttributes JSReceiver::GetElementAttributeWithReceiver(
-    JSReceiver* receiver, uint32_t index, bool continue_search) {
-  if (IsJSProxy()) {
-    return JSProxy::cast(this)->GetElementAttributeWithHandler(receiver, index);
-  }
   return JSObject::cast(this)->GetElementAttributeWithReceiver(
-      receiver, index, continue_search);
+      this, index, false) != ABSENT;
 }
 
 
index 7969e7d4c561c8726112f1aa6fa909238e74020e..a150920b50a570dd826ad7a2c4cd17de83258413 100644 (file)
@@ -3318,7 +3318,7 @@ PropertyAttributes JSObject::GetElementAttributeWithReceiver(
     Object* proto = GetPrototype();
     if (proto->IsNull()) return ABSENT;
     ASSERT(proto->IsJSGlobalObject());
-    return JSReceiver::cast(proto)->GetElementAttributeWithReceiver(
+    return JSObject::cast(proto)->GetElementAttributeWithReceiver(
         receiver, index, continue_search);
   }
 
index 59b781b1c2470a738f1dbb5e7920e62ed1a46951..c86c0b2f431bd08890b7250d4d59d30e770f7e25 100644 (file)
@@ -1483,10 +1483,6 @@ class JSReceiver: public HeapObject {
   PropertyAttributes GetLocalPropertyAttribute(String* name);
 
   inline PropertyAttributes GetElementAttribute(uint32_t index);
-  inline PropertyAttributes GetElementAttributeWithReceiver(
-      JSReceiver* receiver,
-      uint32_t index,
-      bool continue_search);
   inline PropertyAttributes GetLocalElementAttribute(uint32_t index);
 
   // Can cause a GC.