Some final tweaks to the examples

I promise
This commit is contained in:
dcodeIO
2018-04-20 18:56:51 +02:00
parent 4eade0f319
commit bde13b12cf
15 changed files with 2068 additions and 1487 deletions

View File

@ -1,16 +1,90 @@
(module
(type $iiv (func (param i32 i32)))
(type $F (func (result f64)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func))
(import "JSMath" "random" (func $~lib/math/JSMath.random (result f64)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $../../examples/game-of-life/assembly/index/w (mut i32) (i32.const 0))
(global $../../examples/game-of-life/assembly/index/h (mut i32) (i32.const 0))
(global $../../examples/game-of-life/assembly/index/s (mut i32) (i32.const 0))
(global $~lib/math/random_seeded (mut i32) (i32.const 0))
(global $~lib/math/random_state0 (mut i64) (i64.const 0))
(global $~lib/math/random_state1 (mut i64) (i64.const 0))
(memory $0 1)
(data (i32.const 4) "\0c\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s")
(export "init" (func $../../examples/game-of-life/assembly/index/init))
(export "step" (func $../../examples/game-of-life/assembly/index/step))
(export "memory" (memory $0))
(func $../../examples/game-of-life/assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32)
(func $~lib/math/NativeMath.random (; 1 ;) (type $F) (result f64)
(local $0 i64)
(local $1 i64)
(if
(i32.eqz
(get_global $~lib/math/random_seeded)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 1007)
(i32.const 24)
)
(unreachable)
)
)
(set_local $0
(get_global $~lib/math/random_state0)
)
(set_global $~lib/math/random_state0
(tee_local $1
(get_global $~lib/math/random_state1)
)
)
(set_global $~lib/math/random_state1
(tee_local $0
(i64.xor
(i64.xor
(i64.xor
(tee_local $0
(i64.xor
(get_local $0)
(i64.shl
(get_local $0)
(i64.const 23)
)
)
)
(i64.shr_u
(get_local $0)
(i64.const 17)
)
)
(get_local $1)
)
(i64.shr_u
(get_local $1)
(i64.const 26)
)
)
)
)
(f64.sub
(f64.reinterpret/i64
(i64.or
(i64.and
(i64.add
(get_local $1)
(get_local $0)
)
(i64.const 4503599627370495)
)
(i64.const 4607182418800017408)
)
)
(f64.const 1)
)
)
(func $../../examples/game-of-life/assembly/index/init (; 2 ;) (type $iiv) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -55,8 +129,8 @@
(set_local $4
(if (result i32)
(f64.gt
(call $~lib/math/JSMath.random)
(f64.const 0.15)
(call $~lib/math/NativeMath.random)
(f64.const 0.1)
)
(i32.const 8723366)
(i32.const -1666349)
@ -99,7 +173,7 @@
)
)
)
(func $../../examples/game-of-life/assembly/index/step (; 2 ;) (type $v)
(func $../../examples/game-of-life/assembly/index/step (; 3 ;) (type $v)
(local $0 i32)
(local $1 i32)
(local $2 i32)
@ -128,7 +202,7 @@
(get_global $../../examples/game-of-life/assembly/index/h)
)
(block
(set_local $5
(set_local $4
(select
(i32.sub
(get_local $0)
@ -138,7 +212,7 @@
(get_local $0)
)
)
(set_local $6
(set_local $5
(select
(i32.const 0)
(i32.add
@ -174,7 +248,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $5)
(get_local $4)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(tee_local $2
@ -198,7 +272,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $5)
(get_local $4)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $1)
@ -214,7 +288,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $5)
(get_local $4)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(tee_local $3
@ -274,7 +348,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $6)
(get_local $5)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $2)
@ -290,7 +364,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $6)
(get_local $5)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $1)
@ -306,7 +380,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $6)
(get_local $5)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $3)
@ -320,7 +394,7 @@
)
(if
(i32.and
(tee_local $4
(tee_local $3
(i32.load
(i32.shl
(i32.add
@ -360,25 +434,23 @@
)
(i32.or
(i32.shl
(tee_local $4
(tee_local $3
(select
(tee_local $4
(tee_local $3
(i32.sub
(i32.shr_u
(tee_local $2
(get_local $4)
(get_local $3)
)
(i32.const 24)
)
(i32.const 7)
(i32.const 10)
)
)
(tee_local $3
(i32.const 0)
)
(i32.const 0)
(i32.gt_s
(get_local $4)
(get_local $3)
(get_local $6)
)
)
)
@ -449,25 +521,23 @@
(tee_local $2
(i32.sub
(i32.shr_u
(get_local $4)
(get_local $3)
(i32.const 24)
)
(i32.const 7)
(i32.const 10)
)
)
(tee_local $3
(i32.const 0)
)
(i32.const 0)
(i32.gt_s
(get_local $2)
(get_local $3)
(get_local $6)
)
)
)
(i32.const 24)
)
(i32.and
(get_local $4)
(get_local $3)
(i32.const 16777215)
)
)

View File

@ -1,19 +1,109 @@
(module
(type $iiv (func (param i32 i32)))
(type $F (func (result f64)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $v (func))
(import "JSMath" "random" (func $~lib/math/JSMath.random (result f64)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $../../examples/game-of-life/assembly/index/RGB_ALIVE i32 (i32.const 15110867))
(global $../../examples/game-of-life/assembly/index/RGB_DEAD i32 (i32.const 8723366))
(global $../../examples/game-of-life/assembly/index/BIT_ROT i32 (i32.const 10))
(global $../../examples/game-of-life/assembly/index/w (mut i32) (i32.const 0))
(global $../../examples/game-of-life/assembly/index/h (mut i32) (i32.const 0))
(global $../../examples/game-of-life/assembly/index/s (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4))
(global $~lib/math/random_seeded (mut i32) (i32.const 0))
(global $~lib/math/random_state0 (mut i64) (i64.const 0))
(global $~lib/math/random_state1 (mut i64) (i64.const 0))
(global $HEAP_BASE i32 (i32.const 32))
(memory $0 1)
(data (i32.const 4) "\0c\00\00\00~\00l\00i\00b\00/\00m\00a\00t\00h\00.\00t\00s\00")
(export "init" (func $../../examples/game-of-life/assembly/index/init))
(export "step" (func $../../examples/game-of-life/assembly/index/step))
(export "memory" (memory $0))
(func $../../examples/game-of-life/assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32)
(func $~lib/math/NativeMath.random (; 1 ;) (type $F) (result f64)
(local $0 i64)
(local $1 i64)
(local $2 i64)
(if
(i32.eqz
(get_global $~lib/math/random_seeded)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 1007)
(i32.const 24)
)
(unreachable)
)
)
(set_local $0
(get_global $~lib/math/random_state0)
)
(set_local $1
(get_global $~lib/math/random_state1)
)
(set_global $~lib/math/random_state0
(get_local $1)
)
(set_local $0
(i64.xor
(get_local $0)
(i64.shl
(get_local $0)
(i64.const 23)
)
)
)
(set_local $0
(i64.xor
(get_local $0)
(i64.shr_u
(get_local $0)
(i64.const 17)
)
)
)
(set_local $0
(i64.xor
(get_local $0)
(get_local $1)
)
)
(set_local $0
(i64.xor
(get_local $0)
(i64.shr_u
(get_local $1)
(i64.const 26)
)
)
)
(set_global $~lib/math/random_state1
(get_local $0)
)
(set_local $2
(i64.or
(i64.and
(i64.add
(get_local $1)
(get_local $0)
)
(i64.const 4503599627370495)
)
(i64.const 4607182418800017408)
)
)
(return
(f64.sub
(f64.reinterpret/i64
(get_local $2)
)
(f64.const 1)
)
)
)
(func $../../examples/game-of-life/assembly/index/init (; 2 ;) (type $iiv) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -65,8 +155,8 @@
(set_local $6
(if (result i32)
(f64.gt
(call $~lib/math/JSMath.random)
(f64.const 0.15)
(call $~lib/math/NativeMath.random)
(f64.const 0.1)
)
(i32.and
(i32.const 8723366)
@ -120,7 +210,7 @@
)
)
)
(func $../../examples/game-of-life/assembly/index/step (; 2 ;) (type $v)
(func $../../examples/game-of-life/assembly/index/step (; 3 ;) (type $v)
(local $0 i32)
(local $1 i32)
(local $2 i32)
@ -138,15 +228,6 @@
(local $14 i32)
(local $15 i32)
(local $16 i32)
(local $17 i32)
(local $18 i32)
(local $19 i32)
(local $20 i32)
(local $21 i32)
(local $22 i32)
(local $23 i32)
(local $24 i32)
(local $25 i32)
(block
(set_local $0
(i32.sub
@ -241,222 +322,6 @@
)
)
)
(set_local $9
(block $../../examples/game-of-life/assembly/index/get|inlined.0 (result i32)
(set_local $8
(get_local $6)
)
(set_local $9
(get_local $3)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.0
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $9)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $10
(block $../../examples/game-of-life/assembly/index/get|inlined.1 (result i32)
(set_local $8
(get_local $5)
)
(set_local $10
(get_local $3)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.1
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $10)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $11
(block $../../examples/game-of-life/assembly/index/get|inlined.2 (result i32)
(set_local $8
(get_local $7)
)
(set_local $11
(get_local $3)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.2
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $11)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $12
(block $../../examples/game-of-life/assembly/index/get|inlined.3 (result i32)
(set_local $8
(get_local $6)
)
(set_local $12
(get_local $2)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.3
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $12)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $13
(block $../../examples/game-of-life/assembly/index/get|inlined.4 (result i32)
(set_local $8
(get_local $5)
)
(set_local $13
(get_local $2)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.4
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $13)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $14
(block $../../examples/game-of-life/assembly/index/get|inlined.5 (result i32)
(set_local $8
(get_local $7)
)
(set_local $14
(get_local $2)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.5
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $14)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $15
(block $../../examples/game-of-life/assembly/index/get|inlined.6 (result i32)
(set_local $8
(get_local $6)
)
(set_local $15
(get_local $4)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.6
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $15)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $16
(block $../../examples/game-of-life/assembly/index/get|inlined.7 (result i32)
(set_local $8
(get_local $5)
)
(set_local $16
(get_local $4)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.7
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $16)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $17
(block $../../examples/game-of-life/assembly/index/get|inlined.8 (result i32)
(set_local $8
(get_local $7)
)
(set_local $17
(get_local $4)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.8
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $17)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
)
(set_local $8
(i32.add
(i32.add
@ -466,53 +331,242 @@
(i32.add
(i32.add
(i32.and
(get_local $9)
(block $../../examples/game-of-life/assembly/index/get|inlined.0 (result i32)
(set_local $8
(get_local $6)
)
(set_local $9
(get_local $3)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.0
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $9)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
(i32.and
(get_local $10)
(block $../../examples/game-of-life/assembly/index/get|inlined.1 (result i32)
(set_local $9
(get_local $5)
)
(set_local $8
(get_local $3)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.1
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $8)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $9)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
(i32.and
(get_local $11)
(block $../../examples/game-of-life/assembly/index/get|inlined.2 (result i32)
(set_local $8
(get_local $7)
)
(set_local $9
(get_local $3)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.2
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $9)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
(i32.and
(get_local $12)
(block $../../examples/game-of-life/assembly/index/get|inlined.3 (result i32)
(set_local $9
(get_local $6)
)
(set_local $8
(get_local $2)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.3
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $8)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $9)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
(i32.and
(get_local $14)
(block $../../examples/game-of-life/assembly/index/get|inlined.4 (result i32)
(set_local $8
(get_local $7)
)
(set_local $9
(get_local $2)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.4
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $9)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
(i32.and
(get_local $15)
(block $../../examples/game-of-life/assembly/index/get|inlined.5 (result i32)
(set_local $9
(get_local $6)
)
(set_local $8
(get_local $4)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.5
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $8)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $9)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
(i32.and
(get_local $16)
(block $../../examples/game-of-life/assembly/index/get|inlined.6 (result i32)
(set_local $8
(get_local $5)
)
(set_local $9
(get_local $4)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.6
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $9)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $8)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
(i32.and
(get_local $17)
(block $../../examples/game-of-life/assembly/index/get|inlined.7 (result i32)
(set_local $9
(get_local $7)
)
(set_local $8
(get_local $4)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.7
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $8)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $9)
)
(i32.const 2)
)
)
)
)
(i32.const 1)
)
)
)
(set_local $18
(i32.and
(get_local $13)
(i32.const 1)
(set_local $10
(block $../../examples/game-of-life/assembly/index/get|inlined.8 (result i32)
(set_local $9
(get_local $5)
)
(set_local $10
(get_local $2)
)
(br $../../examples/game-of-life/assembly/index/get|inlined.8
(i32.load
(i32.shl
(i32.add
(i32.mul
(get_local $10)
(get_global $../../examples/game-of-life/assembly/index/w)
)
(get_local $9)
)
(i32.const 2)
)
)
)
)
)
(if
(get_local $18)
(i32.and
(get_local $10)
(i32.const 1)
)
(if
(i32.eq
(i32.and
@ -521,51 +575,51 @@
)
(i32.const 2)
)
(block $../../examples/game-of-life/assembly/index/set_fade|inlined.0
(set_local $19
(block $../../examples/game-of-life/assembly/index/rot|inlined.0
(set_local $9
(get_local $5)
)
(set_local $20
(set_local $11
(get_local $2)
)
(set_local $21
(get_local $13)
(set_local $12
(get_local $10)
)
(set_local $22
(set_local $13
(select
(tee_local $22
(tee_local $13
(i32.sub
(i32.shr_u
(get_local $21)
(get_local $12)
(i32.const 24)
)
(i32.const 7)
(i32.const 10)
)
)
(tee_local $23
(tee_local $14
(i32.const 0)
)
(i32.gt_s
(get_local $22)
(get_local $23)
(get_local $13)
(get_local $14)
)
)
)
(block $../../examples/game-of-life/assembly/index/set|inlined.1
(set_local $23
(get_local $19)
(set_local $14
(get_local $9)
)
(set_local $24
(get_local $20)
(set_local $15
(get_local $11)
)
(set_local $25
(set_local $16
(i32.or
(i32.shl
(get_local $22)
(get_local $13)
(i32.const 24)
)
(i32.and
(get_local $21)
(get_local $12)
(i32.const 16777215)
)
)
@ -576,26 +630,26 @@
(i32.add
(get_global $../../examples/game-of-life/assembly/index/s)
(i32.mul
(get_local $24)
(get_local $15)
(get_global $../../examples/game-of-life/assembly/index/w)
)
)
(get_local $23)
(get_local $14)
)
(i32.const 2)
)
(get_local $25)
(get_local $16)
)
)
)
(block $../../examples/game-of-life/assembly/index/set|inlined.2
(set_local $22
(set_local $13
(get_local $5)
)
(set_local $21
(set_local $12
(get_local $2)
)
(set_local $20
(set_local $11
(i32.or
(i32.const 8723366)
(i32.const -16777216)
@ -607,15 +661,15 @@
(i32.add
(get_global $../../examples/game-of-life/assembly/index/s)
(i32.mul
(get_local $21)
(get_local $12)
(get_global $../../examples/game-of-life/assembly/index/w)
)
)
(get_local $22)
(get_local $13)
)
(i32.const 2)
)
(get_local $20)
(get_local $11)
)
)
)
@ -625,13 +679,13 @@
(i32.const 3)
)
(block $../../examples/game-of-life/assembly/index/set|inlined.3
(set_local $20
(set_local $11
(get_local $5)
)
(set_local $21
(set_local $12
(get_local $2)
)
(set_local $22
(set_local $13
(i32.or
(i32.const 15110867)
(i32.const -16777216)
@ -643,62 +697,62 @@
(i32.add
(get_global $../../examples/game-of-life/assembly/index/s)
(i32.mul
(get_local $21)
(get_local $12)
(get_global $../../examples/game-of-life/assembly/index/w)
)
)
(get_local $20)
(get_local $11)
)
(i32.const 2)
)
(get_local $22)
)
)
(block $../../examples/game-of-life/assembly/index/set_fade|inlined.1
(set_local $22
(get_local $5)
)
(set_local $21
(get_local $2)
)
(set_local $20
(get_local $13)
)
(set_local $19
)
(block $../../examples/game-of-life/assembly/index/rot|inlined.1
(set_local $13
(get_local $5)
)
(set_local $12
(get_local $2)
)
(set_local $11
(get_local $10)
)
(set_local $9
(select
(tee_local $19
(tee_local $9
(i32.sub
(i32.shr_u
(get_local $20)
(get_local $11)
(i32.const 24)
)
(i32.const 7)
(i32.const 10)
)
)
(tee_local $25
(tee_local $16
(i32.const 0)
)
(i32.gt_s
(get_local $19)
(get_local $25)
(get_local $9)
(get_local $16)
)
)
)
(block $../../examples/game-of-life/assembly/index/set|inlined.4
(set_local $25
(get_local $22)
(set_local $16
(get_local $13)
)
(set_local $24
(get_local $21)
(set_local $15
(get_local $12)
)
(set_local $23
(set_local $14
(i32.or
(i32.shl
(get_local $19)
(get_local $9)
(i32.const 24)
)
(i32.and
(get_local $20)
(get_local $11)
(i32.const 16777215)
)
)
@ -709,15 +763,15 @@
(i32.add
(get_global $../../examples/game-of-life/assembly/index/s)
(i32.mul
(get_local $24)
(get_local $15)
(get_global $../../examples/game-of-life/assembly/index/w)
)
)
(get_local $25)
(get_local $16)
)
(i32.const 2)
)
(get_local $23)
(get_local $14)
)
)
)

View File

@ -3,11 +3,274 @@
(type $FF (func (param f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFFF (func (param f64 f64 f64) (result f64)))
(import "JSMath" "log" (func $~lib/math/JSMath.log (param f64) (result f64)))
(import "JSMath" "LN2" (global $~lib/math/JSMath.LN2 f64))
(memory $0 1)
(export "computeLine" (func $../../examples/mandelbrot/assembly/index/computeLine))
(export "memory" (memory $0))
(func $~lib/math/NativeMath.log (; 0 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i32)
(local $2 i32)
(local $3 i64)
(local $4 f64)
(local $5 i32)
(local $6 f64)
(local $7 f64)
(local $8 f64)
(if
(i32.and
(if (result i32)
(tee_local $5
(i32.lt_u
(tee_local $1
(i32.wrap/i64
(i64.shr_u
(tee_local $3
(i64.reinterpret/f64
(get_local $0)
)
)
(i64.const 32)
)
)
)
(i32.const 1048576)
)
)
(get_local $5)
(i32.shr_u
(get_local $1)
(i32.const 31)
)
)
(i32.const 1)
)
(block
(if
(i64.eq
(i64.shl
(get_local $3)
(i64.const 1)
)
(i64.const 0)
)
(return
(f64.div
(f64.const -1)
(f64.mul
(get_local $0)
(get_local $0)
)
)
)
)
(if
(i32.shr_u
(get_local $1)
(i32.const 31)
)
(return
(f64.div
(f64.sub
(get_local $0)
(get_local $0)
)
(f64.const 0)
)
)
)
(set_local $2
(i32.sub
(get_local $2)
(i32.const 54)
)
)
(set_local $1
(i32.wrap/i64
(i64.shr_u
(tee_local $3
(i64.reinterpret/f64
(f64.mul
(get_local $0)
(f64.const 18014398509481984)
)
)
)
(i64.const 32)
)
)
)
)
(if
(i32.ge_u
(get_local $1)
(i32.const 2146435072)
)
(return
(get_local $0)
)
(if
(i32.and
(if (result i32)
(tee_local $5
(i32.eq
(get_local $1)
(i32.const 1072693248)
)
)
(i64.eq
(i64.shl
(get_local $3)
(i64.const 32)
)
(i64.const 0)
)
(get_local $5)
)
(i32.const 1)
)
(return
(f64.const 0)
)
)
)
)
(set_local $2
(i32.add
(get_local $2)
(i32.sub
(i32.shr_s
(tee_local $1
(i32.add
(get_local $1)
(i32.const 614242)
)
)
(i32.const 20)
)
(i32.const 1023)
)
)
)
(set_local $6
(f64.mul
(f64.mul
(f64.const 0.5)
(tee_local $4
(f64.sub
(f64.reinterpret/i64
(i64.or
(i64.shl
(i64.extend_u/i32
(i32.add
(i32.and
(get_local $1)
(i32.const 1048575)
)
(i32.const 1072079006)
)
)
(i64.const 32)
)
(i64.and
(get_local $3)
(i64.const 4294967295)
)
)
)
(f64.const 1)
)
)
)
(get_local $4)
)
)
(set_local $0
(f64.mul
(tee_local $8
(f64.mul
(tee_local $7
(f64.div
(get_local $4)
(f64.add
(f64.const 2)
(get_local $4)
)
)
)
(get_local $7)
)
)
(get_local $8)
)
)
(f64.add
(f64.add
(f64.sub
(f64.add
(f64.mul
(get_local $7)
(f64.add
(get_local $6)
(f64.add
(f64.mul
(get_local $8)
(f64.add
(f64.const 0.6666666666666735)
(f64.mul
(get_local $0)
(f64.add
(f64.const 0.2857142874366239)
(f64.mul
(get_local $0)
(f64.add
(f64.const 0.1818357216161805)
(f64.mul
(get_local $0)
(f64.const 0.14798198605116586)
)
)
)
)
)
)
)
(f64.mul
(get_local $0)
(f64.add
(f64.const 0.3999999999940942)
(f64.mul
(get_local $0)
(f64.add
(f64.const 0.22222198432149784)
(f64.mul
(get_local $0)
(f64.const 0.15313837699209373)
)
)
)
)
)
)
)
)
(f64.mul
(f64.convert_s/i32
(get_local $2)
)
(f64.const 1.9082149292705877e-10)
)
)
(get_local $6)
)
(get_local $4)
)
(f64.mul
(f64.convert_s/i32
(get_local $2)
)
(f64.const 0.6931471803691238)
)
)
)
(func $isFinite<f64> (; 1 ;) (type $Fi) (param $0 f64) (result i32)
(f64.eq
(f64.sub
@ -31,14 +294,12 @@
(local $5 f64)
(local $6 i32)
(local $7 f64)
(local $8 i32)
(local $9 i32)
(local $8 f64)
(local $9 f64)
(local $10 f64)
(local $11 f64)
(local $12 f64)
(local $13 f64)
(local $14 f64)
(set_local $12
(set_local $11
(f64.div
(f64.convert_u/i32
(get_local $1)
@ -46,7 +307,7 @@
(f64.const 1.6)
)
)
(set_local $10
(set_local $9
(f64.mul
(f64.sub
(f64.convert_u/i32
@ -59,7 +320,7 @@
(f64.const 2)
)
)
(tee_local $13
(tee_local $12
(f64.div
(f64.const 10)
(f64.min
@ -80,22 +341,25 @@
)
)
)
(set_local $2
(i32.const 0)
)
(loop $continue|0
(if
(i32.lt_u
(get_local $8)
(get_local $2)
(get_local $1)
)
(block
(set_local $11
(set_local $10
(f64.mul
(f64.sub
(f64.convert_u/i32
(get_local $8)
(get_local $2)
)
(get_local $12)
(get_local $11)
)
(get_local $13)
(get_local $12)
)
)
(set_local $4
@ -112,13 +376,13 @@
(if
(f64.le
(f64.add
(tee_local $14
(tee_local $7
(f64.mul
(get_local $4)
(get_local $4)
)
)
(tee_local $7
(tee_local $8
(f64.mul
(get_local $5)
(get_local $5)
@ -137,16 +401,16 @@
)
(get_local $5)
)
(get_local $10)
(get_local $9)
)
)
(set_local $4
(f64.add
(f64.sub
(get_local $14)
(get_local $7)
(get_local $8)
)
(get_local $11)
(get_local $10)
)
)
(br_if $break|1
@ -166,29 +430,24 @@
)
)
)
(set_local $9
(i32.const 0)
(set_local $7
(f64.min
(f64.const 8)
(f64.convert_u/i32
(get_local $3)
)
)
)
(loop $continue|2
(if
(i32.and
(if (result i32)
(tee_local $2
(i32.lt_s
(get_local $9)
(i32.const 5)
)
)
(i32.lt_u
(get_local $6)
(get_local $3)
)
(get_local $2)
(f64.lt
(f64.convert_u/i32
(get_local $6)
)
(i32.const 1)
(get_local $7)
)
(block
(set_local $7
(set_local $8
(f64.add
(f64.sub
(f64.mul
@ -200,7 +459,7 @@
(get_local $5)
)
)
(get_local $11)
(get_local $10)
)
)
(set_local $5
@ -212,17 +471,11 @@
)
(get_local $5)
)
(get_local $10)
(get_local $9)
)
)
(set_local $4
(get_local $7)
)
(set_local $9
(i32.add
(get_local $9)
(i32.const 1)
)
(get_local $8)
)
(set_local $6
(i32.add
@ -234,27 +487,6 @@
)
)
)
(set_local $7
(f64.div
(call $~lib/math/JSMath.log
(call $~lib/math/JSMath.log
(f64.sqrt
(f64.add
(f64.mul
(get_local $4)
(get_local $4)
)
(f64.mul
(get_local $5)
(get_local $5)
)
)
)
)
)
(get_global $~lib/math/JSMath.LN2)
)
)
(i32.store16
(i32.shl
(i32.add
@ -262,13 +494,33 @@
(get_local $0)
(get_local $1)
)
(get_local $8)
(get_local $2)
)
(i32.const 1)
)
(if (result i32)
(call $isFinite<f64>
(get_local $7)
(tee_local $7
(f64.div
(call $~lib/math/NativeMath.log
(call $~lib/math/NativeMath.log
(f64.sqrt
(f64.add
(f64.mul
(get_local $4)
(get_local $4)
)
(f64.mul
(get_local $5)
(get_local $5)
)
)
)
)
)
(f64.const 0.6931471805599453)
)
)
)
(i32.trunc_u/f64
(f64.mul
@ -293,18 +545,12 @@
)
)
)
(i32.div_s
(i32.mul
(get_local $6)
(i32.const 2047)
)
(get_local $3)
)
(i32.const 2047)
)
)
(set_local $8
(set_local $2
(i32.add
(get_local $8)
(get_local $2)
(i32.const 1)
)
)

View File

@ -1,15 +1,327 @@
(module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $FF (func (param f64) (result f64)))
(type $F (func (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFFF (func (param f64 f64 f64) (result f64)))
(import "JSMath" "log" (func $~lib/math/JSMath.log (param f64) (result f64)))
(import "JSMath" "LN2" (global $~lib/math/JSMath.LN2 f64))
(global $../../examples/mandelbrot/assembly/index/NUM_COLORS i32 (i32.const 2048))
(global $HEAP_BASE i32 (i32.const 4))
(memory $0 1)
(export "computeLine" (func $../../examples/mandelbrot/assembly/index/computeLine))
(export "memory" (memory $0))
(func $~lib/math/NativeMath.log (; 0 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 f64)
(local $6 f64)
(local $7 f64)
(local $8 f64)
(local $9 f64)
(local $10 f64)
(local $11 f64)
(local $12 f64)
(local $13 i32)
(nop)
(set_local $1
(i64.reinterpret/f64
(get_local $0)
)
)
(set_local $2
(i32.wrap/i64
(i64.shr_u
(get_local $1)
(i64.const 32)
)
)
)
(set_local $3
(i32.const 0)
)
(if
(i32.and
(if (result i32)
(tee_local $4
(i32.lt_u
(get_local $2)
(i32.const 1048576)
)
)
(get_local $4)
(i32.and
(i32.shr_u
(get_local $2)
(i32.const 31)
)
(i32.const 1)
)
)
(i32.const 1)
)
(block
(if
(i64.eq
(i64.shl
(get_local $1)
(i64.const 1)
)
(i64.const 0)
)
(return
(f64.div
(f64.const -1)
(f64.mul
(get_local $0)
(get_local $0)
)
)
)
)
(if
(i32.shr_u
(get_local $2)
(i32.const 31)
)
(return
(f64.div
(f64.sub
(get_local $0)
(get_local $0)
)
(f64.const 0)
)
)
)
(set_local $3
(i32.sub
(get_local $3)
(i32.const 54)
)
)
(set_local $0
(f64.mul
(get_local $0)
(f64.const 18014398509481984)
)
)
(set_local $1
(i64.reinterpret/f64
(get_local $0)
)
)
(set_local $2
(i32.wrap/i64
(i64.shr_u
(get_local $1)
(i64.const 32)
)
)
)
)
(if
(i32.ge_u
(get_local $2)
(i32.const 2146435072)
)
(return
(get_local $0)
)
(if
(i32.and
(if (result i32)
(tee_local $4
(i32.eq
(get_local $2)
(i32.const 1072693248)
)
)
(i64.eq
(i64.shl
(get_local $1)
(i64.const 32)
)
(i64.const 0)
)
(get_local $4)
)
(i32.const 1)
)
(return
(f64.const 0)
)
)
)
)
(set_local $2
(i32.add
(get_local $2)
(i32.sub
(i32.const 1072693248)
(i32.const 1072079006)
)
)
)
(set_local $3
(i32.add
(get_local $3)
(i32.sub
(i32.shr_s
(get_local $2)
(i32.const 20)
)
(i32.const 1023)
)
)
)
(set_local $2
(i32.add
(i32.and
(get_local $2)
(i32.const 1048575)
)
(i32.const 1072079006)
)
)
(set_local $1
(i64.or
(i64.shl
(i64.extend_u/i32
(get_local $2)
)
(i64.const 32)
)
(i64.and
(get_local $1)
(i64.const 4294967295)
)
)
)
(set_local $0
(f64.reinterpret/i64
(get_local $1)
)
)
(set_local $5
(f64.sub
(get_local $0)
(f64.const 1)
)
)
(set_local $6
(f64.mul
(f64.mul
(f64.const 0.5)
(get_local $5)
)
(get_local $5)
)
)
(set_local $7
(f64.div
(get_local $5)
(f64.add
(f64.const 2)
(get_local $5)
)
)
)
(set_local $8
(f64.mul
(get_local $7)
(get_local $7)
)
)
(set_local $9
(f64.mul
(get_local $8)
(get_local $8)
)
)
(set_local $10
(f64.mul
(get_local $9)
(f64.add
(f64.const 0.3999999999940942)
(f64.mul
(get_local $9)
(f64.add
(f64.const 0.22222198432149784)
(f64.mul
(get_local $9)
(f64.const 0.15313837699209373)
)
)
)
)
)
)
(set_local $11
(f64.mul
(get_local $8)
(f64.add
(f64.const 0.6666666666666735)
(f64.mul
(get_local $9)
(f64.add
(f64.const 0.2857142874366239)
(f64.mul
(get_local $9)
(f64.add
(f64.const 0.1818357216161805)
(f64.mul
(get_local $9)
(f64.const 0.14798198605116586)
)
)
)
)
)
)
)
)
(set_local $12
(f64.add
(get_local $11)
(get_local $10)
)
)
(set_local $13
(get_local $3)
)
(return
(f64.add
(f64.add
(f64.sub
(f64.add
(f64.mul
(get_local $7)
(f64.add
(get_local $6)
(get_local $12)
)
)
(f64.mul
(f64.convert_s/i32
(get_local $13)
)
(f64.const 1.9082149292705877e-10)
)
)
(get_local $6)
)
(get_local $5)
)
(f64.mul
(f64.convert_s/i32
(get_local $13)
)
(f64.const 0.6931471803691238)
)
)
)
)
(func $isFinite<f64> (; 1 ;) (type $Fi) (param $0 f64) (result i32)
(return
(f64.eq
@ -45,7 +357,7 @@
(local $13 f64)
(local $14 i32)
(local $15 f64)
(local $16 i32)
(local $16 f64)
(local $17 i32)
(set_local $4
(f64.div
@ -193,30 +505,25 @@
)
)
(block $break|2
(set_local $16
(i32.const 0)
(set_local $15
(f64.min
(f64.const 8)
(f64.convert_u/i32
(get_local $3)
)
)
)
(loop $continue|2
(if
(i32.and
(if (result i32)
(tee_local $17
(i32.lt_s
(get_local $16)
(i32.const 5)
)
)
(i32.lt_u
(get_local $14)
(get_local $3)
)
(get_local $17)
(f64.lt
(f64.convert_u/i32
(get_local $14)
)
(i32.const 1)
(get_local $15)
)
(block
(block
(set_local $15
(set_local $16
(f64.add
(f64.sub
(f64.mul
@ -244,21 +551,13 @@
)
)
(set_local $10
(get_local $15)
(get_local $16)
)
)
(block
(set_local $16
(i32.add
(get_local $16)
(i32.const 1)
)
)
(set_local $14
(i32.add
(get_local $14)
(i32.const 1)
)
(set_local $14
(i32.add
(get_local $14)
(i32.const 1)
)
)
(br $continue|2)
@ -268,36 +567,33 @@
)
(set_local $15
(f64.div
(call $~lib/math/JSMath.log
(call $~lib/math/JSMath.log
(f64.sqrt
(f64.add
(f64.mul
(get_local $10)
(get_local $10)
(call $~lib/math/NativeMath.log
(call $~lib/math/NativeMath.log
(block $~lib/math/NativeMath.sqrt|inlined.0 (result f64)
(set_local $15
(f64.add
(f64.mul
(get_local $10)
(get_local $10)
)
(f64.mul
(get_local $11)
(get_local $11)
)
)
(f64.mul
(get_local $11)
(get_local $11)
)
(br $~lib/math/NativeMath.sqrt|inlined.0
(f64.sqrt
(get_local $15)
)
)
)
)
)
(get_global $~lib/math/JSMath.LN2)
(f64.const 0.6931471805599453)
)
)
(i32.store16
(i32.shl
(i32.add
(i32.mul
(get_local $0)
(get_local $1)
)
(get_local $8)
)
(i32.const 1)
)
(set_local $17
(if (result i32)
(call $isFinite<f64>
(get_local $15)
@ -330,18 +626,25 @@
)
)
)
(i32.div_s
(i32.mul
(i32.sub
(i32.const 2048)
(i32.const 1)
)
(get_local $14)
)
(get_local $3)
(i32.sub
(i32.const 2048)
(i32.const 1)
)
)
)
(i32.store16
(i32.shl
(i32.add
(i32.mul
(get_local $0)
(get_local $1)
)
(get_local $8)
)
(i32.const 1)
)
(get_local $17)
)
)
(set_local $8
(i32.add