Skip to content

Commit

Permalink
src: re-delete Atomics.wake
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
devsnek authored and BridgeAR committed Sep 25, 2019
1 parent 50b5ad1 commit 3a6bc90
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
2 changes: 0 additions & 2 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 0 additions & 15 deletions lib/internal/per_context/setup.js

This file was deleted.

1 change: 0 additions & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
34 changes: 33 additions & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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};

Expand Down
2 changes: 2 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ void RegisterSignalHandler(int signal,
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
Expand Down
1 change: 1 addition & 0 deletions src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-atomics-wake.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

require('../common');
const assert = require('assert');

// https://github.com/nodejs/node/issues/21219
assert.strictEqual(Atomics.wake, undefined);

0 comments on commit 3a6bc90

Please sign in to comment.