[api] Add a SharedArrayBuffersEnabled callback.
- Adds a SharedArrayBuffersEnabled callback and uses it to enable/disable SABs per context. The feature flag is used if no callback is registered. Bug: chromium:923807 Change-Id: I4d3472fcd79b158cb50dc98793aece6dbbb81d93 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2316901 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Bill Budge <bbudge@chromium.org> Cr-Commit-Position: refs/heads/master@{#69057}
This commit is contained in:
parent
b3b42a3008
commit
76b53b66b0
@ -7506,6 +7506,9 @@ typedef Local<String> (*WasmLoadSourceMapCallback)(Isolate* isolate,
|
||||
// --- Callback for checking if WebAssembly Simd is enabled ---
|
||||
typedef bool (*WasmSimdEnabledCallback)(Local<Context> context);
|
||||
|
||||
// --- Callback for checking if SharedArrayBuffers are enabled ---
|
||||
typedef bool (*SharedArrayBuffersEnabledCallback)(Local<Context> context);
|
||||
|
||||
// --- Garbage Collection Callbacks ---
|
||||
|
||||
/**
|
||||
@ -9373,6 +9376,9 @@ class V8_EXPORT Isolate {
|
||||
|
||||
void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
|
||||
|
||||
void SetSharedArrayBuffersEnabledCallback(
|
||||
SharedArrayBuffersEnabledCallback callback);
|
||||
|
||||
/**
|
||||
* Check if V8 is dead and therefore unusable. This is the case after
|
||||
* fatal errors such as out-of-memory situations.
|
||||
|
@ -8989,6 +8989,10 @@ CALLBACK_SETTER(WasmLoadSourceMapCallback, WasmLoadSourceMapCallback,
|
||||
CALLBACK_SETTER(WasmSimdEnabledCallback, WasmSimdEnabledCallback,
|
||||
wasm_simd_enabled_callback)
|
||||
|
||||
CALLBACK_SETTER(SharedArrayBuffersEnabledCallback,
|
||||
SharedArrayBuffersEnabledCallback,
|
||||
shared_array_buffers_enabled_callback)
|
||||
|
||||
void Isolate::AddNearHeapLimitCallback(v8::NearHeapLimitCallback callback,
|
||||
void* data) {
|
||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
|
@ -2634,6 +2634,14 @@ bool Isolate::IsWasmSimdEnabled(Handle<Context> context) {
|
||||
return FLAG_experimental_wasm_simd;
|
||||
}
|
||||
|
||||
bool Isolate::AreSharedArrayBuffersEnabled(Handle<Context> context) {
|
||||
if (shared_array_buffers_enabled_callback()) {
|
||||
v8::Local<v8::Context> api_context = v8::Utils::ToLocal(context);
|
||||
return shared_array_buffers_enabled_callback()(api_context);
|
||||
}
|
||||
return FLAG_harmony_sharedarraybuffer;
|
||||
}
|
||||
|
||||
Handle<Context> Isolate::GetIncumbentContext() {
|
||||
JavaScriptFrameIterator it(this);
|
||||
|
||||
|
@ -410,6 +410,8 @@ using DebugObjectCache = std::vector<Handle<HeapObject>>;
|
||||
V(WasmThreadsEnabledCallback, wasm_threads_enabled_callback, nullptr) \
|
||||
V(WasmLoadSourceMapCallback, wasm_load_source_map_callback, nullptr) \
|
||||
V(WasmSimdEnabledCallback, wasm_simd_enabled_callback, nullptr) \
|
||||
V(SharedArrayBuffersEnabledCallback, shared_array_buffers_enabled_callback, \
|
||||
nullptr) \
|
||||
/* State for Relocatable. */ \
|
||||
V(Relocatable*, relocatable_top, nullptr) \
|
||||
V(DebugObjectCache*, string_stream_debug_object_cache, nullptr) \
|
||||
@ -634,6 +636,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
|
||||
|
||||
bool AreWasmThreadsEnabled(Handle<Context> context);
|
||||
bool IsWasmSimdEnabled(Handle<Context> context);
|
||||
bool AreSharedArrayBuffersEnabled(Handle<Context> context);
|
||||
|
||||
THREAD_LOCAL_TOP_ADDRESS(Object, pending_exception)
|
||||
|
||||
|
@ -4137,7 +4137,7 @@ void Genesis::InitializeGlobal_harmony_atomics_waitasync() {
|
||||
}
|
||||
|
||||
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
|
||||
if (!FLAG_harmony_sharedarraybuffer) return;
|
||||
if (!isolate()->AreSharedArrayBuffersEnabled(native_context())) return;
|
||||
|
||||
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user