Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaef5fd8

Browse files
committed
src: make BuiltinLoader threadsafe and non-global
nodejs/node#45942
1 parent6210234 commitaef5fd8

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

‎patches/node/fix_expose_lookupandcompile_with_parameters.patch

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,49 @@ parameters.
1010
This should be upstreamed.
1111

1212
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
13-
index 7e4a43a6f13845c8a81bae96ec073ccdfc655999..26ebc322afa36994b4f1b93f992ac8b726263191 100644
13+
index 7e4a43a6f13845c8a81bae96ec073ccdfc655999..b9598eff8acd8390007be0a09ac019b488ce0855 100644
1414
--- a/src/node_builtins.cc
1515
+++ b/src/node_builtins.cc
16-
@@ -482,6 +482,22 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
16+
@@ -482,6 +482,18 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
1717
return fn->Call(context, undefined, argc, argv);
1818
}
1919

2020
+MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
2121
+ Local<Context> context,
2222
+ const char* id,
2323
+ std::vector<Local<String>>* parameters,
24-
+ Environment* optional_env) {
25-
+ Result result;
24+
+ Realm* optional_realm) {
2625
+ Isolate* isolate = context->GetIsolate();
2726
+
28-
+ MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal(
29-
+ context, id, parameters, &result);
30-
+ if (optional_env != nullptr) {
31-
+ RecordResult(id, result, optional_env);
32-
+ }
27+
+ MaybeLocal<Function> maybe = LookupAndCompileInternal(
28+
+ context, id, parameters, optional_realm);
3329
+ return maybe;
3430
+}
3531
+
3632
bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) {
3733
std::vector<std::string_view> ids = GetBuiltinIds();
3834
bool all_succeeded = true;
3935
diff --git a/src/node_builtins.h b/src/node_builtins.h
40-
index ba0c926a7968ec6a4cf07a469f1fd9314287a937..03ecd853b26a581f57b3311915fb7f46e713b00d 100644
36+
index ba0c926a7968ec6a4cf07a469f1fd9314287a937..9e76bc2c9b7031dde9b1497125c4af608e55d54c 100644
4137
--- a/src/node_builtins.h
4238
+++ b/src/node_builtins.h
43-
@@ -107,6 +107,12 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
44-
const char* id,
45-
Realm*realm);
39+
@@ -97,6 +97,12 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
40+
const char* id,
41+
Realm*optional_realm);
4642

47-
+staticv8::MaybeLocal<v8::Function> LookupAndCompile(
43+
+ v8::MaybeLocal<v8::Function> LookupAndCompile(
4844
+ v8::Local<v8::Context> context,
4945
+ const char* id,
5046
+ std::vector<v8::Local<v8::String>>* parameters,
51-
+ Environment* optional_env);
47+
+ Realm* optional_realm);
48+
+
49+
v8::MaybeLocal<v8::Value> CompileAndCall(v8::Local<v8::Context> context,
50+
const char* id,
51+
int argc,
52+
@@ -107,6 +113,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
53+
const char* id,
54+
Realm* realm);
55+
5256
+
5357
// Returns config.gypi as a JSON string
5458
v8::Local<v8::String> GetConfigString(v8::Isolate* isolate);

‎shell/common/node_util.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
1717
node::Environment* optional_env) {
1818
v8::Isolate* isolate = context->GetIsolate();
1919
v8::TryCatchtry_catch(isolate);
20+
thread_local node::builtins::BuiltinLoader builtin_loader;
21+
22+
node::Realm* realm =node::Realm::GetCurrent(context);
2023
v8::MaybeLocal<v8::Function> compiled =
21-
node::builtins::BuiltinLoader::LookupAndCompile(context, id, parameters,
22-
optional_env);
24+
builtin_loader.LookupAndCompile(context, id, parameters, realm);
2325
if (compiled.IsEmpty()) {
2426
return v8::MaybeLocal<v8::Value>();
2527
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp