v8/include
arthursonzogni 22f124cec0 (reland) [api] Add API callback setter for the SAB origin trial
This reland patch:
https://chromium-review.googlesource.com/c/v8/v8/+/2867473
(See patchset 1)

The problem was blink injecting interceptor into the window object. It
observes "observation" and "mutations" on this object. When it happens
to the initial empty document, the IPC DidAccessInitialDocument() is
sent and modify the state of the browser process. Causing two tests to
fail.

The diff (See patchset 1..2) includes:
1. Use JSObject::HasRealNamedProperty instead of JsObject::HasProperty.
   This skips the interceptor and do not walk the prototype chain.
2. Invert JSObject::HasRealNamedProperty() with
   IsSharedArrayBufferConstructorEnabled(), just in case. This avoid
   observing the object when not needed.

Original patch description:
---
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
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2867473
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74378}

---

Bug: chromium:923807,chromium:1071424,chromium:1138860,chromium:1206187
Change-Id: Ibc6b4f8c0e0827178b7f0cbe4b942444bbbe6216
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2880215
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Lutz Vahl <vahl@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74441}
2021-05-07 14:07:48 +00:00
..
cppgc cppgc: Smaller fixes 2021-05-07 13:18:38 +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 [debugger] Remove "Restart frame" feature. 2021-04-29 13:08:14 +00:00
OWNERS Update include/OWNERS 2021-02-25 14:27:28 +00:00
v8-cppgc.h Reland "cppgc: Rework testing GC infrastructure" 2021-02-26 21:29:42 +00:00
v8-fast-api-calls.h [fastcall] Migrate IsLeafTemplateForApiObject to Local<Value> 2021-04-27 11:12:32 +00:00
v8-inspector-protocol.h Fix LINT exceptions across the code base 2020-04-27 16:37:04 +00:00
v8-inspector.h [inspector] Consistently pass around script ID as integer. 2021-05-06 14:30:26 +00:00
v8-internal.h [api] Add v8::metrics::LongTaskStats for the LongTasks UKM 2021-04-14 12:56:34 +00:00
v8-metrics.h [api] Add v8::metrics::LongTaskStats for the LongTasks UKM 2021-04-14 12:56:34 +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.2 2021-04-08 17:30:02 +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 (reland) [api] Add API callback setter for the SAB origin trial 2021-05-07 14:07:48 +00:00
v8config.h Limit [[nodiscard]] to clang 2021-04-28 20:20:31 +00:00