• Leszek Swirski's avatar
    [api] Add API for off-thread code cache deserialization · f888f48e
    Leszek Swirski authored
    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: 's avatarOmer Katz <omerkatz@chromium.org>
    Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
    Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#76155}
    f888f48e
Name
Last commit
Last update
..
api Loading commit data...
asmjs Loading commit data...
ast Loading commit data...
base Loading commit data...
baseline Loading commit data...
bigint Loading commit data...
builtins Loading commit data...
codegen Loading commit data...
common Loading commit data...
compiler Loading commit data...
compiler-dispatcher Loading commit data...
d8 Loading commit data...
date Loading commit data...
debug Loading commit data...
deoptimizer Loading commit data...
diagnostics Loading commit data...
execution Loading commit data...
extensions Loading commit data...
flags Loading commit data...
handles Loading commit data...
heap Loading commit data...
ic Loading commit data...
init Loading commit data...
inspector Loading commit data...
interpreter Loading commit data...
json Loading commit data...
libplatform Loading commit data...
libsampler Loading commit data...
logging Loading commit data...
numbers Loading commit data...
objects Loading commit data...
parsing Loading commit data...
profiler Loading commit data...
protobuf Loading commit data...
regexp Loading commit data...
roots Loading commit data...
runtime Loading commit data...
sanitizer Loading commit data...
snapshot Loading commit data...
strings Loading commit data...
tasks Loading commit data...
third_party Loading commit data...
torque Loading commit data...
tracing Loading commit data...
trap-handler Loading commit data...
utils Loading commit data...
wasm Loading commit data...
web-snapshot Loading commit data...
zone Loading commit data...
DEPS Loading commit data...
DIR_METADATA Loading commit data...
OWNERS Loading commit data...