From 684018ea02936a8254f4938599c67c6207ae7dfe Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Thu, 12 Dec 2024 02:34:40 -0800 Subject: [PATCH] [dart2wasm] Fix js-string builtin detection The `detectJsStringBuiltins` should've negated the validation (i.e. validation will fail if `js-string` builtins is enabled as enabling the builtins causes stricter validation of imports) Closes https://github.com/dart-lang/sdk/issues/59697 Change-Id: I5bcfdcf34e9fad89a84090c5f20284a7aae9e209 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400280 Reviewed-by: Slava Egorov Commit-Queue: Martin Kustermann --- pkg/dart2wasm/lib/js/runtime_blob.dart | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/dart2wasm/lib/js/runtime_blob.dart b/pkg/dart2wasm/lib/js/runtime_blob.dart index d9b15553d1fc..a6ab0e99e10d 100644 --- a/pkg/dart2wasm/lib/js/runtime_blob.dart +++ b/pkg/dart2wasm/lib/js/runtime_blob.dart @@ -3,16 +3,6 @@ // BSD-style license that can be found in the LICENSE file. const jsRuntimeBlobPart1 = r''' -// Returns whether the `js-string` built-in is supported. -function detectJsStringBuiltins() { - let bytes = [ - 0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, - 0, 2, 23, 1, 14, 119, 97, 115, 109, 58, 106, 115, 45, - 115, 116, 114, 105, 110, 103, 4, 99, 97, 115, 116, 0, 0 - ]; - return WebAssembly.validate( - new Uint8Array(bytes), {builtins: ['js-string']}); -} // Compiles a dart2wasm-generated main module from `source` which can then // instantiatable via the `instantiate` method. @@ -20,8 +10,7 @@ function detectJsStringBuiltins() { // `source` needs to be a `Response` object (or promise thereof) e.g. created // via the `fetch()` JS API. export async function compileStreaming(source) { - const builtins = detectJsStringBuiltins() - ? {builtins: ['js-string']} : {}; + const builtins = {builtins: ['js-string']}; return new CompiledApp( await WebAssembly.compileStreaming(source, builtins), builtins); } @@ -29,8 +18,7 @@ export async function compileStreaming(source) { // Compiles a dart2wasm-generated wasm modules from `bytes` which is then // instantiatable via the `instantiate` method. export async function compile(bytes) { - const builtins = detectJsStringBuiltins() - ? {builtins: ['js-string']} : {}; + const builtins = {builtins: ['js-string']}; return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins); }