diff --git a/src/node_builtins.cc b/src/node_builtins.cc index af368bf242f875..0ca360ddf1ef6f 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -243,9 +243,9 @@ MaybeLocal BuiltinLoader::LookupAndCompileInternal( ScriptCompiler::CachedData* cached_data = nullptr; { // Note: The lock here should not extend into the - // `CompileFunctionInContext()` call below, because this function may - // recurse if there is a syntax error during bootstrap (because the fatal - // exception handler is invoked, which may load built-in modules). + // `CompileFunction()` call below, because this function may recurse if + // there is a syntax error during bootstrap (because the fatal exception + // handler is invoked, which may load built-in modules). Mutex::ScopedLock lock(code_cache_mutex_); auto cache_it = code_cache_.find(id); if (cache_it != code_cache_.end()) { @@ -267,20 +267,20 @@ MaybeLocal BuiltinLoader::LookupAndCompileInternal( has_cache ? "with" : "without"); MaybeLocal maybe_fun = - ScriptCompiler::CompileFunctionInContext(context, - &script_source, - parameters->size(), - parameters->data(), - 0, - nullptr, - options); + ScriptCompiler::CompileFunction(context, + &script_source, + parameters->size(), + parameters->data(), + 0, + nullptr, + options); // This could fail when there are early errors in the built-in modules, // e.g. the syntax errors Local fun; if (!maybe_fun.ToLocal(&fun)) { // In the case of early errors, v8 is already capable of - // decorating the stack for us - note that we use CompileFunctionInContext + // decorating the stack for us - note that we use CompileFunction // so there is no need to worry about wrappers. return MaybeLocal(); } diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 969296656b1059..49a049e24abf2a 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -70,7 +70,6 @@ using v8::PropertyHandlerFlags; using v8::Script; using v8::ScriptCompiler; using v8::ScriptOrigin; -using v8::ScriptOrModule; using v8::String; using v8::Uint32; using v8::UnboundScript; @@ -1130,11 +1129,15 @@ void ContextifyContext::CompileFunction( } } - Local script; - MaybeLocal maybe_fn = ScriptCompiler::CompileFunctionInContext( - parsing_context, &source, params.size(), params.data(), - context_extensions.size(), context_extensions.data(), options, - v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason, &script); + MaybeLocal maybe_fn = ScriptCompiler::CompileFunction( + parsing_context, + &source, + params.size(), + params.data(), + context_extensions.size(), + context_extensions.data(), + options, + v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason); Local fn; if (!maybe_fn.ToLocal(&fn)) { @@ -1150,7 +1153,7 @@ void ContextifyContext::CompileFunction( context).ToLocal(&cache_key)) { return; } - CompiledFnEntry* entry = new CompiledFnEntry(env, cache_key, id, script); + CompiledFnEntry* entry = new CompiledFnEntry(env, cache_key, id, fn); env->id_to_function_map.emplace(id, entry); Local result = Object::New(isolate); @@ -1196,16 +1199,14 @@ void CompiledFnEntry::WeakCallback( CompiledFnEntry::CompiledFnEntry(Environment* env, Local object, uint32_t id, - Local script) - : BaseObject(env, object), - id_(id), - script_(env->isolate(), script) { - script_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter); + Local fn) + : BaseObject(env, object), id_(id), fn_(env->isolate(), fn) { + fn_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter); } CompiledFnEntry::~CompiledFnEntry() { env()->id_to_function_map.erase(id_); - script_.ClearWeak(); + fn_.ClearWeak(); } static void StartSigintWatchdog(const FunctionCallbackInfo& args) { diff --git a/src/node_contextify.h b/src/node_contextify.h index d45b73b36e295d..c9b5fc0f62dcfc 100644 --- a/src/node_contextify.h +++ b/src/node_contextify.h @@ -174,14 +174,14 @@ class CompiledFnEntry final : public BaseObject { CompiledFnEntry(Environment* env, v8::Local object, uint32_t id, - v8::Local script); + v8::Local fn); ~CompiledFnEntry(); bool IsNotIndicativeOfMemoryLeakAtExit() const override { return true; } private: uint32_t id_; - v8::Global script_; + v8::Global fn_; static void WeakCallback(const v8::WeakCallbackInfo& data); }; diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index f74e8331f35ed7..b9675b0aa9bb2f 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -1335,13 +1335,13 @@ void CompileSerializeMain(const FunctionCallbackInfo& args) { }; ScriptCompiler::Source script_source(source, origin); Local fn; - if (ScriptCompiler::CompileFunctionInContext(context, - &script_source, - parameters.size(), - parameters.data(), - 0, - nullptr, - ScriptCompiler::kEagerCompile) + if (ScriptCompiler::CompileFunction(context, + &script_source, + parameters.size(), + parameters.data(), + 0, + nullptr, + ScriptCompiler::kEagerCompile) .ToLocal(&fn)) { args.GetReturnValue().Set(fn); }