Commit 71ac9e0e authored by Franziska Hinkelmann's avatar Franziska Hinkelmann Committed by Commit Bot

[runtime] Port TypedArrayPrototypeSet to C++

Bug: v8:6704
Change-Id: If636bdd682d76a6d58d36fc9bfbf1302a32468ab
Reviewed-on: https://chromium-review.googlesource.com/641671
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47732}
parent b1409cb8
......@@ -250,50 +250,12 @@ TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE)
%SetForceInlineFlag(GlobalTypedArray.prototype.subarray);
// 22.2.3.23%TypedArray%.prototype.set ( overloaded [ , offset ] )
DEFINE_METHOD_LEN(
GlobalTypedArray.prototype,
set(obj, offset) {
var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset);
if (intOffset < 0) throw %make_range_error(kTypedArraySetNegativeOffset);
if (intOffset > %_MaxSmi()) {
throw %make_range_error(kTypedArraySetSourceTooLarge);
}
switch (%TypedArraySetFastCases(this, obj, intOffset)) {
// These numbers should be synchronized with runtime-typedarray.cc.
case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE
return;
case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING
%_TypedArraySetFromOverlapping(this, obj, intOffset);
return;
case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING
if (intOffset === 0) {
%TypedArrayCopyElements(this, obj, %_TypedArrayGetLength(obj));
} else {
%_TypedArraySetFromArrayLike(
this, obj, %_TypedArrayGetLength(obj), intOffset);
}
return;
case 3: // TYPED_ARRAY_SET_NON_TYPED_ARRAY
var l = obj.length;
if (IS_UNDEFINED(l)) {
if (IS_NUMBER(obj)) {
// For number as a first argument, throw TypeError
// instead of silently ignoring the call, so that
// users know they did something wrong.
// (Consistent with Firefox and Blink/WebKit)
throw %make_type_error(kInvalidArgument);
}
return;
}
l = TO_LENGTH(l);
if (intOffset + l > %_TypedArrayGetLength(this)) {
throw %make_range_error(kTypedArraySetSourceTooLarge);
}
%_TypedArraySetFromArrayLike(this, obj, l, intOffset);
return;
}
// TODO(franzih): Migrate this to a proper builtin.
%_TypedArrayPrototypeSet(this, obj, offset);
},
1 /* Set function length. */
);
......
This diff is collapsed.
......@@ -623,9 +623,7 @@ namespace internal {
F(ArrayBufferViewWasNeutered, 1, 1) \
F(TypedArrayGetLength, 1, 1) \
F(TypedArrayGetBuffer, 1, 1) \
F(TypedArraySetFromArrayLike, 4, 1) \
F(TypedArraySetFromOverlapping, 3, 1) \
F(TypedArraySetFastCases, 3, 1) \
F(TypedArrayPrototypeSet, 3, 1) \
F(TypedArraySortFast, 1, 1) \
F(TypedArrayMaxSizeInHeap, 0, 1) \
F(IsTypedArray, 1, 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