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
parent 4cf77d77
...@@ -452,14 +452,17 @@ MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, ...@@ -452,14 +452,17 @@ MaybeObject* JSProxy::GetElementWithHandler(Object* receiver,
} }
MaybeObject* JSProxy::SetElementWithHandler(JSReceiver* receiver, Handle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
uint32_t index, Handle<JSReceiver> receiver,
Object* value, uint32_t index,
StrictModeFlag strict_mode) { Handle<Object> value,
String* name; StrictModeFlag strict_mode) {
MaybeObject* maybe = GetHeap()->Uint32ToString(index); Isolate* isolate = proxy->GetIsolate();
if (!maybe->To<String>(&name)) return maybe; Handle<String> name = isolate->factory()->Uint32ToString(index);
return SetPropertyWithHandler(receiver, name, value, NONE, strict_mode); CALL_HEAP_FUNCTION(isolate,
proxy->SetPropertyWithHandler(
*receiver, *name, *value, NONE, strict_mode),
Object);
} }
...@@ -3541,20 +3544,20 @@ MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler( ...@@ -3541,20 +3544,20 @@ MUST_USE_RESULT MaybeObject* JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<Object> JSProxy::DeletePropertyWithHandler( Handle<Object> JSProxy::DeletePropertyWithHandler(
Handle<JSProxy> object, Handle<Name> name, DeleteMode mode) { Handle<JSProxy> proxy, Handle<Name> name, DeleteMode mode) {
Isolate* isolate = object->GetIsolate(); Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies. // TODO(rossberg): adjust once there is a story for symbols vs proxies.
if (name->IsSymbol()) return isolate->factory()->false_value(); if (name->IsSymbol()) return isolate->factory()->false_value();
Handle<Object> args[] = { name }; Handle<Object> args[] = { name };
Handle<Object> result = object->CallTrap( Handle<Object> result = proxy->CallTrap(
"delete", Handle<Object>(), ARRAY_SIZE(args), args); "delete", Handle<Object>(), ARRAY_SIZE(args), args);
if (isolate->has_pending_exception()) return Handle<Object>(); if (isolate->has_pending_exception()) return Handle<Object>();
bool result_bool = result->BooleanValue(); bool result_bool = result->BooleanValue();
if (mode == STRICT_DELETION && !result_bool) { if (mode == STRICT_DELETION && !result_bool) {
Handle<Object> handler(object->handler(), isolate); Handle<Object> handler(proxy->handler(), isolate);
Handle<String> trap_name = isolate->factory()->InternalizeOneByteString( Handle<String> trap_name = isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("delete")); STATIC_ASCII_VECTOR("delete"));
Handle<Object> args[] = { handler, trap_name }; Handle<Object> args[] = { handler, trap_name };
...@@ -3568,10 +3571,10 @@ Handle<Object> JSProxy::DeletePropertyWithHandler( ...@@ -3568,10 +3571,10 @@ Handle<Object> JSProxy::DeletePropertyWithHandler(
Handle<Object> JSProxy::DeleteElementWithHandler( Handle<Object> JSProxy::DeleteElementWithHandler(
Handle<JSProxy> object, uint32_t index, DeleteMode mode) { Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) {
Isolate* isolate = object->GetIsolate(); Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index); Handle<String> 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( ...@@ -12111,18 +12114,17 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement(
} }
MaybeObject* JSReceiver::SetElement(uint32_t index, Handle<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
Object* value, uint32_t index,
PropertyAttributes attributes, Handle<Object> value,
StrictModeFlag strict_mode, PropertyAttributes attributes,
bool check_proto) { StrictModeFlag strict_mode) {
if (IsJSProxy()) { if (object->IsJSProxy()) {
return JSProxy::cast(this)->SetElementWithHandler( return JSProxy::SetElementWithHandler(
this, index, value, strict_mode); Handle<JSProxy>::cast(object), object, index, value, strict_mode);
} else {
return JSObject::cast(this)->SetElement(
index, value, attributes, strict_mode, check_proto);
} }
return JSObject::SetElement(
Handle<JSObject>::cast(object), index, value, attributes, strict_mode);
} }
......
...@@ -1936,6 +1936,11 @@ class JSReceiver: public HeapObject { ...@@ -1936,6 +1936,11 @@ class JSReceiver: public HeapObject {
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes, PropertyAttributes attributes,
StrictModeFlag strict_mode); StrictModeFlag strict_mode);
static Handle<Object> SetElement(Handle<JSReceiver> object,
uint32_t index,
Handle<Object> value,
PropertyAttributes attributes,
StrictModeFlag strict_mode);
MUST_USE_RESULT static MaybeObject* SetPropertyOrFail( MUST_USE_RESULT static MaybeObject* SetPropertyOrFail(
Handle<JSReceiver> object, Handle<JSReceiver> object,
...@@ -1969,14 +1974,6 @@ class JSReceiver: public HeapObject { ...@@ -1969,14 +1974,6 @@ class JSReceiver: public HeapObject {
uint32_t index, uint32_t index,
DeleteMode mode = NORMAL_DELETION); 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. // Tests for the fast common case for property enumeration.
bool IsSimpleEnum(); bool IsSimpleEnum();
...@@ -9088,11 +9085,6 @@ class JSProxy: public JSReceiver { ...@@ -9088,11 +9085,6 @@ class JSProxy: public JSReceiver {
Object* value, Object* value,
PropertyAttributes attributes, PropertyAttributes attributes,
StrictModeFlag strict_mode); 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 the handler defines an accessor property with a setter, invoke it.
// If it defines an accessor property without a setter, or a data property // If it defines an accessor property without a setter, or a data property
...@@ -9151,10 +9143,16 @@ class JSProxy: public JSReceiver { ...@@ -9151,10 +9143,16 @@ class JSProxy: public JSReceiver {
private: private:
friend class JSReceiver; friend class JSReceiver;
static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> object, static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
Handle<Object> value,
StrictModeFlag strict_mode);
static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy,
Handle<Name> name, Handle<Name> name,
DeleteMode mode); DeleteMode mode);
static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> object, static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy,
uint32_t index, uint32_t index,
DeleteMode mode); DeleteMode mode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment