• Antonio Sartori's avatar
    [api] Add API callback setter for the SAB origin trial · bc1eb7b4
    Antonio Sartori authored
    This change makes it possible to enable SharedArrayBuffer per Context,
    controlling whether it should be enabled or not with a callback. The
    previous implementation of the reverse origin trial for
    SharedArrayBuffer was broken, since the feature could only be enabled
    globally per process, and only if the feature flag is set early enough
    in the v8 initialization. This does not play well with how origin
    trials work.
    
    The implementation is similar to the callbacks that already exist for
    the origin trials for WebAssembly simd and exceptions.
    
    SharedArrayBuffer is still controlled by the flag
    harmony_sharedarraybuffer. If that flag is disabled, then
    SharedArrayBuffer is disabled unconditionally. On top of that, this CL
    introduces a new flag for enabling SharedArrayBuffer per context. If
    that flag is set, a callback is used to determine whether
    SharedArrayBuffer should be enabled.
    
    
    Note that this only controls whether the SharedArrayBuffer constructor
    should be exposed on the global object or not. It is always possible
    to construct a SharedArrayBuffer using
    
      new WebAssembly.Memory({
        shared:true, initial:0, maximum:0 }).buffer.constructor;
    
    
    There are few things which I do not like of this approach, but I did
    not have better ideas:
    
    1. The complex logic of dobule flag + callback. However, this seemed
    the best way to me to not break embedders which rely on that flag
    being enabled by default.
    
    2. The fact that what actually matters is just whether the callback
    returns `true` once. It would be good to check that the callback gives
    a consistent return value, or to provide a better API that cannot be
    missunderstood.
    
    
    Bug: chromium:923807,chromium:1071424,chromium:1138860
    Change-Id: Ibe3776fad4d3bff5dda9066967e4b20328014266
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2867473Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
    Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
    Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#74378}
    bc1eb7b4
Name
Last commit
Last update
..
arm Loading commit data...
arm64 Loading commit data...
ia32 Loading commit data...
mips Loading commit data...
mips64 Loading commit data...
ppc Loading commit data...
riscv64 Loading commit data...
s390 Loading commit data...
x64 Loading commit data...
DIR_METADATA Loading commit data...
OWNERS Loading commit data...
arguments-inl.h Loading commit data...
arguments.cc Loading commit data...
arguments.h Loading commit data...
execution.cc Loading commit data...
execution.h Loading commit data...
external-pointer-table.cc Loading commit data...
external-pointer-table.h Loading commit data...
frame-constants.h Loading commit data...
frames-inl.h Loading commit data...
frames.cc Loading commit data...
frames.h Loading commit data...
futex-emulation.cc Loading commit data...
futex-emulation.h Loading commit data...
interrupts-scope.cc Loading commit data...
interrupts-scope.h Loading commit data...
isolate-data.h Loading commit data...
isolate-inl.h Loading commit data...
isolate-utils-inl.h Loading commit data...
isolate-utils.h Loading commit data...
isolate.cc Loading commit data...
isolate.h Loading commit data...
local-isolate-inl.h Loading commit data...
local-isolate.cc Loading commit data...
local-isolate.h Loading commit data...
messages.cc Loading commit data...
messages.h Loading commit data...
microtask-queue.cc Loading commit data...
microtask-queue.h Loading commit data...
pointer-authentication-dummy.h Loading commit data...
pointer-authentication.h Loading commit data...
protectors-inl.h Loading commit data...
protectors.cc Loading commit data...
protectors.h Loading commit data...
runtime-profiler.cc Loading commit data...
runtime-profiler.h Loading commit data...
shared-mutex-guard-if-off-thread.h Loading commit data...
simulator-base.cc Loading commit data...
simulator-base.h Loading commit data...
simulator.h Loading commit data...
stack-guard.cc Loading commit data...
stack-guard.h Loading commit data...
thread-id.cc Loading commit data...
thread-id.h Loading commit data...
thread-local-top.cc Loading commit data...
thread-local-top.h Loading commit data...
v8threads.cc Loading commit data...
v8threads.h Loading commit data...
vm-state-inl.h Loading commit data...
vm-state.h Loading commit data...