Description
I try compiling Dart to Wasm according to the tutorial on the website WebAssembly (Wasm) compilation.
After disassembling the generated main.wasm
file using wasm-dis
, I found that the types in several recgroups are not mutually recursive. They all seem to be able to be split into two separate types, which provides the possibility for deduplicating the types.
(rec
(type $173 (struct))
(type $174 (func (param i64 i64 (ref null $3)) (result (ref $37))))
)
(rec
(type $175 (struct))
(type $176 (func (param (ref $1) (ref $11))))
)
(rec
(type $177 (struct))
(type $178 (func (param (ref $2)) (result i32)))
)
(rec
(type $179 (struct))
(type $180 (func (result (ref $2))))
)
$ dart --version
Dart SDK version: 3.7.2 (stable) (Tue Mar 11 04:27:50 2025 -0700) on "linux_x64"
To my understanding, only when two types are mutually recursive is it necessary to place them in the same recgroup.
(rec
(type $t1 (struct (field i32 (ref $t2))))
(type $t2 (struct (field i64 (ref $t1))))
)
Otherwise, they can be split into two separate recursive groups containing just one type.
(type $173 (struct))
(type $174 (func (param i64 i64 (ref null $3)) (result (ref $37))))
(type $176 (func (param (ref $1) (ref $11))))
(type $178 (func (param (ref $2)) (result i32)))
(type $180 (func (result (ref $2))))
Previously I obtained dozens of files named "main.dart.wasm" from the web, and after decompiling several of them, I found that this issue existed in all of those decompiled files.
I'm wondering if this was done intentionally. If so, what was the reason behind it? Or is it something that hasn't been fully optimized yet?