Commit 4d611d1d authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[builtins] Use the byte_length for byte length, not byte_offset.

length != offset.

Bug: chromium:718285
Change-Id: I150af1473cb5180c242f3817b940fa1cf1c49cea
Reviewed-on: https://chromium-review.googlesource.com/497727
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45121}
parent d871c5ba
......@@ -3149,8 +3149,8 @@ class TypedElementsAccessor
// TypedArrays.
uint8_t* source_data = static_cast<uint8_t*>(source_elements->DataPtr());
uint8_t* dest_data = static_cast<uint8_t*>(destination_elements->DataPtr());
size_t source_byte_length = NumberToSize(source->byte_offset());
size_t dest_byte_length = NumberToSize(destination->byte_offset());
size_t source_byte_length = NumberToSize(source->byte_length());
size_t dest_byte_length = NumberToSize(destination->byte_length());
CHECK(dest_data + dest_byte_length <= source_data ||
source_data + source_byte_length <= dest_data);
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function foo_reference(n) {
var array = new Int32Array(n + 1);
for (var i = 0; i < n; ++i) {
array[i] = i;
}
var array2 = new Int32Array(array);
array2.set(new Uint8Array(array.buffer, 0, n), 1);
return array2;
}
function foo(n) {
var array = new Int32Array(n + 1);
for (var i = 0; i < n; ++i) {
array[i] = i;
}
array.set(new Uint8Array(array.buffer, 0, n), 1);
return array;
}
function bar_reference(n) {
var array = new Int32Array(n + 1);
for (var i = 0; i < n; ++i) {
array[i] = i;
}
var array2 = new Int32Array(array);
array2.set(new Uint8Array(array.buffer, 34), 0);
return array2;
}
function bar(n) {
var array = new Int32Array(n + 1);
for (var i = 0; i < n; ++i) {
array[i] = i;
}
array.set(new Uint8Array(array.buffer, 34), 0);
return array;
}
foo(10);
foo_reference(10);
bar(10);
bar_reference(10);
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