Commit 2da66836 authored by Franziska Hinkelmann's avatar Franziska Hinkelmann Committed by Commit Bot

Reland "[runtime] Port TypedArraySetFormArrayLike to C++"

This is a reland of a50b6751
Original change's description:
> [runtime] Port TypedArraySetFormArrayLike to C++
> 
> Bug: v8:6704
> Change-Id: I316f085801f4fb6a792124f9a6f80a16e6d43162
> Reviewed-on: https://chromium-review.googlesource.com/616721
> Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#47369}

Bug: v8:6704
Change-Id: Id07f141f5f695e871248b4e5dcde0e7aa04e5493

TBR=bmeurer@chromium.org

Change-Id: Id07f141f5f695e871248b4e5dcde0e7aa04e5493
Reviewed-on: https://chromium-review.googlesource.com/619214
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Reviewed-by: 's avatarFranziska Hinkelmann <franzih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47411}
parent 29b61d1c
......@@ -250,21 +250,7 @@ TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE)
%SetForceInlineFlag(GlobalTypedArray.prototype.subarray);
function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
if (offset > 0) {
for (var i = 0; i < sourceLength; i++) {
target[offset + i] = source[i];
}
}
else {
for (var i = 0; i < sourceLength; i++) {
target[i] = source[i];
}
}
}
function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
var sourceElementSize = source.BYTES_PER_ELEMENT;
var targetElementSize = target.BYTES_PER_ELEMENT;
var sourceLength = %_TypedArrayGetLength(source);
......@@ -339,7 +325,7 @@ DEFINE_METHOD_LEN(
if (intOffset === 0) {
%TypedArrayCopyElements(this, obj, %_TypedArrayGetLength(obj));
} else {
TypedArraySetFromArrayLike(
%_TypedArraySetFromArrayLike(
this, obj, %_TypedArrayGetLength(obj), intOffset);
}
return;
......@@ -359,7 +345,7 @@ DEFINE_METHOD_LEN(
if (intOffset + l > %_TypedArrayGetLength(this)) {
throw %make_range_error(kTypedArraySetSourceTooLarge);
}
TypedArraySetFromArrayLike(this, obj, l, intOffset);
%_TypedArraySetFromArrayLike(this, obj, l, intOffset);
return;
}
},
......
......@@ -110,6 +110,32 @@ enum TypedArraySetResultCodes {
TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3
};
// TypedArraySetFromArrayLike(target, source, source_length, offset);
RUNTIME_FUNCTION(Runtime_TypedArraySetFromArrayLike) {
HandleScope scope(isolate);
DCHECK_EQ(4, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, target, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, source, 1);
CONVERT_INT32_ARG_CHECKED(source_length, 2);
DCHECK_GE(source_length, 0);
CONVERT_INT32_ARG_CHECKED(offset, 3);
DCHECK_GE(offset, 0);
for (int i = 0; i < source_length; i++) {
Handle<Object> value;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
Object::GetElement(isolate, source, i));
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, value,
Object::SetElement(isolate, target, offset + i, value,
LanguageMode::STRICT));
}
return *target;
}
RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) {
HandleScope scope(isolate);
......
......@@ -620,6 +620,7 @@ namespace internal {
F(ArrayBufferViewWasNeutered, 1, 1) \
F(TypedArrayGetLength, 1, 1) \
F(TypedArrayGetBuffer, 1, 1) \
F(TypedArraySetFromArrayLike, 4, 1) \
F(TypedArraySetFastCases, 3, 1) \
F(TypedArraySortFast, 1, 1) \
F(TypedArrayMaxSizeInHeap, 0, 1) \
......
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