From 1f9f8fe9ebe4f2438ba87f03f59fafd307e3f384 Mon Sep 17 00:00:00 2001 From: "ishell@chromium.org" Date: Fri, 4 Apr 2014 13:20:24 +0000 Subject: [PATCH] ElementsAccessor's public interface handlification. R=yangguo@chromium.org Review URL: https://codereview.chromium.org/225933002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20514 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/elements.cc | 40 +++++++++++++++++----------------- src/elements.h | 58 +++++++++++++++++++++++++++++++++++++------------ src/objects.cc | 2 +- 3 files changed, 65 insertions(+), 35 deletions(-) diff --git a/src/elements.cc b/src/elements.cc index cda95774b0..f0375acc2a 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -643,25 +643,11 @@ class ElementsAccessorBase : public ElementsAccessor { Object); } - // TODO(ishell): Temporary wrapper until handlified. - MUST_USE_RESULT virtual Handle Get( - Handle receiver, - Handle holder, - uint32_t key) V8_FINAL V8_OVERRIDE { - CALL_HEAP_FUNCTION(holder->GetIsolate(), - Get(*receiver, *holder, key, NULL), - Object); - } - MUST_USE_RESULT virtual MaybeObject* Get( Object* receiver, JSObject* holder, uint32_t key, FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { - if (backing_store == NULL) { - backing_store = holder->elements(); - } - if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && FLAG_trace_js_array_abuse) { CheckArrayAbuse(holder, "elements read", key); @@ -685,14 +671,21 @@ class ElementsAccessorBase : public ElementsAccessor { : backing_store->GetHeap()->the_hole_value(); } + MUST_USE_RESULT virtual PropertyAttributes GetAttributes( + Handle receiver, + Handle holder, + uint32_t key, + Handle backing_store) V8_FINAL V8_OVERRIDE { + return ElementsAccessorSubclass::GetAttributesImpl( + *receiver, *holder, key, *backing_store); + } + + // TODO(ishell): To be removed once elements.cc is handlified. MUST_USE_RESULT virtual PropertyAttributes GetAttributes( Object* receiver, JSObject* holder, uint32_t key, FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { - if (backing_store == NULL) { - backing_store = holder->elements(); - } return ElementsAccessorSubclass::GetAttributesImpl( receiver, holder, key, backing_store); } @@ -708,14 +701,21 @@ class ElementsAccessorBase : public ElementsAccessor { return BackingStore::cast(backing_store)->is_the_hole(key) ? ABSENT : NONE; } + MUST_USE_RESULT virtual PropertyType GetType( + Handle receiver, + Handle holder, + uint32_t key, + Handle backing_store) V8_FINAL V8_OVERRIDE { + return ElementsAccessorSubclass::GetTypeImpl( + *receiver, *holder, key, *backing_store); + } + + // TODO(ishell): To be removed once elements.cc is handlified. MUST_USE_RESULT virtual PropertyType GetType( Object* receiver, JSObject* holder, uint32_t key, FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { - if (backing_store == NULL) { - backing_store = holder->elements(); - } return ElementsAccessorSubclass::GetTypeImpl( receiver, holder, key, backing_store); } diff --git a/src/elements.h b/src/elements.h index 1292a3cbac..ef2089882e 100644 --- a/src/elements.h +++ b/src/elements.h @@ -79,16 +79,12 @@ class ElementsAccessor { uint32_t key, Handle backing_store) = 0; - MUST_USE_RESULT virtual Handle Get( + MUST_USE_RESULT inline Handle Get( Handle receiver, Handle holder, - uint32_t key) = 0; - - MUST_USE_RESULT virtual MaybeObject* Get( - Object* receiver, - JSObject* holder, - uint32_t key, - FixedArrayBase* backing_store = NULL) = 0; + uint32_t key) { + return Get(receiver, holder, key, handle(holder->elements())); + } // Returns an element's attributes, or ABSENT if there is no such // element. This method doesn't iterate up the prototype chain. The caller @@ -96,10 +92,17 @@ class ElementsAccessor { // be compatible with the ElementsKind of the ElementsAccessor. If // backing_store is NULL, the holder->elements() is used as the backing store. MUST_USE_RESULT virtual PropertyAttributes GetAttributes( - Object* receiver, - JSObject* holder, + Handle receiver, + Handle holder, uint32_t key, - FixedArrayBase* backing_store = NULL) = 0; + Handle backing_store) = 0; + + MUST_USE_RESULT inline PropertyAttributes GetAttributes( + Handle receiver, + Handle holder, + uint32_t key) { + return GetAttributes(receiver, holder, key, handle(holder->elements())); + } // Returns an element's type, or NONEXISTENT if there is no such // element. This method doesn't iterate up the prototype chain. The caller @@ -107,10 +110,17 @@ class ElementsAccessor { // be compatible with the ElementsKind of the ElementsAccessor. If // backing_store is NULL, the holder->elements() is used as the backing store. MUST_USE_RESULT virtual PropertyType GetType( - Object* receiver, - JSObject* holder, + Handle receiver, + Handle holder, uint32_t key, - FixedArrayBase* backing_store = NULL) = 0; + Handle backing_store) = 0; + + MUST_USE_RESULT inline PropertyType GetType( + Handle receiver, + Handle holder, + uint32_t key) { + return GetType(receiver, holder, key, handle(holder->elements())); + } // Returns an element's accessors, or NULL if the element does not exist or // is plain. This method doesn't iterate up the prototype chain. The caller @@ -234,6 +244,26 @@ class ElementsAccessor { virtual uint32_t GetKeyForIndex(Handle backing_store, uint32_t index) = 0; + // TODO(ishell): Non-handlified versions, used only by accessors' + // implementations. To be removed once elements.cc is handlified. + MUST_USE_RESULT virtual MaybeObject* Get( + Object* receiver, + JSObject* holder, + uint32_t key, + FixedArrayBase* backing_store) = 0; + + MUST_USE_RESULT virtual PropertyAttributes GetAttributes( + Object* receiver, + JSObject* holder, + uint32_t key, + FixedArrayBase* backing_store) = 0; + + MUST_USE_RESULT virtual PropertyType GetType( + Object* receiver, + JSObject* holder, + uint32_t key, + FixedArrayBase* backing_store) = 0; + private: static ElementsAccessor** elements_accessors_; const char* name_; diff --git a/src/objects.cc b/src/objects.cc index 2f76da7544..ce0aa6d92e 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -4498,7 +4498,7 @@ PropertyAttributes JSObject::GetElementAttributeWithoutInterceptor( uint32_t index, bool continue_search) { PropertyAttributes attr = object->GetElementsAccessor()->GetAttributes( - *receiver, *object, index); + receiver, object, index); if (attr != ABSENT) return attr; // Handle [] on String objects.