Improve inlining where locals can be aliased; Add a crude mechanism for explicit unchecked array accesses

The `unchecked` builtin should be handled with ultimate care and it would be a lot better if there'd be a mechanism doing this automatically.
This commit is contained in:
dcodeIO
2018-04-25 05:04:35 +02:00
parent 391db28fe2
commit 6d6d1dddcf
47 changed files with 5374 additions and 15672 deletions

View File

@ -9388,19 +9388,19 @@
(local $10 i32)
(local $11 i32)
(local $12 f64)
(local $13 i32)
(local $14 f64)
(local $15 i32)
(local $13 f64)
(local $14 i32)
(local $15 f64)
(local $16 f64)
(local $17 f64)
(local $18 f64)
(local $19 i64)
(local $18 i64)
(local $19 i32)
(block $folding-inner1
(block $folding-inner0
(set_local $4
(set_local $19
(i32.wrap/i64
(i64.shr_u
(tee_local $19
(tee_local $18
(i64.reinterpret/f64
(get_local $0)
)
@ -9409,14 +9409,14 @@
)
)
)
(set_local $13
(set_local $7
(i32.wrap/i64
(get_local $19)
(get_local $18)
)
)
(set_local $5
(set_local $6
(i32.and
(get_local $4)
(get_local $19)
(i32.const 2147483647)
)
)
@ -9428,7 +9428,7 @@
(tee_local $11
(i32.wrap/i64
(i64.shr_u
(tee_local $19
(tee_local $18
(i64.reinterpret/f64
(get_local $1)
)
@ -9440,9 +9440,9 @@
(i32.const 2147483647)
)
)
(tee_local $6
(tee_local $4
(i32.wrap/i64
(get_local $19)
(get_local $18)
)
)
)
@ -9454,37 +9454,37 @@
(if
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.gt_s
(get_local $5)
(get_local $6)
(i32.const 2146435072)
)
)
(get_local $7)
(get_local $5)
(if (result i32)
(tee_local $7
(tee_local $5
(i32.eq
(get_local $5)
(get_local $6)
(i32.const 2146435072)
)
)
(i32.ne
(get_local $13)
(get_local $7)
(i32.const 0)
)
(get_local $7)
(get_local $5)
)
)
(i32.const 1)
)
)
(get_local $7)
(get_local $5)
(i32.gt_s
(get_local $10)
(i32.const 2146435072)
@ -9493,19 +9493,19 @@
(i32.const 1)
)
)
(get_local $7)
(get_local $5)
(if (result i32)
(tee_local $7
(tee_local $5
(i32.eq
(get_local $10)
(i32.const 2146435072)
)
)
(i32.ne
(get_local $6)
(get_local $4)
(i32.const 0)
)
(get_local $7)
(get_local $5)
)
)
(i32.const 1)
@ -9519,7 +9519,7 @@
)
(if
(i32.lt_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(if
@ -9527,7 +9527,7 @@
(get_local $10)
(i32.const 1128267776)
)
(set_local $15
(set_local $14
(i32.const 2)
)
(if
@ -9551,9 +9551,9 @@
(if
(i32.eq
(i32.shl
(tee_local $7
(tee_local $5
(i32.shr_u
(get_local $6)
(get_local $4)
(i32.sub
(i32.const 52)
(get_local $8)
@ -9565,13 +9565,13 @@
(get_local $8)
)
)
(get_local $6)
(get_local $4)
)
(set_local $15
(set_local $14
(i32.sub
(i32.const 2)
(i32.and
(get_local $7)
(get_local $5)
(i32.const 1)
)
)
@ -9579,12 +9579,12 @@
)
(if
(i32.eqz
(get_local $6)
(get_local $4)
)
(if
(i32.eq
(i32.shl
(tee_local $7
(tee_local $5
(i32.shr_s
(get_local $10)
(i32.sub
@ -9600,11 +9600,11 @@
)
(get_local $10)
)
(set_local $15
(set_local $14
(i32.sub
(i32.const 2)
(i32.and
(get_local $7)
(get_local $5)
(i32.const 1)
)
)
@ -9617,7 +9617,7 @@
)
(if
(i32.eqz
(get_local $6)
(get_local $4)
)
(block
(if
@ -9628,14 +9628,14 @@
(if
(i32.or
(i32.sub
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(get_local $13)
(get_local $7)
)
(if
(i32.ge_s
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(return
@ -9708,7 +9708,7 @@
)
(if
(i32.ge_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(return
@ -9727,31 +9727,31 @@
)
(if
(i32.eqz
(get_local $13)
(get_local $7)
)
(if
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.and
(if (result i32)
(tee_local $7
(tee_local $5
(i32.eq
(get_local $5)
(get_local $6)
(i32.const 2146435072)
)
)
(get_local $7)
(get_local $5)
(i32.eqz
(get_local $5)
(get_local $6)
)
)
(i32.const 1)
)
)
(get_local $7)
(get_local $5)
(i32.eq
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
)
@ -9772,20 +9772,20 @@
)
(if
(i32.lt_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(if
(i32.or
(i32.sub
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(get_local $15)
(get_local $14)
)
(if
(i32.eq
(get_local $15)
(get_local $14)
(i32.const 1)
)
(set_local $2
@ -9819,13 +9819,13 @@
)
(if
(i32.lt_s
(get_local $4)
(get_local $19)
(i32.const 0)
)
(block
(if
(i32.eqz
(get_local $15)
(get_local $14)
)
(return
(f64.div
@ -9842,7 +9842,7 @@
)
(if
(i32.eq
(get_local $15)
(get_local $14)
(i32.const 1)
)
(set_local $12
@ -9866,7 +9866,7 @@
(block
(if
(i32.le_s
(get_local $5)
(get_local $6)
(i32.const 1072693247)
)
(return
@ -9882,7 +9882,7 @@
)
(if
(i32.ge_s
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(return
@ -9900,7 +9900,7 @@
)
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(i32.const 1072693247)
)
(return
@ -9928,7 +9928,7 @@
)
(if
(i32.gt_s
(get_local $5)
(get_local $6)
(i32.const 1072693248)
)
(return
@ -9985,13 +9985,13 @@
(i64.and
(i64.reinterpret/f64
(f64.add
(tee_local $16
(tee_local $15
(f64.mul
(f64.const 1.4426950216293335)
(get_local $3)
)
)
(tee_local $17
(tee_local $16
(f64.sub
(f64.mul
(get_local $3)
@ -10010,10 +10010,10 @@
)
)
(f64.sub
(get_local $17)
(get_local $16)
(f64.sub
(get_local $9)
(get_local $16)
(get_local $15)
)
)
)
@ -10023,7 +10023,7 @@
)
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(i32.const 1048576)
)
(block
@ -10033,7 +10033,7 @@
(i32.const 53)
)
)
(set_local $5
(set_local $6
(i32.wrap/i64
(i64.shr_u
(i64.reinterpret/f64
@ -10055,18 +10055,18 @@
(get_local $4)
(i32.sub
(i32.shr_s
(get_local $5)
(get_local $6)
(i32.const 20)
)
(i32.const 1023)
)
)
)
(set_local $5
(set_local $6
(i32.or
(tee_local $6
(tee_local $7
(i32.and
(get_local $5)
(get_local $6)
(i32.const 1048575)
)
)
@ -10076,13 +10076,13 @@
(set_local $8
(if (result i32)
(i32.le_s
(get_local $6)
(get_local $7)
(i32.const 235662)
)
(i32.const 0)
(if (result i32)
(i32.lt_s
(get_local $6)
(get_local $7)
(i32.const 767610)
)
(i32.const 1)
@ -10093,9 +10093,9 @@
(i32.const 1)
)
)
(set_local $5
(set_local $6
(i32.add
(get_local $5)
(get_local $6)
(i32.const -1048576)
)
)
@ -10108,9 +10108,9 @@
(f64.reinterpret/i64
(i64.and
(i64.reinterpret/f64
(tee_local $18
(tee_local $17
(f64.mul
(tee_local $16
(tee_local $15
(f64.sub
(tee_local $2
(f64.reinterpret/i64
@ -10123,7 +10123,7 @@
)
(i64.shl
(i64.extend_u/i32
(get_local $5)
(get_local $6)
)
(i64.const 32)
)
@ -10139,7 +10139,7 @@
)
)
)
(tee_local $17
(tee_local $16
(f64.div
(f64.const 1)
(f64.add
@ -10167,7 +10167,7 @@
(i32.add
(i32.or
(i32.shr_s
(get_local $5)
(get_local $6)
(i32.const 1)
)
(i32.const 536870912)
@ -10194,34 +10194,34 @@
(f64.add
(f64.mul
(f64.mul
(tee_local $14
(tee_local $13
(f64.mul
(get_local $18)
(get_local $18)
(get_local $17)
(get_local $17)
)
)
(get_local $14)
(get_local $13)
)
(f64.add
(f64.const 0.5999999999999946)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.4285714285785502)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.33333332981837743)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.272728123808534)
(f64.mul
(get_local $14)
(get_local $13)
(f64.add
(f64.const 0.23066074577556175)
(f64.mul
(get_local $14)
(get_local $13)
(f64.const 0.20697501780033842)
)
)
@ -10237,10 +10237,10 @@
(f64.mul
(tee_local $0
(f64.mul
(get_local $17)
(get_local $16)
(f64.sub
(f64.sub
(get_local $16)
(get_local $15)
(f64.mul
(get_local $3)
(get_local $9)
@ -10255,7 +10255,7 @@
)
(f64.add
(get_local $3)
(get_local $18)
(get_local $17)
)
)
)
@ -10269,7 +10269,7 @@
(f64.add
(f64.add
(f64.const 3)
(tee_local $14
(tee_local $13
(f64.mul
(get_local $3)
(get_local $3)
@ -10285,7 +10285,7 @@
)
(f64.const 3)
)
(get_local $14)
(get_local $13)
)
)
)
@ -10296,7 +10296,7 @@
(f64.add
(f64.add
(f64.add
(tee_local $18
(tee_local $17
(f64.mul
(f64.const 0.9617967009544373)
(tee_local $0
@ -10304,13 +10304,13 @@
(i64.and
(i64.reinterpret/f64
(f64.add
(tee_local $16
(tee_local $15
(f64.mul
(get_local $3)
(get_local $9)
)
)
(tee_local $17
(tee_local $16
(f64.add
(f64.mul
(get_local $0)
@ -10318,7 +10318,7 @@
)
(f64.mul
(get_local $2)
(get_local $18)
(get_local $17)
)
)
)
@ -10339,10 +10339,10 @@
)
(f64.mul
(f64.sub
(get_local $17)
(get_local $16)
(f64.sub
(get_local $0)
(get_local $16)
(get_local $15)
)
)
(f64.const 0.9617966939259756)
@ -10385,16 +10385,16 @@
)
(get_local $0)
)
(get_local $18)
(get_local $17)
)
)
)
)
)
(set_local $6
(set_local $7
(i32.wrap/i64
(i64.shr_u
(tee_local $19
(tee_local $18
(i64.reinterpret/f64
(tee_local $2
(f64.add
@ -10436,24 +10436,24 @@
)
)
)
(set_local $13
(set_local $5
(i32.wrap/i64
(get_local $19)
(get_local $18)
)
)
(if
(i32.ge_s
(get_local $6)
(get_local $7)
(i32.const 1083179008)
)
(br_if $folding-inner1
(i32.or
(i32.or
(i32.sub
(get_local $6)
(get_local $7)
(i32.const 1083179008)
)
(get_local $13)
(get_local $5)
)
(f64.gt
(f64.add
@ -10470,7 +10470,7 @@
(if
(i32.ge_s
(i32.and
(get_local $6)
(get_local $7)
(i32.const 2147483647)
)
(i32.const 1083231232)
@ -10479,10 +10479,10 @@
(i32.or
(i32.or
(i32.sub
(get_local $6)
(get_local $7)
(i32.const -1064252416)
)
(get_local $13)
(get_local $5)
)
(f64.le
(get_local $1)
@ -10498,9 +10498,9 @@
(set_local $8
(i32.sub
(i32.shr_s
(tee_local $13
(tee_local $5
(i32.and
(get_local $6)
(get_local $7)
(i32.const 2147483647)
)
)
@ -10514,7 +10514,7 @@
)
(if
(i32.gt_s
(get_local $13)
(get_local $5)
(i32.const 1071644672)
)
(block
@ -10524,7 +10524,7 @@
(i32.and
(tee_local $4
(i32.add
(get_local $6)
(get_local $7)
(i32.shr_s
(i32.const 1048576)
(i32.add
@ -10577,7 +10577,7 @@
)
(if
(i32.lt_s
(get_local $6)
(get_local $7)
(i32.const 0)
)
(set_local $4
@ -10602,7 +10602,7 @@
(if (result f64)
(i32.le_s
(i32.shr_s
(tee_local $6
(tee_local $7
(i32.add
(i32.wrap/i64
(i64.shr_u
@ -10616,7 +10616,7 @@
(f64.mul
(tee_local $2
(f64.add
(tee_local $16
(tee_local $15
(f64.mul
(tee_local $3
(f64.reinterpret/i64
@ -10634,7 +10634,7 @@
(f64.const 0.6931471824645996)
)
)
(tee_local $17
(tee_local $16
(f64.add
(f64.mul
(f64.sub
@ -10701,10 +10701,10 @@
(f64.add
(tee_local $0
(f64.sub
(get_local $17)
(get_local $16)
(f64.sub
(get_local $2)
(get_local $16)
(get_local $15)
)
)
)
@ -10746,7 +10746,7 @@
)
(i64.shl
(i64.extend_u/i32
(get_local $6)
(get_local $7)
)
(i64.const 32)
)
@ -12414,7 +12414,6 @@
)
(func $std/math/test_sign (; 141 ;) (type $FFFii) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 i32) (result i32)
(local $4 i32)
(local $5 f64)
(i32.and
(if (result i32)
(tee_local $4
@ -12422,14 +12421,12 @@
(select
(f64.copysign
(f64.const 1)
(tee_local $5
(get_local $0)
)
(get_local $0)
)
(get_local $5)
(get_local $0)
(f64.gt
(f64.abs
(get_local $5)
(get_local $0)
)
(f64.const 0)
)
@ -12459,19 +12456,16 @@
)
)
(func $std/math/test_signf (; 142 ;) (type $fffii) (param $0 f32) (param $1 f32) (param $2 f32) (param $3 i32) (result i32)
(local $4 f32)
(call $std/math/check<f32>
(select
(f32.copysign
(f32.const 1)
(tee_local $4
(get_local $0)
)
(get_local $0)
)
(get_local $4)
(get_local $0)
(f32.gt
(f32.abs
(get_local $4)
(get_local $0)
)
(f32.const 0)
)
@ -44523,14 +44517,14 @@
(call $~lib/math/JSMath.random)
)
)
(set_local $0
(set_local $1
(i32.const 0)
)
(loop $continue|1
(if
(f64.lt
(f64.convert_s/i32
(get_local $0)
(get_local $1)
)
(f64.const 1e6)
)
@ -44539,7 +44533,7 @@
(i32.eqz
(i32.and
(if (result i32)
(tee_local $1
(tee_local $0
(f32.ge
(tee_local $3
(call $~lib/math/NativeMathf.random)
@ -44551,7 +44545,7 @@
(get_local $3)
(f32.const 1)
)
(get_local $1)
(get_local $0)
)
(i32.const 1)
)
@ -44566,9 +44560,9 @@
(unreachable)
)
)
(set_local $0
(set_local $1
(i32.add
(get_local $0)
(get_local $1)
(i32.const 1)
)
)