Fix a few issues with TSD generation; Update Binaryen

This commit is contained in:
dcodeIO
2018-05-21 10:31:00 +02:00
parent 98a0aa863d
commit e049e72171
25 changed files with 3082 additions and 2539 deletions

View File

@ -0,0 +1,15 @@
declare module ASModule {
type i8 = number;
type i16 = number;
type i32 = number;
type u8 = number;
type u16 = number;
type u32 = number;
type f32 = number;
type f64 = number;
type bool = any;
function init(width: i32, height: i32): void;
function step(): void;
function fill(x: u32, y: u32, p: f64): void;
}
export default ASModule;

View File

@ -171,7 +171,7 @@
(get_global $assembly/index/h)
)
(block
(set_local $4
(set_local $5
;;@ assembly/index.ts:53:14
(if (result i32)
(get_local $0)
@ -185,7 +185,7 @@
(get_local $7)
)
)
(set_local $5
(set_local $6
;;@ assembly/index.ts:54:14
(if (result i32)
(i32.eq
@ -233,10 +233,10 @@
(i32.shl
(i32.add
(i32.mul
(get_local $4)
(get_local $5)
(get_global $assembly/index/w)
)
(tee_local $3
(tee_local $2
;;@ assembly/index.ts:56:16
(if (result i32)
(get_local $1)
@ -263,7 +263,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $4)
(get_local $5)
(get_global $assembly/index/w)
)
(get_local $1)
@ -281,10 +281,10 @@
(i32.shl
(i32.add
(i32.mul
(get_local $4)
(get_local $5)
(get_global $assembly/index/w)
)
(tee_local $2
(tee_local $3
;;@ assembly/index.ts:57:16
(if (result i32)
(i32.eq
@ -319,7 +319,7 @@
(get_local $0)
(get_global $assembly/index/w)
)
(get_local $3)
(get_local $2)
)
(i32.const 2)
)
@ -337,7 +337,7 @@
(get_local $0)
(get_global $assembly/index/w)
)
(get_local $2)
(get_local $3)
)
(i32.const 2)
)
@ -352,10 +352,10 @@
(i32.shl
(i32.add
(i32.mul
(get_local $5)
(get_local $6)
(get_global $assembly/index/w)
)
(get_local $3)
(get_local $2)
)
(i32.const 2)
)
@ -370,7 +370,7 @@
(i32.shl
(i32.add
(i32.mul
(get_local $5)
(get_local $6)
(get_global $assembly/index/w)
)
(get_local $1)
@ -388,10 +388,10 @@
(i32.shl
(i32.add
(i32.mul
(get_local $5)
(get_local $6)
(get_global $assembly/index/w)
)
(get_local $2)
(get_local $3)
)
(i32.const 2)
)
@ -406,7 +406,7 @@
;;@ assembly/index.ts:68:10
(i32.and
;;@ assembly/index.ts:67:6
(tee_local $3
(tee_local $4
;;@ assembly/index.ts:15:9
(i32.load
;;@ assembly/index.ts:15:19
@ -429,7 +429,7 @@
;;@ assembly/index.ts:68:17
(i32.const 1)
)
;;@ assembly/index.ts:70:8
;;@ assembly/index.ts:68:20
(if
;;@ assembly/index.ts:70:12
(i32.eq
@ -462,13 +462,15 @@
(tee_local $2
(i32.sub
(i32.shr_u
(get_local $3)
(get_local $4)
(i32.const 24)
)
(get_global $assembly/index/BIT_ROT)
)
)
(i32.const 0)
(tee_local $3
(i32.const 0)
)
(i32.gt_s
(get_local $2)
(i32.const 0)
@ -477,7 +479,7 @@
(i32.const 24)
)
(i32.and
(get_local $3)
(get_local $4)
(i32.const 16777215)
)
)
@ -504,7 +506,7 @@
)
)
)
;;@ assembly/index.ts:75:8
;;@ assembly/index.ts:73:13
(if
;;@ assembly/index.ts:75:12
(i32.eq
@ -564,7 +566,7 @@
(i32.sub
(i32.shr_u
;;@ assembly/index.ts:27:20
(get_local $3)
(get_local $4)
;;@ assembly/index.ts:27:26
(i32.const 24)
)
@ -572,8 +574,10 @@
(get_global $assembly/index/BIT_ROT)
)
)
;;@ assembly/index.ts:27:41
(i32.const 0)
(tee_local $3
;;@ assembly/index.ts:27:41
(i32.const 0)
)
(i32.gt_s
(get_local $2)
(i32.const 0)
@ -585,7 +589,7 @@
;;@ assembly/index.ts:28:24
(i32.and
;;@ assembly/index.ts:28:25
(get_local $3)
(get_local $4)
;;@ assembly/index.ts:28:29
(i32.const 16777215)
)
@ -629,7 +633,7 @@
(get_global $assembly/index/w)
)
(block
;;@ assembly/index.ts:86:4
;;@ assembly/index.ts:85:33
(if
;;@ assembly/index.ts:86:8
(f64.lt
@ -673,7 +677,7 @@
)
)
;;@ assembly/index.ts:88:7
(set_local $1
(set_local $3
;;@ assembly/index.ts:88:16
(i32.const 0)
)
@ -681,12 +685,12 @@
(if
;;@ assembly/index.ts:88:19
(i32.lt_s
(get_local $1)
(get_local $3)
;;@ assembly/index.ts:88:24
(get_global $assembly/index/h)
)
(block
;;@ assembly/index.ts:89:4
;;@ assembly/index.ts:88:33
(if
;;@ assembly/index.ts:89:8
(f64.lt
@ -705,7 +709,7 @@
(get_global $assembly/index/s)
;;@ assembly/index.ts:21:18
(i32.mul
(get_local $1)
(get_local $3)
;;@ assembly/index.ts:21:22
(get_global $assembly/index/w)
)
@ -725,10 +729,10 @@
)
)
;;@ assembly/index.ts:88:27
(set_local $1
(set_local $3
(i32.add
;;@ assembly/index.ts:88:29
(get_local $1)
(get_local $3)
(i32.const 1)
)
)

View File

@ -1,7 +1,6 @@
(module
(type $iiv (func (param i32 i32)))
(type $F (func (result f64)))
(type $i (func (result i32)))
(type $v (func))
(type $iiFv (func (param i32 i32 f64)))
(import "env" "BGR_ALIVE" (global $assembly/index/BGR_ALIVE i32))
@ -12,7 +11,7 @@
(global $assembly/index/w (mut i32) (i32.const 0))
(global $assembly/index/h (mut i32) (i32.const 0))
(global $assembly/index/s (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 4))
(global $HEAP_BASE i32 (i32.const 8))
(export "init" (func $assembly/index/init))
(export "step" (func $assembly/index/step))
(export "fill" (func $assembly/index/fill))
@ -56,83 +55,79 @@
(get_global $assembly/index/h)
)
(block
(block
(block $break|1
;;@ assembly/index.ts:39:9
(set_local $3
;;@ assembly/index.ts:39:17
(i32.const 0)
)
(loop $continue|1
(if
;;@ assembly/index.ts:39:20
(i32.lt_s
(get_local $3)
;;@ assembly/index.ts:39:24
(get_global $assembly/index/w)
)
(block
(block
(block $assembly/index/set|inlined.0
(set_local $4
;;@ assembly/index.ts:40:16
(if (result i32)
(f64.gt
;;@ assembly/index.ts:40:21
(call $~lib/math/JSMath.random)
;;@ assembly/index.ts:40:32
(f64.const 0.1)
)
;;@ assembly/index.ts:40:38
(i32.and
(get_global $assembly/index/BGR_DEAD)
;;@ assembly/index.ts:40:49
(i32.const 16777215)
)
;;@ assembly/index.ts:40:62
(i32.or
(get_global $assembly/index/BGR_ALIVE)
;;@ assembly/index.ts:40:74
(i32.const -16777216)
)
)
(block $break|1
;;@ assembly/index.ts:39:9
(set_local $3
;;@ assembly/index.ts:39:17
(i32.const 0)
)
(loop $continue|1
(if
;;@ assembly/index.ts:39:20
(i32.lt_s
(get_local $3)
;;@ assembly/index.ts:39:24
(get_global $assembly/index/w)
)
(block
(block $assembly/index/set|inlined.0
(set_local $4
;;@ assembly/index.ts:40:16
(if (result i32)
(f64.gt
;;@ assembly/index.ts:40:21
(call $~lib/math/JSMath.random)
;;@ assembly/index.ts:40:32
(f64.const 0.1)
)
;;@ assembly/index.ts:21:2
(i32.store
;;@ assembly/index.ts:21:13
(i32.shl
(i32.add
;;@ assembly/index.ts:21:14
(i32.add
(get_global $assembly/index/s)
;;@ assembly/index.ts:21:18
(i32.mul
(get_local $2)
;;@ assembly/index.ts:21:22
(get_global $assembly/index/w)
)
)
;;@ assembly/index.ts:21:26
(get_local $3)
)
;;@ assembly/index.ts:21:32
(i32.const 2)
)
;;@ assembly/index.ts:21:35
(get_local $4)
;;@ assembly/index.ts:40:38
(i32.and
(get_global $assembly/index/BGR_DEAD)
;;@ assembly/index.ts:40:49
(i32.const 16777215)
)
;;@ assembly/index.ts:40:62
(i32.or
(get_global $assembly/index/BGR_ALIVE)
;;@ assembly/index.ts:40:74
(i32.const -16777216)
)
)
)
;;@ assembly/index.ts:39:27
(set_local $3
(i32.add
;;@ assembly/index.ts:39:29
(get_local $3)
(i32.const 1)
;;@ assembly/index.ts:21:2
(i32.store
;;@ assembly/index.ts:21:13
(i32.shl
(i32.add
;;@ assembly/index.ts:21:14
(i32.add
(get_global $assembly/index/s)
;;@ assembly/index.ts:21:18
(i32.mul
(get_local $2)
;;@ assembly/index.ts:21:22
(get_global $assembly/index/w)
)
)
;;@ assembly/index.ts:21:26
(get_local $3)
)
;;@ assembly/index.ts:21:32
(i32.const 2)
)
;;@ assembly/index.ts:21:35
(get_local $4)
)
(br $continue|1)
)
;;@ assembly/index.ts:39:27
(set_local $3
(i32.add
;;@ assembly/index.ts:39:29
(get_local $3)
(i32.const 1)
)
)
(br $continue|1)
)
)
)
@ -164,10 +159,6 @@
(local $9 i32)
(local $10 i32)
(local $11 i32)
(local $12 i32)
(local $13 i32)
(local $14 i32)
(local $15 i32)
;;@ assembly/index.ts:47:2
(block
(set_local $0
@ -526,7 +517,7 @@
;;@ assembly/index.ts:68:17
(i32.const 1)
)
;;@ assembly/index.ts:70:8
;;@ assembly/index.ts:68:20
(if
;;@ assembly/index.ts:70:12
(i32.eq
@ -594,7 +585,7 @@
)
;;@ assembly/index.ts:72:13
(block $assembly/index/set|inlined.2
(set_local $12
(set_local $10
;;@ assembly/index.ts:72:23
(i32.or
(get_global $assembly/index/BGR_DEAD)
@ -616,11 +607,11 @@
)
(i32.const 2)
)
(get_local $12)
(get_local $10)
)
)
)
;;@ assembly/index.ts:75:8
;;@ assembly/index.ts:73:13
(if
;;@ assembly/index.ts:75:12
(i32.eq
@ -630,7 +621,7 @@
)
;;@ assembly/index.ts:75:33
(block $assembly/index/set|inlined.3
(set_local $13
(set_local $10
;;@ assembly/index.ts:75:43
(i32.or
(get_global $assembly/index/BGR_ALIVE)
@ -652,16 +643,16 @@
)
(i32.const 2)
)
(get_local $13)
(get_local $10)
)
)
;;@ assembly/index.ts:77:13
(block $assembly/index/rot|inlined.1
;;@ assembly/index.ts:27:2
(set_local $14
(set_local $10
;;@ assembly/index.ts:27:10
(select
(tee_local $14
(tee_local $10
;;@ assembly/index.ts:27:19
(i32.sub
(i32.shr_u
@ -674,24 +665,24 @@
(get_global $assembly/index/BIT_ROT)
)
)
(tee_local $15
(tee_local $11
;;@ assembly/index.ts:27:41
(i32.const 0)
)
(i32.gt_s
(get_local $14)
(get_local $15)
(get_local $10)
(get_local $11)
)
)
)
;;@ assembly/index.ts:28:2
(block $assembly/index/set|inlined.4
(set_local $15
(set_local $11
;;@ assembly/index.ts:28:12
(i32.or
(i32.shl
;;@ assembly/index.ts:28:13
(get_local $14)
(get_local $10)
;;@ assembly/index.ts:28:18
(i32.const 24)
)
@ -726,7 +717,7 @@
(i32.const 2)
)
;;@ assembly/index.ts:21:35
(get_local $15)
(get_local $11)
)
)
)
@ -764,8 +755,6 @@
(func $assembly/index/fill (; 3 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
;;@ assembly/index.ts:85:2
(block $break|0
;;@ assembly/index.ts:85:7
@ -782,42 +771,40 @@
(get_global $assembly/index/w)
)
(block
(block
;;@ assembly/index.ts:86:4
(if
;;@ assembly/index.ts:86:8
(f64.lt
;;@ assembly/index.ts:86:13
(call $~lib/math/JSMath.random)
;;@ assembly/index.ts:86:24
(get_local $2)
;;@ assembly/index.ts:85:33
(if
;;@ assembly/index.ts:86:8
(f64.lt
;;@ assembly/index.ts:86:13
(call $~lib/math/JSMath.random)
;;@ assembly/index.ts:86:24
(get_local $2)
)
;;@ assembly/index.ts:86:27
(block $assembly/index/set|inlined.5
(set_local $4
;;@ assembly/index.ts:86:38
(i32.or
(get_global $assembly/index/BGR_ALIVE)
;;@ assembly/index.ts:86:50
(i32.const -16777216)
)
)
;;@ assembly/index.ts:86:27
(block $assembly/index/set|inlined.5
(set_local $4
;;@ assembly/index.ts:86:38
(i32.or
(get_global $assembly/index/BGR_ALIVE)
;;@ assembly/index.ts:86:50
(i32.const -16777216)
)
)
(i32.store
(i32.shl
(i32.store
(i32.shl
(i32.add
(i32.add
(i32.add
(get_global $assembly/index/s)
(i32.mul
(get_local $1)
(get_global $assembly/index/w)
)
(get_global $assembly/index/s)
(i32.mul
(get_local $1)
(get_global $assembly/index/w)
)
(get_local $3)
)
(i32.const 2)
(get_local $3)
)
(get_local $4)
(i32.const 2)
)
(get_local $4)
)
)
)
@ -837,7 +824,7 @@
;;@ assembly/index.ts:88:2
(block $break|1
;;@ assembly/index.ts:88:7
(set_local $5
(set_local $3
;;@ assembly/index.ts:88:16
(i32.const 0)
)
@ -845,63 +832,61 @@
(if
;;@ assembly/index.ts:88:19
(i32.lt_s
(get_local $5)
(get_local $3)
;;@ assembly/index.ts:88:24
(get_global $assembly/index/h)
)
(block
(block
;;@ assembly/index.ts:89:4
(if
;;@ assembly/index.ts:89:8
(f64.lt
;;@ assembly/index.ts:89:13
(call $~lib/math/JSMath.random)
;;@ assembly/index.ts:89:24
(get_local $2)
;;@ assembly/index.ts:88:33
(if
;;@ assembly/index.ts:89:8
(f64.lt
;;@ assembly/index.ts:89:13
(call $~lib/math/JSMath.random)
;;@ assembly/index.ts:89:24
(get_local $2)
)
;;@ assembly/index.ts:89:27
(block $assembly/index/set|inlined.6
(set_local $4
;;@ assembly/index.ts:89:38
(i32.or
(get_global $assembly/index/BGR_ALIVE)
;;@ assembly/index.ts:89:50
(i32.const -16777216)
)
)
;;@ assembly/index.ts:89:27
(block $assembly/index/set|inlined.6
(set_local $6
;;@ assembly/index.ts:89:38
(i32.or
(get_global $assembly/index/BGR_ALIVE)
;;@ assembly/index.ts:89:50
(i32.const -16777216)
)
)
;;@ assembly/index.ts:21:2
(i32.store
;;@ assembly/index.ts:21:13
(i32.shl
;;@ assembly/index.ts:21:2
(i32.store
;;@ assembly/index.ts:21:13
(i32.shl
(i32.add
;;@ assembly/index.ts:21:14
(i32.add
;;@ assembly/index.ts:21:14
(i32.add
(get_global $assembly/index/s)
;;@ assembly/index.ts:21:18
(i32.mul
(get_local $5)
;;@ assembly/index.ts:21:22
(get_global $assembly/index/w)
)
(get_global $assembly/index/s)
;;@ assembly/index.ts:21:18
(i32.mul
(get_local $3)
;;@ assembly/index.ts:21:22
(get_global $assembly/index/w)
)
;;@ assembly/index.ts:21:26
(get_local $0)
)
;;@ assembly/index.ts:21:32
(i32.const 2)
;;@ assembly/index.ts:21:26
(get_local $0)
)
;;@ assembly/index.ts:21:35
(get_local $6)
;;@ assembly/index.ts:21:32
(i32.const 2)
)
;;@ assembly/index.ts:21:35
(get_local $4)
)
)
)
;;@ assembly/index.ts:88:27
(set_local $5
(set_local $3
(i32.add
;;@ assembly/index.ts:88:29
(get_local $5)
(get_local $3)
(i32.const 1)
)
)

View File

@ -4,7 +4,7 @@
"private": true,
"scripts": {
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --validate --measure",
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --use Math=JSMath -O3 --importMemory --sourceMap --validate --noDebug --measure",
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --noDebug --measure",
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
"server": "http-server . -o -c-1"
},

View File

@ -0,0 +1,43 @@
declare module ASModule {
type i8 = number;
type i16 = number;
type i32 = number;
type u8 = number;
type u16 = number;
type u32 = number;
type f32 = number;
type f64 = number;
type bool = any;
function getLo(): u32;
function getHi(): u32;
function clz(loLeft: u32, hiLeft: u32): void;
function ctz(loLeft: u32, hiLeft: u32): void;
function popcnt(loLeft: u32, hiLeft: u32): void;
function eqz(loLeft: u32, hiLeft: u32): void;
function add(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function sub(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function mul(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function div_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function div_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function rem_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function rem_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function and(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function or(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function xor(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function shl(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function shr_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function shr_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function rotl(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function rotr(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function eq(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function ne(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function lt_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function lt_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function le_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function le_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function gt_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function gt_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function ge_s(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
function ge_u(loLeft: u32, hiLeft: u32, loRight: u32, hiRight: u32): void;
}
export default ASModule;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@
"scripts": {
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
"asbuild:untouched": "asc assembly/i64.ts -t build/untouched.wat -b build/untouched.wasm --noMemory --validate --sourceMap --measure",
"asbuild:optimized": "asc -O assembly/i64.ts -b build/optimized.wasm -t build/optimized.wat --noMemory --validate --sourceMap --measure",
"asbuild:optimized": "asc -O assembly/i64.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --noMemory --validate --sourceMap --measure",
"test": "node tests"
},
"files": [

View File

@ -0,0 +1,13 @@
declare module ASModule {
type i8 = number;
type i16 = number;
type i32 = number;
type u8 = number;
type u16 = number;
type u32 = number;
type f32 = number;
type f64 = number;
type bool = any;
function computeLine(y: u32, width: u32, height: u32, limit: u32): void;
}
export default ASModule;

View File

@ -124,7 +124,7 @@
;;@ assembly/index.ts:18:11
(f64.le
(f64.add
(tee_local $8
(tee_local $7
;;@ assembly/index.ts:18:19
(f64.mul
(get_local $4)
@ -133,7 +133,7 @@
)
)
;;@ assembly/index.ts:18:30
(tee_local $7
(tee_local $8
;;@ assembly/index.ts:18:38
(f64.mul
(get_local $5)
@ -168,9 +168,9 @@
;;@ assembly/index.ts:19:18
(f64.add
(f64.sub
(get_local $8)
;;@ assembly/index.ts:19:25
(get_local $7)
;;@ assembly/index.ts:19:25
(get_local $8)
)
;;@ assembly/index.ts:19:32
(get_local $10)
@ -199,7 +199,7 @@
)
)
;;@ assembly/index.ts:27:9
(set_local $8
(set_local $7
;;@ assembly/index.ts:27:29
(f64.min
;;@ assembly/index.ts:27:33
@ -218,11 +218,11 @@
(get_local $6)
)
;;@ assembly/index.ts:27:56
(get_local $8)
(get_local $7)
)
(block
;;@ assembly/index.ts:28:6
(set_local $7
(set_local $8
;;@ assembly/index.ts:28:18
(f64.add
(f64.sub
@ -262,7 +262,7 @@
;;@ assembly/index.ts:30:6
(set_local $4
;;@ assembly/index.ts:30:11
(get_local $7)
(get_local $8)
)
;;@ assembly/index.ts:27:71
(set_local $6
@ -297,7 +297,7 @@
(if (result i32)
(f64.eq
(f64.sub
(tee_local $4
(tee_local $8
;;@ assembly/index.ts:36:4
(tee_local $7
;;@ assembly/index.ts:36:15
@ -330,7 +330,7 @@
)
)
)
(get_local $4)
(get_local $8)
)
(f64.const 0)
)

View File

@ -1,6 +1,5 @@
(module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $FF (func (param f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFFF (func (param f64 f64 f64) (result f64)))
@ -9,11 +8,11 @@
(import "JSMath" "LN2" (global $~lib/math/JSMath.LN2 f64))
(import "env" "memory" (memory $0 1))
(global $assembly/index/NUM_COLORS i32 (i32.const 2048))
(global $HEAP_BASE i32 (i32.const 4))
(global $HEAP_BASE i32 (i32.const 8))
(export "computeLine" (func $assembly/index/computeLine))
(export "memory" (memory $0))
(func $isFinite<f64> (; 2 ;) (type $Fi) (param $0 f64) (result i32)
;;@ ~lib/builtins.ts:22:26
;;@ ~lib/builtins.ts:21:44
(return
;;@ ~lib/builtins.ts:22:9
(f64.eq
@ -28,7 +27,7 @@
)
)
(func $assembly/index/clamp<f64> (; 3 ;) (type $FFFF) (param $0 f64) (param $1 f64) (param $2 f64) (result f64)
;;@ assembly/index.ts:47:43
;;@ assembly/index.ts:46:57
(return
;;@ assembly/index.ts:47:9
(f64.min
@ -58,9 +57,7 @@
(local $14 i32)
(local $15 f64)
(local $16 f64)
(local $17 f64)
(local $18 f64)
(local $19 i32)
(local $17 i32)
;;@ assembly/index.ts:8:2
(set_local $4
;;@ assembly/index.ts:8:19
@ -267,7 +264,7 @@
;;@ assembly/index.ts:27:4
(block $break|2
;;@ assembly/index.ts:27:9
(set_local $16
(set_local $15
;;@ assembly/index.ts:27:29
(f64.min
;;@ assembly/index.ts:27:33
@ -286,12 +283,12 @@
(get_local $14)
)
;;@ assembly/index.ts:27:56
(get_local $16)
(get_local $15)
)
(block
(block
;;@ assembly/index.ts:28:6
(set_local $17
(set_local $16
;;@ assembly/index.ts:28:18
(f64.add
(f64.sub
@ -331,7 +328,7 @@
;;@ assembly/index.ts:30:6
(set_local $10
;;@ assembly/index.ts:30:11
(get_local $17)
(get_local $16)
)
)
;;@ assembly/index.ts:27:71
@ -348,7 +345,7 @@
)
)
;;@ assembly/index.ts:36:4
(set_local $18
(set_local $15
;;@ assembly/index.ts:36:15
(f64.div
;;@ assembly/index.ts:36:20
@ -379,12 +376,12 @@
)
)
;;@ assembly/index.ts:37:4
(set_local $19
(set_local $17
;;@ assembly/index.ts:37:15
(if (result i32)
(call $isFinite<f64>
;;@ assembly/index.ts:37:24
(get_local $18)
(get_local $15)
)
;;@ assembly/index.ts:38:8
(i32.trunc_u/f64
@ -412,7 +409,7 @@
)
)
;;@ assembly/index.ts:38:56
(get_local $18)
(get_local $15)
)
(f64.convert_u/i32
;;@ assembly/index.ts:38:64
@ -452,7 +449,7 @@
(i32.const 1)
)
;;@ assembly/index.ts:40:37
(get_local $19)
(get_local $17)
)
)
;;@ assembly/index.ts:12:34

View File

@ -4,7 +4,7 @@
"private": true,
"scripts": {
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --validate --measure",
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat --use Math=JSMath -O3 --importMemory --sourceMap --validate --noDebug --measure",
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --noDebug --measure",
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
"server": "http-server . -o -c-1"
},

View File

@ -14,26 +14,28 @@ function asmFunc(global, env, buffer) {
var Math_clz32 = global.Math.clz32;
var Math_min = global.Math.min;
var Math_max = global.Math.max;
var Math_floor = global.Math.floor;
var Math_ceil = global.Math.ceil;
var Math_sqrt = global.Math.sqrt;
var abort = env.abort;
var $lib_allocator_arena_startOffset = 0;
var $lib_allocator_arena_offset = 0;
var assembly_index_system = 0;
var HEAP_BASE = 36;
var HEAP_BASE = 40;
var i64toi32_i32$HIGH_BITS = 0;
function $lib_allocator_arena_allocate_memory($0) {
$0 = $0 | 0;
var $1 = 0, $2 = 0, $3 = 0, $4 = 0, wasm2asm_i32$0 = 0, wasm2asm_i32$1 = 0, wasm2asm_i32$2 = 0;
var $3 = 0, $1 = 0, $2 = 0, wasm2asm_i32$0 = 0, wasm2asm_i32$1 = 0, wasm2asm_i32$2 = 0;
if ($0) {
if ($0 >>> 0 > 1073741824 >>> 0) abort();
$1 = $lib_allocator_arena_offset;
$2 = (($1 + $0 | 0) + 7 | 0) & 4294967288 | 0;
$0 = __wasm_current_memory();
if ($2 >>> 0 > ($0 << 16 | 0) >>> 0) {
$3 = ((($2 - $1 | 0) + 65535 | 0) & 4294901760 | 0) >>> 16 | 0;
$4 = $3;
if ((__wasm_grow_memory((wasm2asm_i32$2 = ($0 | 0) > ($4 | 0), wasm2asm_i32$0 = $0, wasm2asm_i32$1 = $4, wasm2asm_i32$2 ? wasm2asm_i32$0 : wasm2asm_i32$1) | 0) | 0) < (0 | 0)) if ((__wasm_grow_memory($3 | 0) | 0) < (0 | 0)) abort();;
$0 = (($1 + $0 | 0) + 7 | 0) & 4294967288 | 0;
$2 = __wasm_current_memory();
if ($0 >>> 0 > ($2 << 16 | 0) >>> 0) {
$3 = ((($0 - $1 | 0) + 65535 | 0) & 4294901760 | 0) >>> 16 | 0;
if ((__wasm_grow_memory((wasm2asm_i32$2 = ($2 | 0) > ($3 | 0), wasm2asm_i32$0 = $2, wasm2asm_i32$1 = $3, wasm2asm_i32$2 ? wasm2asm_i32$0 : wasm2asm_i32$1) | 0) | 0) < (0 | 0)) if ((__wasm_grow_memory($3 | 0) | 0) < (0 | 0)) abort();;
}
$lib_allocator_arena_offset = $2;
$lib_allocator_arena_offset = $0;
return $1 | 0;
}
return 0 | 0;
@ -48,8 +50,8 @@ function asmFunc(global, env, buffer) {
$5 = +$5;
$6 = +$6;
$7 = +$7;
var $8 = 0, $9 = 0;
if ($0) $9 = $0; else {
var $8 = 0, $29 = 0;
if ($0) $29 = $0; else {
$8 = $lib_allocator_arena_allocate_memory(56 | 0) | 0;
HEAPF64[$8 >> 3] = $1;
HEAPF64[($8 + 8 | 0) >> 3] = $2;
@ -58,16 +60,16 @@ function asmFunc(global, env, buffer) {
HEAPF64[($8 + 32 | 0) >> 3] = $5;
HEAPF64[($8 + 40 | 0) >> 3] = $6;
HEAPF64[($8 + 48 | 0) >> 3] = $7;
$9 = $8;
$29 = $8;
}
return $9 | 0;
return $29 | 0;
}
function $lib_memory_set_memory($0, $1, $2) {
$0 = $0 | 0;
$1 = $1 | 0;
$2 = $2 | 0;
var i64toi32_i32$3 = 0, i64toi32_i32$2 = 0, $4 = 0, i64toi32_i32$5 = 0, $3 = 0, $3$hi = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, $11 = 0, i64toi32_i32$0 = 0, wasm2asm_i32$0 = 0, wasm2asm_i32$1 = 0;
var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, $4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $3 = 0, $14 = 0, $126 = 0, $126$hi = 0, $129$hi = 0, $3$hi = 0, wasm2asm_i32$0 = 0, wasm2asm_i32$1 = 0;
if (($2 | 0) == (0 | 0)) return;
HEAP8[$0 >> 0] = $1;
HEAP8[(($0 + $2 | 0) - 1 | 0) >> 0] = $1;
@ -104,41 +106,52 @@ function asmFunc(global, env, buffer) {
$0 = $0 + $4 | 0;
$2 = $2 - $4 | 0;
i64toi32_i32$0 = 0;
i64toi32_i32$3 = $1;
$126 = $1;
$126$hi = i64toi32_i32$0;
i64toi32_i32$0 = 0;
i64toi32_i32$0 = i64toi32_i32$0;
i64toi32_i32$2 = $1;
i64toi32_i32$1 = 0;
i64toi32_i32$3 = $1;
i64toi32_i32$2 = 0;
i64toi32_i32$4 = 32;
i64toi32_i32$5 = i64toi32_i32$4 & 31 | 0;
if (32 >>> 0 <= (i64toi32_i32$4 & 63 | 0) >>> 0) {
i64toi32_i32$2 = i64toi32_i32$3 << i64toi32_i32$5 | 0;
$11 = 0;
i64toi32_i32$3 = 32;
i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0;
if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) {
i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4 | 0;
$14 = 0;
} else {
i64toi32_i32$2 = ((1 << i64toi32_i32$5 | 0) - 1 | 0) & (i64toi32_i32$3 >>> (32 - i64toi32_i32$5 | 0) | 0) | 0 | (i64toi32_i32$1 << i64toi32_i32$5 | 0) | 0;
$11 = i64toi32_i32$3 << i64toi32_i32$5 | 0;
i64toi32_i32$1 = ((1 << i64toi32_i32$4 | 0) - 1 | 0) & (i64toi32_i32$2 >>> (32 - i64toi32_i32$4 | 0) | 0) | 0 | (i64toi32_i32$0 << i64toi32_i32$4 | 0) | 0;
$14 = i64toi32_i32$2 << i64toi32_i32$4 | 0;
}
i64toi32_i32$1 = $11;
i64toi32_i32$2 = i64toi32_i32$0 | i64toi32_i32$2 | 0;
$3 = i64toi32_i32$3 | i64toi32_i32$1 | 0;
$129$hi = i64toi32_i32$1;
i64toi32_i32$1 = $126$hi;
i64toi32_i32$0 = $126;
i64toi32_i32$2 = $129$hi;
i64toi32_i32$3 = $14;
i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
$3 = i64toi32_i32$0 | i64toi32_i32$3 | 0;
$3$hi = i64toi32_i32$2;
continue_0 : do {
if ($2 >>> 0 >= 32 >>> 0) {
i64toi32_i32$3 = $0;
i64toi32_i32$2 = $3$hi;
HEAP32[i64toi32_i32$3 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$3, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$3 = $0 + 8 | 0;
i64toi32_i32$2 = $3$hi;
HEAP32[i64toi32_i32$3 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$3, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$3 = $0 + 16 | 0;
i64toi32_i32$2 = $3$hi;
HEAP32[i64toi32_i32$3 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$3, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$3 = $0 + 24 | 0;
i64toi32_i32$2 = $3$hi;
HEAP32[i64toi32_i32$3 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$3, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$0 = $0;
i64toi32_i32$2 = i64toi32_i32$2;
HEAP32[$0 >> 2] = $3;
(wasm2asm_i32$0 = $0, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
i64toi32_i32$0 = $0 + 8 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
HEAP32[i64toi32_i32$0 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$0, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
i64toi32_i32$0 = $0 + 16 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
HEAP32[i64toi32_i32$0 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$0, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
i64toi32_i32$0 = $0 + 24 | 0;
i64toi32_i32$2 = i64toi32_i32$2;
HEAP32[i64toi32_i32$0 >> 2] = $3;
(wasm2asm_i32$0 = i64toi32_i32$0, wasm2asm_i32$1 = i64toi32_i32$2), ((HEAP8[(wasm2asm_i32$0 + 4 | 0) >> 0] = wasm2asm_i32$1 & 255 | 0, HEAP8[(wasm2asm_i32$0 + 5 | 0) >> 0] = (wasm2asm_i32$1 >>> 8 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 6 | 0) >> 0] = (wasm2asm_i32$1 >>> 16 | 0) & 255 | 0), HEAP8[(wasm2asm_i32$0 + 7 | 0) >> 0] = (wasm2asm_i32$1 >>> 24 | 0) & 255 | 0;
$2 = $2 - 32 | 0;
$0 = $0 + 32 | 0;
continue continue_0;
@ -152,7 +165,7 @@ function asmFunc(global, env, buffer) {
$1 = $1 | 0;
var $2 = 0, $3 = 0, $4 = 0;
if ($1 >>> 0 > 268435454 >>> 0) {
abort(0 | 0, 4 | 0, 23 | 0, 39 | 0);
abort(0 | 0, 8 | 0, 23 | 0, 39 | 0);
abort();
}
$3 = $1 << 2 | 0;
@ -174,7 +187,7 @@ function asmFunc(global, env, buffer) {
function assembly_index_NBodySystem_constructor($0, $1) {
$0 = $0 | 0;
$1 = $1 | 0;
var $2 = 0, $3 = 0, $4 = 0.0, $5 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0, $9 = 0;
var $2 = 0, $3 = 0, $4 = 0.0, $5 = 0.0, $6 = 0.0, $7 = 0.0, $72 = 0, $8 = 0, $50 = 0;
$8 = HEAP32[($1 + 4 | 0) >> 2] | 0;
continue_0 : do {
if (($2 | 0) < ($8 | 0)) {
@ -189,16 +202,17 @@ function asmFunc(global, env, buffer) {
break continue_0;
} while (1);
$2 = HEAPU32[$1 >> 2] | 0;
if (0 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $9 = HEAPU32[($2 + 8 | 0) >> 2] | 0; else abort();
$2 = $9;
if (0 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $50 = HEAPU32[($2 + 8 | 0) >> 2] | 0; else abort();
$2 = $50;
HEAPF64[($2 + 24 | 0) >> 3] = -$5 / 39.47841760435743;
HEAPF64[($2 + 32 | 0) >> 3] = -$6 / 39.47841760435743;
HEAPF64[($2 + 40 | 0) >> 3] = -$7 / 39.47841760435743;
if (($0 | 0) == (0 | 0)) {
$0 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
HEAP32[$0 >> 2] = $1;
if ($0) $72 = $0; else {
$2 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
HEAP32[$2 >> 2] = $1;
$72 = $2;
}
return $0 | 0;
return $72 | 0;
}
function assembly_index_init() {
@ -206,7 +220,7 @@ function asmFunc(global, env, buffer) {
$1 = $lib_array_Array_Body__constructor(0 | 0, 5 | 0) | 0;
$0 = $1;
$2 = assembly_index_Body_constructor(0 | 0, +(0.0), +(0.0), +(0.0), +(0.0), +(0.0), +(0.0), +(39.47841760435743)) | 0;
HEAP32[((HEAPU32[$0 >> 2] | 0) + 8 | 0) >> 2] = $2;
HEAP32[((HEAPU32[$1 >> 2] | 0) + 8 | 0) >> 2] = $2;
$0 = assembly_index_Body_constructor(0 | 0, +(4.841431442464721), +(-1.1603200440274284), +(-.10362204447112311), +(.606326392995832), +(2.81198684491626), +(-.02521836165988763), +(.03769367487038949)) | 0;
HEAP32[(((HEAPU32[$1 >> 2] | 0) + 4 | 0) + 8 | 0) >> 2] = $0;
$0 = assembly_index_Body_constructor(0 | 0, +(8.34336671824458), +(4.124798564124305), +(-.4035234171143214), +(-1.0107743461787924), +(1.8256623712304119), +(.008415761376584154), +(.011286326131968767)) | 0;
@ -220,14 +234,14 @@ function asmFunc(global, env, buffer) {
function assembly_index_getBody($0) {
$0 = $0 | 0;
var $1 = 0, $2 = 0, $3 = 0;
var $1 = 0, $22 = 0, $20 = 0;
$1 = HEAPU32[assembly_index_system >> 2] | 0;
if ($0 >>> 0 < (HEAP32[($1 + 4 | 0) >> 2] | 0) >>> 0) {
$1 = HEAPU32[$1 >> 2] | 0;
if ($0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $3 = HEAPU32[(($1 + ($0 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $3;
} else $2 = 0;
return $2 | 0;
if ($0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $20 = HEAPU32[(($1 + ($0 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$22 = $20;
} else $22 = 0;
return $22 | 0;
}
function assembly_index_NBodySystem_advance($0, $1) {
@ -283,7 +297,7 @@ function asmFunc(global, env, buffer) {
function assembly_index_NBodySystem_energy($0) {
$0 = $0 | 0;
var $1 = 0.0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $10 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $9 = 0.0, $11 = 0.0, $12 = 0.0, $13 = 0.0, $14 = 0.0, $15 = 0, $16 = 0.0, $17 = 0.0;
var $1 = 0.0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $10 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $9 = 0.0, $30 = 0.0, $39 = 0.0, $45 = 0.0, $59 = 0.0, $72 = 0, $77 = 0.0, $92 = 0.0;
$4 = HEAPU32[$0 >> 2] | 0;
$5 = HEAP32[($4 + 4 | 0) >> 2] | 0;
continue_0 : do {
@ -292,27 +306,27 @@ function asmFunc(global, env, buffer) {
$7 = +HEAPF64[$0 >> 3];
$8 = +HEAPF64[($0 + 8 | 0) >> 3];
$9 = +HEAPF64[($0 + 16 | 0) >> 3];
$11 = $1;
$30 = $1;
$10 = +HEAPF64[($0 + 48 | 0) >> 3];
$1 = +HEAPF64[($0 + 24 | 0) >> 3];
$12 = $1 * $1;
$39 = $1 * $1;
$1 = +HEAPF64[($0 + 32 | 0) >> 3];
$13 = $12 + $1 * $1;
$45 = $39 + $1 * $1;
$1 = +HEAPF64[($0 + 40 | 0) >> 3];
$1 = $11 + .5 * $10 * ($13 + $1 * $1);
$1 = $30 + .5 * $10 * ($45 + $1 * $1);
$0 = $3 + 1 | 0;
continue_1 : do {
if ($0 >>> 0 < $5 >>> 0) {
$14 = $7;
$59 = $7;
$2 = HEAPU32[$4 >> 2] | 0;
if ($0 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $15 = HEAPU32[(($2 + ($0 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $15;
$6 = $14 - +HEAPF64[$2 >> 3];
$16 = $1;
if ($0 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $72 = HEAPU32[(($2 + ($0 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $72;
$6 = $59 - +HEAPF64[$2 >> 3];
$77 = $1;
$1 = $8 - +HEAPF64[($2 + 8 | 0) >> 3];
$17 = $6 * $6 + $1 * $1;
$92 = $6 * $6 + $1 * $1;
$1 = $9 - +HEAPF64[($2 + 16 | 0) >> 3];
$1 = $16 - $10 * +HEAPF64[($2 + 48 | 0) >> 3] / Math_sqrt($17 + $1 * $1);
$1 = $77 - $10 * +HEAPF64[($2 + 48 | 0) >> 3] / Math_sqrt($92 + $1 * $1);
$0 = $0 + 1 | 0;
continue continue_1;
}
@ -349,42 +363,6 @@ function asmFunc(global, env, buffer) {
$lib_allocator_arena_offset = $lib_allocator_arena_startOffset;
}
function __wasm_ctz_i32(x) {
x = x | 0;
var $1 = 0;
if ((x | 0) == (0 | 0)) $1 = 32; else $1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
return $1 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
var count = 0, $2 = 0;
count = 0;
b : {
l : do {
$2 = count;
if ((x | 0) == (0 | 0)) break b;
x = x & (x - 1 | 0) | 0;
count = count + 1 | 0;
continue l;
break l;
} while (1);
};
return $2 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
}
function __wasm_grow_memory(pagesToAdd) {
pagesToAdd = pagesToAdd | 0;
var oldPages = __wasm_current_memory() | 0;

Binary file not shown.

View File

@ -1,11 +1,11 @@
(module
(type $F (func (result f64)))
(type $v (func))
(type $iFFFFFFFi (func (param i32 f64 f64 f64 f64 f64 f64 f64) (result i32)))
(type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $F (func (result f64)))
(type $iFv (func (param i32 f64)))
(type $iF (func (param i32) (result f64)))
(type $iv (func (param i32)))
@ -13,9 +13,9 @@
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $assembly/index/system (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 36))
(global $HEAP_BASE i32 (i32.const 40))
(memory $0 1)
(data (i32.const 4) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
(data (i32.const 8) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
(export "init" (func $assembly/index/init))
(export "getBody" (func $assembly/index/getBody))
(export "step" (func $assembly/index/step))
@ -39,7 +39,7 @@
)
(if
(i32.gt_u
(tee_local $2
(tee_local $0
(i32.and
(i32.add
(i32.add
@ -54,7 +54,7 @@
)
)
(i32.shl
(tee_local $0
(tee_local $2
(current_memory)
)
(i32.const 16)
@ -64,14 +64,14 @@
(i32.lt_s
(grow_memory
(select
(get_local $0)
(get_local $2)
(tee_local $4
(tee_local $3
(i32.shr_u
(i32.and
(i32.add
(i32.sub
(get_local $2)
(get_local $0)
(get_local $1)
)
(i32.const 65535)
@ -83,7 +83,7 @@
)
)
(i32.gt_s
(get_local $0)
(get_local $2)
(get_local $4)
)
)
@ -102,7 +102,7 @@
)
)
(set_global $~lib/allocator/arena/offset
(get_local $2)
(get_local $0)
)
(return
(get_local $1)
@ -501,7 +501,7 @@
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 8)
(i32.const 23)
(i32.const 39)
)
@ -701,20 +701,21 @@
(f64.const 39.47841760435743)
)
)
(if
(i32.eqz
(get_local $0)
)
(i32.store
(tee_local $0
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
(if (result i32)
(get_local $0)
(get_local $0)
(block (result i32)
(i32.store
(tee_local $2
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
)
(get_local $1)
)
(get_local $1)
(get_local $2)
)
)
(get_local $0)
)
(func $assembly/index/init (; 6 ;) (type $v)
(local $0 i32)

View File

@ -1,13 +1,13 @@
(module
(type $i (func (result i32)))
(type $F (func (result f64)))
(type $v (func))
(type $i (func (result i32)))
(type $iFFFFFFFi (func (param i32 f64 f64 f64 f64 f64 f64 f64) (result i32)))
(type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $iiiv (func (param i32 i32 i32)))
(type $iFFFi (func (param i32 f64 f64 f64) (result i32)))
(type $F (func (result f64)))
(type $iFv (func (param i32 f64)))
(type $iF (func (param i32) (result f64)))
(type $iv (func (param i32)))
@ -23,10 +23,10 @@
(global $assembly/index/system (mut i32) (i32.const 0))
(global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8))
(global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816))
(global $HEAP_BASE i32 (i32.const 96))
(global $HEAP_BASE i32 (i32.const 100))
(memory $0 1)
(data (i32.const 4) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00")
(data (i32.const 36) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
(data (i32.const 8) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00")
(data (i32.const 40) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00")
(export "init" (func $assembly/index/init))
(export "getBody" (func $assembly/index/getBody))
(export "step" (func $assembly/index/step))
@ -159,7 +159,7 @@
;;@ ~lib/allocator/arena.ts:25:37
(i32.const 0)
)
;;@ ~lib/allocator/arena.ts:26:8
;;@ ~lib/allocator/arena.ts:25:40
(if
;;@ ~lib/allocator/arena.ts:26:12
(i32.lt_s
@ -170,7 +170,7 @@
;;@ ~lib/allocator/arena.ts:26:39
(i32.const 0)
)
;;@ ~lib/allocator/arena.ts:27:10
;;@ ~lib/allocator/arena.ts:26:42
(unreachable)
)
)
@ -195,8 +195,7 @@
(func $assembly/index/Body#constructor (; 2 ;) (type $iFFFFFFFi) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (param $7 f64) (result i32)
(local $8 i32)
;;@ assembly/index.ts:19:4
(block
)
(nop)
(tee_local $0
(if (result i32)
(get_local $0)
@ -243,7 +242,7 @@
)
)
(func $assembly/index/Sun (; 3 ;) (type $i) (result i32)
;;@ assembly/index.ts:32:2
;;@ assembly/index.ts:29:21
(return
;;@ assembly/index.ts:30:9
(call $assembly/index/Body#constructor
@ -266,7 +265,7 @@
)
)
(func $assembly/index/Jupiter (; 4 ;) (type $i) (result i32)
;;@ assembly/index.ts:44:2
;;@ assembly/index.ts:35:25
(return
;;@ assembly/index.ts:36:9
(call $assembly/index/Body#constructor
@ -305,7 +304,7 @@
)
)
(func $assembly/index/Saturn (; 5 ;) (type $i) (result i32)
;;@ assembly/index.ts:56:2
;;@ assembly/index.ts:47:24
(return
;;@ assembly/index.ts:48:9
(call $assembly/index/Body#constructor
@ -344,7 +343,7 @@
)
)
(func $assembly/index/Uranus (; 6 ;) (type $i) (result i32)
;;@ assembly/index.ts:68:2
;;@ assembly/index.ts:59:24
(return
;;@ assembly/index.ts:60:9
(call $assembly/index/Body#constructor
@ -383,7 +382,7 @@
)
)
(func $assembly/index/Neptune (; 7 ;) (type $i) (result i32)
;;@ assembly/index.ts:80:2
;;@ assembly/index.ts:71:25
(return
;;@ assembly/index.ts:72:9
(call $assembly/index/Body#constructor
@ -422,7 +421,7 @@
)
)
(func $~lib/internal/arraybuffer/computeSize (; 8 ;) (type $ii) (param $0 i32) (result i32)
;;@ ~lib/internal/arraybuffer.ts:17:77
;;@ ~lib/internal/arraybuffer.ts:10:52
(return
;;@ ~lib/internal/arraybuffer.ts:17:9
(i32.shl
@ -463,7 +462,7 @@
(block
(call $abort
(i32.const 0)
(i32.const 36)
(i32.const 40)
(i32.const 22)
(i32.const 2)
)
@ -1023,8 +1022,6 @@
(local $4 i32)
;;@ ~lib/array.ts:21:31
(block
;;@ ~lib/array.ts:22:4
(nop)
;;@ ~lib/array.ts:23:4
(if
;;@ ~lib/array.ts:23:8
@ -1037,7 +1034,7 @@
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 8)
(i32.const 23)
(i32.const 39)
)
@ -1114,7 +1111,7 @@
)
(func $~lib/array/Array<Body>#__unchecked_set (; 12 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
;;@ ~lib/array.ts:96:4
;;@ ~lib/array.ts:95:54
(block $~lib/internal/arraybuffer/storeUnsafe<Body,Body>|inlined.0
(set_local $3
;;@ ~lib/array.ts:96:21
@ -1141,7 +1138,7 @@
)
)
(func $~lib/array/Array<Body>#get:length (; 13 ;) (type $ii) (param $0 i32) (result i32)
;;@ ~lib/array.ts:36:16
;;@ ~lib/array.ts:35:20
(return
;;@ ~lib/array.ts:36:11
(i32.load offset=4
@ -1151,7 +1148,7 @@
)
(func $~lib/array/Array<Body>#__unchecked_get (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
;;@ ~lib/array.ts:77:46
;;@ ~lib/array.ts:76:41
(return
;;@ ~lib/array.ts:77:11
(block $~lib/internal/arraybuffer/loadUnsafe<Body,Body>|inlined.0 (result i32)
@ -1284,7 +1281,6 @@
(local $6 i32)
(local $7 i32)
(local $8 f64)
(local $9 i32)
;;@ assembly/index.ts:87:4
(block
;;@ assembly/index.ts:88:4
@ -1422,16 +1418,16 @@
(get_local $0)
(tee_local $0
(block (result i32)
(set_local $9
(set_local $6
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
)
(i32.store
(get_local $9)
(get_local $6)
(get_local $1)
)
(get_local $9)
(get_local $6)
)
)
)
@ -1439,7 +1435,7 @@
)
(func $assembly/index/init (; 18 ;) (type $v)
(local $0 i32)
;;@ assembly/index.ts:189:2
;;@ assembly/index.ts:188:29
(set_global $assembly/index/system
;;@ assembly/index.ts:189:11
(call $assembly/index/NBodySystem#constructor
@ -1960,7 +1956,6 @@
(local $16 f64)
(local $17 f64)
(local $18 f64)
(local $19 f64)
;;@ assembly/index.ts:155:4
(set_local $1
;;@ assembly/index.ts:155:12
@ -2157,7 +2152,7 @@
)
)
;;@ assembly/index.ts:178:8
(set_local $19
(set_local $18
;;@ assembly/index.ts:178:28
(block $~lib/math/NativeMath.sqrt|inlined.1 (result f64)
(set_local $18
@ -2208,7 +2203,7 @@
)
)
;;@ assembly/index.ts:179:32
(get_local $19)
(get_local $18)
)
)
)
@ -2264,7 +2259,7 @@
)
(func $assembly/index/bench (; 23 ;) (type $iv) (param $0 i32)
(local $1 i32)
;;@ assembly/index.ts:209:2
;;@ assembly/index.ts:208:40
(block $break|0
;;@ assembly/index.ts:209:7
(set_local $1

View File

@ -6,10 +6,6 @@ const nbodyRS = require("../rust/index.js");
// Load ASMJS version
var src = fs.readFileSync(__dirname + "/../build/index.asm.js", "utf8");
if (src.indexOf("var Math_sqrt =") < 0) { // currently missing in asm.js output
let p = src.indexOf(" var abort = env.abort;");
src = src.substring(0, p) + " var Math_sqrt = global.Math.sqrt;\n " + src.substring(p);
}
const nbodyAsmJS = eval("0," + src)({
Int8Array,