Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: re-delete Atomics.wake #29586

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
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);