Reviewers: Toon Verwaest,
Description:
Minor cleanup and optimisation of element methods.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/11365175/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/elements.cc
M src/objects-inl.h
M src/objects.h
M src/objects.cc
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index
89d3a7b93c85aa6a508bda421baca5fdccac7428..8cb48c6ad8a418e3640b82d2d796b191eddc9a7a
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,
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
71a169bb71970e9dfe1a72997c9fcce90835559c..d5815f2ecffa12f71ad39ab5a89c21088d92bf4e
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;
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
7969e7d4c561c8726112f1aa6fa909238e74020e..a150920b50a570dd826ad7a2c4cd17de83258413
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);
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
59b781b1c2470a738f1dbb5e7920e62ed1a46951..c86c0b2f431bd08890b7250d4d59d30e770f7e25
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.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev