diff --git a/src/codegen/background-merge-task.h b/src/codegen/background-merge-task.h index 033e26b2e8..ad90ed36a3 100644 --- a/src/codegen/background-merge-task.h +++ b/src/codegen/background-merge-task.h @@ -25,8 +25,6 @@ struct ScriptDetails; // compilation cache. class V8_EXPORT_PRIVATE BackgroundMergeTask { public: - ~BackgroundMergeTask(); - // Step 1: on the main thread, check whether the Isolate compilation cache // contains the script. void SetUpOnMainThread(Isolate* isolate, Handle source_text, diff --git a/src/codegen/compiler.cc b/src/codegen/compiler.cc index 158d6f2d87..4b0cd12437 100644 --- a/src/codegen/compiler.cc +++ b/src/codegen/compiler.cc @@ -1963,10 +1963,6 @@ class ConstantPoolPointerForwarder { std::unordered_map> forwarding_table_; }; -BackgroundMergeTask::~BackgroundMergeTask() { - DCHECK(!HasPendingForegroundWork()); -} - void BackgroundMergeTask::SetUpOnMainThread(Isolate* isolate, Handle source_text, const ScriptDetails& script_details, diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index f2fb83d7da..05eb3595f7 100644 --- a/src/snapshot/code-serializer.cc +++ b/src/snapshot/code-serializer.cc @@ -613,6 +613,9 @@ MaybeHandle CodeSerializer::FinishOffThreadDeserialize( FinalizeDeserialization(isolate, result, timer); + DCHECK(!background_merge_task || + !background_merge_task->HasPendingForegroundWork()); + return scope.CloseAndEscape(result); } diff --git a/test/unittests/api/deserialize-unittest.cc b/test/unittests/api/deserialize-unittest.cc index c740794638..ab4d41f147 100644 --- a/test/unittests/api/deserialize-unittest.cc +++ b/test/unittests/api/deserialize-unittest.cc @@ -822,4 +822,98 @@ TEST_F(MergeDeserializedCodeTest, MergeThatCompilesLazyFunction) { CHECK(expected->StrictEquals(actual)); } +TEST_F(MergeDeserializedCodeTest, MergeThatStartsButDoesNotFinish) { + i::v8_flags.merge_background_deserialized_script_with_compilation_cache = + true; + constexpr int kSimultaneousScripts = 10; + std::vector> cached_data; + IsolateAndContextScope scope(this); + i::Isolate* i_isolate = reinterpret_cast(isolate()); + ScriptOrigin default_origin(isolate(), NewString("")); + + // Compile the script for the first time to produce code cache data. + { + v8::HandleScope handle_scope(isolate()); + Local