optimize logical and/or, initial null checking in flows

This commit is contained in:
dcode
2019-04-09 03:04:45 +02:00
parent c16c19e18d
commit da4a7751fd
73 changed files with 5920 additions and 6866 deletions

View File

@ -39,19 +39,15 @@
(export "$.collect" (func $~lib/runtime/runtime.collect))
(start $start)
(func $~lib/runtime/runtime.flags (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
local.tee $1
i32.eqz
if
if (result i32)
local.get $0
i32.const 176
i32.load
i32.gt_u
local.set $1
else
i32.const 1
end
local.get $1
if (result i32)
unreachable
else
@ -940,7 +936,7 @@
i32.load
i32.le_u
else
local.get $0
i32.const 0
end
if
loop $continue|0
@ -1128,7 +1124,7 @@
(local $5 i32)
local.get $1
i32.load
local.tee $2
local.tee $3
i32.const 1
i32.and
i32.eqz
@ -1140,20 +1136,19 @@
call $~lib/builtins/abort
unreachable
end
local.get $2
local.get $3
i32.const -4
i32.and
local.tee $3
local.tee $2
i32.const 16
i32.ge_u
local.tee $2
if
local.get $3
if (result i32)
local.get $2
i32.const 1073741824
i32.lt_u
local.set $2
else
i32.const 0
end
local.get $2
i32.eqz
if
i32.const 0
@ -1163,67 +1158,67 @@
call $~lib/builtins/abort
unreachable
end
local.get $3
local.get $2
i32.const 256
i32.lt_u
if (result i32)
local.get $3
local.get $2
i32.const 8
i32.div_u
local.set $4
i32.const 0
else
local.get $3
local.get $3
local.get $2
local.get $2
call $~lib/allocator/tlsf/fls<usize>
local.tee $2
local.tee $3
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $4
local.get $2
local.get $3
i32.const 7
i32.sub
end
local.set $2
local.set $3
local.get $1
i32.load offset=8
local.set $3
local.set $2
local.get $1
i32.load offset=4
local.tee $5
if
local.get $5
local.get $3
local.get $2
i32.store offset=8
end
local.get $3
local.get $2
if
local.get $3
local.get $2
local.get $5
i32.store offset=4
end
local.get $0
local.get $2
local.get $3
local.get $4
call $~lib/allocator/tlsf/Root#getHead
local.get $1
i32.eq
if
local.get $0
local.get $2
local.get $3
local.get $4
local.get $3
local.get $2
call $~lib/allocator/tlsf/Root#setHead
local.get $3
local.get $2
i32.eqz
if
local.get $0
local.get $2
local.get $3
local.get $0
local.get $2
local.get $3
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 1
local.get $4
@ -1240,7 +1235,7 @@
local.get $0
i32.load
i32.const 1
local.get $2
local.get $3
i32.shl
i32.const -1
i32.xor
@ -1342,7 +1337,7 @@
end
local.get $1
i32.load
local.tee $3
local.tee $2
i32.const 1
i32.and
i32.eqz
@ -1358,17 +1353,16 @@
i32.load
i32.const -4
i32.and
local.tee $4
local.tee $3
i32.const 16
i32.ge_u
local.tee $2
if
local.get $4
if (result i32)
local.get $3
i32.const 1073741824
i32.lt_u
local.set $2
else
i32.const 0
end
local.get $2
i32.eqz
if
i32.const 0
@ -1380,7 +1374,7 @@
end
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $2
local.tee $3
i32.eqz
if
i32.const 0
@ -1390,14 +1384,14 @@
call $~lib/builtins/abort
unreachable
end
local.get $2
local.get $3
i32.load
local.tee $4
i32.const 1
i32.and
if
local.get $0
local.get $2
local.get $3
call $~lib/allocator/tlsf/Root#remove
local.get $1
local.get $4
@ -1405,17 +1399,17 @@
i32.and
i32.const 8
i32.add
local.get $3
local.get $2
i32.add
local.tee $3
local.tee $2
i32.store
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $2
local.tee $3
i32.load
local.set $4
end
local.get $3
local.get $2
i32.const 2
i32.and
if
@ -1449,38 +1443,37 @@
local.get $1
call $~lib/allocator/tlsf/Root#remove
local.get $1
local.get $3
local.get $2
i32.const -4
i32.and
i32.const 8
i32.add
local.get $5
i32.add
local.tee $3
local.tee $2
i32.store
end
local.get $2
local.get $3
local.get $4
i32.const 2
i32.or
i32.store
local.get $1
local.get $2
call $~lib/allocator/tlsf/Root#setJump
local.get $3
call $~lib/allocator/tlsf/Root#setJump
local.get $2
i32.const -4
i32.and
local.tee $3
local.tee $2
i32.const 16
i32.ge_u
local.tee $2
if
local.get $3
if (result i32)
local.get $2
i32.const 1073741824
i32.lt_u
local.set $2
else
i32.const 0
end
local.get $2
i32.eqz
if
i32.const 0
@ -1491,32 +1484,32 @@
unreachable
end
local.get $0
local.get $3
local.get $2
i32.const 256
i32.lt_u
if (result i32)
local.get $3
local.get $2
i32.const 8
i32.div_u
local.set $3
local.set $2
i32.const 0
else
local.get $3
local.get $3
local.get $2
local.get $2
call $~lib/allocator/tlsf/fls<usize>
local.tee $2
local.tee $3
i32.const 5
i32.sub
i32.shr_u
i32.const 32
i32.xor
local.set $3
local.get $2
local.set $2
local.get $3
i32.const 7
i32.sub
end
local.tee $2
local.get $3
local.tee $3
local.get $2
call $~lib/allocator/tlsf/Root#getHead
local.set $4
local.get $1
@ -1532,25 +1525,25 @@
i32.store offset=4
end
local.get $0
local.get $2
local.get $3
local.get $2
local.get $1
call $~lib/allocator/tlsf/Root#setHead
local.get $0
local.get $0
i32.load
i32.const 1
local.get $2
local.get $3
i32.shl
i32.or
i32.store
local.get $0
local.get $2
local.get $3
local.get $0
local.get $2
local.get $3
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 1
local.get $3
local.get $2
i32.shl
i32.or
call $~lib/allocator/tlsf/Root#setSLMap
@ -1696,16 +1689,13 @@
(local $2 i32)
(local $3 i32)
local.get $1
i32.const 1073741824
i32.lt_u
i32.const 0
local.get $1
i32.const 16
i32.ge_u
local.tee $2
if
local.get $1
i32.const 1073741824
i32.lt_u
local.set $2
end
local.get $2
select
i32.eqz
if
i32.const 0
@ -1719,8 +1709,6 @@
i32.const 256
i32.lt_u
if (result i32)
i32.const 0
local.set $2
local.get $1
i32.const 8
i32.div_u
@ -1809,7 +1797,7 @@
(local $4 i32)
local.get $1
i32.load
local.tee $4
local.tee $3
i32.const 1
i32.and
i32.eqz
@ -1822,16 +1810,13 @@
unreachable
end
local.get $2
i32.const 1073741824
i32.lt_u
i32.const 0
local.get $2
i32.const 16
i32.ge_u
local.tee $3
if
local.get $2
i32.const 1073741824
i32.lt_u
local.set $3
end
local.get $3
select
i32.eqz
if
i32.const 0
@ -1855,17 +1840,17 @@
local.get $0
local.get $1
call $~lib/allocator/tlsf/Root#remove
local.get $4
local.get $3
i32.const -4
i32.and
local.get $2
i32.sub
local.tee $3
local.tee $4
i32.const 24
i32.ge_u
if
local.get $1
local.get $4
local.get $3
i32.const 2
i32.and
local.get $2
@ -1877,7 +1862,7 @@
local.get $2
i32.add
local.tee $2
local.get $3
local.get $4
i32.const 8
i32.sub
i32.const 1
@ -1888,7 +1873,7 @@
call $~lib/allocator/tlsf/Root#insert
else
local.get $1
local.get $4
local.get $3
i32.const -2
i32.and
i32.store
@ -1925,18 +1910,17 @@
if
i32.const 1
current_memory
local.tee $1
i32.gt_s
local.tee $2
i32.gt_s
if (result i32)
i32.const 1
local.get $1
local.get $2
i32.sub
grow_memory
i32.const 0
i32.lt_s
else
local.get $2
i32.const 0
end
if
unreachable
@ -1951,8 +1935,6 @@
i32.const 656
i32.const 0
i32.store
i32.const 0
local.set $1
loop $repeat|0
local.get $1
i32.const 22
@ -2296,19 +2278,17 @@
i32.store offset=8
)
(func $~lib/collector/itcm/__ref_link (; 63 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
call $~lib/collector/itcm/maybeInit
global.get $~lib/collector/itcm/white
i32.eqz
local.get $1
i32.const 16
i32.sub
local.tee $2
local.tee $1
i32.load offset=8
i32.const 3
i32.and
i32.eq
local.tee $1
if (result i32)
global.get $~lib/collector/itcm/white
local.get $0
@ -2319,10 +2299,10 @@
i32.and
i32.eq
else
local.get $1
i32.const 0
end
if
local.get $2
local.get $1
call $~lib/collector/itcm/ManagedObject#makeGray
end
)
@ -2333,15 +2313,13 @@
(local $5 i32)
local.get $0
local.tee $3
i32.eqz
local.tee $0
if (result i32)
local.get $0
else
local.get $3
i32.const 176
i32.load
i32.gt_u
else
i32.const 1
end
if (result i32)
unreachable

View File

@ -58,14 +58,12 @@
(start $start)
(func $~lib/runtime/runtime.flags (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
global.get $~lib/runtime/RTTI_BASE
local.set $1
local.get $0
i32.eqz
local.tee $2
if (result i32)
local.get $2
i32.const 1
else
local.get $0
local.get $1
@ -845,7 +843,7 @@
i32.load
i32.le_u
else
local.get $2
i32.const 0
end
if
loop $continue|0
@ -1093,13 +1091,12 @@
local.get $3
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
i32.ge_u
local.tee $4
if (result i32)
local.get $3
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.lt_u
else
local.get $4
i32.const 0
end
i32.eqz
if
@ -1115,17 +1112,17 @@
i32.lt_u
if
i32.const 0
local.set $5
local.set $4
local.get $3
i32.const 8
i32.div_u
local.set $6
local.set $5
else
local.get $3
call $~lib/allocator/tlsf/fls<usize>
local.set $5
local.set $4
local.get $3
local.get $5
local.get $4
global.get $~lib/allocator/tlsf/SL_BITS
i32.sub
i32.shr_u
@ -1133,70 +1130,70 @@
global.get $~lib/allocator/tlsf/SL_BITS
i32.shl
i32.xor
local.set $6
local.get $5
local.set $5
local.get $4
global.get $~lib/allocator/tlsf/SB_BITS
i32.const 1
i32.sub
i32.sub
local.set $5
local.set $4
end
local.get $1
i32.load offset=4
local.set $7
local.set $6
local.get $1
i32.load offset=8
local.set $8
local.set $7
local.get $6
if
local.get $6
local.get $7
i32.store offset=8
end
local.get $7
if
local.get $7
local.get $8
i32.store offset=8
end
local.get $8
if
local.get $8
local.get $7
local.get $6
i32.store offset=4
end
local.get $1
local.get $0
local.get $4
local.get $5
local.get $6
call $~lib/allocator/tlsf/Root#getHead
i32.eq
if
local.get $0
local.get $4
local.get $5
local.get $6
local.get $8
local.get $7
call $~lib/allocator/tlsf/Root#setHead
local.get $8
local.get $7
i32.eqz
if
local.get $0
local.get $5
call $~lib/allocator/tlsf/Root#getSLMap
local.set $4
local.get $0
local.get $5
local.get $4
call $~lib/allocator/tlsf/Root#getSLMap
local.set $8
local.get $0
local.get $4
local.get $8
i32.const 1
local.get $6
local.get $5
i32.shl
i32.const -1
i32.xor
i32.and
local.tee $4
local.tee $8
call $~lib/allocator/tlsf/Root#setSLMap
local.get $4
local.get $8
i32.eqz
if
local.get $0
local.get $0
i32.load
i32.const 1
local.get $5
local.get $4
i32.shl
i32.const -1
i32.xor
@ -1328,13 +1325,12 @@
local.tee $3
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
i32.ge_u
local.tee $4
if (result i32)
local.get $3
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.lt_u
else
local.get $4
i32.const 0
end
i32.eqz
if
@ -1461,13 +1457,12 @@
local.get $3
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
i32.ge_u
local.tee $7
if (result i32)
local.get $3
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.lt_u
else
local.get $7
i32.const 0
end
i32.eqz
if
@ -1745,13 +1740,12 @@
local.get $1
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
i32.ge_u
local.tee $2
if (result i32)
local.get $1
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.lt_u
else
local.get $2
i32.const 0
end
i32.eqz
if
@ -1767,17 +1761,17 @@
i32.lt_u
if
i32.const 0
local.set $3
local.set $2
local.get $1
i32.const 8
i32.div_u
local.set $4
local.set $3
else
local.get $1
call $~lib/allocator/tlsf/fls<usize>
local.set $3
local.set $2
local.get $1
local.get $3
local.get $2
global.get $~lib/allocator/tlsf/SL_BITS
i32.sub
i32.shr_u
@ -1785,43 +1779,43 @@
global.get $~lib/allocator/tlsf/SL_BITS
i32.shl
i32.xor
local.set $4
local.get $3
local.set $3
local.get $2
global.get $~lib/allocator/tlsf/SB_BITS
i32.const 1
i32.sub
i32.sub
local.set $3
local.get $4
local.set $2
local.get $3
global.get $~lib/allocator/tlsf/SL_SIZE
i32.const 1
i32.sub
i32.lt_u
if
local.get $4
i32.const 1
i32.add
local.set $4
else
local.get $3
i32.const 1
i32.add
local.set $3
else
local.get $2
i32.const 1
i32.add
local.set $2
i32.const 0
local.set $4
local.set $3
end
end
local.get $0
local.get $3
local.get $2
call $~lib/allocator/tlsf/Root#getSLMap
i32.const 0
i32.const -1
i32.xor
local.get $4
local.get $3
i32.shl
i32.and
local.set $5
local.get $5
local.set $4
local.get $4
i32.eqz
if
local.get $0
@ -1829,23 +1823,23 @@
i32.const 0
i32.const -1
i32.xor
local.get $3
local.get $2
i32.const 1
i32.add
i32.shl
i32.and
local.set $2
local.get $2
local.set $6
local.get $6
i32.eqz
if
i32.const 0
local.set $6
local.set $5
else
local.get $2
local.get $6
call $~lib/allocator/tlsf/ffs<usize>
local.set $3
local.set $2
local.get $0
local.get $3
local.get $2
call $~lib/allocator/tlsf/Root#getSLMap
local.tee $7
if (result i32)
@ -1858,23 +1852,23 @@
call $~lib/builtins/abort
unreachable
end
local.set $5
local.set $4
local.get $0
local.get $3
local.get $5
local.get $2
local.get $4
call $~lib/allocator/tlsf/ffs<u32>
call $~lib/allocator/tlsf/Root#getHead
local.set $6
local.set $5
end
else
local.get $0
local.get $3
local.get $5
local.get $2
local.get $4
call $~lib/allocator/tlsf/ffs<u32>
call $~lib/allocator/tlsf/Root#getHead
local.set $6
local.set $5
end
local.get $6
local.get $5
)
(func $~lib/allocator/tlsf/Root#use (; 56 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
@ -1898,13 +1892,12 @@
local.get $2
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
i32.ge_u
local.tee $4
if (result i32)
local.get $2
global.get $~lib/allocator/tlsf/Block.MAX_SIZE
i32.lt_u
else
local.get $4
i32.const 0
end
i32.eqz
if
@ -1938,8 +1931,8 @@
i32.and
local.get $2
i32.sub
local.set $5
local.get $5
local.set $4
local.get $4
global.get $~lib/allocator/tlsf/Block.INFO
global.get $~lib/allocator/tlsf/Block.MIN_SIZE
i32.add
@ -1957,16 +1950,16 @@
i32.add
local.get $2
i32.add
local.set $4
local.get $4
local.set $5
local.get $5
local.get $4
global.get $~lib/allocator/tlsf/Block.INFO
i32.sub
global.get $~lib/allocator/tlsf/FREE
i32.or
i32.store
local.get $0
local.get $4
local.get $5
call $~lib/allocator/tlsf/Root#insert
else
local.get $1
@ -1978,7 +1971,7 @@
i32.store
local.get $1
call $~lib/allocator/tlsf/Block#get:right
local.tee $4
local.tee $5
i32.eqz
if (result i32)
i32.const 0
@ -1988,11 +1981,11 @@
call $~lib/builtins/abort
unreachable
else
local.get $4
local.get $5
end
local.set $4
local.get $4
local.get $4
local.set $5
local.get $5
local.get $5
i32.load
global.get $~lib/allocator/tlsf/LEFT_FREE
i32.const -1
@ -2042,7 +2035,6 @@
local.get $4
local.get $3
i32.gt_s
local.tee $5
if (result i32)
local.get $4
local.get $3
@ -2051,7 +2043,7 @@
i32.const 0
i32.lt_s
else
local.get $5
i32.const 0
end
if
unreachable
@ -2501,7 +2493,6 @@
global.get $~lib/collector/itcm/white
i32.eqz
i32.eq
local.tee $2
if (result i32)
block $~lib/collector/itcm/refToObj|inlined.3 (result i32)
local.get $0
@ -2514,7 +2505,7 @@
global.get $~lib/collector/itcm/white
i32.eq
else
local.get $2
i32.const 0
end
if
local.get $3

View File

@ -239,7 +239,7 @@
i32.load
i32.le_u
else
local.get $0
i32.const 0
end
if
loop $continue|0
@ -669,19 +669,15 @@
end
)
(func $~lib/runtime/runtime.flags (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
i32.eqz
local.tee $1
i32.eqz
if
if (result i32)
local.get $0
i32.const 280
i32.load
i32.gt_u
local.set $1
else
i32.const 1
end
local.get $1
if (result i32)
unreachable
else
@ -759,15 +755,13 @@
(local $6 i32)
local.get $0
local.tee $3
i32.eqz
local.tee $0
if (result i32)
local.get $0
else
local.get $3
i32.const 280
i32.load
i32.gt_u
else
i32.const 1
end
if (result i32)
unreachable

View File

@ -290,7 +290,7 @@
i32.load
i32.le_u
else
local.get $2
i32.const 0
end
if
loop $continue|0
@ -826,14 +826,12 @@
)
(func $~lib/runtime/runtime.flags (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
global.get $~lib/runtime/RTTI_BASE
local.set $1
local.get $0
i32.eqz
local.tee $2
if (result i32)
local.get $2
i32.const 1
else
local.get $0
local.get $1