Files
sdk/pkg/dart2wasm/test/ir_tests/pure_function.wat
T
Simon Binder 58f9d88fb2 [dart2wasm, standalone] Migrate String
This migrates the `String` implementation from using JS interop to
explicit host imports for the standalone target.

This moves a few helper methods shared between the JS and standalone
targets to `dart:_string_helper`. This also moves the embedder regexp
implementation to `dart:_string` to be able to access internals in some
string methods (similar to how the JS implementation special-cases
`JSSyntaxRegExp`).

This removes the final real use of JS-interop in the standalone target.
So, we can:

 - Remove internal JS helper libraries from the target.
 - Skip JS-interop transformations in the compiler.
 - Stop emitting a helper module and support script.

Because `js_interop` is imported in `dart:_wasm`, we can't remove the
library entirely. This replaces it with a stub to avoid compilation
errors, a proper removal is tracked in dartbug.com/63166.

Change-Id: Ide495c210c3a272438deebf8fe4f3f44ba314ffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-20 00:22:27 -07:00

41 lines
1.4 KiB
WebAssembly Text Format

(module $$
(type $#Top <...>)
(type $BoxedInt <...>)
(type $JSExternWrapper <...>)
(@binaryen.removable.if.unused)
(func $"wasm:js-string.length (import)" (import "wasm:js-string" "length") (param externref) (result i32))
(global $"\")\"" (ref $JSExternWrapper) <...>)
(global $"\"3\"" (ref $JSExternWrapper) <...>)
(global $"\"4\"" (ref $JSExternWrapper) <...>)
(global $"\"bar(\"" (ref $JSExternWrapper) <...>)
(global $"\"foo(\"" (ref $JSExternWrapper) <...>)
(@binaryen.removable.if.unused)
(func $"foo <noInline>" (param $var0 (ref $JSExternWrapper)) (result (ref $BoxedInt))
global.get $"\"foo(\""
local.get $var0
global.get $"\")\""
call $JSStringImpl._interpolate3
drop
global.get $"\"bar(\""
local.get $var0
global.get $"\")\""
call $JSStringImpl._interpolate3
drop
i32.const 84
local.get $var0
struct.get $JSExternWrapper $_externRef
call $"wasm:js-string.length (import)"
i64.extend_i32_u
struct.new $BoxedInt
)
(func $"runApp <noInline>"
global.get $"\"3\""
call $"foo <noInline>"
call $print
global.get $"\"4\""
call $"foo <noInline>"
call $print
)
(func $JSStringImpl._interpolate3 (param $var0 (ref $JSExternWrapper)) (param $var1 (ref $#Top)) (param $var2 (ref $JSExternWrapper)) (result (ref $JSExternWrapper)) <...>)
(func $print (param $var0 (ref $#Top)) <...>)
)