diff options
author | Gus Caplan <me@gus.host> | 2019-09-16 16:05:20 -0500 |
---|---|---|
committer | Gus Caplan <me@gus.host> | 2019-09-18 16:09:20 -0500 |
commit | 1ec4154e507ba71d7aefca0a6e5c155be34e989a (patch) | |
tree | bbfbdcae6ecf134be8b21534f1d5c6795b5356a7 | |
parent | 954bf56c1e9a4a1c195114f61d9b0fe39c80ca2e (diff) | |
download | node-new-1ec4154e507ba71d7aefca0a6e5c155be34e989a.tar.gz |
src: re-delete Atomics.wake
PR-URL: https://github.com/nodejs/node/pull/29586
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
-rw-r--r-- | lib/internal/bootstrap/node.js | 2 | ||||
-rw-r--r-- | lib/internal/per_context/setup.js | 15 | ||||
-rw-r--r-- | node.gyp | 1 | ||||
-rw-r--r-- | src/api/environment.cc | 34 | ||||
-rw-r--r-- | src/node_internals.h | 2 | ||||
-rw-r--r-- | src/node_main_instance.cc | 1 | ||||
-rw-r--r-- | test/parallel/test-atomics-wake.js | 7 |
7 files changed, 43 insertions, 19 deletions
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 86b2164bb0..18acd9d2b6 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -15,8 +15,6 @@ // many dependencies are invoked lazily. // // Scripts run before this file: -// - `lib/internal/per_context/setup.js`: to setup the v8::Context with -// Node.js-specific tweaks - this is also done in vm contexts. // - `lib/internal/per_context/primordials.js`: to save copies of JavaScript // builtins that won't be affected by user land monkey-patching for internal // modules to use. diff --git a/lib/internal/per_context/setup.js b/lib/internal/per_context/setup.js deleted file mode 100644 index 16bd7db586..0000000000 --- a/lib/internal/per_context/setup.js +++ /dev/null @@ -1,15 +0,0 @@ -// 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 -if (global.Atomics) { - delete global.Atomics.wake; -} @@ -30,7 +30,6 @@ 'lib/internal/bootstrap/node.js', 'lib/internal/bootstrap/pre_execution.js', 'lib/internal/per_context/primordials.js', - 'lib/internal/per_context/setup.js', 'lib/internal/per_context/domexception.js', 'lib/async_hooks.js', 'lib/assert.js', diff --git a/src/api/environment.cc b/src/api/environment.cc index 7fd219d6e8..2c0fe13063 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -357,9 +357,42 @@ Local<Context> NewContext(Isolate* isolate, if (!InitializeContext(context)) { return Local<Context>(); } + + InitializeContextRuntime(context); + return context; } +// This runs at runtime, regardless of whether the context +// is created from a snapshot. +void InitializeContextRuntime(Local<Context> context) { + Isolate* isolate = context->GetIsolate(); + HandleScope handle_scope(isolate); + + // Delete `Intl.v8BreakIterator` + // https://github.com/nodejs/node/issues/14909 + Local<String> intl_string = FIXED_ONE_BYTE_STRING(isolate, "Intl"); + Local<String> break_iter_string = + FIXED_ONE_BYTE_STRING(isolate, "v8BreakIterator"); + Local<Value> intl_v; + if (context->Global()->Get(context, intl_string).ToLocal(&intl_v) && + intl_v->IsObject()) { + Local<Object> intl = intl_v.As<Object>(); + intl->Delete(context, break_iter_string).FromJust(); + } + + // Delete `Atomics.wake` + // https://github.com/nodejs/node/issues/21219 + Local<String> atomics_string = FIXED_ONE_BYTE_STRING(isolate, "Atomics"); + Local<String> wake_string = FIXED_ONE_BYTE_STRING(isolate, "wake"); + Local<Value> atomics_v; + if (context->Global()->Get(context, atomics_string).ToLocal(&atomics_v) && + atomics_v->IsObject()) { + Local<Object> atomics = atomics_v.As<Object>(); + atomics->Delete(context, wake_string).FromJust(); + } +} + bool InitializeContext(Local<Context> context) { Isolate* isolate = context->GetIsolate(); HandleScope handle_scope(isolate); @@ -386,7 +419,6 @@ bool InitializeContext(Local<Context> context) { } static const char* context_files[] = {"internal/per_context/primordials", - "internal/per_context/setup", "internal/per_context/domexception", nullptr}; diff --git a/src/node_internals.h b/src/node_internals.h index 691b954dc4..0f4c32bb94 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -99,6 +99,8 @@ void SignalExit(int signal, siginfo_t* info, void* ucontext); std::string GetHumanReadableProcessName(); void GetHumanReadableProcessName(char (*name)[1024]); +void InitializeContextRuntime(v8::Local<v8::Context>); + namespace task_queue { void PromiseRejectCallback(v8::PromiseRejectMessage message); } // namespace task_queue diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 05ff8d5526..630933cec8 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -179,6 +179,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment( if (deserialize_mode_) { context = Context::FromSnapshot(isolate_, kNodeContextIndex).ToLocalChecked(); + InitializeContextRuntime(context); SetIsolateUpForNode(isolate_, IsolateSettingCategories::kErrorHandlers); } else { context = NewContext(isolate_); diff --git a/test/parallel/test-atomics-wake.js b/test/parallel/test-atomics-wake.js new file mode 100644 index 0000000000..0f38700176 --- /dev/null +++ b/test/parallel/test-atomics-wake.js @@ -0,0 +1,7 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +// https://github.com/nodejs/node/issues/21219 +assert.strictEqual(Atomics.wake, undefined); |