v8/include
Leszek Swirski f888f48e4c [api] Add API for off-thread code cache deserialization
To consume a code cache off-thread

  1. The embedder creates a CachedData object wrapping the data blob.
  2. The embedder calls ScriptCompiler::StartConsumingCodeCache with the
     CachedData, and receives a ScriptCompiler::CodeCacheConsumeTask
     which takes ownership of the CachedData.
  3. The embedder calls ScriptCompiler::CodeCacheConsumeTask::Run
     on a different thread.
  4. Once this completes, the embedded passes the completed task as an
     optional argument into Source constructor, and calls Compile as
     before.

This is roughly similar to how streaming compilation works, with the
QoL improvement that Source owns the CodeCacheConsumeTask and therefore
we can reuse the same Compile method and do the off-thread finalization
behind the scenes inside Compile.

On the v8::internal side, ScriptCompiler::CodeCacheConsumeTask wraps a
v8::internal::BackgroundDeserializeTask, which has a Run and a Finish
method. The Run creates a LocalIsolate (again, similar to
BackgroundCompileTask), calls some helpers on CodeSerializer, and stores
the pre-finalization result in a OffThreadDeserializeData structure.
This stores Persistent Handles to the off-thread initialized SFI and
a vector of Scripts needing fixing up, and it owns the PersistentHandles
object which owns those Handles. Finally, the Finish method consumes
this OffThreadDeserializeData structure, fixes up Scripts, moves the
SFI Handle into the caller HandleScope, and that's it.

Since we don't yet have the source at off-thread deserialization time,
the various code cache sanity checks are done without the source hash
when deserializing, and the Finish method re-does them now that the
source is available.

Bug: chromium:1075999
Change-Id: If1faf35ba3ef840fa4e735581d0b29c96c1d5fc8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3067322
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76155}
2021-08-09 08:55:41 +00:00
..
cppgc cppgc: Fix comment 2021-08-05 04:43:48 +00:00
libplatform Step 1 (of 3-ish): Basic ETW Instrumentation in V8 2021-01-05 20:11:03 +00:00
APIDesign.md Move inspector protocol definitions to include/ 2019-06-18 17:59:36 +00:00
DEPS cppgc: Implement process-global state accessors. 2021-02-17 22:37:24 +00:00
DIR_METADATA Add DIR_METADATA files to v8. 2020-10-20 22:12:28 +00:00
js_protocol-1.2.json Move inspector protocol definitions to include/ 2019-06-18 17:59:36 +00:00
js_protocol-1.3.json Move inspector protocol definitions to include/ 2019-06-18 17:59:36 +00:00
js_protocol.pdl [inspector] Add executionContextId to Runtime.inspectRequested. 2021-07-23 08:41:03 +00:00
OWNERS Revert "Make autoroll account owner of auto-updated files" 2021-08-06 10:40:25 +00:00
v8-cppgc.h [cppgc] Add API to query custom space sizes at last GC 2021-05-07 17:57:28 +00:00
v8-fast-api-calls.h [api][fastcall] Small TryCopyAndConvertArrayToCppBuffer fixes 2021-08-02 12:01:46 +00:00
v8-inspector-protocol.h Fix LINT exceptions across the code base 2020-04-27 16:37:04 +00:00
v8-inspector.h Revert "[build] Separate out inspector as a shared library" 2021-07-02 16:15:20 +00:00
v8-internal.h [fastcall] Type-specialize CopyAndConvertArrayToCppBuffer 2021-07-30 10:52:12 +00:00
v8-metrics.h [wasm] Add CPU time metrics (reland) 2021-07-14 08:01:41 +00:00
v8-platform.h [Jobs]: Cleanup in v8 platform. 2021-04-07 16:00:22 +00:00
v8-profiler.h [cleanup][include] Remove redundant NOLINT annotations 2021-04-30 16:22:19 +00:00
v8-unwinder-state.h Add RISC-V backend 2021-02-09 17:06:36 +00:00
v8-util.h [cleanup][include] Remove redundant NOLINT annotations 2021-04-30 16:22:19 +00:00
v8-value-serializer-version.h Expose the ValueSerializer data format version as a compile-time constant. 2017-04-27 15:14:41 +00:00
v8-version-string.h Fix LINT exceptions across the code base 2020-04-27 16:37:04 +00:00
v8-version.h Changed version number to 9.4 2021-07-15 08:13:36 +00:00
v8-wasm-trap-handler-posix.h Fix LINT exceptions across the code base 2020-04-27 16:37:04 +00:00
v8-wasm-trap-handler-win.h Fix LINT exceptions across the code base 2020-04-27 16:37:04 +00:00
v8.h [api] Add API for off-thread code cache deserialization 2021-08-09 08:55:41 +00:00
v8config.h [wasm] Disable MAP_JIT functionality on iOS 2021-08-06 17:30:47 +00:00