mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 02:06:12 +00:00

This allows the repl to function normally while using the `--no-harmony-sharedarraybuffer` V8 flag. It also fixes using workers while using the `--no-harmony-atomics` V8 flag. Fixes: https://github.com/nodejs/node/issues/39717 Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: https://github.com/nodejs/node/pull/41023 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
23 lines
564 B
JavaScript
23 lines
564 B
JavaScript
'use strict';
|
|
|
|
if (typeof SharedArrayBuffer === 'undefined') {
|
|
throw new Error('SharedArrayBuffers must be enabled to run this benchmark');
|
|
}
|
|
|
|
if (typeof Atomics === 'undefined') {
|
|
throw new Error('Atomics must be enabled to run this benchmark');
|
|
}
|
|
|
|
const common = require('../common.js');
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e7],
|
|
});
|
|
|
|
function main({ n }) {
|
|
const i32arr = new Int32Array(new SharedArrayBuffer(4));
|
|
bench.start();
|
|
for (let i = 0; i < n; i++)
|
|
Atomics.wait(i32arr, 0, 1); // Will return immediately.
|
|
bench.end(n);
|
|
}
|