Atomics.notify changed to always return 0 on non-shared

This commit is contained in:
Rick Waldron 2020-05-06 14:15:39 -04:00
parent f7322cca7a
commit 302f37eeff
10 changed files with 202 additions and 69 deletions

View File

@ -0,0 +1,35 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Evaluates index before returning 0, when TA.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
...
Else,
Let intCount be ? ToInteger(count).
Let c be max(intCount, 0).
...
If IsSharedArrayBuffer(buffer) is false, return 0.
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
const i64a = new BigInt64Array(
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
);
const poisoned = {
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
Atomics.notify(i64a, poisoned, 0);
}, '`Atomics.notify(i64a, poisoned, 0)` throws Test262Error');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Evaluates index before returning 0, when TA.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
Let i be ? ValidateAtomicAccess(typedArray, index).
...
If IsSharedArrayBuffer(buffer) is false, return 0.
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
const i64a = new BigInt64Array(
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
);
const poisoned = {
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
Atomics.notify(i64a, 0, poisoned);
}, '`Atomics.notify(i64a, 0, poisoned)` throws Test262Error');

View File

@ -0,0 +1,21 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Atomics.notify throws on non-shared integer TypedArrays
features: [ArrayBuffer, Atomics, BigInt TypedArray]
---*/
const nonsab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8);
const poisoned = {
valueOf() {
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.notify(new BigUint64Array(nonsab), poisoned, poisoned);
}, '`Atomics.notify(new BigUint64Array(nonsab), poisoned, poisoned)` throws TypeError');

View File

@ -0,0 +1,21 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Returns 0, when TA.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
...
If IsSharedArrayBuffer(buffer) is false, return 0.
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
const i64a = new BigInt64Array(
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
);
assert.sameValue(Atomics.notify(i64a, 0, 0), 0);

View File

@ -1,33 +0,0 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
...
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
...
4.If bufferData is a Data Block, return false.
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
const i64a = new BigInt64Array(
new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8)
);
const poisoned = {
valueOf: function() {
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.notify(i64a, 0, 0);
}, '`Atomics.notify(i64a, 0, 0)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.notify(i64a, poisoned, poisoned);
}, '`Atomics.notify(i64a, poisoned, poisoned)` throws TypeError');

View File

@ -0,0 +1,36 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Evaluates count before returning 0, when TA.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
...
Else,
Let intCount be ? ToInteger(count).
Let c be max(intCount, 0).
...
If IsSharedArrayBuffer(buffer) is false, return 0.
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const i32a = new Int32Array(
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
);
const poisoned = {
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
Atomics.notify(i32a, 0, poisoned);
}, '`Atomics.notify(i32a, 0, poisoned)` throws Test262Error');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Evaluates index before returning 0, when TA.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
Let i be ? ValidateAtomicAccess(typedArray, index).
...
If IsSharedArrayBuffer(buffer) is false, return 0.
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const i32a = new Int32Array(
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
);
const poisoned = {
valueOf() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
Atomics.notify(i32a, poisoned, 0);
}, '`Atomics.notify(i32a, poisoned, 0)` throws Test262Error');

View File

@ -4,7 +4,7 @@
/*---
esid: sec-atomics.notify
description: >
Test Atomics.notify on non-shared integer TypedArrays
Atomics.notify throws on non-shared integer TypedArrays
features: [ArrayBuffer, Atomics, TypedArray]
---*/
@ -25,7 +25,7 @@ assert.throws(TypeError, function() {
}, '`Atomics.notify(new Int8Array(nonsab), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.notify(new Uint32Array(nonsab), poisoned, poisoned);
Atomics.notify(new Uint32Array(nonsab), poisoned, poisoned);
}, '`Atomics.notify(new Uint32Array(nonsab), poisoned, poisoned)` throws TypeError');
assert.throws(TypeError, function() {

View File

@ -0,0 +1,23 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Returns 0, when TA.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
Let buffer be ? ValidateIntegerTypedArray(typedArray, true).
...
If IsSharedArrayBuffer(buffer) is false, return 0.
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const i32a = new Int32Array(
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.notify(i32a, 0, 0), 0);
assert.sameValue(Atomics.notify(i32a, 0, 1), 0);

View File

@ -1,34 +0,0 @@
// Copyright (C) 2018 Amal Hussein. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.notify
description: >
Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer
info: |
Atomics.notify( typedArray, index, count )
1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true).
...
9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception.
...
4.If bufferData is a Data Block, return false.
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const i32a = new Int32Array(
new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
);
const poisoned = {
valueOf: function() {
throw new Test262Error('should not evaluate this code');
}
};
assert.throws(TypeError, function() {
Atomics.notify(i32a, 0, 0);
}, '`Atomics.notify(i32a, 0, 0)` throws TypeError');
assert.throws(TypeError, function() {
Atomics.notify(i32a, poisoned, poisoned);
}, '`Atomics.notify(i32a, poisoned, poisoned)` throws TypeError');