Skip to content

Commit

Permalink
Extensions: Enable wasm threads for extension processes.
Browse files Browse the repository at this point in the history
r869703 granted temporary SharedArrayBuffer (SAB) access to the
extension scheme since there is no way currently for extensions to opt
into cross origin isolation. Since Wasm Threads should be enabled
whenever SABs are enabled, also temporarily enable wasm threads for
extension processes. These exceptions will be removed once there is a
way for extensions to opt into cross origin isolation.

This also fixes the regression with ChromeOS PDF Annotation component
extension which relies on construction of shared WebAssembly.Memory
instances (which require wasm threads to be enabled). Verified that the
currently disabled PDFExtensionJSTest.AnnotationsFeatureEnabled test
(which tests the annotation extension) succeeds after this CL.

Also rename
third_party/blink/renderer/core/exported/web_context_features.cc to
web_v8_features.cc. This was an oversight in r870311.

Note that a merge for this CL will be requested for M91.

Bug: 1196189, 1184892, 1177131

Change-Id: I42e54355fb8d6ae033eedebc8e6258884e96692b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2822801
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#872328}
GitOrigin-RevId: eecede49c55a5f9489d4a37813213fb710618036
  • Loading branch information
Karandeep Bhatia authored and copybara-github committed Apr 14, 2021
1 parent 53f383c commit 313df77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions blink/public/web/web_v8_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class WebV8Features {
// Enables SharedArrayBuffer for this process.
BLINK_EXPORT static void EnableSharedArrayBuffer();

// Enables web assembly threads for this process.
BLINK_EXPORT static void EnableWasmThreads();

private:
WebV8Features() = delete;
};
Expand Down
2 changes: 1 addition & 1 deletion blink/renderer/core/exported/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ blink_core_sources("exported") {
"web_blob.cc",
"web_console_message.cc",
"web_content_holder.cc",
"web_context_features.cc",
"web_custom_element.cc",
"web_dev_tools_agent_impl.cc",
"web_dev_tools_agent_impl.h",
Expand Down Expand Up @@ -88,6 +87,7 @@ blink_core_sources("exported") {
"web_shared_worker_impl.h",
"web_text_checking_result.cc",
"web_v8_context_snapshot.cc",
"web_v8_features.cc",
"web_view_impl.cc",
"web_view_impl.h",
"web_view_observer.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ void WebV8Features::EnableSharedArrayBuffer() {
v8::V8::SetFlagsFromString(kSABFlag, sizeof(kSABFlag));
}

void WebV8Features::EnableWasmThreads() {
static bool wasm_threads_enabled = false;
if (wasm_threads_enabled)
return;

wasm_threads_enabled = true;
constexpr char kWasmThreadsFlag[] = "--experimental-wasm-threads";
v8::V8::SetFlagsFromString(kWasmThreadsFlag, sizeof(kWasmThreadsFlag));
}

} // namespace blink

0 comments on commit 313df77

Please sign in to comment.