Files
sdk/pkg/dart2wasm/test/ir_tests/deferred.constant.multi_module_use_module2.wat
T
Martin Kustermann e3cf529f87 [dart2wasm] More compact encoding of deferred load lists
Measured on size of e main module (baseline is we don't embed
it in application code):

* embedding before: +16.5% uncompressed / +9.1% compressed
* embedding with this CL: +4% uncompressed / +4.3% compressed

When embeddeding deferred load list information into the app
(as opposed to a separate json file) we now use a more compact
encoding.

Specifically: Instead of encoding it as an array of an array of
strings (which are module names), we encode it as an array of an
array of module ids and construct the module name from the id.

To make the array of module ids more compact we utilize the fact
that we can sort them and encode in delta encoding (i.e. instead
of absolute module ids, encode the diff between previous module
id in the list).

We put the encoded module id lists in a data section and create
`WasmArray<WasmI8>`s from them at startup. When we trigger a load
we then decode them into the list of module names.

There's more opportunity to optimize it, but it's good to do
this as a first step.

Change-Id: I293fb8879d992fc370786f6c9b258ccd27e1559b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508980
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-06-05 00:50:46 -07:00

36 lines
1.1 KiB
WebAssembly Text Format

(module $module2
(type $#Top (struct
(field $field0 i32)))
(type $JSExternWrapper (sub $Object (struct
(field $field0 i32)
(field $field1 (mut i32))
(field $_externRef externref))))
(type $MyConstClass (sub final $Object (struct
(field $field0 i32)
(field $field1 (mut i32))
(field $b (ref $JSExternWrapper)))))
(type $Object (sub $#Top (struct
(field $field0 i32)
(field $field1 (mut i32)))))
(global $.h0-nonshared-const (import "" "h0-nonshared-const") (ref extern))
(table $module0.cross-module-funcs-0 (import "module0" "cross-module-funcs-0") 17 funcref)
(global $MyConstClass (ref $MyConstClass)
(i32.const 109)
(i32.const 0)
(i32.const 60)
(i32.const 0)
(global.get $.h0-nonshared-const)
(struct.new $JSExternWrapper)
(struct.new $MyConstClass))
(elem $module0.cross-module-funcs-0
(set 3 (ref.func $"modH0Use <noInline>")))
(func $"modH0Use <noInline>" (param $var0 i32) (result (ref $MyConstClass))
local.get $var0
if (result (ref $MyConstClass))
global.get $MyConstClass
else
i32.const 16
call_indirect (result (ref $MyConstClass))
end
)
)