From 1c90992ffc2c6d12b9a130c1b7c93ff869bb5b7f Mon Sep 17 00:00:00 2001 From: Seth Brenith Date: Wed, 16 Nov 2022 10:18:33 -0800 Subject: [PATCH] Merge with cached Script after streaming compilation Currently, if a script is compiled on the main thread or deserialized on any thread, and a matching Script object is found in the Isolate compilation cache, the new content is merged into the existing Script. This CL implements the same merging for scripts which were compiled by a background task. I expect speed changes to be minimal, because merging is only needed in a small minority of compilations. When needed, it usually takes about 10% as long as the deserialization of the script, which in turn is faster than compilation from source text. This CL also removes some code which I added in preparation for merging on a background thread in this case. Upon further discussion, we've determined that the extra round trip to a background thread when the main thread is likely just waiting for completion would do more harm than good, and performing the compilation cache lookup from the background thread would be quite cumbersome. Bug: v8:12808 Change-Id: Ia7a14a739779ab658b505572d19df4ec489a078e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4023904 Commit-Queue: Seth Brenith Reviewed-by: Leszek Swirski Cr-Commit-Position: refs/heads/main@{#84402} --- src/codegen/compiler.cc | 70 ++++++++++------------------------------- src/codegen/compiler.h | 26 ++------------- test/cctest/test-api.cc | 6 ---- 3 files changed, 18 insertions(+), 84 deletions(-) diff --git a/src/codegen/compiler.cc b/src/codegen/compiler.cc index 88496b8fd0..b87ebc2ba1 100644 --- a/src/codegen/compiler.cc +++ b/src/codegen/compiler.cc @@ -2148,7 +2148,8 @@ Handle BackgroundMergeTask::CompleteMergeInForeground( MaybeHandle BackgroundCompileTask::FinalizeScript( Isolate* isolate, Handle source, - const ScriptDetails& script_details) { + const ScriptDetails& script_details, + MaybeHandle