From: ishell@chromium.org Date: Tue, 25 Mar 2014 09:29:48 +0000 (+0000) Subject: Reland of "FastElementsAccessor::SetLengthWithoutNormalize() handlified." X-Git-Tag: upstream/4.7.83~10031 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ad4e2cc352ca8d10699a99284275d8686c40002;p=platform%2Fupstream%2Fv8.git Reland of "FastElementsAccessor::SetLengthWithoutNormalize() handlified." R=yangguo@chromium.org Review URL: https://codereview.chromium.org/210563003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20227 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/elements.cc b/src/elements.cc index 527df6e..7fb294e 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -784,6 +784,16 @@ class ElementsAccessorBase : public ElementsAccessor { return obj; } + // TODO(ishell): Temporary wrapper until handlified. + MUST_USE_RESULT static Handle SetFastElementsCapacityAndLength( + Handle obj, + int capacity, + int length) { + CALL_HEAP_FUNCTION(obj->GetIsolate(), + SetFastElementsCapacityAndLength(*obj, capacity, length), + Object); + } + MUST_USE_RESULT virtual Handle Delete( Handle obj, uint32_t key, @@ -978,28 +988,28 @@ class FastElementsAccessor // Adjusts the length of the fast backing store or returns the new length or // undefined in case conversion to a slow backing store should be performed. - static MaybeObject* SetLengthWithoutNormalize(FixedArrayBase* backing_store, - JSArray* array, - Object* length_object, - uint32_t length) { + static Handle SetLengthWithoutNormalize( + Handle backing_store, + Handle array, + Handle length_object, + uint32_t length) { + Isolate* isolate = array->GetIsolate(); uint32_t old_capacity = backing_store->length(); - Object* old_length = array->length(); + Handle old_length(array->length(), isolate); bool same_or_smaller_size = old_length->IsSmi() && - static_cast(Smi::cast(old_length)->value()) >= length; + static_cast(Handle::cast(old_length)->value()) >= length; ElementsKind kind = array->GetElementsKind(); if (!same_or_smaller_size && IsFastElementsKind(kind) && !IsFastHoleyElementsKind(kind)) { kind = GetHoleyElementsKind(kind); - MaybeObject* maybe_obj = array->TransitionElementsKind(kind); - if (maybe_obj->IsFailure()) return maybe_obj; + JSObject::TransitionElementsKind(array, kind); } // Check whether the backing store should be shrunk. if (length <= old_capacity) { if (array->HasFastSmiOrObjectElements()) { - MaybeObject* maybe_obj = array->EnsureWritableFastElements(); - if (!maybe_obj->To(&backing_store)) return maybe_obj; + backing_store = JSObject::EnsureWritableFastElements(array); } if (2 * length <= old_capacity) { // If more than half the elements won't be used, trim the array. @@ -1016,7 +1026,7 @@ class FastElementsAccessor // Otherwise, fill the unused tail with holes. int old_length = FastD2IChecked(array->length()->Number()); for (int i = length; i < old_length; i++) { - BackingStore::cast(backing_store)->set_the_hole(i); + Handle::cast(backing_store)->set_the_hole(i); } } return length_object; @@ -1026,27 +1036,14 @@ class FastElementsAccessor uint32_t min = JSObject::NewElementsCapacity(old_capacity); uint32_t new_capacity = length > min ? length : min; if (!array->ShouldConvertToSlowElements(new_capacity)) { - MaybeObject* result = FastElementsAccessorSubclass:: + FastElementsAccessorSubclass:: SetFastElementsCapacityAndLength(array, new_capacity, length); - if (result->IsFailure()) return result; array->ValidateElements(); return length_object; } // Request conversion to slow elements. - return array->GetHeap()->undefined_value(); - } - - // TODO(ishell): Temporary wrapper until handlified. - static Handle SetLengthWithoutNormalize( - Handle backing_store, - Handle array, - Handle length_object, - uint32_t length) { - CALL_HEAP_FUNCTION(array->GetIsolate(), - SetLengthWithoutNormalize( - *backing_store, *array, *length_object, length), - Object); + return isolate->factory()->undefined_value(); } static Handle DeleteCommon(Handle obj, @@ -1244,6 +1241,16 @@ class FastSmiOrObjectElementsAccessor length, set_capacity_mode); } + + // TODO(ishell): Temporary wrapper until handlified. + static Handle SetFastElementsCapacityAndLength( + Handle obj, + int capacity, + int length) { + CALL_HEAP_FUNCTION(obj->GetIsolate(), + SetFastElementsCapacityAndLength(*obj, capacity, length), + Object); + } }; @@ -1314,6 +1321,16 @@ class FastDoubleElementsAccessor length); } + // TODO(ishell): Temporary wrapper until handlified. + static Handle SetFastElementsCapacityAndLength( + Handle obj, + int capacity, + int length) { + CALL_HEAP_FUNCTION(obj->GetIsolate(), + SetFastElementsCapacityAndLength(*obj, capacity, length), + Object); + } + protected: static MaybeObject* CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,