Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: pre-emptively fix tests broken by V8 CL #48671

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.10',
'v8_embedder_string': '-node.11',

##### V8 defaults for Node.js #####

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions deps/v8/test/cctest/test-serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
const bool has_cache = cached_data.data != nullptr;
ScriptCompiler::CompileOptions options =
has_cache ? ScriptCompiler::kConsumeCodeCache
: ScriptCompiler::kEagerCompile;
: ScriptCompiler::kNoCompileOptions;
ScriptCompiler::Source script_source(
source,
origin,
Expand Down
2 changes: 1 addition & 1 deletion src/node_snapshotable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ void CompileSerializeMain(const FunctionCallbackInfo<Value>& args) {
parameters.data(),
0,
nullptr,
ScriptCompiler::kEagerCompile)
ScriptCompiler::kNoCompileOptions)
.ToLocal(&fn)) {
args.GetReturnValue().Set(fn);
}
Expand Down