-
Notifications
You must be signed in to change notification settings - Fork 838
Open
Description
Consider the larger wasm snippet below. There are multiple instances of the same group of instructions:
local.get $var0
struct.get $#Top $field0
$var0 doesn't change between these struct.gets. I would expect wasm-opt to be able to identify this, do the lookup once and store it in a local prior to entering the block. This would save both code size and performance. We have some functions with hundreds of these patterns so the code size savings from this could be significant.
...
block $label1
block $label0 (result (ref $#Top))
local.get $var0
br_on_non_null $label0
local.get $var0
global.get $C6307 SymbolConstant(#[]=)
local.get $var4
call $_typeArgumentsToList
local.get $var3
call $_positionalParametersToList
local.get $var10
call $_namedParametersToMap
call $_Invocation.method
call $NoSuchMethodError._throwWithInvocation
unreachable
end $label0
local.tee $var0
struct.get $#Top $field0
i32.const 15
i32.eq
br_if $label1
local.get $var0
struct.get $#Top $field0
i32.const 16
i32.eq
if
local.get $var0
ref.as_non_null
local.get $var4
local.get $var3
global.get $C5979 WasmArray<Object>[0]
call $__ConstMap&_HashFieldBase&MapMixin&_HashBase&_OperatorEqualsAndHashCode&_LinkedHashMapMixin&_MapCreateIndexMixin&_UnmodifiableMapMixin.[]= invocation type checker
drop
return
end
local.get $var0
struct.get $#Top $field0
i32.const 17
i32.eq
br_if $label1
local.get $var0
struct.get $#Top $field0
i32.const 18
i32.eq
if
local.get $var0
ref.as_non_null
local.get $var4
local.get $var3
global.get $C5979 WasmArray<Object>[0]
i32.const 0
call_indirect (param (ref $#Top) (ref $Array<_Type>) (ref $Array<Object?>) (ref $Array<Object?>)) (result (ref null $#Top)) $&
drop
return
end
local.get $var0
struct.get $#Top $field0
i32.const 51
i32.eq
if
local.get $var0
ref.as_non_null
local.get $var4
local.get $var3
global.get $C5979 WasmArray<Object>[0]
call $CrossappCacheStorage.[]= invocation type checker
drop
return
end
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels