From b5848499c5144e5d2f973799d47517540b2162ab Mon Sep 17 00:00:00 2001 From: Adam Klein Date: Wed, 15 May 2024 09:16:00 +0200 Subject: [PATCH] src: remove calls to recently deprecated V8 APIs Closes: https://github.com/nodejs/node/issues/52991 --- src/module_wrap.cc | 4 +--- src/node_builtins.cc | 2 +- src/node_contextify.cc | 28 ++++++++++++---------------- test/cctest/test_environment.cc | 3 --- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/module_wrap.cc b/src/module_wrap.cc index f6285182d92871..ce6ff0da27241f 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -339,8 +339,7 @@ MaybeLocal ModuleWrap::CompileSourceTextModule( bool* cache_rejected) { Isolate* isolate = realm->isolate(); EscapableHandleScope scope(isolate); - ScriptOrigin origin(isolate, - url, + ScriptOrigin origin(url, line_offset, column_offset, true, // is cross origin @@ -549,7 +548,6 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo& args) { ShouldNotAbortOnUncaughtScope no_abort_scope(realm->env()); TryCatchScope try_catch(realm->env()); - Isolate::SafeForTerminationScope safe_for_termination(isolate); bool timed_out = false; bool received_signal = false; diff --git a/src/node_builtins.cc b/src/node_builtins.cc index 3a2320e33d0354..81d3c9f7511e5d 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -265,7 +265,7 @@ MaybeLocal BuiltinLoader::LookupAndCompileInternal( std::string filename_s = std::string("node:") + id; Local filename = OneByteString(isolate, filename_s.c_str(), filename_s.size()); - ScriptOrigin origin(isolate, filename, 0, 0, true); + ScriptOrigin origin(filename, 0, 0, true); BuiltinCodeCacheData cached_data{}; { diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 26aa4a206da37c..6dbc127374492e 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -886,16 +886,15 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { host_defined_options->Set( isolate, loader::HostDefinedOptions::kID, id_symbol); - ScriptOrigin origin(isolate, - filename, - line_offset, // line offset - column_offset, // column offset - true, // is cross origin - -1, // script id - Local(), // source map URL - false, // is opaque (?) - false, // is WASM - false, // is ES Module + ScriptOrigin origin(filename, + line_offset, // line offset + column_offset, // column offset + true, // is cross origin + -1, // script id + Local(), // source map URL + false, // is opaque (?) + false, // is WASM + false, // is ES Module host_defined_options); ScriptCompiler::Source source(code, origin, cached_data); ScriptCompiler::CompileOptions compile_options = @@ -1006,7 +1005,7 @@ MaybeLocal CompileFunction(Local context, Local filename, Local content, std::vector>* parameters) { - ScriptOrigin script_origin(context->GetIsolate(), filename, 0, 0, true); + ScriptOrigin script_origin(filename, 0, 0, true); ScriptCompiler::Source script_source(content, script_origin); return ScriptCompiler::CompileFunction(context, @@ -1116,7 +1115,6 @@ bool ContextifyScript::EvalMachine(Local context, } TryCatchScope try_catch(env); - Isolate::SafeForTerminationScope safe_for_termination(env->isolate()); ContextifyScript* wrapped_script; ASSIGN_OR_RETURN_UNWRAP(&wrapped_script, args.Holder(), false); Local unbound_script = @@ -1270,8 +1268,7 @@ void ContextifyContext::CompileFunction( Local host_defined_options = loader::ModuleWrap::GetHostDefinedOptions(isolate, id_symbol); - ScriptOrigin origin(isolate, - filename, + ScriptOrigin origin(filename, line_offset, // line offset column_offset, // column offset true, // is cross origin @@ -1452,8 +1449,7 @@ static MaybeLocal CompileFunctionForCJSLoader(Environment* env, Local symbol = env->vm_dynamic_import_default_internal(); Local hdo = loader::ModuleWrap::GetHostDefinedOptions(isolate, symbol); - ScriptOrigin origin(isolate, - filename, + ScriptOrigin origin(filename, 0, // line offset 0, // column offset true, // is cross origin diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc index 64e38c83006a00..14e82cc80ff730 100644 --- a/test/cctest/test_environment.cc +++ b/test/cctest/test_environment.cc @@ -620,12 +620,9 @@ TEST_F(EnvironmentTest, SetImmediateMicrotasks) { #ifndef _WIN32 // No SIGINT on Windows. TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) { - // We need to go through the whole setup dance here because we want to - // set only_terminate_in_safe_scope. // Allocate and initialize Isolate. v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = allocator.get(); - create_params.only_terminate_in_safe_scope = true; v8::Isolate* isolate = v8::Isolate::Allocate(); CHECK_NOT_NULL(isolate); platform->RegisterIsolate(isolate, ¤t_loop);