• Clemens Hammacher's avatar
    [wasm] Split adding code from publishing it · 25d8a157
    Clemens Hammacher authored
    This prepares a refactoring to add and publish compilation results in
    batches. For this, we need to separate the two phases, so that we can
    lock the module, allocate all the code space, release the lock, copy
    the code, lock the module, publish the code, and release the lock
    again.
    In particular, this CL does the following:
    1) It removes the {AddOwnedCode} method. The functionality of creating
       the {WasmCode} and memcpy'ing the instruction into that is done in
       the other {Add*Code} methods. Adding to {owned_code_} is done in
       {PublishCode}.
    2) {PublishInterpreterEntry} is now functionally equivalent to
       {PublishCode}, so it's removed.
    3) After {AddCode}, the caller has to call {PublishCode}. In a
       follow-up CL, this will be called in batches (first {AddCode} them
       all, then {PublishCode} them all).
    4) {AddCompiledCode} now assumes that the {WasmCompilationResult}
       succeeded. Otherwise, the caller should directly call {SetError} on
       the {CompilationState}.
    5) {PublishCode} is now the chokepoint for installing code to the code
       table, the owned code vector, the jump table, and setting interpreter
       redirections. It replaces previous direct calls to {InstallCode} or
       explicitly adding to {owned_code_}.
    6) Increasing the {generated_code_size_} counter is now done in
       {AllocateForCode}, which is the chokepoint for allocating space for
       generated code. This way, we will only increase this counter once
       once we allocate in batches.
    
    R=titzer@chromium.org
    
    Bug: v8:8916
    Change-Id: I71e02e3a838f21797915cee3ebd373804fb12237
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1530817
    Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
    Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#60369}
    25d8a157
function-compiler.cc 8.28 KB