Commit c1699fde authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[builtins] Copy TypedArray elements with the elements accessor in Set.

Performance regressed for this with the I+TF switch. This speeds up
the simple case by using optimizations in the elements accessor.

Bug: chromium:700835
Change-Id: Iaba30951b93daefa0fb32acd6656ac705cdc73ed
Reviewed-on: https://chromium-review.googlesource.com/483341
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarFranziska Hinkelmann <franzih@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44913}
parent b5de6719
...@@ -3131,7 +3131,7 @@ class TypedElementsAccessor ...@@ -3131,7 +3131,7 @@ class TypedElementsAccessor
Handle<BackingStore> destination_elements( Handle<BackingStore> destination_elements(
BackingStore::cast(destination->elements())); BackingStore::cast(destination->elements()));
DCHECK_EQ(source->length(), destination->length()); DCHECK_GE(destination->length(), source->length());
DCHECK(source->length()->IsSmi()); DCHECK(source->length()->IsSmi());
DCHECK_EQ(Smi::FromInt(static_cast<int>(length)), source->length()); DCHECK_EQ(Smi::FromInt(static_cast<int>(length)), source->length());
...@@ -3284,6 +3284,9 @@ class TypedElementsAccessor ...@@ -3284,6 +3284,9 @@ class TypedElementsAccessor
return Smi::kZero; return Smi::kZero;
} }
// This doesn't guarantee that the destination array will be completely
// filled. The caller must do this by passing a source with equal length, if
// that is required.
static Object* CopyElementsHandleImpl(Handle<JSReceiver> source, static Object* CopyElementsHandleImpl(Handle<JSReceiver> source,
Handle<JSObject> destination, Handle<JSObject> destination,
size_t length) { size_t length) {
......
...@@ -255,9 +255,7 @@ function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { ...@@ -255,9 +255,7 @@ function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
} }
} }
else { else {
for (var i = 0; i < sourceLength; i++) { %TypedArrayCopyElements(target, source, sourceLength);
target[i] = source[i];
}
} }
} }
...@@ -338,7 +336,7 @@ function TypedArraySet(obj, offset) { ...@@ -338,7 +336,7 @@ function TypedArraySet(obj, offset) {
if (IS_NUMBER(obj)) { if (IS_NUMBER(obj)) {
// For number as a first argument, throw TypeError // For number as a first argument, throw TypeError
// instead of silently ignoring the call, so that // instead of silently ignoring the call, so that
// the user knows (s)he did something wrong. // users know they did something wrong.
// (Consistent with Firefox and Blink/WebKit) // (Consistent with Firefox and Blink/WebKit)
throw %make_type_error(kInvalidArgument); throw %make_type_error(kInvalidArgument);
} }
......
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