diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-03-07 15:12:52 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-03-15 16:54:19 +0100 |
commit | 7e2088f773d97e00e29cacdc20e1a36b80528be0 (patch) | |
tree | 5c99263864c7cf624c4fc3093e0df5429c95fda1 /lib/internal/per_context | |
parent | 0752a18b88452fd0cbf554856dc5305076cb9da5 (diff) | |
download | android-node-v8-7e2088f773d97e00e29cacdc20e1a36b80528be0.tar.gz android-node-v8-7e2088f773d97e00e29cacdc20e1a36b80528be0.tar.bz2 android-node-v8-7e2088f773d97e00e29cacdc20e1a36b80528be0.zip |
src,lib: allow running multiple per-context files
Create an `lib/internal/per_context/` directory that can
host multiple files which we execute for each context.
PR-URL: https://github.com/nodejs/node/pull/26497
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/per_context')
-rw-r--r-- | lib/internal/per_context/setup.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/internal/per_context/setup.js b/lib/internal/per_context/setup.js new file mode 100644 index 0000000000..725ba403df --- /dev/null +++ b/lib/internal/per_context/setup.js @@ -0,0 +1,44 @@ +// This file is compiled as if it's wrapped in a function with arguments +// passed by node::NewContext() +/* global global */ + +'use strict'; + +// https://github.com/nodejs/node/issues/14909 +if (global.Intl) delete global.Intl.v8BreakIterator; + +// https://github.com/nodejs/node/issues/21219 +// Adds Atomics.notify and warns on first usage of Atomics.wake +// https://github.com/v8/v8/commit/c79206b363 adds Atomics.notify so +// now we alias Atomics.wake to notify so that we can remove it +// semver major without worrying about V8. + +const AtomicsNotify = global.Atomics.notify; +const ReflectApply = global.Reflect.apply; + +const warning = 'Atomics.wake will be removed in a future version, ' + + 'use Atomics.notify instead.'; + +let wakeWarned = false; +function wake(typedArray, index, count) { + if (!wakeWarned) { + wakeWarned = true; + + if (global.process !== undefined) { + global.process.emitWarning(warning, 'Atomics'); + } else { + global.console.error(`Atomics: ${warning}`); + } + } + + return ReflectApply(AtomicsNotify, this, arguments); +} + +global.Object.defineProperties(global.Atomics, { + wake: { + value: wake, + writable: true, + enumerable: false, + configurable: true, + }, +}); |