Open
Description
Due to our very conservative inlining, sometimes there's calls to functions we know have no effect. If the use-site doesn't use return value, then binaryen could eliminate those calls if we told it that they have no effect.
Example of this is is <type>
checkers: We call JSStringImpl._interpolate2
and TFA may infer an argument to be JSStringImpl
and another to be just Object?
. Now our wasm code may look like this
(func $JSStringImpl._interpolate2 (;29;) (param $var0 (ref $JSStringImpl)) (param $var1 (ref $#Top)) (result (ref $JSStringImpl))
local.get $var0
call $<obj> is String
drop
local.get $var0
struct.get $JSStringImpl $field1
local.get $var1
call $<obj> is String
if (result (ref $JSStringImpl))
local.get $var1
ref.cast $JSStringImpl
else
local.get $var1
local.get $var1
struct.get $#Top $field0
i32.const 236
i32.add
call_indirect (param (ref $#Top)) (result (ref $JSStringImpl))
end
struct.get $JSStringImpl $field1
call $wasm:js-string.concat (import)
call $JSStringImpl.fromRefUnchecked
)
Here the call $<obj> is String
could be dropped by binaryen if it knew it doesn't have an effect (arguably the dart2wasm compiler could also be smarter and not emit the check in the first place).