Skip to content

Commit 3a6bc90

Browse files
devsnekBridgeAR
authored andcommitted
src: re-delete Atomics.wake
PR-URL: #29586 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: David Carlier <[email protected]>
1 parent 50b5ad1 commit 3a6bc90

File tree

7 files changed

+43
-19
lines changed

7 files changed

+43
-19
lines changed

lib/internal/bootstrap/node.js

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
// many dependencies are invoked lazily.
1616
//
1717
// Scripts run before this file:
18-
// - `lib/internal/per_context/setup.js`: to setup the v8::Context with
19-
// Node.js-specific tweaks - this is also done in vm contexts.
2018
// - `lib/internal/per_context/primordials.js`: to save copies of JavaScript
2119
// builtins that won't be affected by user land monkey-patching for internal
2220
// modules to use.

lib/internal/per_context/setup.js

-15
This file was deleted.

node.gyp

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
'lib/internal/bootstrap/node.js',
3131
'lib/internal/bootstrap/pre_execution.js',
3232
'lib/internal/per_context/primordials.js',
33-
'lib/internal/per_context/setup.js',
3433
'lib/internal/per_context/domexception.js',
3534
'lib/async_hooks.js',
3635
'lib/assert.js',

src/api/environment.cc

+33-1
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,42 @@ Local<Context> NewContext(Isolate* isolate,
357357
if (!InitializeContext(context)) {
358358
return Local<Context>();
359359
}
360+
361+
InitializeContextRuntime(context);
362+
360363
return context;
361364
}
362365

366+
// This runs at runtime, regardless of whether the context
367+
// is created from a snapshot.
368+
void InitializeContextRuntime(Local<Context> context) {
369+
Isolate* isolate = context->GetIsolate();
370+
HandleScope handle_scope(isolate);
371+
372+
// Delete `Intl.v8BreakIterator`
373+
// https://github.com/nodejs/node/issues/14909
374+
Local<String> intl_string = FIXED_ONE_BYTE_STRING(isolate, "Intl");
375+
Local<String> break_iter_string =
376+
FIXED_ONE_BYTE_STRING(isolate, "v8BreakIterator");
377+
Local<Value> intl_v;
378+
if (context->Global()->Get(context, intl_string).ToLocal(&intl_v) &&
379+
intl_v->IsObject()) {
380+
Local<Object> intl = intl_v.As<Object>();
381+
intl->Delete(context, break_iter_string).FromJust();
382+
}
383+
384+
// Delete `Atomics.wake`
385+
// https://github.com/nodejs/node/issues/21219
386+
Local<String> atomics_string = FIXED_ONE_BYTE_STRING(isolate, "Atomics");
387+
Local<String> wake_string = FIXED_ONE_BYTE_STRING(isolate, "wake");
388+
Local<Value> atomics_v;
389+
if (context->Global()->Get(context, atomics_string).ToLocal(&atomics_v) &&
390+
atomics_v->IsObject()) {
391+
Local<Object> atomics = atomics_v.As<Object>();
392+
atomics->Delete(context, wake_string).FromJust();
393+
}
394+
}
395+
363396
bool InitializeContext(Local<Context> context) {
364397
Isolate* isolate = context->GetIsolate();
365398
HandleScope handle_scope(isolate);
@@ -386,7 +419,6 @@ bool InitializeContext(Local<Context> context) {
386419
}
387420

388421
static const char* context_files[] = {"internal/per_context/primordials",
389-
"internal/per_context/setup",
390422
"internal/per_context/domexception",
391423
nullptr};
392424

src/node_internals.h

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ void RegisterSignalHandler(int signal,
102102
std::string GetHumanReadableProcessName();
103103
void GetHumanReadableProcessName(char (*name)[1024]);
104104

105+
void InitializeContextRuntime(v8::Local<v8::Context>);
106+
105107
namespace task_queue {
106108
void PromiseRejectCallback(v8::PromiseRejectMessage message);
107109
} // namespace task_queue

src/node_main_instance.cc

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment(
179179
if (deserialize_mode_) {
180180
context =
181181
Context::FromSnapshot(isolate_, kNodeContextIndex).ToLocalChecked();
182+
InitializeContextRuntime(context);
182183
SetIsolateUpForNode(isolate_, IsolateSettingCategories::kErrorHandlers);
183184
} else {
184185
context = NewContext(isolate_);

test/parallel/test-atomics-wake.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
// https://github.com/nodejs/node/issues/21219
7+
assert.strictEqual(Atomics.wake, undefined);

0 commit comments

Comments
 (0)