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

v8: backport 22116dd6c884c026225e56dd8e442a660193e729 #21992

Closed
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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.23',
'v8_embedder_string': '-node.24',

# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
Expand Down
7 changes: 5 additions & 2 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,11 @@ StartupData SnapshotCreator::CreateBlob(
// Complete in-object slack tracking for all functions.
fun->CompleteInobjectSlackTrackingIfActive();

// Also, clear out feedback vectors.
fun->feedback_cell()->set_value(isolate->heap()->undefined_value());
// Also, clear out feedback vectors, or any optimized code.
if (fun->has_feedback_vector()) {
fun->feedback_cell()->set_value(isolate->heap()->undefined_value());
fun->set_code(isolate->builtins()->builtin(i::Builtins::kCompileLazy));
}
}

// Clear out re-compilable data from all shared function infos. Any
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/snapshot/partial-serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
// Unconditionally reset the JSFunction to its SFI's code, since we can't
// serialize optimized code anyway.
JSFunction* closure = JSFunction::cast(obj);
closure->set_code(closure->shared()->GetCode());
if (closure->is_compiled()) closure->set_code(closure->shared()->GetCode());
}

CheckRehashability(obj);
Expand Down
41 changes: 41 additions & 0 deletions deps/v8/test/cctest/test-serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,47 @@ TEST(SnapshotCreatorNoExternalReferencesDefault) {
delete[] blob.data;
}

v8::StartupData CreateCustomSnapshotArrayJoinWithKeep() {
v8::SnapshotCreator creator;
v8::Isolate* isolate = creator.GetIsolate();
{
v8::HandleScope handle_scope(isolate);
{
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
CompileRun(
"[].join('');\n"
"function g() { return String([1,2,3]); }\n");
ExpectString("g()", "1,2,3");
creator.SetDefaultContext(context);
}
}
return creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);
}

TEST(SnapshotCreatorArrayJoinWithKeep) {
DisableAlwaysOpt();
v8::StartupData blob = CreateCustomSnapshotArrayJoinWithKeep();

// Deserialize with an incomplete list of external references.
{
v8::Isolate::CreateParams params;
params.snapshot_blob = &blob;
params.array_buffer_allocator = CcTest::array_buffer_allocator();
// Test-appropriate equivalent of v8::Isolate::New.
v8::Isolate* isolate = TestIsolate::New(params);
{
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
ExpectString("g()", "1,2,3");
}
isolate->Dispose();
}
delete[] blob.data;
}

TEST(SnapshotCreatorNoExternalReferencesCustomFail1) {
DisableAlwaysOpt();
v8::StartupData blob = CreateSnapshotWithDefaultAndCustom();
Expand Down