Commit 99abc4db authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[rab/gsab] TA.prototype.{every,some}: Support RAB / GSAB

Bug: v8:11111
Change-Id: I784a9d347fa4a21fd38f04b4d4e3a8a4398292c0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3186438
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77234}
parent 63459652
......@@ -307,9 +307,18 @@ extern enum ElementsKind extends int32 {
UINT8_CLAMPED_ELEMENTS,
BIGUINT64_ELEMENTS,
BIGINT64_ELEMENTS,
RAB_GSAB_UINT8_ELEMENTS,
// TODO(torque): Allow duplicate enum values.
// FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND,
// FIRST_RAB_GSAB_FIXED_TYPED_ARRAY_ELEMENTS_KIND,
...
}
const kFirstFixedTypedArrayElementsKind: constexpr ElementsKind =
ElementsKind::UINT8_ELEMENTS;
const kFirstRabGsabFixedTypedArrayElementsKind: constexpr ElementsKind =
ElementsKind::RAB_GSAB_UINT8_ELEMENTS;
extern enum AllocationFlag extends int32
constexpr 'CodeStubAssembler::AllocationFlag' {
kNone,
......@@ -804,6 +813,8 @@ extern macro IsElementsKindLessThanOrEqual(
ElementsKind, constexpr ElementsKind): bool;
extern macro IsElementsKindGreaterThan(
ElementsKind, constexpr ElementsKind): bool;
extern macro IsElementsKindGreaterThanOrEqual(
ElementsKind, constexpr ElementsKind): bool;
extern macro IsElementsKindInRange(
ElementsKind, constexpr ElementsKind, constexpr ElementsKind): bool;
......
......@@ -184,6 +184,7 @@ void ArrayBuiltinsAssembler::GenerateIteratingTypedArrayBuiltinBody(
void ArrayBuiltinsAssembler::VisitAllTypedArrayElements(
TNode<JSArrayBuffer> array_buffer, const CallResultProcessor& processor,
ForEachDirection direction, TNode<JSTypedArray> typed_array) {
// TODO(v8:11111): Support RAB / GSAB.
VariableList list({&a_, &k_}, zone());
TNode<UintPtrT> start = UintPtrConstant(0);
......
......@@ -9,11 +9,11 @@ const kBuiltinNameEvery: constexpr string = '%TypedArray%.prototype.every';
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
transitioning macro EveryAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: JSAny): Boolean {
array: typed_array::AttachedJSTypedArray, length: uintptr,
callbackfn: Callable, thisArg: JSAny): Boolean {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
const length: uintptr = witness.Get().length;
// 5. Let k be 0.
// 6. Repeat, while k < len
for (let k: uintptr = 0; k < length; k++) {
// 6a. Let Pk be ! ToString(𝔽(k)).
......@@ -23,9 +23,9 @@ transitioning macro EveryAllElements(implicit context: Context)(
// kValue must be undefined when the buffer is detached.
let value: JSAny;
try {
witness.Recheck() otherwise goto IsDetached;
witness.RecheckIndex(k) otherwise goto IsDetachedOrOutOfBounds;
value = witness.Load(k);
} label IsDetached deferred {
} label IsDetachedOrOutOfBounds deferred {
value = Undefined;
}
......@@ -54,19 +54,24 @@ TypedArrayPrototypeEvery(
// arguments[0] = callback
// arguments[1] = thisArg
try {
// 1. Let O be the this value.
// 2. Perform ? ValidateTypedArray(O).
// 3. Let len be IntegerIndexedObjectLength(O).
const array: JSTypedArray = Cast<JSTypedArray>(receiver)
otherwise NotTypedArray;
const uarray = typed_array::EnsureAttached(array) otherwise IsDetached;
const length = LoadJSTypedArrayLengthAndCheckDetached(array)
otherwise IsDetachedOrOutOfBounds;
// 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable;
const thisArg = arguments[1];
return EveryAllElements(uarray, callbackfn, thisArg);
} label NotCallable deferred {
ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
return EveryAllElements(
%RawDownCast<AttachedJSTypedArray>(array), length, callbackfn, thisArg);
} label NotTypedArray deferred {
ThrowTypeError(MessageTemplate::kNotTypedArray, kBuiltinNameEvery);
} label IsDetached deferred {
} label IsDetachedOrOutOfBounds deferred {
ThrowTypeError(MessageTemplate::kDetachedOperation, kBuiltinNameEvery);
} label NotCallable deferred {
ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
}
}
}
......@@ -9,11 +9,11 @@ const kBuiltinNameSome: constexpr string = '%TypedArray%.prototype.some';
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.some
transitioning macro SomeAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: JSAny): Boolean {
array: typed_array::AttachedJSTypedArray, length: uintptr,
callbackfn: Callable, thisArg: JSAny): Boolean {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
const length: uintptr = witness.Get().length;
// 5. Let k be 0.
// 6. Repeat, while k < len
for (let k: uintptr = 0; k < length; k++) {
// 6a. Let Pk be ! ToString(𝔽(k)).
......@@ -23,9 +23,9 @@ transitioning macro SomeAllElements(implicit context: Context)(
// kValue must be undefined when the buffer is detached.
let value: JSAny;
try {
witness.Recheck() otherwise goto IsDetached;
witness.RecheckIndex(k) otherwise goto IsDetachedOrOutOfBounds;
value = witness.Load(k);
} label IsDetached deferred {
} label IsDetachedOrOutOfBounds deferred {
value = Undefined;
}
......@@ -54,22 +54,26 @@ transitioning javascript builtin
TypedArrayPrototypeSome(
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
// arguments[0] = callback
// arguments[1] = thisArg.
// arguments[1] = thisArg
try {
// 1. Let O be the this value.
// 2. Perform ? ValidateTypedArray(O).
// 3. Let len be IntegerIndexedObjectLength(O).
const array: JSTypedArray = Cast<JSTypedArray>(receiver)
otherwise NotTypedArray;
const uarray = typed_array::EnsureAttached(array) otherwise IsDetached;
const length = LoadJSTypedArrayLengthAndCheckDetached(array)
otherwise IsDetachedOrOutOfBounds;
// 4. If IsCallable(callbackfn) is false, throw a TypeError exception.
const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable;
const thisArg = arguments[1];
return SomeAllElements(uarray, callbackfn, thisArg);
} label NotCallable deferred {
ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
return SomeAllElements(
%RawDownCast<AttachedJSTypedArray>(array), length, callbackfn, thisArg);
} label NotTypedArray deferred {
ThrowTypeError(MessageTemplate::kNotTypedArray, kBuiltinNameSome);
} label IsDetached deferred {
} label IsDetachedOrOutOfBounds deferred {
ThrowTypeError(MessageTemplate::kDetachedOperation, kBuiltinNameSome);
} label NotCallable deferred {
ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
}
}
}
......@@ -19,6 +19,7 @@ type Float64Elements extends ElementsKind;
type Uint8ClampedElements extends ElementsKind;
type BigUint64Elements extends ElementsKind;
type BigInt64Elements extends ElementsKind;
type RabGsabUint8Elements extends ElementsKind;
@export
struct TypedArrayElementsInfo {
......@@ -136,7 +137,15 @@ macro GetTypedArrayAccessor<T : type extends ElementsKind>():
return TypedArrayAccessor{loadNumericFn, storeNumericFn, storeJSAnyFn};
}
macro GetTypedArrayAccessor(elementsKind: ElementsKind): TypedArrayAccessor {
macro GetTypedArrayAccessor(elementsKindParam: ElementsKind):
TypedArrayAccessor {
let elementsKind = elementsKindParam;
if (IsElementsKindGreaterThanOrEqual(
elementsKind, kFirstRabGsabFixedTypedArrayElementsKind)) {
elementsKind = %RawDownCast<ElementsKind>(
elementsKind - kFirstRabGsabFixedTypedArrayElementsKind +
kFirstFixedTypedArrayElementsKind);
}
if (IsElementsKindGreaterThan(elementsKind, ElementsKind::UINT32_ELEMENTS)) {
if (elementsKind == ElementsKind::INT32_ELEMENTS) {
return GetTypedArrayAccessor<Int32Elements>();
......@@ -195,11 +204,21 @@ struct AttachedJSTypedArrayWitness {
return this.stable;
}
// TODO(v8:11111): Migrate users to use RecheckIndex.
macro Recheck(): void labels Detached {
if (IsDetachedBuffer(this.stable.buffer)) goto Detached;
this.unstable = %RawDownCast<AttachedJSTypedArray>(this.stable);
}
macro RecheckIndex(index: uintptr): void labels DetachedOrOutOfBounds {
const length = LoadJSTypedArrayLengthAndCheckDetached(this.stable)
otherwise DetachedOrOutOfBounds;
if (index >= length) {
goto DetachedOrOutOfBounds;
}
this.unstable = %RawDownCast<AttachedJSTypedArray>(this.stable);
}
macro Load(implicit context: Context)(k: uintptr): JSAny {
const lf: LoadNumericFn = this.loadfn;
return lf(this.unstable, k);
......
......@@ -14237,6 +14237,11 @@ TNode<BoolT> CodeStubAssembler::IsElementsKindGreaterThan(
return Int32GreaterThan(target_kind, Int32Constant(reference_kind));
}
TNode<BoolT> CodeStubAssembler::IsElementsKindGreaterThanOrEqual(
TNode<Int32T> target_kind, ElementsKind reference_kind) {
return Int32GreaterThanOrEqual(target_kind, Int32Constant(reference_kind));
}
TNode<BoolT> CodeStubAssembler::IsElementsKindLessThanOrEqual(
TNode<Int32T> target_kind, ElementsKind reference_kind) {
return Int32LessThanOrEqual(target_kind, Int32Constant(reference_kind));
......
......@@ -2629,6 +2629,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<BoolT> IsHoleyFastElementsKindForRead(TNode<Int32T> elements_kind);
TNode<BoolT> IsElementsKindGreaterThan(TNode<Int32T> target_kind,
ElementsKind reference_kind);
TNode<BoolT> IsElementsKindGreaterThanOrEqual(TNode<Int32T> target_kind,
ElementsKind reference_kind);
TNode<BoolT> IsElementsKindLessThanOrEqual(TNode<Int32T> target_kind,
ElementsKind reference_kind);
// Check if lower_reference_kind <= target_kind <= higher_reference_kind.
......
......@@ -399,7 +399,7 @@ function CreateGrowableSharedArrayBuffer(byteLength, maxByteLength) {
// We can use the same GSAB for all the TAs below, since we won't modify it
// after writing the initial values.
const gsab = CreateGrowableSharedArrayBuffer(buffer_byte_length,
2 * buffer_byte_length);
2 * buffer_byte_length);
const byte_offset = offset * ctor.BYTES_PER_ELEMENT;
// Write some data into the array.
......@@ -577,7 +577,7 @@ function TestIterationAndGrow(ta, expected, gsab, grow_after,
(function Destructuring() {
for (let ctor of ctors) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(gsab, 0, 4);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
const lengthTracking = new ctor(gsab, 0);
......@@ -645,7 +645,7 @@ function TestIterationAndGrow(ta, expected, gsab, grow_after,
(function TestFill() {
for (let ctor of ctors) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(gsab, 0, 4);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
const lengthTracking = new ctor(gsab, 0);
......@@ -839,7 +839,7 @@ function TestIterationAndGrow(ta, expected, gsab, grow_after,
(function CopyWithin() {
for (let ctor of ctors) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(gsab, 0, 4);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
const lengthTracking = new ctor(gsab, 0);
......@@ -1140,3 +1140,239 @@ function TestIterationAndGrow(ta, expected, gsab, grow_after,
gsab, 2, 6 * ctor.BYTES_PER_ELEMENT);
}
})();
(function EverySome() {
for (let ctor of ctors) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(gsab, 0, 4);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
const lengthTracking = new ctor(gsab, 0);
const lengthTrackingWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(gsab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function div3(n) {
return Number(n) % 3 == 0;
}
function even(n) {
return Number(n) % 2 == 0;
}
function over10(n) {
return Number(n) > 10;
}
assertFalse(fixedLength.every(div3));
assertTrue(fixedLength.every(even));
assertTrue(fixedLength.some(div3));
assertFalse(fixedLength.some(over10));
assertFalse(fixedLengthWithOffset.every(div3));
assertTrue(fixedLengthWithOffset.every(even));
assertTrue(fixedLengthWithOffset.some(div3));
assertFalse(fixedLengthWithOffset.some(over10));
assertFalse(lengthTracking.every(div3));
assertTrue(lengthTracking.every(even));
assertTrue(lengthTracking.some(div3));
assertFalse(lengthTracking.some(over10));
assertFalse(lengthTrackingWithOffset.every(div3));
assertTrue(lengthTrackingWithOffset.every(even));
assertTrue(lengthTrackingWithOffset.some(div3));
assertFalse(lengthTrackingWithOffset.some(over10));
// Grow.
gsab.grow(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, 8, 10, ...] << lengthTracking
// [4, 6, 8, 10, ...] << lengthTrackingWithOffset
assertFalse(fixedLength.every(div3));
assertTrue(fixedLength.every(even));
assertTrue(fixedLength.some(div3));
assertFalse(fixedLength.some(over10));
assertFalse(fixedLengthWithOffset.every(div3));
assertTrue(fixedLengthWithOffset.every(even));
assertTrue(fixedLengthWithOffset.some(div3));
assertFalse(fixedLengthWithOffset.some(over10));
assertFalse(lengthTracking.every(div3));
assertTrue(lengthTracking.every(even));
assertTrue(lengthTracking.some(div3));
assertFalse(lengthTracking.some(over10));
assertFalse(lengthTrackingWithOffset.every(div3));
assertTrue(lengthTrackingWithOffset.every(even));
assertTrue(lengthTrackingWithOffset.some(div3));
assertFalse(lengthTrackingWithOffset.some(over10));
}
})();
(function EveryGrowMidIteration() {
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function CreateGsabForTest(ctor) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(gsab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
return gsab;
}
let values;
let gsab;
let growAfter;
let growTo;
function myFunc(n) {
if (n == undefined) {
values.push(n);
} else {
values.push(Number(n));
}
if (values.length == growAfter) {
gsab.grow(growTo);
}
return true;
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const fixedLength = new ctor(gsab, 0, 4);
values = [];
growAfter = 2;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertTrue(fixedLength.every(myFunc));
assertEquals([0, 2, 4, 6], values);
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
values = [];
growAfter = 1;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertTrue(fixedLengthWithOffset.every(myFunc));
assertEquals([4, 6], values);
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const lengthTracking = new ctor(gsab, 0);
values = [];
growAfter = 2;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertTrue(lengthTracking.every(myFunc));
assertEquals([0, 2, 4, 6], values);
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const lengthTrackingWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT);
values = [];
growAfter = 1;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertTrue(lengthTrackingWithOffset.every(myFunc));
assertEquals([4, 6], values);
}
})();
(function SomeGrowMidIteration() {
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function CreateGsabForTest(ctor) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(gsab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
return gsab;
}
let values;
let gsab;
let growAfter;
let growTo;
function myFunc(n) {
if (n == undefined) {
values.push(n);
} else {
values.push(Number(n));
}
if (values.length == growAfter) {
gsab.grow(growTo);
}
return false;
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const fixedLength = new ctor(gsab, 0, 4);
values = [];
growAfter = 2;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertFalse(fixedLength.some(myFunc));
assertEquals([0, 2, 4, 6], values);
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
values = [];
gsab = gsab;
growAfter = 1;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertFalse(fixedLengthWithOffset.some(myFunc));
assertEquals([4, 6], values);
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const lengthTracking = new ctor(gsab, 0);
values = [];
growAfter = 2;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertFalse(lengthTracking.some(myFunc));
assertEquals([0, 2, 4, 6], values);
}
for (let ctor of ctors) {
gsab = CreateGsabForTest(ctor);
const lengthTrackingWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT);
values = [];
growAfter = 1;
growTo = 5 * ctor.BYTES_PER_ELEMENT;
assertFalse(lengthTrackingWithOffset.some(myFunc));
assertEquals([4, 6], values);
}
})();
......@@ -150,3 +150,141 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
}, TypeError);
}
})();
(function EveryDetachMidIteration() {
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function CreateRabForTest(ctor) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
return rab;
}
let values = [];
let rab;
let detachAfter;
function myFunc(n) {
if (n == undefined) {
values.push(n);
} else {
values.push(Number(n));
}
if (values.length == detachAfter) {
%ArrayBufferDetach(rab);
}
return true;
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLength = new ctor(rab, 0, 4);
values = [];
detachAfter = 2;
assertTrue(fixedLength.every(myFunc));
assertEquals([0, 2, undefined, undefined], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
values = [];
detachAfter = 1;
assertTrue(fixedLengthWithOffset.every(myFunc));
assertEquals([4, undefined], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTracking = new ctor(rab, 0);
values = [];
detachAfter = 2;
assertTrue(lengthTracking.every(myFunc));
assertEquals([0, 2, undefined, undefined], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
values = [];
detachAfter = 1;
assertTrue(lengthTrackingWithOffset.every(myFunc));
assertEquals([4, undefined], values);
}
})();
(function SomeDetachMidIteration() {
// Orig. array: [0, 2, 4, 6]
// [0, 2, 4, 6] << fixedLength
// [4, 6] << fixedLengthWithOffset
// [0, 2, 4, 6, ...] << lengthTracking
// [4, 6, ...] << lengthTrackingWithOffset
function CreateRabForTest(ctor) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
}
return rab;
}
let values;
let rab;
let detachAfter;
function myFunc(n) {
if (n == undefined) {
values.push(n);
} else {
values.push(Number(n));
}
if (values.length == detachAfter) {
%ArrayBufferDetach(rab);
}
return false;
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLength = new ctor(rab, 0, 4);
values = [];
detachAfter = 2;
assertFalse(fixedLength.some(myFunc));
assertEquals([0, 2, undefined, undefined], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
values = [];
detachAfter = 1;
assertFalse(fixedLengthWithOffset.some(myFunc));
assertEquals([4, undefined], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTracking = new ctor(rab, 0);
values = [];
detachAfter = 2;
assertFalse(lengthTracking.some(myFunc));
assertEquals([0, 2, undefined, undefined], values);
}
for (let ctor of ctors) {
rab = CreateRabForTest(ctor);
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
values = [];
detachAfter = 1;
assertFalse(lengthTrackingWithOffset.some(myFunc));
assertEquals([4, undefined], values);
}
})();
......@@ -319,8 +319,6 @@
'built-ins/DataView/prototype/setUint16/resizable-buffer': [FAIL],
'built-ins/DataView/prototype/setUint32/resizable-buffer': [FAIL],
'built-ins/DataView/prototype/setUint8/resizable-buffer': [FAIL],
'built-ins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds': [SKIP],
......@@ -352,8 +350,6 @@
'built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized': [SKIP],
'built-ins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds': [SKIP],
'built-ins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds': [FAIL],
'built-ins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds': [FAIL],
'built-ins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds': [SKIP],
......
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