Skip to content

Commit 684018e

Browse files
mkustermannCommit Queue
authored andcommitted
[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 #59697 Change-Id: I5bcfdcf34e9fad89a84090c5f20284a7aae9e209 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400280 Reviewed-by: Slava Egorov <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent 1d684cd commit 684018e

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

pkg/dart2wasm/lib/js/runtime_blob.dart

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,22 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
const jsRuntimeBlobPart1 = r'''
6-
// Returns whether the `js-string` built-in is supported.
7-
function detectJsStringBuiltins() {
8-
let bytes = [
9-
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0,
10-
0, 2, 23, 1, 14, 119, 97, 115, 109, 58, 106, 115, 45,
11-
115, 116, 114, 105, 110, 103, 4, 99, 97, 115, 116, 0, 0
12-
];
13-
return WebAssembly.validate(
14-
new Uint8Array(bytes), {builtins: ['js-string']});
15-
}
166
177
// Compiles a dart2wasm-generated main module from `source` which can then
188
// instantiatable via the `instantiate` method.
199
//
2010
// `source` needs to be a `Response` object (or promise thereof) e.g. created
2111
// via the `fetch()` JS API.
2212
export async function compileStreaming(source) {
23-
const builtins = detectJsStringBuiltins()
24-
? {builtins: ['js-string']} : {};
13+
const builtins = {builtins: ['js-string']};
2514
return new CompiledApp(
2615
await WebAssembly.compileStreaming(source, builtins), builtins);
2716
}
2817
2918
// Compiles a dart2wasm-generated wasm modules from `bytes` which is then
3019
// instantiatable via the `instantiate` method.
3120
export async function compile(bytes) {
32-
const builtins = detectJsStringBuiltins()
33-
? {builtins: ['js-string']} : {};
21+
const builtins = {builtins: ['js-string']};
3422
return new CompiledApp(await WebAssembly.compile(bytes, builtins), builtins);
3523
}
3624

0 commit comments

Comments
 (0)