Revision: 20621
Author:   [email protected]
Date:     Wed Apr  9 13:16:19 2014 UTC
Log:      ElementsAccessor::SetLength() maybehandlified.

[email protected]

Review URL: https://codereview.chromium.org/229943006
http://code.google.com/p/v8/source/detail?r=20621

Modified:
 /branches/bleeding_edge/src/accessors.cc
 /branches/bleeding_edge/src/elements.cc
 /branches/bleeding_edge/src/elements.h
 /branches/bleeding_edge/src/ic.cc
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/cctest/test-heap.cc

=======================================
--- /branches/bleeding_edge/src/accessors.cc    Fri Apr  4 12:06:11 2014 UTC
+++ /branches/bleeding_edge/src/accessors.cc    Wed Apr  9 13:16:19 2014 UTC
@@ -211,8 +211,10 @@
   if (has_exception) return Failure::Exception();

   if (uint32_v->Number() == number_v->Number()) {
- Handle<Object> result = JSArray::SetElementsLength(array_handle, uint32_v);
-    RETURN_IF_EMPTY_HANDLE(isolate, result);
+    Handle<Object> result;
+    ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+        isolate, result,
+        JSArray::SetElementsLength(array_handle, uint32_v));
     return *result;
   }
   return isolate->Throw(
=======================================
--- /branches/bleeding_edge/src/elements.cc     Wed Apr  9 12:56:24 2014 UTC
+++ /branches/bleeding_edge/src/elements.cc     Wed Apr  9 13:16:19 2014 UTC
@@ -162,11 +162,11 @@
 }


-static Handle<Object> ThrowArrayLengthRangeError(Isolate* isolate) {
-  isolate->Throw(
-      *isolate->factory()->NewRangeError("invalid_array_length",
-                                         HandleVector<Object>(NULL, 0)));
-  return Handle<Object>();
+MUST_USE_RESULT
+static MaybeHandle<Object> ThrowArrayLengthRangeError(Isolate* isolate) {
+  return isolate->Throw<Object>(
+      isolate->factory()->NewRangeError("invalid_array_length",
+                                        HandleVector<Object>(NULL, 0)));
 }


@@ -727,14 +727,14 @@
     return MaybeHandle<AccessorPair>();
   }

-  MUST_USE_RESULT virtual Handle<Object> SetLength(
+  MUST_USE_RESULT virtual MaybeHandle<Object> SetLength(
       Handle<JSArray> array,
       Handle<Object> length) V8_FINAL V8_OVERRIDE {
     return ElementsAccessorSubclass::SetLengthImpl(
         array, length, handle(array->elements()));
   }

-  MUST_USE_RESULT static Handle<Object> SetLengthImpl(
+  MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
       Handle<JSObject> obj,
       Handle<Object> length,
       Handle<FixedArrayBase> backing_store);
@@ -1364,7 +1364,7 @@
           ? FIELD : NONEXISTENT;
   }

-  MUST_USE_RESULT static Handle<Object> SetLengthImpl(
+  MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
       Handle<JSObject> obj,
       Handle<Object> length,
       Handle<FixedArrayBase> backing_store) {
@@ -1749,7 +1749,7 @@
     }
   }

