d0e0290702
When there's no expression on the stack but we expect something on the
stack, then the code should be unreachable.
Though the current code would just synthesize a value that matches
the expected type (`convertType(voidMarker, <some type>)`). This
is problematic: If we ever used that synthesized value we may
have incorrect program behavior.
Now there were some valid uses where we synthesize values
* A function that has `void` return type but no explicit return
=> Here we should synthesize `null`
* Synthesize `null` in cases where we know it's not going to be used
=> e.g. for CFE desugaring of `a[i] = b` is roughly
`let tmp = b in (let ignored = a.[]=(tmp) in b)`
where we synthesize `null` as `a.[]=(tmp)` result,
`ignored` isn't used.
* ...
With this CL we no longer allow synthesizing a value of a type
out of thin air, instead all the places where this occurs have
to do that explicitly.
There's some impurities around how setters and index setters
are handled today (and even after this CL). Those impurities
start all the way at CFE, which treats setters and index
setters very differently. See the CFE issue [0].
For those we have two choices:
* special case all call sites that require synthesizing
null values
* special case all call sites that require dropping an
auto synthesized null value
This CL now marks instance setter/index-setter methods as
requiring auto-synthesizeing null values on usage sites and
make code that doesn't need them explicitly drop them.
Somewhat related to this change is how we deal with `void`
on the Dart <-> Wasm Import / Wasm Export boundary: When we
call an imported wasm function that has `void` as return
type (meaning no return values) we have to synthesize a `null`
(as the caller may "use"/"observe" the `void`).
=> We now are more strict and instead use `WasmVoid` as type
instead of allowing `void` as type on the import/export
functions.
[0] https://github.com/dart-lang/sdk/issues/63360
Change-Id: Ie30df3bd68553724437607bab3163c98f5467efe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501061
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
80 lines
3.0 KiB
WebAssembly Text Format
80 lines
3.0 KiB
WebAssembly Text Format
(module $module0
|
|
(type $"dummy struct" <...>)
|
|
(type $#Closure-0-0 <...>)
|
|
(type $#Closure-0-2 (sub final $#Closure-0-0 (struct
|
|
(field $field0 i32)
|
|
(field $field1 (mut i32))
|
|
(field $context (ref struct))
|
|
(field $vtable (ref $#Vtable-0-2))
|
|
(field $functionType (ref $_FunctionType)))))
|
|
(type $#Top <...>)
|
|
(type $#Vtable-0-2 (sub final $"dummy struct" (struct
|
|
(field $closureCallEntry-0-1 (ref $type0))
|
|
(field $closureCallEntry-0-2 (ref $type2)))))
|
|
(type $Array<_NamedParameter> <...>)
|
|
(type $Array<_Type> <...>)
|
|
(type $_FunctionType <...>)
|
|
(type $_InterfaceType <...>)
|
|
(type $_TopType <...>)
|
|
(type $type0 <...>)
|
|
(type $type2 <...>)
|
|
(global $"WasmArray<_NamedParameter>[0]" (ref $Array<_NamedParameter>) <...>)
|
|
(global $"WasmArray<_Type>[0]" (ref $Array<_Type>) <...>)
|
|
(global $"bar tear-off" (ref $#Closure-0-2)
|
|
(i32.const 47)
|
|
(i32.const 0)
|
|
(global.get $global0)
|
|
(ref.func $"bar tear-off trampoline")
|
|
(ref.func $"bar tear-off trampoline_119")
|
|
(struct.new $#Vtable-0-2)
|
|
(i32.const 11)
|
|
(i32.const 0)
|
|
(i32.const 0)
|
|
(global.get $"WasmArray<_Type>[0]")
|
|
(global.get $"WasmArray<_Type>[0]")
|
|
(global.get $_TopType_290)
|
|
(global.get $_InterfaceType_29)
|
|
(i32.const 9)
|
|
(i32.const 0)
|
|
(i32.const 1)
|
|
(i32.const 126)
|
|
(global.get $"WasmArray<_Type>[0]")
|
|
(struct.new $_InterfaceType)
|
|
(array.new_fixed $Array<_Type> 2)
|
|
(i64.const 1)
|
|
(global.get $"WasmArray<_NamedParameter>[0]")
|
|
(struct.new $_FunctionType)
|
|
(struct.new $#Closure-0-2))
|
|
(global $"foo tear-off" (ref $#Closure-0-2)
|
|
(i32.const 47)
|
|
(i32.const 0)
|
|
(global.get $global0)
|
|
(ref.func $"foo tear-off trampoline")
|
|
(ref.func $"foo tear-off trampoline_115")
|
|
(struct.new $#Vtable-0-2)
|
|
(i32.const 11)
|
|
(i32.const 0)
|
|
(i32.const 0)
|
|
(global.get $"WasmArray<_Type>[0]")
|
|
(global.get $"WasmArray<_Type>[0]")
|
|
(global.get $_TopType_290)
|
|
(global.get $_InterfaceType_29)
|
|
(i32.const 9)
|
|
(i32.const 0)
|
|
(i32.const 1)
|
|
(i32.const 143)
|
|
(global.get $"WasmArray<_Type>[0]")
|
|
(struct.new $_InterfaceType)
|
|
(array.new_fixed $Array<_Type> 2)
|
|
(i64.const 1)
|
|
(global.get $"WasmArray<_NamedParameter>[0]")
|
|
(struct.new $_FunctionType)
|
|
(struct.new $#Closure-0-2))
|
|
(global $_InterfaceType_29 (ref $_InterfaceType) <...>)
|
|
(global $_TopType_290 (ref $_TopType) <...>)
|
|
(global $global0 (ref $"dummy struct") <...>)
|
|
(func $bar tear-off trampoline (param $var0 (ref struct)) (param $var1 (ref null $#Top)) (result (ref null $#Top)) <...>)
|
|
(func $bar tear-off trampoline_119 (param $var0 (ref struct)) (param $var1 (ref null $#Top)) (param $var2 (ref null $#Top)) (result (ref null $#Top)) <...>)
|
|
(func $foo tear-off trampoline (param $var0 (ref struct)) (param $var1 (ref null $#Top)) (result (ref null $#Top)) <...>)
|
|
(func $foo tear-off trampoline_115 (param $var0 (ref struct)) (param $var1 (ref null $#Top)) (param $var2 (ref null $#Top)) (result (ref null $#Top)) <...>)
|
|
) |