From 92e783bc28538821c3f7026fb69cef6fae18f585 Mon Sep 17 00:00:00 2001 From: "rossberg@chromium.org" Date: Mon, 12 Nov 2012 11:08:34 +0000 Subject: [PATCH] Minor cleanup and optimisation of element methods. 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 | 5 ++--- src/objects-inl.h | 20 ++++++++------------ src/objects.cc | 2 +- src/objects.h | 4 ---- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/elements.cc b/src/elements.cc index 89d3a7b93c..8cb48c6ad8 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -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, diff --git a/src/objects-inl.h b/src/objects-inl.h index 71a169bb71..d5815f2ecf 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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; } diff --git a/src/objects.cc b/src/objects.cc index 7969e7d4c5..a150920b50 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -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); } diff --git a/src/objects.h b/src/objects.h index 59b781b1c2..c86c0b2f43 100644 --- a/src/objects.h +++ b/src/objects.h @@ -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.