-  MUST_USE_RESULT static Handle<Object> SetLengthImpl(
+  MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
       Handle<JSObject> obj,
       Handle<Object> length,
       Handle<FixedArrayBase> parameter_map) {
@@ -1867,8 +1867,9 @@


 template <typename ElementsAccessorSubclass, typename ElementsKindTraits>
-MUST_USE_RESULT Handle<Object> ElementsAccessorBase<ElementsAccessorSubclass,
-                                                    ElementsKindTraits>::
+MUST_USE_RESULT
+MaybeHandle<Object> ElementsAccessorBase<ElementsAccessorSubclass,
+                                         ElementsKindTraits>::
     SetLengthImpl(Handle<JSObject> obj,
                   Handle<Object> length,
                   Handle<FixedArrayBase> backing_store) {
@@ -1883,7 +1884,7 @@
     if (value >= 0) {
       Handle<Object> new_length = ElementsAccessorSubclass::
SetLengthWithoutNormalize(backing_store, array, smi_length, value);
-      RETURN_IF_EMPTY_HANDLE_VALUE(isolate, new_length, new_length);
+      ASSERT(!new_length.is_null());

       // even though the proposed length was a smi, new_length could
       // still be a heap number because SetLengthWithoutNormalize doesn't
@@ -1910,11 +1911,11 @@
     if (length->ToArrayIndex(&value)) {
       Handle<SeededNumberDictionary> dictionary =
           JSObject::NormalizeElements(array);
-      RETURN_IF_EMPTY_HANDLE_VALUE(isolate, dictionary, dictionary);
+      ASSERT(!dictionary.is_null());

       Handle<Object> new_length = DictionaryElementsAccessor::
           SetLengthWithoutNormalize(dictionary, array, length, value);
-      RETURN_IF_EMPTY_HANDLE_VALUE(isolate, new_length, new_length);
+      ASSERT(!new_length.is_null());

       ASSERT(new_length->IsNumber());
       array->set_length(*new_length);
@@ -1933,8 +1934,8 @@
 }


-Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array,
-                                                Arguments* args) {
+MaybeHandle<Object> ArrayConstructInitializeElements(Handle<JSArray> array,
+                                                     Arguments* args) {
   // Optimize the case where there is one argument and the argument is a
   // small smi.
   if (args->length() == 1) {
=======================================
--- /branches/bleeding_edge/src/elements.h      Wed Apr  9 12:56:24 2014 UTC
+++ /branches/bleeding_edge/src/elements.h      Wed Apr  9 13:16:19 2014 UTC
@@ -145,7 +145,7 @@
// changing array sizes as defined in EcmaScript 5.1 15.4.5.2, i.e. array that
   // have non-deletable elements can only be shrunk to the size of highest
   // element that is non-deletable.
-  MUST_USE_RESULT virtual Handle<Object> SetLength(
+  MUST_USE_RESULT virtual MaybeHandle<Object> SetLength(
       Handle<JSArray> holder,
       Handle<Object> new_length) = 0;

@@ -257,8 +257,9 @@
 void CheckArrayAbuse(Handle<JSObject> obj, const char* op, uint32_t key,
                      bool allow_appending = false);

-Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array,
-                                                Arguments* args);
+MUST_USE_RESULT MaybeHandle<Object> ArrayConstructInitializeElements(
+    Handle<JSArray> array,
+    Arguments* args);

 } }  // namespace v8::internal

=======================================
--- /branches/bleeding_edge/src/ic.cc   Tue Apr  8 07:04:13 2014 UTC
+++ /branches/bleeding_edge/src/ic.cc   Wed Apr  9 13:16:19 2014 UTC
@@ -1833,8 +1833,8 @@
   ASSERT(debug_lookup.IsPropertyCallbacks() && !debug_lookup.IsReadOnly());
 #endif

-  RETURN_IF_EMPTY_HANDLE(isolate,
-                         JSArray::SetElementsLength(receiver, len));
+  RETURN_FAILURE_ON_EXCEPTION(
+      isolate, JSArray::SetElementsLength(receiver, len));
   return *len;
 }

=======================================
--- /branches/bleeding_edge/src/objects.cc      Wed Apr  9 13:05:56 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Wed Apr  9 13:16:19 2014 UTC
@@ -11439,8 +11439,9 @@
 }


-Handle<Object> JSArray::SetElementsLength(Handle<JSArray> array,
- Handle<Object> new_length_handle) {
+MaybeHandle<Object> JSArray::SetElementsLength(
+    Handle<JSArray> array,
+    Handle<Object> new_length_handle) {
   // We should never end in here with a pixel or external array.
   ASSERT(array->AllowsSetElementsLength());
   if (!array->map()->is_observed()) {
@@ -11478,9 +11479,11 @@
     }
   }

-  Handle<Object> hresult =
-      array->GetElementsAccessor()->SetLength(array, new_length_handle);
-  RETURN_IF_EMPTY_HANDLE_VALUE(isolate, hresult, hresult);
+  Handle<Object> hresult;
+  ASSIGN_RETURN_ON_EXCEPTION(
+      isolate, hresult,
+      array->GetElementsAccessor()->SetLength(array, new_length_handle),
+      Object);

   CHECK(array->length()->ToArrayIndex(&new_length));
   if (old_length == new_length) return hresult;
=======================================
--- /branches/bleeding_edge/src/objects.h       Wed Apr  9 13:05:56 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Wed Apr  9 13:16:19 2014 UTC
@@ -10232,8 +10232,9 @@
   // Initializes the array to a certain length.
   inline bool AllowsSetElementsLength();
   // Can cause GC.
-  static Handle<Object> SetElementsLength(Handle<JSArray> array,
-                                          Handle<Object> length);
+  MUST_USE_RESULT static MaybeHandle<Object> SetElementsLength(
+      Handle<JSArray> array,
+      Handle<Object> length);

   // Set the content of the array to the content of storage.
   static inline void SetContent(Handle<JSArray> array,
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Apr  9 12:33:51 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Wed Apr  9 13:16:19 2014 UTC
@@ -15034,8 +15034,8 @@
   factory->NewJSArrayStorage(array, 0, 0, DONT_INITIALIZE_ARRAY_ELEMENTS);

   ElementsKind old_kind = array->GetElementsKind();
-  RETURN_IF_EMPTY_HANDLE(isolate,
- ArrayConstructInitializeElements(array, caller_args));
+  RETURN_FAILURE_ON_EXCEPTION(
+      isolate, ArrayConstructInitializeElements(array, caller_args));
   if (!site.is_null() &&
       (old_kind != array->GetElementsKind() ||
        !can_use_type_feedback)) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Wed Apr 9 12:21:47 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-heap.cc Wed Apr 9 13:16:19 2014 UTC
@@ -767,7 +767,7 @@
   JSArray::Initialize(array, 0);

   // Set array length to 0.
-  *JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate));
+ JSArray::SetElementsLength(array, handle(Smi::FromInt(0), isolate)).Check();
   CHECK_EQ(Smi::FromInt(0), array->length());
   // Must be in fast mode.
   CHECK(array->HasFastSmiOrObjectElements());
@@ -780,7 +780,7 @@
   // Set array length with larger than smi value.
   Handle<Object> length =
factory->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1);
-  *JSArray::SetElementsLength(array, length);
+  JSArray::SetElementsLength(array, length).Check();

   uint32_t int_length = 0;
   CHECK(length->ToArrayIndex(&int_length));

--
--
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/d/optout.

Reply via email to