Reviewers: rossberg,

Message:
Since you want to keep this dead method, you get to review it's handlification.
:)

Description:
Handlify JSReceiver::SetElement method.

[email protected]

Please review this at https://codereview.chromium.org/23541006/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/objects.h
  M src/objects.cc


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 8cf74ad33836a191159334430bd6b8c71323f554..abfa477f690feaa051b644c33c511707d3d7a8a0 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<String>(&name)) return maybe;
-  return SetPropertyWithHandler(receiver, name, value, NONE, strict_mode);
+Handle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> object,
+                                              Handle<JSReceiver> receiver,
+                                              uint32_t index,
+                                              Handle<Object> value,
+                                              StrictModeFlag strict_mode) {
+  Isolate* isolate = object->GetIsolate();
+  Handle<String> name = isolate->factory()->Uint32ToString(index);
+  CALL_HEAP_FUNCTION(isolate,
+                     object->SetPropertyWithHandler(
+                         *receiver, *name, *value, NONE, strict_mode),
+                     Object);
 }


@@ -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<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
+                                      uint32_t index,
+                                      Handle<Object> value,
+                                      PropertyAttributes attributes,
+                                      StrictModeFlag strict_mode) {
+  if (object->IsJSProxy()) {
+    return JSProxy::SetElementWithHandler(
+        Handle<JSProxy>::cast(object), object, index, value, strict_mode);
   }
+  return JSObject::SetElement(
+ Handle<JSObject>::cast(object), index, value, attributes, strict_mode);
 }


Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index d42b90853723f041017a1478a70e18b494cb66b4..8aa2a36a44909cae6ec3f3e72c330863adae1613 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1951,6 +1951,11 @@ class JSReceiver: public HeapObject {
                                     Handle<Object> value,
                                     PropertyAttributes attributes,
                                     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(
       Handle<JSReceiver> object,
@@ -1984,14 +1989,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();

@@ -9129,11 +9126,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
@@ -9192,6 +9184,12 @@ class JSProxy: public JSReceiver {
  private:
   friend class JSReceiver;

+  static Handle<Object> SetElementWithHandler(Handle<JSProxy> object,
+                                              Handle<JSReceiver> receiver,
+                                              uint32_t index,
+                                              Handle<Object> value,
+                                              StrictModeFlag strict_mode);
+
   static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> object,
                                                   Handle<Name> name,
                                                   DeleteMode mode);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to