From: mstarzinger@chromium.org Date: Fri, 30 Aug 2013 11:44:39 +0000 (+0000) Subject: Handlify JSReceiver::SetElement method. X-Git-Tag: upstream/4.7.83~12732 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25d86eacbde6677ebbbdbd2eda774d72c7320e6c;p=platform%2Fupstream%2Fv8.git Handlify JSReceiver::SetElement method. R=rossberg@chromium.org Review URL: https://codereview.chromium.org/23541006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16448 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/objects.cc b/src/objects.cc index 8cf74ad..2937cec 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -452,14 +452,17 @@ MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, } -MaybeObject* JSProxy::SetElementWithHandler(JSReceiver* receiver, - uint32_t index, - Object* value, - StrictModeFlag strict_mode) { - String* name; - MaybeObject* maybe = GetHeap()->Uint32ToString(index); - if (!maybe->To(&name)) return maybe; - return SetPropertyWithHandler(receiver, name, value, NONE, strict_mode); +Handle JSProxy::SetElementWithHandler(Handle proxy, + Handle receiver, + uint32_t index, + Handle value, + StrictModeFlag strict_mode) { + Isolate* isolate = proxy->GetIsolate(); + Handle name = isolate->factory()->Uint32ToString(index); + CALL_HEAP_FUNCTION(isolate, + proxy->SetPropertyWithHandler( + *receiver, *name, *value, NONE, strict_mode), + Object); } @@ -3541,20 +3544,20 @@ MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler( Handle JSProxy::DeletePropertyWithHandler( - Handle object, Handle name, DeleteMode mode) { - Isolate* isolate = object->GetIsolate(); + Handle proxy, Handle name, DeleteMode mode) { + Isolate* isolate = proxy->GetIsolate(); // TODO(rossberg): adjust once there is a story for symbols vs proxies. if (name->IsSymbol()) return isolate->factory()->false_value(); Handle args[] = { name }; - Handle result = object->CallTrap( + Handle result = proxy->CallTrap( "delete", Handle(), ARRAY_SIZE(args), args); if (isolate->has_pending_exception()) return Handle(); bool result_bool = result->BooleanValue(); if (mode == STRICT_DELETION && !result_bool) { - Handle handler(object->handler(), isolate); + Handle handler(proxy->handler(), isolate); Handle trap_name = isolate->factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("delete")); Handle args[] = { handler, trap_name }; @@ -3568,10 +3571,10 @@ Handle JSProxy::DeletePropertyWithHandler( Handle JSProxy::DeleteElementWithHandler( - Handle object, uint32_t index, DeleteMode mode) { - Isolate* isolate = object->GetIsolate(); + Handle proxy, uint32_t index, DeleteMode mode) { + Isolate* isolate = proxy->GetIsolate(); Handle name = isolate->factory()->Uint32ToString(index); - return JSProxy::DeletePropertyWithHandler(object, name, mode); + return JSProxy::DeletePropertyWithHandler(proxy, name, mode); } @@ -12111,18 +12114,17 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement( } -MaybeObject* JSReceiver::SetElement(uint32_t index, - Object* value, - PropertyAttributes attributes, - StrictModeFlag strict_mode, - bool check_proto) { - if (IsJSProxy()) { - return JSProxy::cast(this)->SetElementWithHandler( - this, index, value, strict_mode); - } else { - return JSObject::cast(this)->SetElement( - index, value, attributes, strict_mode, check_proto); +Handle JSReceiver::SetElement(Handle object, + uint32_t index, + Handle value, + PropertyAttributes attributes, + StrictModeFlag strict_mode) { + if (object->IsJSProxy()) { + return JSProxy::SetElementWithHandler( + Handle::cast(object), object, index, value, strict_mode); } + return JSObject::SetElement( + Handle::cast(object), index, value, attributes, strict_mode); } diff --git a/src/objects.h b/src/objects.h index 657d245..bc68305 100644 --- a/src/objects.h +++ b/src/objects.h @@ -1936,6 +1936,11 @@ class JSReceiver: public HeapObject { Handle value, PropertyAttributes attributes, StrictModeFlag strict_mode); + static Handle SetElement(Handle object, + uint32_t index, + Handle value, + PropertyAttributes attributes, + StrictModeFlag strict_mode); MUST_USE_RESULT static MaybeObject* SetPropertyOrFail( Handle object, @@ -1969,14 +1974,6 @@ class JSReceiver: public HeapObject { uint32_t index, DeleteMode mode = NORMAL_DELETION); - // Set the index'th array element. - // Can cause GC, or return failure if GC is required. - MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, - Object* value, - PropertyAttributes attributes, - StrictModeFlag strict_mode, - bool check_prototype); - // Tests for the fast common case for property enumeration. bool IsSimpleEnum(); @@ -9088,11 +9085,6 @@ class JSProxy: public JSReceiver { Object* value, PropertyAttributes attributes, StrictModeFlag strict_mode); - MUST_USE_RESULT MaybeObject* SetElementWithHandler( - JSReceiver* receiver, - uint32_t index, - Object* value, - StrictModeFlag strict_mode); // If the handler defines an accessor property with a setter, invoke it. // If it defines an accessor property without a setter, or a data property @@ -9151,10 +9143,16 @@ class JSProxy: public JSReceiver { private: friend class JSReceiver; - static Handle DeletePropertyWithHandler(Handle object, + static Handle SetElementWithHandler(Handle proxy, + Handle receiver, + uint32_t index, + Handle value, + StrictModeFlag strict_mode); + + static Handle DeletePropertyWithHandler(Handle proxy, Handle name, DeleteMode mode); - static Handle DeleteElementWithHandler(Handle object, + static Handle DeleteElementWithHandler(Handle proxy, uint32_t index, DeleteMode mode);