src: initialize privateSymbols for per_context by jazelly · Pull Request #57479 · nodejs/node · GitHub
Skip to content
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
46 changes: 42 additions & 4 deletions src/api/environment.cc
1 change: 1 addition & 0 deletions src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
parameters = {
FIXED_ONE_BYTE_STRING(isolate, "exports"),
FIXED_ONE_BYTE_STRING(isolate, "primordials"),
FIXED_ONE_BYTE_STRING(isolate, "privateSymbols"),
};
} else if (strncmp(id, "internal/main/", strlen("internal/main/")) == 0 ||
strncmp(id,
Expand Down
8 changes: 6 additions & 2 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ std::string GetHumanReadableProcessName();
v8::Maybe<void> InitializeBaseContextForSnapshot(
v8::Local<v8::Context> context);
v8::Maybe<void> InitializeContextRuntime(v8::Local<v8::Context> context);
v8::Maybe<void> InitializePrimordials(v8::Local<v8::Context> context);
v8::Maybe<void> InitializePrimordials(v8::Local<v8::Context> context,
IsolateData* isolate_data);
v8::MaybeLocal<v8::Object> InitializePrivateSymbols(
v8::Local<v8::Context> context, IsolateData* isolate_data);

class NodeArrayBufferAllocator : public ArrayBufferAllocator {
public:
Expand Down Expand Up @@ -340,7 +343,8 @@ v8::Isolate* NewIsolate(v8::Isolate::CreateParams* params,
// was provided by the embedder.
v8::MaybeLocal<v8::Value> StartExecution(Environment* env,
StartExecutionCallback cb = nullptr);
v8::MaybeLocal<v8::Object> GetPerContextExports(v8::Local<v8::Context> context);
v8::MaybeLocal<v8::Object> GetPerContextExports(
v8::Local<v8::Context> context, IsolateData* isolate_data = nullptr);
void MarkBootstrapComplete(const v8::FunctionCallbackInfo<v8::Value>& args);

class InitializationResultImpl final : public InitializationResult {
Expand Down
15 changes: 9 additions & 6 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,16 @@ void Message::AdoptSharedValueConveyor(SharedValueConveyor&& conveyor) {

namespace {

MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context) {
MaybeLocal<Function> GetEmitMessageFunction(Local<Context> context,
IsolateData* isolate_data) {
Isolate* isolate = context->GetIsolate();
Local<Object> per_context_bindings;
Local<Value> emit_message_val;
if (!GetPerContextExports(context).ToLocal(&per_context_bindings) ||
!per_context_bindings->Get(context,
FIXED_ONE_BYTE_STRING(isolate, "emitMessage"))
.ToLocal(&emit_message_val)) {
if (!GetPerContextExports(context, isolate_data)
.ToLocal(&per_context_bindings) ||
!per_context_bindings
->Get(context, FIXED_ONE_BYTE_STRING(isolate, "emitMessage"))
.ToLocal(&emit_message_val)) {
return MaybeLocal<Function>();
}
CHECK(emit_message_val->IsFunction());
Expand Down Expand Up @@ -682,7 +684,8 @@ MessagePort::MessagePort(Environment* env,
}

Local<Function> emit_message_fn;
if (!GetEmitMessageFunction(context).ToLocal(&emit_message_fn))
if (!GetEmitMessageFunction(context, env->isolate_data())
.ToLocal(&emit_message_fn))
return;
emit_message_fn_.Reset(env->isolate(), emit_message_fn);

Expand Down
2 changes: 1 addition & 1 deletion src/node_realm.cc