mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Add some smoothing to mandelbrot example
This commit is contained in:
parent
9cd3304e13
commit
b53b3e08ec
@ -25,7 +25,7 @@ function set_fade(x: u32, y: u32, v: u32): void {
|
||||
}
|
||||
|
||||
/** Initializes width and height. Called once from JS. */
|
||||
export function init(width: i32, height: i32, seed: f64): void {
|
||||
export function init(width: i32, height: i32): void {
|
||||
w = width;
|
||||
h = height;
|
||||
s = width * height;
|
||||
@ -46,7 +46,6 @@ export function step(): void {
|
||||
// The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square
|
||||
// "cells", each of which is in one of two possible states, alive or dead.
|
||||
for (let y = 0; y < h; ++y) {
|
||||
|
||||
let ym1 = y == 0 ? hm1 : y - 1,
|
||||
yp1 = y == hm1 ? 0 : y + 1;
|
||||
for (let x = 0; x < w; ++x) {
|
||||
@ -74,15 +73,14 @@ export function step(): void {
|
||||
|
||||
let alive = mm & 1;
|
||||
if (alive) {
|
||||
// A live cell with fewer than 2 live neighbors dies, as if caused by underpopulation.
|
||||
// A live cell with more than 3 live neighbors dies, as if by overpopulation.
|
||||
if (aliveNeighbors < 2 || aliveNeighbors > 3) set(x, y, RGB_DEAD | 0xff000000);
|
||||
// A live cell with 2 or 3 live neighbors lives on to the next generation.
|
||||
else set_fade(x, y, mm);
|
||||
if ((aliveNeighbors & 0b1110) == 0b0010) set_fade(x, y, mm);
|
||||
// A live cell with fewer than 2 or more than 3 live neighbors dies.
|
||||
else set(x, y, RGB_DEAD | 0xff000000);
|
||||
} else {
|
||||
// A dead cell with exactly 3 live neighbors becomes a live cell, as if by reproduction.
|
||||
// A dead cell with exactly 3 live neighbors becomes a live cell.
|
||||
if (aliveNeighbors == 3) set(x, y, RGB_ALIVE | 0xff000000);
|
||||
// Otherwise the dead cell remains dead.
|
||||
// A dead cell with fewer or more than 3 live neighbors remains dead.
|
||||
else set_fade(x, y, mm);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -158,79 +158,110 @@
|
||||
)
|
||||
(block
|
||||
(set_local $5
|
||||
;;@ assembly/index.ts:50:14
|
||||
;;@ assembly/index.ts:49:14
|
||||
(if (result i32)
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:50:29
|
||||
;;@ assembly/index.ts:49:29
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:50:33
|
||||
;;@ assembly/index.ts:49:33
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:50:23
|
||||
;;@ assembly/index.ts:49:23
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(set_local $6
|
||||
;;@ assembly/index.ts:51:14
|
||||
;;@ assembly/index.ts:50:14
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:51:19
|
||||
;;@ assembly/index.ts:50:19
|
||||
(get_local $7)
|
||||
)
|
||||
;;@ assembly/index.ts:51:25
|
||||
;;@ assembly/index.ts:50:25
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:51:29
|
||||
;;@ assembly/index.ts:50:29
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:51:33
|
||||
;;@ assembly/index.ts:50:33
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:52:9
|
||||
;;@ assembly/index.ts:51:9
|
||||
(set_local $1
|
||||
;;@ assembly/index.ts:52:17
|
||||
;;@ assembly/index.ts:51:17
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
;;@ assembly/index.ts:52:20
|
||||
;;@ assembly/index.ts:51:20
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:52:24
|
||||
;;@ assembly/index.ts:51:24
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
(block
|
||||
;;@ assembly/index.ts:62:6
|
||||
(set_local $4
|
||||
;;@ assembly/index.ts:61:6
|
||||
(set_local $3
|
||||
(i32.load
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:62:24
|
||||
;;@ assembly/index.ts:61:24
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:62:19
|
||||
;;@ assembly/index.ts:61:19
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:69:6
|
||||
;;@ assembly/index.ts:68:6
|
||||
(set_local $2
|
||||
;;@ assembly/index.ts:69:27
|
||||
;;@ assembly/index.ts:68:27
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:70:8
|
||||
;;@ assembly/index.ts:69:8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:57:24
|
||||
(get_local $5)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
(tee_local $2
|
||||
;;@ assembly/index.ts:52:16
|
||||
(if (result i32)
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:52:31
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:52:35
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:52:25
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:69:14
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:69:19
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
@ -240,28 +271,17 @@
|
||||
(get_local $5)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
(tee_local $2
|
||||
;;@ assembly/index.ts:53:16
|
||||
(if (result i32)
|
||||
;;@ assembly/index.ts:58:19
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:53:31
|
||||
(i32.sub
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:53:35
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:53:25
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:70:14
|
||||
;;@ assembly/index.ts:69:25
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:70:19
|
||||
)
|
||||
;;@ assembly/index.ts:69:30
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
@ -271,13 +291,49 @@
|
||||
(get_local $5)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:59:19
|
||||
(tee_local $4
|
||||
;;@ assembly/index.ts:53:16
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:53:21
|
||||
(get_local $8)
|
||||
)
|
||||
;;@ assembly/index.ts:53:27
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:53:31
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:53:35
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:70:25
|
||||
;;@ assembly/index.ts:69:36
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:70:8
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:60:24
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:60:19
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:70:14
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -287,28 +343,12 @@
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:60:24
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:62:24
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
(tee_local $3
|
||||
;;@ assembly/index.ts:54:16
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:54:21
|
||||
(get_local $8)
|
||||
)
|
||||
;;@ assembly/index.ts:54:27
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:54:31
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:54:35
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:62:19
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -323,11 +363,11 @@
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:61:24
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:63:24
|
||||
(get_local $6)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:61:19
|
||||
;;@ assembly/index.ts:63:19
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
@ -337,27 +377,7 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:71:30
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:63:24
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:63:19
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:71:36
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:8
|
||||
;;@ assembly/index.ts:71:19
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
@ -368,36 +388,16 @@
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:64:19
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:14
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:19
|
||||
(i32.and
|
||||
(i32.load
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:65:24
|
||||
(get_local $6)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:65:19
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:25
|
||||
;;@ assembly/index.ts:71:25
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:30
|
||||
;;@ assembly/index.ts:71:30
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:11:9
|
||||
(i32.load
|
||||
@ -406,108 +406,81 @@
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:11:20
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:66:24
|
||||
;;@ assembly/index.ts:65:24
|
||||
(get_local $6)
|
||||
;;@ assembly/index.ts:11:24
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:66:19
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:65:19
|
||||
(get_local $4)
|
||||
)
|
||||
;;@ assembly/index.ts:11:34
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:36
|
||||
;;@ assembly/index.ts:71:36
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:76:6
|
||||
;;@ assembly/index.ts:75:6
|
||||
(if
|
||||
;;@ assembly/index.ts:75:18
|
||||
;;@ assembly/index.ts:74:18
|
||||
(i32.and
|
||||
(get_local $4)
|
||||
;;@ assembly/index.ts:75:23
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:79:8
|
||||
(if
|
||||
;;@ assembly/index.ts:79:12
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:79:29
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:79:34
|
||||
(i32.gt_u
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:79:51
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:74:23
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:79:61
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:79:58
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:77:8
|
||||
(if
|
||||
;;@ assembly/index.ts:77:12
|
||||
(i32.eq
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:77:13
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:77:30
|
||||
(i32.const 14)
|
||||
)
|
||||
;;@ assembly/index.ts:77:41
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const -8053850)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:81:25
|
||||
;;@ assembly/index.ts:77:61
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:81:22
|
||||
;;@ assembly/index.ts:77:58
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.or
|
||||
(i32.shl
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(select
|
||||
(tee_local $4
|
||||
(tee_local $3
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
(tee_local $3
|
||||
;;@ assembly/index.ts:81:28
|
||||
(get_local $4)
|
||||
(tee_local $2
|
||||
;;@ assembly/index.ts:77:64
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 7)
|
||||
)
|
||||
)
|
||||
(tee_local $2
|
||||
(tee_local $4
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
(i32.const 0)
|
||||
)
|
||||
)
|
||||
@ -515,18 +488,36 @@
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.const 16777215)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:79:20
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
;;@ assembly/index.ts:84:8
|
||||
)
|
||||
;;@ assembly/index.ts:79:17
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const -8053850)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:82:8
|
||||
(if
|
||||
;;@ assembly/index.ts:84:12
|
||||
;;@ assembly/index.ts:82:12
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:84:30
|
||||
;;@ assembly/index.ts:82:30
|
||||
(i32.const 3)
|
||||
)
|
||||
(i32.store
|
||||
@ -535,12 +526,12 @@
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:84:40
|
||||
;;@ assembly/index.ts:82:40
|
||||
(get_local $0)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:84:37
|
||||
;;@ assembly/index.ts:82:37
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 2)
|
||||
@ -557,13 +548,13 @@
|
||||
(get_global $assembly/index/s)
|
||||
;;@ assembly/index.ts:17:18
|
||||
(i32.mul
|
||||
;;@ assembly/index.ts:86:25
|
||||
;;@ assembly/index.ts:84:25
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:17:22
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:86:22
|
||||
;;@ assembly/index.ts:84:22
|
||||
(get_local $1)
|
||||
)
|
||||
;;@ assembly/index.ts:17:32
|
||||
@ -580,8 +571,8 @@
|
||||
;;@ assembly/index.ts:23:19
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
;;@ assembly/index.ts:86:28
|
||||
(get_local $4)
|
||||
;;@ assembly/index.ts:84:28
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:23:26
|
||||
(i32.const 24)
|
||||
)
|
||||
@ -589,7 +580,7 @@
|
||||
(i32.const 7)
|
||||
)
|
||||
)
|
||||
(tee_local $3
|
||||
(tee_local $4
|
||||
;;@ assembly/index.ts:23:35
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -605,7 +596,7 @@
|
||||
;;@ assembly/index.ts:24:24
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:24:25
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:24:29
|
||||
(i32.const 16777215)
|
||||
)
|
||||
@ -613,10 +604,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:52:27
|
||||
;;@ assembly/index.ts:51:27
|
||||
(set_local $1
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:52:29
|
||||
;;@ assembly/index.ts:51:29
|
||||
(get_local $1)
|
||||
(i32.const 1)
|
||||
)
|
||||
|
@ -222,107 +222,107 @@
|
||||
(block
|
||||
(block
|
||||
(set_local $3
|
||||
;;@ assembly/index.ts:49:14
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:49:19
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:49:23
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:49:29
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:49:33
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
;;@ assembly/index.ts:50:14
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:50:19
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:50:23
|
||||
(get_local $0)
|
||||
)
|
||||
;;@ assembly/index.ts:50:25
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:50:29
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:50:33
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
;;@ assembly/index.ts:51:14
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:51:19
|
||||
(get_local $0)
|
||||
)
|
||||
;;@ assembly/index.ts:51:25
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:51:29
|
||||
(i32.add
|
||||
(get_local $2)
|
||||
;;@ assembly/index.ts:51:33
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:52:4
|
||||
;;@ assembly/index.ts:51:4
|
||||
(block $break|1
|
||||
;;@ assembly/index.ts:52:9
|
||||
;;@ assembly/index.ts:51:9
|
||||
(set_local $5
|
||||
;;@ assembly/index.ts:52:17
|
||||
;;@ assembly/index.ts:51:17
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
;;@ assembly/index.ts:52:20
|
||||
;;@ assembly/index.ts:51:20
|
||||
(i32.lt_s
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:52:24
|
||||
;;@ assembly/index.ts:51:24
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(block
|
||||
(set_local $6
|
||||
;;@ assembly/index.ts:52:16
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:52:21
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:52:25
|
||||
(get_local $1)
|
||||
;;@ assembly/index.ts:52:31
|
||||
(i32.sub
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:52:35
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
;;@ assembly/index.ts:53:16
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:53:21
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:53:25
|
||||
(get_local $1)
|
||||
)
|
||||
;;@ assembly/index.ts:53:27
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:53:31
|
||||
(i32.sub
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:53:35
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $7
|
||||
;;@ assembly/index.ts:54:16
|
||||
(if (result i32)
|
||||
(i32.eq
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:54:21
|
||||
(get_local $1)
|
||||
)
|
||||
;;@ assembly/index.ts:54:27
|
||||
(i32.const 0)
|
||||
;;@ assembly/index.ts:54:31
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:54:35
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:58:6
|
||||
;;@ assembly/index.ts:57:6
|
||||
(set_local $9
|
||||
;;@ assembly/index.ts:58:15
|
||||
;;@ assembly/index.ts:57:15
|
||||
(block $assembly/index/get|inlined.0 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:58:19
|
||||
;;@ assembly/index.ts:57:19
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $9
|
||||
;;@ assembly/index.ts:58:24
|
||||
;;@ assembly/index.ts:57:24
|
||||
(get_local $3)
|
||||
)
|
||||
(br $assembly/index/get|inlined.0
|
||||
@ -341,16 +341,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:59:6
|
||||
;;@ assembly/index.ts:58:6
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:59:15
|
||||
;;@ assembly/index.ts:58:15
|
||||
(block $assembly/index/get|inlined.1 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:59:19
|
||||
;;@ assembly/index.ts:58:19
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:59:24
|
||||
;;@ assembly/index.ts:58:24
|
||||
(get_local $3)
|
||||
)
|
||||
(br $assembly/index/get|inlined.1
|
||||
@ -369,16 +369,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:60:6
|
||||
;;@ assembly/index.ts:59:6
|
||||
(set_local $11
|
||||
;;@ assembly/index.ts:60:15
|
||||
;;@ assembly/index.ts:59:15
|
||||
(block $assembly/index/get|inlined.2 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:60:19
|
||||
;;@ assembly/index.ts:59:19
|
||||
(get_local $7)
|
||||
)
|
||||
(set_local $11
|
||||
;;@ assembly/index.ts:60:24
|
||||
;;@ assembly/index.ts:59:24
|
||||
(get_local $3)
|
||||
)
|
||||
(br $assembly/index/get|inlined.2
|
||||
@ -397,16 +397,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:61:6
|
||||
;;@ assembly/index.ts:60:6
|
||||
(set_local $12
|
||||
;;@ assembly/index.ts:61:15
|
||||
;;@ assembly/index.ts:60:15
|
||||
(block $assembly/index/get|inlined.3 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:61:19
|
||||
;;@ assembly/index.ts:60:19
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $12
|
||||
;;@ assembly/index.ts:61:24
|
||||
;;@ assembly/index.ts:60:24
|
||||
(get_local $2)
|
||||
)
|
||||
(br $assembly/index/get|inlined.3
|
||||
@ -425,16 +425,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:62:6
|
||||
;;@ assembly/index.ts:61:6
|
||||
(set_local $13
|
||||
;;@ assembly/index.ts:62:15
|
||||
;;@ assembly/index.ts:61:15
|
||||
(block $assembly/index/get|inlined.4 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:62:19
|
||||
;;@ assembly/index.ts:61:19
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $13
|
||||
;;@ assembly/index.ts:62:24
|
||||
;;@ assembly/index.ts:61:24
|
||||
(get_local $2)
|
||||
)
|
||||
(br $assembly/index/get|inlined.4
|
||||
@ -453,16 +453,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:63:6
|
||||
;;@ assembly/index.ts:62:6
|
||||
(set_local $14
|
||||
;;@ assembly/index.ts:63:15
|
||||
;;@ assembly/index.ts:62:15
|
||||
(block $assembly/index/get|inlined.5 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:63:19
|
||||
;;@ assembly/index.ts:62:19
|
||||
(get_local $7)
|
||||
)
|
||||
(set_local $14
|
||||
;;@ assembly/index.ts:63:24
|
||||
;;@ assembly/index.ts:62:24
|
||||
(get_local $2)
|
||||
)
|
||||
(br $assembly/index/get|inlined.5
|
||||
@ -481,16 +481,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:64:6
|
||||
;;@ assembly/index.ts:63:6
|
||||
(set_local $15
|
||||
;;@ assembly/index.ts:64:15
|
||||
;;@ assembly/index.ts:63:15
|
||||
(block $assembly/index/get|inlined.6 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:64:19
|
||||
;;@ assembly/index.ts:63:19
|
||||
(get_local $6)
|
||||
)
|
||||
(set_local $15
|
||||
;;@ assembly/index.ts:64:24
|
||||
;;@ assembly/index.ts:63:24
|
||||
(get_local $4)
|
||||
)
|
||||
(br $assembly/index/get|inlined.6
|
||||
@ -509,16 +509,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:65:6
|
||||
;;@ assembly/index.ts:64:6
|
||||
(set_local $16
|
||||
;;@ assembly/index.ts:65:15
|
||||
;;@ assembly/index.ts:64:15
|
||||
(block $assembly/index/get|inlined.7 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:65:19
|
||||
;;@ assembly/index.ts:64:19
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $16
|
||||
;;@ assembly/index.ts:65:24
|
||||
;;@ assembly/index.ts:64:24
|
||||
(get_local $4)
|
||||
)
|
||||
(br $assembly/index/get|inlined.7
|
||||
@ -537,16 +537,16 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:66:6
|
||||
;;@ assembly/index.ts:65:6
|
||||
(set_local $17
|
||||
;;@ assembly/index.ts:66:15
|
||||
;;@ assembly/index.ts:65:15
|
||||
(block $assembly/index/get|inlined.8 (result i32)
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:66:19
|
||||
;;@ assembly/index.ts:65:19
|
||||
(get_local $7)
|
||||
)
|
||||
(set_local $17
|
||||
;;@ assembly/index.ts:66:24
|
||||
;;@ assembly/index.ts:65:24
|
||||
(get_local $4)
|
||||
)
|
||||
;;@ assembly/index.ts:11:35
|
||||
@ -572,11 +572,11 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:69:6
|
||||
;;@ assembly/index.ts:68:6
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:69:27
|
||||
;;@ assembly/index.ts:68:27
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:70:8
|
||||
;;@ assembly/index.ts:69:8
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.add
|
||||
@ -584,23 +584,39 @@
|
||||
(i32.add
|
||||
(i32.add
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:70:9
|
||||
;;@ assembly/index.ts:69:9
|
||||
(get_local $9)
|
||||
;;@ assembly/index.ts:70:14
|
||||
;;@ assembly/index.ts:69:14
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:70:19
|
||||
;;@ assembly/index.ts:69:19
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:70:20
|
||||
;;@ assembly/index.ts:69:20
|
||||
(get_local $10)
|
||||
;;@ assembly/index.ts:70:25
|
||||
;;@ assembly/index.ts:69:25
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:69:30
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:69:31
|
||||
(get_local $11)
|
||||
;;@ assembly/index.ts:69:36
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:70:8
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:70:9
|
||||
(get_local $12)
|
||||
;;@ assembly/index.ts:70:14
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:70:30
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:70:31
|
||||
(get_local $11)
|
||||
(get_local $14)
|
||||
;;@ assembly/index.ts:70:36
|
||||
(i32.const 1)
|
||||
)
|
||||
@ -608,126 +624,66 @@
|
||||
;;@ assembly/index.ts:71:8
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:71:9
|
||||
(get_local $12)
|
||||
(get_local $15)
|
||||
;;@ assembly/index.ts:71:14
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:71:19
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:71:20
|
||||
(get_local $16)
|
||||
;;@ assembly/index.ts:71:25
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:71:30
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:71:31
|
||||
(get_local $14)
|
||||
(get_local $17)
|
||||
;;@ assembly/index.ts:71:36
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:8
|
||||
)
|
||||
;;@ assembly/index.ts:74:6
|
||||
(set_local $18
|
||||
;;@ assembly/index.ts:74:18
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:72:9
|
||||
(get_local $15)
|
||||
;;@ assembly/index.ts:72:14
|
||||
(get_local $13)
|
||||
;;@ assembly/index.ts:74:23
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:19
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:72:20
|
||||
(get_local $16)
|
||||
;;@ assembly/index.ts:72:25
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:72:30
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:72:31
|
||||
(get_local $17)
|
||||
;;@ assembly/index.ts:72:36
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:75:6
|
||||
(set_local $18
|
||||
;;@ assembly/index.ts:75:18
|
||||
(i32.and
|
||||
(get_local $13)
|
||||
;;@ assembly/index.ts:75:23
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:76:6
|
||||
(if
|
||||
;;@ assembly/index.ts:76:10
|
||||
;;@ assembly/index.ts:75:10
|
||||
(get_local $18)
|
||||
;;@ assembly/index.ts:79:8
|
||||
;;@ assembly/index.ts:77:8
|
||||
(if
|
||||
;;@ assembly/index.ts:79:12
|
||||
;;@ assembly/index.ts:77:12
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $19
|
||||
(i32.lt_u
|
||||
;;@ assembly/index.ts:77:13
|
||||
(get_local $8)
|
||||
;;@ assembly/index.ts:79:29
|
||||
;;@ assembly/index.ts:77:30
|
||||
(i32.const 14)
|
||||
)
|
||||
;;@ assembly/index.ts:77:41
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $19)
|
||||
;;@ assembly/index.ts:79:34
|
||||
(i32.gt_u
|
||||
(get_local $8)
|
||||
;;@ assembly/index.ts:79:51
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:79:54
|
||||
(block $assembly/index/set|inlined.1
|
||||
(set_local $19
|
||||
;;@ assembly/index.ts:79:58
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $20
|
||||
;;@ assembly/index.ts:79:61
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $21
|
||||
;;@ assembly/index.ts:79:64
|
||||
(i32.or
|
||||
(i32.const 8723366)
|
||||
;;@ assembly/index.ts:79:75
|
||||
(i32.const -16777216)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $20)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $19)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $21)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:81:13
|
||||
;;@ assembly/index.ts:77:49
|
||||
(block $assembly/index/set_fade|inlined.0
|
||||
(set_local $21
|
||||
;;@ assembly/index.ts:81:22
|
||||
(set_local $19
|
||||
;;@ assembly/index.ts:77:58
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $20
|
||||
;;@ assembly/index.ts:81:25
|
||||
;;@ assembly/index.ts:77:61
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $19
|
||||
;;@ assembly/index.ts:81:28
|
||||
(set_local $21
|
||||
;;@ assembly/index.ts:77:64
|
||||
(get_local $13)
|
||||
)
|
||||
(set_local $22
|
||||
@ -735,7 +691,7 @@
|
||||
(tee_local $22
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 7)
|
||||
@ -750,9 +706,9 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $assembly/index/set|inlined.2
|
||||
(block $assembly/index/set|inlined.1
|
||||
(set_local $23
|
||||
(get_local $21)
|
||||
(get_local $19)
|
||||
)
|
||||
(set_local $24
|
||||
(get_local $20)
|
||||
@ -764,7 +720,7 @@
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
(i32.const 16777215)
|
||||
)
|
||||
)
|
||||
@ -787,30 +743,21 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:84:8
|
||||
(if
|
||||
;;@ assembly/index.ts:84:12
|
||||
(i32.eq
|
||||
(get_local $8)
|
||||
;;@ assembly/index.ts:84:30
|
||||
(i32.const 3)
|
||||
)
|
||||
;;@ assembly/index.ts:84:33
|
||||
(block $assembly/index/set|inlined.3
|
||||
;;@ assembly/index.ts:79:13
|
||||
(block $assembly/index/set|inlined.2
|
||||
(set_local $22
|
||||
;;@ assembly/index.ts:84:37
|
||||
;;@ assembly/index.ts:79:17
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $19
|
||||
;;@ assembly/index.ts:84:40
|
||||
(set_local $21
|
||||
;;@ assembly/index.ts:79:20
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $20
|
||||
;;@ assembly/index.ts:84:43
|
||||
;;@ assembly/index.ts:79:23
|
||||
(i32.or
|
||||
(i32.const 15110867)
|
||||
;;@ assembly/index.ts:84:55
|
||||
(i32.const 8723366)
|
||||
;;@ assembly/index.ts:79:34
|
||||
(i32.const -16777216)
|
||||
)
|
||||
)
|
||||
@ -820,7 +767,7 @@
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
@ -831,30 +778,74 @@
|
||||
(get_local $20)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:86:13
|
||||
(block $assembly/index/set_fade|inlined.1
|
||||
)
|
||||
;;@ assembly/index.ts:82:8
|
||||
(if
|
||||
;;@ assembly/index.ts:82:12
|
||||
(i32.eq
|
||||
(get_local $8)
|
||||
;;@ assembly/index.ts:82:30
|
||||
(i32.const 3)
|
||||
)
|
||||
;;@ assembly/index.ts:82:33
|
||||
(block $assembly/index/set|inlined.3
|
||||
(set_local $20
|
||||
;;@ assembly/index.ts:86:22
|
||||
;;@ assembly/index.ts:82:37
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $19
|
||||
;;@ assembly/index.ts:86:25
|
||||
(set_local $21
|
||||
;;@ assembly/index.ts:82:40
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $22
|
||||
;;@ assembly/index.ts:86:28
|
||||
;;@ assembly/index.ts:82:43
|
||||
(i32.or
|
||||
(i32.const 15110867)
|
||||
;;@ assembly/index.ts:82:55
|
||||
(i32.const -16777216)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $21)
|
||||
(get_global $assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $20)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $22)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:84:13
|
||||
(block $assembly/index/set_fade|inlined.1
|
||||
(set_local $22
|
||||
;;@ assembly/index.ts:84:22
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $21
|
||||
;;@ assembly/index.ts:84:25
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $20
|
||||
;;@ assembly/index.ts:84:28
|
||||
(get_local $13)
|
||||
)
|
||||
;;@ assembly/index.ts:23:2
|
||||
(set_local $21
|
||||
(set_local $19
|
||||
;;@ assembly/index.ts:23:10
|
||||
(select
|
||||
(tee_local $21
|
||||
(tee_local $19
|
||||
;;@ assembly/index.ts:23:19
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
;;@ assembly/index.ts:23:20
|
||||
(get_local $22)
|
||||
(get_local $20)
|
||||
;;@ assembly/index.ts:23:26
|
||||
(i32.const 24)
|
||||
)
|
||||
@ -867,7 +858,7 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $21)
|
||||
(get_local $19)
|
||||
(get_local $25)
|
||||
)
|
||||
)
|
||||
@ -876,25 +867,25 @@
|
||||
(block $assembly/index/set|inlined.4
|
||||
(set_local $25
|
||||
;;@ assembly/index.ts:24:6
|
||||
(get_local $20)
|
||||
(get_local $22)
|
||||
)
|
||||
(set_local $24
|
||||
;;@ assembly/index.ts:24:9
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
)
|
||||
(set_local $23
|
||||
;;@ assembly/index.ts:24:12
|
||||
(i32.or
|
||||
(i32.shl
|
||||
;;@ assembly/index.ts:24:13
|
||||
(get_local $21)
|
||||
(get_local $19)
|
||||
;;@ assembly/index.ts:24:18
|
||||
(i32.const 24)
|
||||
)
|
||||
;;@ assembly/index.ts:24:24
|
||||
(i32.and
|
||||
;;@ assembly/index.ts:24:25
|
||||
(get_local $22)
|
||||
(get_local $20)
|
||||
;;@ assembly/index.ts:24:29
|
||||
(i32.const 16777215)
|
||||
)
|
||||
@ -929,10 +920,10 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:52:27
|
||||
;;@ assembly/index.ts:51:27
|
||||
(set_local $5
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:52:29
|
||||
;;@ assembly/index.ts:51:29
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Conway's Game Of Life - AssemblyScript</title>
|
||||
<title>Conway's Game of Life - AssemblyScript</title>
|
||||
<style>
|
||||
html, body { height: 100%; margin: 0; overflow: hidden; color: #111; background: #fff; font-family: sans-serif; }
|
||||
h1 { padding: 20px; font-size: 12pt; margin: 0; }
|
||||
@ -12,7 +12,7 @@ canvas { position: absolute; top: 60px; left: 20px; width: calc(100% - 40px); he
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
<a href="https://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway's Game Of Life</a> in
|
||||
<a href="https://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway's Game of Life</a> in
|
||||
<a href="http://assemblyscript.org">AssemblyScript</a>
|
||||
( <a href="https://github.com/AssemblyScript/assemblyscript/blob/master/examples/game-of-life/assembly/index.ts">source</a> )
|
||||
</h1>
|
||||
@ -56,7 +56,7 @@ fetch("build/optimized.wasm")
|
||||
var exports = module.instance.exports;
|
||||
|
||||
// Initialize the module with the universe's width and height
|
||||
exports.init(width, height, Math.random());
|
||||
exports.init(width, height);
|
||||
|
||||
var mem = new Uint32Array(memory.buffer);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
Mandelbrot Set
|
||||
==============
|
||||
|
||||
An [AssemblyScript](http://assemblyscript.org) example. Renders the Mandelbrot set to a canvas. Compiles to ~350 bytes of optimized WASM.
|
||||
An [AssemblyScript](http://assemblyscript.org) example. Renders the Mandelbrot set to a canvas. Compiles to ~550 bytes of optimized WASM.
|
||||
|
||||
Instructions
|
||||
------------
|
||||
|
@ -1,24 +1,41 @@
|
||||
// see: https://en.wikipedia.org/wiki/Mandelbrot_set
|
||||
|
||||
/** Computes the number of iterations in the rectangle `width` x `height`, limited to `max`. */
|
||||
export function compute(width: u32, height: u32, max: u32): void {
|
||||
export function compute(width: u32, height: u32, limit: u32): void {
|
||||
var translateX = width / 1.6;
|
||||
var translateY = height / 2.0;
|
||||
var scale = 4.0 / width;
|
||||
var scale = 10.0 / min(3 * width, 4 * height);
|
||||
for (let y: u32 = 0; y < height; ++y) {
|
||||
let imaginary = (y - translateY) * scale;
|
||||
for (let x: u32 = 0; x < width; ++x) {
|
||||
let real = (x - translateX) * scale;
|
||||
let iteration = <u32>0;
|
||||
let ixsq: f64, iysq: f64;
|
||||
for (let ix = 0.0, iy = 0.0; (ixsq = ix * ix) + (iysq = iy * iy) <= 4.0; ++iteration) {
|
||||
|
||||
// Iterate until either the escape radius or iteration limit is exceeded
|
||||
let ix = 0.0, iy = 0.0, ixsq: f64, iysq: f64;
|
||||
let iteration: u32 = 0;
|
||||
while ((ixsq = ix * ix) + (iysq = iy * iy) <= 4.0) {
|
||||
let t = ixsq - iysq + real;
|
||||
iy = 2.0 * ix * iy + imaginary;
|
||||
ix = t;
|
||||
if (++iteration >= max) break;
|
||||
if (iteration >= limit) break;
|
||||
++iteration;
|
||||
}
|
||||
|
||||
// Do a few extra iterations to reduce error margin
|
||||
for (let i = 0; i < 4; ++i) {
|
||||
let t = (ixsq = ix * ix) - (iysq = iy * iy) + real;
|
||||
iy = 2.0 * ix * iy + imaginary;
|
||||
ix = t;
|
||||
}
|
||||
|
||||
// Renormalize, see: http://linas.org/art-gallery/escape/escape.html
|
||||
let frac: f64 = JSMath.log(JSMath.log(sqrt(ix * ix + iy * iy))) / JSMath.LN2;
|
||||
if (frac > 0) {
|
||||
let norm: f64 = max<f64>(min<f64>((<f64>(iteration + 1) - frac) / limit, 1.0), 0.0);
|
||||
store<u16>((y * width + x) << 1, <u32>(2047 * norm));
|
||||
} else {
|
||||
store<u16>((y * width + x) << 1, iteration * 2047 / limit);
|
||||
}
|
||||
// write normalized iterations to [0, width * height], row by row
|
||||
store<u8>(y * width + x, iteration * 255 / max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -1,23 +1,27 @@
|
||||
(module
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $FF (func (param 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 "compute" (func $assembly/index/compute))
|
||||
(export "memory" (memory $0))
|
||||
(func $assembly/index/compute (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(func $assembly/index/compute (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 f64)
|
||||
(local $4 f64)
|
||||
(local $5 i32)
|
||||
(local $6 f64)
|
||||
(local $7 f64)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 f64)
|
||||
(local $9 f64)
|
||||
(local $9 i32)
|
||||
(local $10 f64)
|
||||
(local $11 f64)
|
||||
(local $12 f64)
|
||||
(local $13 f64)
|
||||
(local $14 f64)
|
||||
(local $15 f64)
|
||||
;;@ assembly/index.ts:5:2
|
||||
(set_local $9
|
||||
(set_local $13
|
||||
;;@ assembly/index.ts:5:19
|
||||
(f64.div
|
||||
(f64.convert_u/i32
|
||||
@ -28,7 +32,7 @@
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:6:2
|
||||
(set_local $10
|
||||
(set_local $14
|
||||
;;@ assembly/index.ts:6:19
|
||||
(f64.div
|
||||
(f64.convert_u/i32
|
||||
@ -39,13 +43,28 @@
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:7:2
|
||||
(set_local $8
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:7:14
|
||||
(f64.div
|
||||
(f64.const 10)
|
||||
;;@ assembly/index.ts:7:21
|
||||
(f64.min
|
||||
;;@ assembly/index.ts:7:25
|
||||
(f64.mul
|
||||
(f64.const 3)
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:7:29
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:7:36
|
||||
(f64.mul
|
||||
(f64.const 4)
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:7:20
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:7:40
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -53,7 +72,7 @@
|
||||
(if
|
||||
;;@ assembly/index.ts:8:23
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:8:27
|
||||
(get_local $1)
|
||||
)
|
||||
@ -65,17 +84,17 @@
|
||||
(f64.sub
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:9:21
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
)
|
||||
;;@ assembly/index.ts:9:25
|
||||
(get_local $10)
|
||||
(get_local $14)
|
||||
)
|
||||
;;@ assembly/index.ts:9:39
|
||||
(get_local $8)
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:10:9
|
||||
(set_local $4
|
||||
(set_local $6
|
||||
;;@ assembly/index.ts:10:22
|
||||
(i32.const 0)
|
||||
)
|
||||
@ -83,7 +102,7 @@
|
||||
(if
|
||||
;;@ assembly/index.ts:10:25
|
||||
(i32.lt_u
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
;;@ assembly/index.ts:10:29
|
||||
(get_local $0)
|
||||
)
|
||||
@ -95,107 +114,101 @@
|
||||
(f64.sub
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:11:18
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
)
|
||||
;;@ assembly/index.ts:11:22
|
||||
(get_local $9)
|
||||
(get_local $13)
|
||||
)
|
||||
;;@ assembly/index.ts:11:36
|
||||
(get_local $8)
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:12:6
|
||||
(set_local $5
|
||||
;;@ assembly/index.ts:12:22
|
||||
(set_local $3
|
||||
;;@ assembly/index.ts:14:15
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $4
|
||||
;;@ assembly/index.ts:14:25
|
||||
(f64.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:15:6
|
||||
(set_local $7
|
||||
;;@ assembly/index.ts:15:27
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:14:6
|
||||
;;@ assembly/index.ts:16:6
|
||||
(block $break|2
|
||||
(set_local $6
|
||||
;;@ assembly/index.ts:14:20
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $7
|
||||
;;@ assembly/index.ts:14:30
|
||||
(f64.const 0)
|
||||
)
|
||||
(loop $continue|2
|
||||
(if
|
||||
;;@ assembly/index.ts:14:35
|
||||
;;@ assembly/index.ts:16:13
|
||||
(f64.le
|
||||
(f64.add
|
||||
(tee_local $13
|
||||
;;@ assembly/index.ts:14:43
|
||||
(tee_local $15
|
||||
;;@ assembly/index.ts:16:21
|
||||
(f64.mul
|
||||
(get_local $6)
|
||||
;;@ assembly/index.ts:14:48
|
||||
(get_local $6)
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:16:26
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:14:54
|
||||
(tee_local $14
|
||||
;;@ assembly/index.ts:14:62
|
||||
;;@ assembly/index.ts:16:32
|
||||
(tee_local $8
|
||||
;;@ assembly/index.ts:16:40
|
||||
(f64.mul
|
||||
(get_local $7)
|
||||
;;@ assembly/index.ts:14:67
|
||||
(get_local $7)
|
||||
(get_local $4)
|
||||
;;@ assembly/index.ts:16:45
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:14:74
|
||||
;;@ assembly/index.ts:16:52
|
||||
(f64.const 4)
|
||||
)
|
||||
(block
|
||||
;;@ assembly/index.ts:16:8
|
||||
(set_local $7
|
||||
;;@ assembly/index.ts:16:13
|
||||
;;@ assembly/index.ts:18:8
|
||||
(set_local $4
|
||||
;;@ assembly/index.ts:18:13
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
;;@ assembly/index.ts:16:19
|
||||
(get_local $6)
|
||||
;;@ assembly/index.ts:18:19
|
||||
(get_local $3)
|
||||
)
|
||||
;;@ assembly/index.ts:16:24
|
||||
(get_local $7)
|
||||
;;@ assembly/index.ts:18:24
|
||||
(get_local $4)
|
||||
)
|
||||
;;@ assembly/index.ts:16:29
|
||||
;;@ assembly/index.ts:18:29
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:17:8
|
||||
(set_local $6
|
||||
;;@ assembly/index.ts:15:16
|
||||
;;@ assembly/index.ts:19:8
|
||||
(set_local $3
|
||||
;;@ assembly/index.ts:17:16
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(get_local $13)
|
||||
;;@ assembly/index.ts:15:23
|
||||
(get_local $14)
|
||||
(get_local $15)
|
||||
;;@ assembly/index.ts:17:23
|
||||
(get_local $8)
|
||||
)
|
||||
;;@ assembly/index.ts:15:30
|
||||
;;@ assembly/index.ts:17:30
|
||||
(get_local $12)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:18:32
|
||||
;;@ assembly/index.ts:20:32
|
||||
(br_if $break|2
|
||||
;;@ assembly/index.ts:18:12
|
||||
;;@ assembly/index.ts:20:12
|
||||
(i32.ge_u
|
||||
(tee_local $5
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:18:14
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:18:27
|
||||
(get_local $7)
|
||||
;;@ assembly/index.ts:20:25
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:14:79
|
||||
(set_local $5
|
||||
;;@ assembly/index.ts:21:8
|
||||
(set_local $7
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:14:81
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:21:10
|
||||
(get_local $7)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -204,34 +217,203 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:21:6
|
||||
(i32.store8
|
||||
;;@ assembly/index.ts:21:16
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:21:20
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:25:11
|
||||
(set_local $9
|
||||
;;@ assembly/index.ts:25:19
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:21:28
|
||||
(loop $continue|3
|
||||
(if
|
||||
;;@ assembly/index.ts:25:22
|
||||
(i32.lt_s
|
||||
(get_local $9)
|
||||
;;@ assembly/index.ts:25:26
|
||||
(i32.const 4)
|
||||
)
|
||||
(block
|
||||
;;@ assembly/index.ts:26:8
|
||||
(set_local $8
|
||||
;;@ assembly/index.ts:26:16
|
||||
(f64.add
|
||||
(f64.sub
|
||||
;;@ assembly/index.ts:26:24
|
||||
(f64.mul
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:26:29
|
||||
(get_local $3)
|
||||
)
|
||||
;;@ assembly/index.ts:26:43
|
||||
(f64.mul
|
||||
(get_local $4)
|
||||
;;@ assembly/index.ts:26:48
|
||||
(get_local $4)
|
||||
)
|
||||
;;@ assembly/index.ts:21:31
|
||||
(i32.div_u
|
||||
)
|
||||
;;@ assembly/index.ts:26:54
|
||||
(get_local $12)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:27:8
|
||||
(set_local $4
|
||||
;;@ assembly/index.ts:27:13
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
;;@ assembly/index.ts:27:19
|
||||
(get_local $3)
|
||||
)
|
||||
;;@ assembly/index.ts:27:24
|
||||
(get_local $4)
|
||||
)
|
||||
;;@ assembly/index.ts:27:29
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:28:8
|
||||
(set_local $3
|
||||
;;@ assembly/index.ts:28:13
|
||||
(get_local $8)
|
||||
)
|
||||
;;@ assembly/index.ts:25:29
|
||||
(set_local $9
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:25:31
|
||||
(get_local $9)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|3)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:33:6
|
||||
(if
|
||||
;;@ assembly/index.ts:33:10
|
||||
(f64.gt
|
||||
;;@ assembly/index.ts:32:6
|
||||
(tee_local $8
|
||||
;;@ assembly/index.ts:32:22
|
||||
(f64.div
|
||||
;;@ assembly/index.ts:32:29
|
||||
(call $~lib/math/JSMath.log
|
||||
;;@ assembly/index.ts:32:40
|
||||
(call $~lib/math/JSMath.log
|
||||
;;@ assembly/index.ts:32:44
|
||||
(f64.sqrt
|
||||
;;@ assembly/index.ts:32:49
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(get_local $3)
|
||||
;;@ assembly/index.ts:32:54
|
||||
(get_local $3)
|
||||
)
|
||||
;;@ assembly/index.ts:32:59
|
||||
(f64.mul
|
||||
(get_local $4)
|
||||
;;@ assembly/index.ts:32:64
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:32:72
|
||||
(get_global $~lib/math/JSMath.LN2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:33:17
|
||||
(f64.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:35:8
|
||||
(i32.store16
|
||||
;;@ assembly/index.ts:35:19
|
||||
(i32.shl
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:35:20
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:21:43
|
||||
(i32.const 255)
|
||||
;;@ assembly/index.ts:35:24
|
||||
(get_local $0)
|
||||
)
|
||||
;;@ assembly/index.ts:21:49
|
||||
;;@ assembly/index.ts:35:32
|
||||
(get_local $6)
|
||||
)
|
||||
;;@ assembly/index.ts:35:38
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:35:41
|
||||
(i32.trunc_u/f64
|
||||
;;@ assembly/index.ts:35:47
|
||||
(f64.mul
|
||||
(f64.const 2047)
|
||||
;;@ assembly/index.ts:34:24
|
||||
(f64.max
|
||||
;;@ assembly/index.ts:34:33
|
||||
(f64.min
|
||||
;;@ assembly/index.ts:34:42
|
||||
(f64.div
|
||||
(f64.sub
|
||||
;;@ assembly/index.ts:34:43
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:34:49
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
;;@ assembly/index.ts:34:61
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:34:66
|
||||
(get_local $8)
|
||||
)
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:34:74
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:34:81
|
||||
(f64.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:34:87
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:37:8
|
||||
(i32.store16
|
||||
;;@ assembly/index.ts:37:19
|
||||
(i32.shl
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:37:20
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
;;@ assembly/index.ts:37:24
|
||||
(get_local $0)
|
||||
)
|
||||
;;@ assembly/index.ts:37:32
|
||||
(get_local $6)
|
||||
)
|
||||
;;@ assembly/index.ts:37:38
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:37:41
|
||||
(i32.div_u
|
||||
(i32.mul
|
||||
(get_local $7)
|
||||
;;@ assembly/index.ts:37:53
|
||||
(i32.const 2047)
|
||||
)
|
||||
;;@ assembly/index.ts:37:60
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:10:36
|
||||
(set_local $4
|
||||
(set_local $6
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:10:38
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -240,10 +422,10 @@
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:8:35
|
||||
(set_local $3
|
||||
(set_local $5
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:8:37
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
|
@ -1,10 +1,13 @@
|
||||
(module
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $FF (func (param 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 $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "compute" (func $assembly/index/compute))
|
||||
(export "memory" (memory $0))
|
||||
(func $assembly/index/compute (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $assembly/index/compute (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 f64)
|
||||
(local $4 f64)
|
||||
(local $5 f64)
|
||||
@ -12,12 +15,14 @@
|
||||
(local $7 f64)
|
||||
(local $8 i32)
|
||||
(local $9 f64)
|
||||
(local $10 i32)
|
||||
(local $10 f64)
|
||||
(local $11 f64)
|
||||
(local $12 f64)
|
||||
(local $13 f64)
|
||||
(local $14 f64)
|
||||
(local $14 i32)
|
||||
(local $15 f64)
|
||||
(local $16 i32)
|
||||
(local $17 f64)
|
||||
;;@ assembly/index.ts:5:2
|
||||
(set_local $3
|
||||
;;@ assembly/index.ts:5:19
|
||||
@ -44,10 +49,25 @@
|
||||
(set_local $5
|
||||
;;@ assembly/index.ts:7:14
|
||||
(f64.div
|
||||
(f64.const 10)
|
||||
;;@ assembly/index.ts:7:21
|
||||
(f64.min
|
||||
;;@ assembly/index.ts:7:25
|
||||
(f64.mul
|
||||
(f64.const 3)
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:7:29
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:7:36
|
||||
(f64.mul
|
||||
(f64.const 4)
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:7:20
|
||||
(get_local $0)
|
||||
;;@ assembly/index.ts:7:40
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -117,143 +137,326 @@
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:12:6
|
||||
;;@ assembly/index.ts:14:6
|
||||
(block
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:12:22
|
||||
;;@ assembly/index.ts:14:15
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $11
|
||||
;;@ assembly/index.ts:14:25
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:15:6
|
||||
(set_local $14
|
||||
;;@ assembly/index.ts:15:27
|
||||
(i32.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:13:6
|
||||
(nop)
|
||||
;;@ assembly/index.ts:14:6
|
||||
;;@ assembly/index.ts:16:6
|
||||
(block $break|2
|
||||
(block
|
||||
(set_local $13
|
||||
;;@ assembly/index.ts:14:20
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $14
|
||||
;;@ assembly/index.ts:14:30
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(loop $continue|2
|
||||
(if
|
||||
;;@ assembly/index.ts:14:35
|
||||
;;@ assembly/index.ts:16:13
|
||||
(f64.le
|
||||
(f64.add
|
||||
(tee_local $11
|
||||
;;@ assembly/index.ts:14:43
|
||||
(f64.mul
|
||||
(get_local $13)
|
||||
;;@ assembly/index.ts:14:48
|
||||
(get_local $13)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:14:54
|
||||
(tee_local $12
|
||||
;;@ assembly/index.ts:14:62
|
||||
;;@ assembly/index.ts:16:21
|
||||
(f64.mul
|
||||
(get_local $14)
|
||||
;;@ assembly/index.ts:14:67
|
||||
(get_local $14)
|
||||
(get_local $10)
|
||||
;;@ assembly/index.ts:16:26
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:16:32
|
||||
(tee_local $13
|
||||
;;@ assembly/index.ts:16:40
|
||||
(f64.mul
|
||||
(get_local $11)
|
||||
;;@ assembly/index.ts:16:45
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:14:74
|
||||
;;@ assembly/index.ts:16:52
|
||||
(f64.const 4)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
;;@ assembly/index.ts:15:8
|
||||
;;@ assembly/index.ts:17:8
|
||||
(set_local $15
|
||||
;;@ assembly/index.ts:15:16
|
||||
;;@ assembly/index.ts:17:16
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(get_local $11)
|
||||
;;@ assembly/index.ts:15:23
|
||||
(get_local $12)
|
||||
;;@ assembly/index.ts:17:23
|
||||
(get_local $13)
|
||||
)
|
||||
;;@ assembly/index.ts:15:30
|
||||
;;@ assembly/index.ts:17:30
|
||||
(get_local $9)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:16:8
|
||||
(set_local $14
|
||||
;;@ assembly/index.ts:16:13
|
||||
;;@ assembly/index.ts:18:8
|
||||
(set_local $11
|
||||
;;@ assembly/index.ts:18:13
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
;;@ assembly/index.ts:16:19
|
||||
(get_local $13)
|
||||
;;@ assembly/index.ts:18:19
|
||||
(get_local $10)
|
||||
)
|
||||
;;@ assembly/index.ts:16:24
|
||||
(get_local $14)
|
||||
;;@ assembly/index.ts:18:24
|
||||
(get_local $11)
|
||||
)
|
||||
;;@ assembly/index.ts:16:29
|
||||
;;@ assembly/index.ts:18:29
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:17:8
|
||||
(set_local $13
|
||||
;;@ assembly/index.ts:17:13
|
||||
;;@ assembly/index.ts:19:8
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:19:13
|
||||
(get_local $15)
|
||||
)
|
||||
;;@ assembly/index.ts:18:8
|
||||
;;@ assembly/index.ts:20:8
|
||||
(if
|
||||
;;@ assembly/index.ts:18:12
|
||||
;;@ assembly/index.ts:20:12
|
||||
(i32.ge_u
|
||||
(tee_local $10
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:18:14
|
||||
(get_local $10)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:18:27
|
||||
(get_local $14)
|
||||
;;@ assembly/index.ts:20:25
|
||||
(get_local $2)
|
||||
)
|
||||
;;@ assembly/index.ts:18:32
|
||||
;;@ assembly/index.ts:20:32
|
||||
(br $break|2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:14:79
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:21:8
|
||||
(set_local $14
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:14:81
|
||||
(get_local $10)
|
||||
;;@ assembly/index.ts:21:10
|
||||
(get_local $14)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:21:6
|
||||
(i32.store8
|
||||
;;@ assembly/index.ts:21:16
|
||||
;;@ assembly/index.ts:25:6
|
||||
(block $break|3
|
||||
;;@ assembly/index.ts:25:11
|
||||
(set_local $16
|
||||
;;@ assembly/index.ts:25:19
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|3
|
||||
(if
|
||||
;;@ assembly/index.ts:25:22
|
||||
(i32.lt_s
|
||||
(get_local $16)
|
||||
;;@ assembly/index.ts:25:26
|
||||
(i32.const 4)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
;;@ assembly/index.ts:26:8
|
||||
(set_local $15
|
||||
;;@ assembly/index.ts:26:16
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(tee_local $12
|
||||
;;@ assembly/index.ts:26:24
|
||||
(f64.mul
|
||||
(get_local $10)
|
||||
;;@ assembly/index.ts:26:29
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:26:35
|
||||
(tee_local $13
|
||||
;;@ assembly/index.ts:26:43
|
||||
(f64.mul
|
||||
(get_local $11)
|
||||
;;@ assembly/index.ts:26:48
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:26:54
|
||||
(get_local $9)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:27:8
|
||||
(set_local $11
|
||||
;;@ assembly/index.ts:27:13
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
;;@ assembly/index.ts:27:19
|
||||
(get_local $10)
|
||||
)
|
||||
;;@ assembly/index.ts:27:24
|
||||
(get_local $11)
|
||||
)
|
||||
;;@ assembly/index.ts:27:29
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:28:8
|
||||
(set_local $10
|
||||
;;@ assembly/index.ts:28:13
|
||||
(get_local $15)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:25:29
|
||||
(set_local $16
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:25:31
|
||||
(get_local $16)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:32:6
|
||||
(set_local $15
|
||||
;;@ assembly/index.ts:32:22
|
||||
(f64.div
|
||||
;;@ assembly/index.ts:32:29
|
||||
(call $~lib/math/JSMath.log
|
||||
;;@ assembly/index.ts:32:40
|
||||
(call $~lib/math/JSMath.log
|
||||
;;@ assembly/index.ts:32:44
|
||||
(f64.sqrt
|
||||
;;@ assembly/index.ts:32:49
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(get_local $10)
|
||||
;;@ assembly/index.ts:32:54
|
||||
(get_local $10)
|
||||
)
|
||||
;;@ assembly/index.ts:32:59
|
||||
(f64.mul
|
||||
(get_local $11)
|
||||
;;@ assembly/index.ts:32:64
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:32:72
|
||||
(get_global $~lib/math/JSMath.LN2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:33:6
|
||||
(if
|
||||
;;@ assembly/index.ts:33:10
|
||||
(f64.gt
|
||||
(get_local $15)
|
||||
;;@ assembly/index.ts:33:17
|
||||
(f64.const 0)
|
||||
)
|
||||
;;@ assembly/index.ts:33:20
|
||||
(block
|
||||
;;@ assembly/index.ts:34:8
|
||||
(set_local $17
|
||||
;;@ assembly/index.ts:34:24
|
||||
(f64.max
|
||||
;;@ assembly/index.ts:34:33
|
||||
(f64.min
|
||||
;;@ assembly/index.ts:34:42
|
||||
(f64.div
|
||||
(f64.sub
|
||||
;;@ assembly/index.ts:34:43
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:34:49
|
||||
(i32.add
|
||||
(get_local $14)
|
||||
;;@ assembly/index.ts:34:61
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:34:66
|
||||
(get_local $15)
|
||||
)
|
||||
(f64.convert_u/i32
|
||||
;;@ assembly/index.ts:34:74
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:34:81
|
||||
(f64.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:34:87
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:35:8
|
||||
(i32.store16
|
||||
;;@ assembly/index.ts:35:19
|
||||
(i32.shl
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:35:20
|
||||
(i32.mul
|
||||
(get_local $6)
|
||||
;;@ assembly/index.ts:21:20
|
||||
;;@ assembly/index.ts:35:24
|
||||
(get_local $0)
|
||||
)
|
||||
;;@ assembly/index.ts:21:28
|
||||
;;@ assembly/index.ts:35:32
|
||||
(get_local $8)
|
||||
)
|
||||
;;@ assembly/index.ts:21:31
|
||||
;;@ assembly/index.ts:35:38
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:35:41
|
||||
(i32.trunc_u/f64
|
||||
;;@ assembly/index.ts:35:47
|
||||
(f64.mul
|
||||
(f64.convert_u/i32
|
||||
(i32.const 2047)
|
||||
)
|
||||
;;@ assembly/index.ts:35:54
|
||||
(get_local $17)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:37:8
|
||||
(i32.store16
|
||||
;;@ assembly/index.ts:37:19
|
||||
(i32.shl
|
||||
(i32.add
|
||||
;;@ assembly/index.ts:37:20
|
||||
(i32.mul
|
||||
(get_local $6)
|
||||
;;@ assembly/index.ts:37:24
|
||||
(get_local $0)
|
||||
)
|
||||
;;@ assembly/index.ts:37:32
|
||||
(get_local $8)
|
||||
)
|
||||
;;@ assembly/index.ts:37:38
|
||||
(i32.const 1)
|
||||
)
|
||||
;;@ assembly/index.ts:37:41
|
||||
(i32.div_u
|
||||
(i32.mul
|
||||
(get_local $10)
|
||||
;;@ assembly/index.ts:21:43
|
||||
(i32.const 255)
|
||||
(get_local $14)
|
||||
;;@ assembly/index.ts:37:53
|
||||
(i32.const 2047)
|
||||
)
|
||||
;;@ assembly/index.ts:21:49
|
||||
;;@ assembly/index.ts:37:60
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;@ assembly/index.ts:10:36
|
||||
(set_local $8
|
||||
(i32.add
|
||||
|
@ -29,30 +29,30 @@ cnv.height = bcr.height | 0;
|
||||
// Fetch and instantiate the module
|
||||
fetch("build/optimized.wasm")
|
||||
.then(response => response.arrayBuffer())
|
||||
.then(buffer => WebAssembly.instantiate(buffer))
|
||||
.then(buffer => WebAssembly.instantiate(buffer, { JSMath: Math }))
|
||||
.then(module => {
|
||||
var exports = module.instance.exports;
|
||||
var memory = exports.memory;
|
||||
|
||||
// Compute required memory size and grow if necessary
|
||||
// Determine required memory size and grow if necessary
|
||||
var width = cnv.width | 0;
|
||||
var height = cnv.height | 0;
|
||||
var byteSize = width * height;
|
||||
var byteSize = 2 * width * height; // 2b per pixel (0..2041)
|
||||
if (memory.buffer.byteLength < byteSize) {
|
||||
let pages = ((byteSize - memory.buffer.byteLength + 0xffff) & ~0xffff) >>> 16;
|
||||
memory.grow(pages);
|
||||
}
|
||||
|
||||
// Compute number of iterations
|
||||
exports.compute(width, height, 100);
|
||||
|
||||
// Render to the canvas
|
||||
var mem = new Uint8Array(memory.buffer);
|
||||
// Compute and render to the canvas
|
||||
exports.compute(width, height, 40);
|
||||
var mem = new Uint16Array(memory.buffer);
|
||||
var imageData = ctx.createImageData(width, height);
|
||||
var argb = new Uint32Array(imageData.data.buffer);
|
||||
for (let y = 0; y < height; ++y) {
|
||||
let yx = y * width;
|
||||
for (let x = 0; x < width; ++x) argb[yx + x] = colors[mem[yx + x]];
|
||||
for (let x = 0; x < width; ++x) {
|
||||
argb[yx + x] = colors[mem[yx + x]];
|
||||
}
|
||||
}
|
||||
ctx.putImageData(imageData, 0, 0);
|
||||
}).catch(err => {
|
||||
@ -63,19 +63,18 @@ fetch("build/optimized.wasm")
|
||||
// Compute a nice set of colors using a gradient
|
||||
var colors = (() => {
|
||||
var cnv = document.createElement("canvas");
|
||||
cnv.width = 256;
|
||||
cnv.width = 2048;
|
||||
cnv.height = 1;
|
||||
var ctx = cnv.getContext("2d");
|
||||
var grd = ctx.createLinearGradient(0, 0, 256, 0);
|
||||
var grd = ctx.createLinearGradient(0, 0, 2048, 0);
|
||||
grd.addColorStop(0, "#000764");
|
||||
grd.addColorStop(0.16, "#2068CB");
|
||||
grd.addColorStop(0.42, "#EDFFFF");
|
||||
grd.addColorStop(0.6425, "#FFAA00");
|
||||
grd.addColorStop(0.8575, "#000200");
|
||||
grd.addColorStop(1.0, "#000764");
|
||||
grd.addColorStop(0.25, "#2068CB");
|
||||
grd.addColorStop(0.50, "#EDFFFF");
|
||||
grd.addColorStop(0.65, "#FFAA00");
|
||||
grd.addColorStop(0.85, "#000200");
|
||||
ctx.fillStyle = grd;
|
||||
ctx.fillRect(0, 0, 256, 1);
|
||||
return new Uint32Array(ctx.getImageData(0, 0, 256, 1).data.buffer);
|
||||
ctx.fillRect(0, 0, 2048, 1);
|
||||
return new Uint32Array(ctx.getImageData(0, 0, 2048, 1).data.buffer);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
@ -1,6 +1,6 @@
|
||||
const fs = require("fs");
|
||||
const compiled = new WebAssembly.Module(fs.readFileSync(__dirname + "/build/optimized.wasm"));
|
||||
const imports = {};
|
||||
const imports = { JSMath: Math };
|
||||
Object.defineProperty(module, "exports", {
|
||||
get: () => new WebAssembly.Instance(compiled, imports).exports
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
(module
|
||||
(type $iiFv (func (param i32 i32 f64)))
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $F (func (result f64)))
|
||||
(type $v (func))
|
||||
(import "JSMath" "random" (func $~lib/math/JSMath.random (result f64)))
|
||||
@ -10,10 +10,10 @@
|
||||
(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 $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(func $../../examples/game-of-life/assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(set_global $../../examples/game-of-life/assembly/index/w
|
||||
(get_local $0)
|
||||
)
|
||||
@ -46,13 +46,13 @@
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
(block
|
||||
(set_local $3
|
||||
(set_local $2
|
||||
(get_local $1)
|
||||
)
|
||||
(set_local $4
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $5
|
||||
(set_local $4
|
||||
(if (result i32)
|
||||
(f64.gt
|
||||
(call $~lib/math/JSMath.random)
|
||||
@ -68,15 +68,15 @@
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $5)
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
@ -337,38 +337,13 @@
|
||||
(i32.const 1)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $3
|
||||
(i32.lt_u
|
||||
(get_local $2)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $3)
|
||||
(i32.gt_u
|
||||
(get_local $2)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
(i32.const 14)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const -8053850)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
@ -390,7 +365,7 @@
|
||||
(tee_local $4
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
(tee_local $3
|
||||
(tee_local $2
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 24)
|
||||
@ -398,23 +373,39 @@
|
||||
(i32.const 7)
|
||||
)
|
||||
)
|
||||
(tee_local $2
|
||||
(tee_local $3
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $4)
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.const 16777215)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $0)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const -8053850)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
|
@ -1,5 +1,5 @@
|
||||
(module
|
||||
(type $iiFv (func (param i32 i32 f64)))
|
||||
(type $iiv (func (param i32 i32)))
|
||||
(type $F (func (result f64)))
|
||||
(type $v (func))
|
||||
(import "JSMath" "random" (func $~lib/math/JSMath.random (result f64)))
|
||||
@ -13,12 +13,12 @@
|
||||
(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 $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
|
||||
(func $../../examples/game-of-life/assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(set_global $../../examples/game-of-life/assembly/index/w
|
||||
(get_local $0)
|
||||
)
|
||||
@ -32,37 +32,37 @@
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(set_local $3
|
||||
(set_local $2
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(get_global $../../examples/game-of-life/assembly/index/h)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(block $break|1
|
||||
(set_local $4
|
||||
(set_local $3
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.0
|
||||
(set_local $5
|
||||
(get_local $4)
|
||||
)
|
||||
(set_local $6
|
||||
(set_local $4
|
||||
(get_local $3)
|
||||
)
|
||||
(set_local $7
|
||||
(set_local $5
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $6
|
||||
(if (result i32)
|
||||
(f64.gt
|
||||
(call $~lib/math/JSMath.random)
|
||||
@ -84,21 +84,21 @@
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $6)
|
||||
(get_local $5)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $5)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(set_local $3
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $3)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -108,9 +108,9 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(set_local $2
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -514,60 +514,21 @@
|
||||
(if
|
||||
(get_local $18)
|
||||
(if
|
||||
(i32.eq
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(tee_local $19
|
||||
(i32.lt_u
|
||||
(get_local $8)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(get_local $19)
|
||||
(i32.gt_u
|
||||
(get_local $8)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.1
|
||||
(set_local $19
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $20
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $21
|
||||
(i32.or
|
||||
(i32.const 8723366)
|
||||
(i32.const -16777216)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $20)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $19)
|
||||
(i32.const 14)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $21)
|
||||
)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set_fade|inlined.0
|
||||
(set_local $21
|
||||
(set_local $19
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $20
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $19
|
||||
(set_local $21
|
||||
(get_local $13)
|
||||
)
|
||||
(set_local $22
|
||||
@ -575,7 +536,7 @@
|
||||
(tee_local $22
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 7)
|
||||
@ -590,9 +551,9 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.2
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.1
|
||||
(set_local $23
|
||||
(get_local $21)
|
||||
(get_local $19)
|
||||
)
|
||||
(set_local $24
|
||||
(get_local $20)
|
||||
@ -604,7 +565,7 @@
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
(i32.const 16777215)
|
||||
)
|
||||
)
|
||||
@ -627,6 +588,36 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.2
|
||||
(set_local $22
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $21
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $20
|
||||
(i32.or
|
||||
(i32.const 8723366)
|
||||
(i32.const -16777216)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $21)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $22)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $20)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
@ -634,13 +625,13 @@
|
||||
(i32.const 3)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.3
|
||||
(set_local $22
|
||||
(set_local $20
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $19
|
||||
(set_local $21
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $20
|
||||
(set_local $22
|
||||
(i32.or
|
||||
(i32.const 15110867)
|
||||
(i32.const -16777216)
|
||||
@ -652,33 +643,33 @@
|
||||
(i32.add
|
||||
(get_global $../../examples/game-of-life/assembly/index/s)
|
||||
(i32.mul
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
(get_global $../../examples/game-of-life/assembly/index/w)
|
||||
)
|
||||
)
|
||||
(get_local $22)
|
||||
(get_local $20)
|
||||
)
|
||||
(i32.const 2)
|
||||
)
|
||||
(get_local $20)
|
||||
(get_local $22)
|
||||
)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set_fade|inlined.1
|
||||
(set_local $20
|
||||
(set_local $22
|
||||
(get_local $5)
|
||||
)
|
||||
(set_local $19
|
||||
(set_local $21
|
||||
(get_local $2)
|
||||
)
|
||||
(set_local $22
|
||||
(set_local $20
|
||||
(get_local $13)
|
||||
)
|
||||
(set_local $21
|
||||
(set_local $19
|
||||
(select
|
||||
(tee_local $21
|
||||
(tee_local $19
|
||||
(i32.sub
|
||||
(i32.shr_u
|
||||
(get_local $22)
|
||||
(get_local $20)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.const 7)
|
||||
@ -688,26 +679,26 @@
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $21)
|
||||
(get_local $19)
|
||||
(get_local $25)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $../../examples/game-of-life/assembly/index/set|inlined.4
|
||||
(set_local $25
|
||||
(get_local $20)
|
||||
(get_local $22)
|
||||
)
|
||||
(set_local $24
|
||||
(get_local $19)
|
||||
(get_local $21)
|
||||
)
|
||||
(set_local $23
|
||||
(i32.or
|
||||
(i32.shl
|
||||
(get_local $21)
|
||||
(get_local $19)
|
||||
(i32.const 24)
|
||||
)
|
||||
(i32.and
|
||||
(get_local $22)
|
||||
(get_local $20)
|
||||
(i32.const 16777215)
|
||||
)
|
||||
)
|
||||
|
@ -1,22 +1,26 @@
|
||||
(module
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $FF (func (param 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 "compute" (func $../../examples/mandelbrot/assembly/index/compute))
|
||||
(export "memory" (memory $0))
|
||||
(func $../../examples/mandelbrot/assembly/index/compute (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(func $../../examples/mandelbrot/assembly/index/compute (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 f64)
|
||||
(local $4 f64)
|
||||
(local $5 i32)
|
||||
(local $6 f64)
|
||||
(local $7 f64)
|
||||
(local $6 i32)
|
||||
(local $7 i32)
|
||||
(local $8 f64)
|
||||
(local $9 f64)
|
||||
(local $9 i32)
|
||||
(local $10 f64)
|
||||
(local $11 f64)
|
||||
(local $12 f64)
|
||||
(local $13 f64)
|
||||
(local $14 f64)
|
||||
(set_local $9
|
||||
(local $15 f64)
|
||||
(set_local $13
|
||||
(f64.div
|
||||
(f64.convert_u/i32
|
||||
(get_local $0)
|
||||
@ -24,7 +28,7 @@
|
||||
(f64.const 1.6)
|
||||
)
|
||||
)
|
||||
(set_local $10
|
||||
(set_local $14
|
||||
(f64.div
|
||||
(f64.convert_u/i32
|
||||
(get_local $1)
|
||||
@ -32,18 +36,29 @@
|
||||
(f64.const 2)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(set_local $10
|
||||
(f64.div
|
||||
(f64.const 4)
|
||||
(f64.const 10)
|
||||
(f64.min
|
||||
(f64.mul
|
||||
(f64.const 3)
|
||||
(f64.convert_u/i32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(f64.mul
|
||||
(f64.const 4)
|
||||
(f64.convert_u/i32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|0
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
(get_local $1)
|
||||
)
|
||||
(block
|
||||
@ -51,20 +66,20 @@
|
||||
(f64.mul
|
||||
(f64.sub
|
||||
(f64.convert_u/i32
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
)
|
||||
(get_local $14)
|
||||
)
|
||||
(get_local $10)
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(set_local $6
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(i32.lt_u
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
@ -72,78 +87,73 @@
|
||||
(f64.mul
|
||||
(f64.sub
|
||||
(f64.convert_u/i32
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
)
|
||||
(get_local $9)
|
||||
(get_local $13)
|
||||
)
|
||||
(get_local $8)
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(i32.const 0)
|
||||
(set_local $3
|
||||
(f64.const 0)
|
||||
)
|
||||
(block $break|2
|
||||
(set_local $6
|
||||
(set_local $4
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $7
|
||||
(f64.const 0)
|
||||
(i32.const 0)
|
||||
)
|
||||
(block $break|2
|
||||
(loop $continue|2
|
||||
(if
|
||||
(f64.le
|
||||
(f64.add
|
||||
(tee_local $13
|
||||
(tee_local $15
|
||||
(f64.mul
|
||||
(get_local $6)
|
||||
(get_local $6)
|
||||
(get_local $3)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(tee_local $14
|
||||
(tee_local $8
|
||||
(f64.mul
|
||||
(get_local $7)
|
||||
(get_local $7)
|
||||
(get_local $4)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f64.const 4)
|
||||
)
|
||||
(block
|
||||
(set_local $7
|
||||
(set_local $4
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
(get_local $6)
|
||||
(get_local $3)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $4)
|
||||
)
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
(set_local $6
|
||||
(set_local $3
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(get_local $13)
|
||||
(get_local $14)
|
||||
(get_local $15)
|
||||
(get_local $8)
|
||||
)
|
||||
(get_local $12)
|
||||
)
|
||||
)
|
||||
(br_if $break|2
|
||||
(i32.ge_u
|
||||
(tee_local $5
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $7)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(set_local $7
|
||||
(i32.add
|
||||
(get_local $5)
|
||||
(get_local $7)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -152,25 +162,141 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(set_local $9
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|3
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $9)
|
||||
(i32.const 4)
|
||||
)
|
||||
(block
|
||||
(set_local $8
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(f64.mul
|
||||
(get_local $3)
|
||||
(get_local $3)
|
||||
)
|
||||
(f64.mul
|
||||
(get_local $4)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(get_local $12)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
(get_local $3)
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.div_u
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(get_local $8)
|
||||
)
|
||||
(set_local $9
|
||||
(i32.add
|
||||
(get_local $9)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f64.gt
|
||||
(tee_local $8
|
||||
(f64.div
|
||||
(call $~lib/math/JSMath.log
|
||||
(call $~lib/math/JSMath.log
|
||||
(f64.sqrt
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(get_local $3)
|
||||
(get_local $3)
|
||||
)
|
||||
(f64.mul
|
||||
(get_local $4)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_global $~lib/math/JSMath.LN2)
|
||||
)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(i32.store16
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
(i32.const 255)
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.trunc_u/f64
|
||||
(f64.mul
|
||||
(f64.const 2047)
|
||||
(f64.max
|
||||
(f64.min
|
||||
(f64.div
|
||||
(f64.sub
|
||||
(f64.convert_u/i32
|
||||
(i32.add
|
||||
(get_local $7)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
(f64.convert_u/i32
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store16
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $5)
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.div_u
|
||||
(i32.mul
|
||||
(get_local $7)
|
||||
(i32.const 2047)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
)
|
||||
(set_local $6
|
||||
(i32.add
|
||||
(get_local $4)
|
||||
(get_local $6)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
@ -178,9 +304,9 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(set_local $5
|
||||
(i32.add
|
||||
(get_local $3)
|
||||
(get_local $5)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
|
@ -1,10 +1,13 @@
|
||||
(module
|
||||
(type $iiiv (func (param i32 i32 i32)))
|
||||
(type $FF (func (param 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 $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "compute" (func $../../examples/mandelbrot/assembly/index/compute))
|
||||
(export "memory" (memory $0))
|
||||
(func $../../examples/mandelbrot/assembly/index/compute (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(func $../../examples/mandelbrot/assembly/index/compute (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
|
||||
(local $3 f64)
|
||||
(local $4 f64)
|
||||
(local $5 f64)
|
||||
@ -12,12 +15,14 @@
|
||||
(local $7 f64)
|
||||
(local $8 i32)
|
||||
(local $9 f64)
|
||||
(local $10 i32)
|
||||
(local $10 f64)
|
||||
(local $11 f64)
|
||||
(local $12 f64)
|
||||
(local $13 f64)
|
||||
(local $14 f64)
|
||||
(local $14 i32)
|
||||
(local $15 f64)
|
||||
(local $16 i32)
|
||||
(local $17 f64)
|
||||
(set_local $3
|
||||
(f64.div
|
||||
(f64.convert_u/i32
|
||||
@ -36,11 +41,22 @@
|
||||
)
|
||||
(set_local $5
|
||||
(f64.div
|
||||
(f64.const 4)
|
||||
(f64.const 10)
|
||||
(f64.min
|
||||
(f64.mul
|
||||
(f64.const 3)
|
||||
(f64.convert_u/i32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(f64.mul
|
||||
(f64.const 4)
|
||||
(f64.convert_u/i32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(set_local $6
|
||||
@ -88,33 +104,32 @@
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
(set_local $10
|
||||
(i32.const 0)
|
||||
)
|
||||
(nop)
|
||||
(block $break|2
|
||||
(block
|
||||
(set_local $13
|
||||
(set_local $10
|
||||
(f64.const 0)
|
||||
)
|
||||
(set_local $11
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(set_local $14
|
||||
(f64.const 0)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(block $break|2
|
||||
(loop $continue|2
|
||||
(if
|
||||
(f64.le
|
||||
(f64.add
|
||||
(tee_local $11
|
||||
(f64.mul
|
||||
(get_local $13)
|
||||
(get_local $13)
|
||||
)
|
||||
)
|
||||
(tee_local $12
|
||||
(f64.mul
|
||||
(get_local $14)
|
||||
(get_local $14)
|
||||
(get_local $10)
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
(tee_local $13
|
||||
(f64.mul
|
||||
(get_local $11)
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -125,52 +140,155 @@
|
||||
(set_local $15
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(get_local $11)
|
||||
(get_local $12)
|
||||
(get_local $13)
|
||||
)
|
||||
(get_local $9)
|
||||
)
|
||||
)
|
||||
(set_local $14
|
||||
(set_local $11
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
(get_local $13)
|
||||
(get_local $10)
|
||||
)
|
||||
(get_local $14)
|
||||
(get_local $11)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(set_local $13
|
||||
(set_local $10
|
||||
(get_local $15)
|
||||
)
|
||||
(if
|
||||
(i32.ge_u
|
||||
(tee_local $10
|
||||
(i32.add
|
||||
(get_local $10)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $14)
|
||||
(get_local $2)
|
||||
)
|
||||
(br $break|2)
|
||||
)
|
||||
)
|
||||
(set_local $10
|
||||
(set_local $14
|
||||
(i32.add
|
||||
(get_local $10)
|
||||
(get_local $14)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $continue|2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store8
|
||||
(block $break|3
|
||||
(set_local $16
|
||||
(i32.const 0)
|
||||
)
|
||||
(loop $continue|3
|
||||
(if
|
||||
(i32.lt_s
|
||||
(get_local $16)
|
||||
(i32.const 4)
|
||||
)
|
||||
(block
|
||||
(block
|
||||
(set_local $15
|
||||
(f64.add
|
||||
(f64.sub
|
||||
(tee_local $12
|
||||
(f64.mul
|
||||
(get_local $10)
|
||||
(get_local $10)
|
||||
)
|
||||
)
|
||||
(tee_local $13
|
||||
(f64.mul
|
||||
(get_local $11)
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_local $9)
|
||||
)
|
||||
)
|
||||
(set_local $11
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(f64.mul
|
||||
(f64.const 2)
|
||||
(get_local $10)
|
||||
)
|
||||
(get_local $11)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
(set_local $10
|
||||
(get_local $15)
|
||||
)
|
||||
)
|
||||
(set_local $16
|
||||
(i32.add
|
||||
(get_local $16)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(br $continue|3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(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)
|
||||
)
|
||||
(f64.mul
|
||||
(get_local $11)
|
||||
(get_local $11)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_global $~lib/math/JSMath.LN2)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(f64.gt
|
||||
(get_local $15)
|
||||
(f64.const 0)
|
||||
)
|
||||
(block
|
||||
(set_local $17
|
||||
(f64.max
|
||||
(f64.min
|
||||
(f64.div
|
||||
(f64.sub
|
||||
(f64.convert_u/i32
|
||||
(i32.add
|
||||
(get_local $14)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $15)
|
||||
)
|
||||
(f64.convert_u/i32
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(i32.store16
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $6)
|
||||
@ -178,15 +296,39 @@
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.trunc_u/f64
|
||||
(f64.mul
|
||||
(f64.convert_u/i32
|
||||
(i32.const 2047)
|
||||
)
|
||||
(get_local $17)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.store16
|
||||
(i32.shl
|
||||
(i32.add
|
||||
(i32.mul
|
||||
(get_local $6)
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $8)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(i32.div_u
|
||||
(i32.mul
|
||||
(get_local $10)
|
||||
(i32.const 255)
|
||||
(get_local $14)
|
||||
(i32.const 2047)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $8
|
||||
(i32.add
|
||||
(get_local $8)
|
||||
|
Loading…
x
Reference in New Issue
Block a user