@@ -15,27 +15,37 @@ This patch is expected to be deleted once we catch up with a Node.js
1515upgrade that includes the original Node.js commit above.
1616
1717diff --git a/src/module_wrap.cc b/src/module_wrap.cc
18- index ff658ec88e5161cd66536ee6e95dba675b16eccc..9bbb8ab908d8d992abb43254860d51f57f56387b 100644
18+ index 0f0b16fcdd8a97bba60faeff09300dd8102cf02c..094d12ffe99500af700a591f5cb33e7d7b247ed1 100644
1919--- a/src/module_wrap.cc
2020+++ b/src/module_wrap.cc
21- @@ -202 ,8 +202 ,7 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
22- }
23-
24- Local<String> source_text = args[2].As<String>( );
25- - ScriptOrigin origin(isolate,
26- - url,
27- + ScriptOrigin origin(url,
28- line_offset,
29- column_offset,
30- true, // is cross origin
31- @@ -464 ,7 +463 ,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
21+ @@ -304 ,8 +304 ,7 @@ MaybeLocal<Module> ModuleWrap::CompileSourceTextModule(
22+ bool* cache_rejected) {
23+ Isolate* isolate = realm->isolate();
24+ EscapableHandleScope scope(isolate );
25+ - ScriptOrigin origin(isolate,
26+ - url,
27+ + ScriptOrigin origin(url,
28+ line_offset,
29+ column_offset,
30+ true, // is cross origin
31+ @@ -500 ,7 +499 ,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
3232
3333 ShouldNotAbortOnUncaughtScope no_abort_scope(realm->env());
3434 TryCatchScope try_catch(realm->env());
3535- Isolate::SafeForTerminationScope safe_for_termination(isolate);
3636
3737 bool timed_out = false;
3838 bool received_signal = false;
39+ @@ -1009,8 +1007,7 @@ void ModuleWrap::CreateRequiredModuleFacade(
40+ ASSIGN_OR_RETURN_UNWRAP(&original, wrap);
41+
42+ // Use the same facade source and URL to hit the compilation cache.
43+ - ScriptOrigin origin(isolate,
44+ - env->required_module_facade_url_string(),
45+ + ScriptOrigin origin(env->required_module_facade_url_string(),
46+ 0, // line offset
47+ 0, // column offset
48+ true, // is cross origin
3949diff --git a/src/node_builtins.cc b/src/node_builtins.cc
4050index 4bf80aa6cc6385dc376fd0a3538efc27fe5bd0a2..3e37aa8b0c9696cceb3f3cfab9721f38c74a2fba 100644
4151--- a/src/node_builtins.cc
@@ -50,36 +60,20 @@ index 4bf80aa6cc6385dc376fd0a3538efc27fe5bd0a2..3e37aa8b0c9696cceb3f3cfab9721f38
5060 BuiltinCodeCacheData cached_data{};
5161 {
5262diff --git a/src/node_contextify.cc b/src/node_contextify.cc
53- index 6456d87d4202c013aafe071adbac06852b3ae2c1..28ba7dbe66a44a43c39e3d75edf0be9513bcf732 100644
63+ index c8ccf38eaaeaccf3715b742e7e64cf7803dbb392..a3f70f6cba773d0a7a00aca96a1687c1e2ae38e6 100644
5464--- a/src/node_contextify.cc
5565+++ b/src/node_contextify.cc
56- @@ -877,16 +877,15 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
66+ @@ -878,8 +878,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
5767 host_defined_options->Set(
5868 isolate, loader::HostDefinedOptions::kID, id_symbol);
5969
6070- ScriptOrigin origin(isolate,
6171- filename,
62- - line_offset, // line offset
63- - column_offset, // column offset
64- - true, // is cross origin
65- - -1, // script id
66- - Local<Value>(), // source map URL
67- - false, // is opaque (?)
68- - false, // is WASM
69- - false, // is ES Module
7072+ ScriptOrigin origin(filename,
71- + line_offset, // line offset
72- + column_offset, // column offset
73- + true, // is cross origin
74- + -1, // script id
75- + Local<Value>(), // source map URL
76- + false, // is opaque (?)
77- + false, // is WASM
78- + false, // is ES Module
79- host_defined_options);
80- ScriptCompiler::Source source(code, origin, cached_data);
81- ScriptCompiler::CompileOptions compile_options =
82- @@ -998,7 +997,7 @@ MaybeLocal<Function> CompileFunction(Local<Context> context,
73+ line_offset, // line offset
74+ column_offset, // column offset
75+ true, // is cross origin
76+ @@ -999,7 +998,7 @@ MaybeLocal<Function> CompileFunction(Local<Context> context,
8377 Local<String> filename,
8478 Local<String> content,
8579 std::vector<Local<String>>* parameters) {
@@ -88,81 +82,34 @@ index 6456d87d4202c013aafe071adbac06852b3ae2c1..28ba7dbe66a44a43c39e3d75edf0be95
8882 ScriptCompiler::Source script_source(content, script_origin);
8983
9084 return ScriptCompiler::CompileFunction(context,
91- @@ -1108 ,7 +1107 ,6 @@ bool ContextifyScript::EvalMachine(Local<Context> context,
85+ @@ -1109 ,7 +1108 ,6 @@ bool ContextifyScript::EvalMachine(Local<Context> context,
9286 }
9387
9488 TryCatchScope try_catch(env);
9589- Isolate::SafeForTerminationScope safe_for_termination(env->isolate());
9690 ContextifyScript* wrapped_script;
9791 ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.This(), false);
9892 Local<UnboundScript> unbound_script =
99- @@ -1286 ,8 +1284 ,7 @@ void ContextifyContext::CompileFunction(
93+ @@ -1278 ,8 +1276 ,7 @@ void ContextifyContext::CompileFunction(
10094 Local<PrimitiveArray> host_defined_options =
101- GetHostDefinedOptions(isolate, id_symbol);
102- ScriptCompiler::Source source =
103- - GetCommonJSSourceInstance(isolate,
104- - code,
105- + GetCommonJSSourceInstance(code,
106- filename,
107- line_offset,
108- column_offset,
109- @@ -1342,15 +1339,13 @@ void ContextifyContext::CompileFunction(
110- }
95+ loader::ModuleWrap::GetHostDefinedOptions(isolate, id_symbol);
11196
112- ScriptCompiler::Source ContextifyContext::GetCommonJSSourceInstance(
113- - Isolate* isolate,
114- Local<String> code,
115- Local<String> filename,
116- int line_offset,
117- int column_offset,
118- Local<PrimitiveArray> host_defined_options,
119- ScriptCompiler::CachedData* cached_data) {
12097- ScriptOrigin origin(isolate,
12198- filename,
12299+ ScriptOrigin origin(filename,
123100 line_offset, // line offset
124101 column_offset, // column offset
125102 true, // is cross origin
126- @@ -1528,7 +1523,7 @@ void ContextifyContext::ContainsModuleSyntax(
127- Local<PrimitiveArray> host_defined_options =
128- GetHostDefinedOptions(isolate, id_symbol);
129- ScriptCompiler::Source source = GetCommonJSSourceInstance(
130- - isolate, code, filename, 0, 0, host_defined_options, nullptr);
131- + code, filename, 0, 0, host_defined_options, nullptr);
132- ScriptCompiler::CompileOptions options = GetCompileOptions(source);
133-
134- std::vector<Local<String>> params = GetCJSParameters(env->isolate_data());
135- @@ -1576,7 +1571,7 @@ void ContextifyContext::ContainsModuleSyntax(
136- code,
137- String::NewFromUtf8(isolate, "})();").ToLocalChecked());
138- ScriptCompiler::Source wrapped_source = GetCommonJSSourceInstance(
139- - isolate, code, filename, 0, 0, host_defined_options, nullptr);
140- + code, filename, 0, 0, host_defined_options, nullptr);
141- std::ignore = ScriptCompiler::CompileFunction(
142- context,
143- &wrapped_source,
144- @@ -1629,8 +1624,7 @@ static void CompileFunctionForCJSLoader(
145-
103+ @@ -1466,8 +1463,7 @@ static MaybeLocal<Function> CompileFunctionForCJSLoader(
146104 Local<Symbol> symbol = env->vm_dynamic_import_default_internal();
147- Local<PrimitiveArray> hdo = GetHostDefinedOptions(isolate, symbol);
105+ Local<PrimitiveArray> hdo =
106+ loader::ModuleWrap::GetHostDefinedOptions(isolate, symbol);
148107- ScriptOrigin origin(isolate,
149108- filename,
150109+ ScriptOrigin origin(filename,
151110 0, // line offset
152111 0, // column offset
153112 true, // is cross origin
154- diff --git a/src/node_contextify.h b/src/node_contextify.h
155- index 517e3f44d324900222e1da961a4cd60bbb4a85f9..10715c7eb07715cc11e49734bd54747dad95f6a4 100644
156- --- a/src/node_contextify.h
157- +++ b/src/node_contextify.h
158- @@ -99,7 +99,6 @@ class ContextifyContext : public BaseObject {
159- v8::Local<v8::Symbol> id_symbol,
160- const errors::TryCatchScope& try_catch);
161- static v8::ScriptCompiler::Source GetCommonJSSourceInstance(
162- - v8::Isolate* isolate,
163- v8::Local<v8::String> code,
164- v8::Local<v8::String> filename,
165- int line_offset,
166113diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc
167114index 64e38c83006a004ebc3519a5e9f8b04263244514..14e82cc80ff73084fb43b2ef07febfd2667a0abc 100644
168115--- a/test/cctest/test_environment.cc
0 commit comments