mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
deps: V8: cherry-pick cb00db4dba6c
Original commit message:
[compiler] fix CompileFunction ignoring kEagerCompile
v8::ScriptCompiler::CompileFunction was ignoring kEagerCompile. Unlike
the other functions in v8::ScriptCompiler, it was not actually
propagating kEagerCompile to the parser. The newly updated test fails
without this change.
I did some archeology and found that this was commented out since the
original CL in https://crrev.com/c/980944.
As far as I know Node.js is the main consumer of this particular API.
This CL speeds up Node.js's overall startup time by ~13%.
Change-Id: Ifc3cd6653555194d46ca48db14f7ba7a4afe0053
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4571822
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#87944}
Refs: https://github.com/v8/v8/commit/cb00db4dba6c4a1900700d134e2293c59155db28
PR-URL: https://github.com/nodejs/node/pull/48671
Refs: https://github.com/nodejs/node/pull/48576
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
1 parent
f08341c70f
commit
8a725c7d02
2 files changed
+32
-1
No files matched your search
Vendored
+1
-1
@@ -3686,7 +3686,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
|
||||
// functions fully non-lazy instead thus preventing source positions from
|
||||
// being omitted.
|
||||
flags.set_collect_source_positions(true);
|
||||
// flags.set_eager(compile_options == ScriptCompiler::kEagerCompile);
|
||||
flags.set_is_eager(compile_options == ScriptCompiler::kEagerCompile);
|
||||
|
||||
UnoptimizedCompileState compile_state;
|
||||
ReusableUnoptimizedCompileState reusable_state(isolate);
|
||||
|
||||
+31
@@ -4979,6 +4979,37 @@ TEST(CachedCompileFunction) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(CachedCompileFunctionRespectsEager) {
|
||||
DisableAlwaysOpt();
|
||||
LocalContext env;
|
||||
Isolate* isolate = CcTest::i_isolate();
|
||||
isolate->compilation_cache()
|
||||
->DisableScriptAndEval(); // Disable same-isolate code cache.
|
||||
|
||||
v8::HandleScope scope(CcTest::isolate());
|
||||
|
||||
v8::Local<v8::String> source = v8_str("return function() { return 42; }");
|
||||
v8::ScriptCompiler::Source script_source(source);
|
||||
|
||||
for (bool eager_compile : {false, true}) {
|
||||
v8::ScriptCompiler::CompileOptions options =
|
||||
eager_compile ? v8::ScriptCompiler::kEagerCompile
|
||||
: v8::ScriptCompiler::kNoCompileOptions;
|
||||
v8::Local<v8::Value> fun =
|
||||
v8::ScriptCompiler::CompileFunction(env.local(), &script_source, 0,
|
||||
nullptr, 0, nullptr, options)
|
||||
.ToLocalChecked()
|
||||
.As<v8::Function>()
|
||||
->Call(env.local(), v8::Undefined(CcTest::isolate()), 0, nullptr)
|
||||
.ToLocalChecked();
|
||||
|
||||
auto i_fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(*fun));
|
||||
|
||||
// Function should be compiled iff kEagerCompile was used.
|
||||
CHECK_EQ(i_fun->shared().is_compiled(), eager_compile);
|
||||
}
|
||||
}
|
||||
|
||||
UNINITIALIZED_TEST(SnapshotCreatorAnonClassWithKeep) {
|
||||
DisableAlwaysOpt();
|
||||
v8::SnapshotCreator creator;
|
||||
|
||||
Reference in new issue
Block a user