Commit bfcc65d6 authored by binji's avatar binji Committed by Commit bot

[SAB] Handle non-numerics in Atomics.isLockFree

BUG=v8:4741

Review-Url: https://codereview.chromium.org/2658143003
Cr-Commit-Position: refs/heads/master@{#42822}
parent eb9b5edf
...@@ -101,7 +101,7 @@ function AtomicsExchangeJS(ia, index, value) { ...@@ -101,7 +101,7 @@ function AtomicsExchangeJS(ia, index, value) {
} }
function AtomicsIsLockFreeJS(size) { function AtomicsIsLockFreeJS(size) {
return %_AtomicsIsLockFree(size); return %_AtomicsIsLockFree(TO_INTEGER(size));
} }
function AtomicsWaitJS(ia, index, value, timeout) { function AtomicsWaitJS(ia, index, value, timeout) {
......
...@@ -386,6 +386,15 @@ function clearArray(sab) { ...@@ -386,6 +386,15 @@ function clearArray(sab) {
})(); })();
(function TestIsLockFree() { (function TestIsLockFree() {
// Various invalid cases.
var valueOf = {valueOf: function(){ return 3;}};
var toString = {toString: function(){ return '3';}};
var invalid = [3.14, 'foo', Infinity, NaN, false, undefined, valueOf,
toString];
invalid.forEach(function(v) {
assertEquals(false, Atomics.isLockFree(v), JSON.stringify(v));
});
// For all platforms we support, 1, 2 and 4 bytes should be lock-free. // For all platforms we support, 1, 2 and 4 bytes should be lock-free.
assertEquals(true, Atomics.isLockFree(1)); assertEquals(true, Atomics.isLockFree(1));
assertEquals(true, Atomics.isLockFree(2)); assertEquals(true, Atomics.isLockFree(2));
......
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