f68ee6e7e4
This is purely a renaming change. The ES spec uses the term 'detach' for the process of removing the backing store of a typed array, while V8 uses the historical term 'neuter'. Update our internal implementation, including method names and flag names, to match the spec. Note that some error messages still use the term 'neuter' since error messages are asserted by some embedder tests, like layout tests. R=bmeurer@chromium.org, yangguo@chromium.org, mstarzinger@chromium.org, mlippautz@chromium.org BUG=chromium:913887 Change-Id: I62f1c3ac9ae67ba01d612a5221afa3d92deae272 Reviewed-on: https://chromium-review.googlesource.com/c/1370036 Commit-Queue: Ben Titzer <titzer@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#58149}
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
// 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.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
function Baseline() {
|
|
let array = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
|
|
|
let it = array[Symbol.iterator]();
|
|
assertEquals(0, it.next().value);
|
|
assertEquals(1, it.next().value);
|
|
assertEquals(2, it.next().value);
|
|
%ArrayBufferDetach(array.buffer);
|
|
it.next();
|
|
};
|
|
%NeverOptimizeFunction(Baseline);
|
|
|
|
assertThrows(Baseline, TypeError,
|
|
"Cannot perform Array Iterator.prototype.next on a neutered ArrayBuffer");
|
|
|
|
function Turbo(count = 10000) {
|
|
let array = Array(10000);
|
|
for (let i = 0; i < 10000; ++i) {
|
|
array[i] = 254;
|
|
}
|
|
array[5000] = 255;
|
|
array = new Uint8Array(array);
|
|
|
|
let sum = 0;
|
|
let it = array[Symbol.iterator]();
|
|
for (let i = 0; i < count; ++i) {
|
|
let result = it.next();
|
|
if (result.value === 255) {
|
|
%ArrayBufferDetach(array.buffer);
|
|
}
|
|
sum += result.value;
|
|
}
|
|
return sum;
|
|
}
|
|
|
|
Turbo(10);
|
|
Turbo(10);
|
|
%OptimizeFunctionOnNextCall(Turbo);
|
|
|
|
assertThrows(Turbo, TypeError,
|
|
"Cannot perform Array Iterator.prototype.next on a neutered ArrayBuffer");
|