Slim down indexed access as far as currently possible

Interestingly, the same code written as statements is significantly slower. See notes.
This commit is contained in:
dcodeIO
2018-04-23 23:57:15 +02:00
parent de98a19eb8
commit 63aa648ace
16 changed files with 964 additions and 1384 deletions

View File

@ -666,7 +666,7 @@ function asmFunc(global, env, buffer) {
$3 = HEAPU32[$0 >> 2] | 0;
if ($1 >>> 0 >= ((HEAP32[$3 >> 2] | 0) >>> 2 | 0) >>> 0) {
if ($1 >>> 0 >= 268435454 >>> 0) {
abort(0 | 0, 4 | 0, 75 | 0, 41 | 0);
abort(0 | 0, 4 | 0, 81 | 0, 41 | 0);
abort();
}
$3 = $lib_internal_arraybuffer_reallocUnsafe($3 | 0, ($1 + 1 | 0) << 2 | 0 | 0) | 0;
@ -676,47 +676,42 @@ function asmFunc(global, env, buffer) {
HEAP32[(($3 + ($1 << 2 | 0) | 0) + 8 | 0) >> 2] = $2;
}
function $lib_array_Array_Body____get($0, $1) {
$0 = $0 | 0;
$1 = $1 | 0;
var $2 = 0;
$2 = HEAPU32[$0 >> 2] | 0;
if ($1 >>> 0 >= ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) {
abort(0 | 0, 4 | 0, 64 | 0, 37 | 0);
abort();
}
return HEAPU32[(($2 + ($1 << 2 | 0) | 0) + 8 | 0) >> 2] | 0 | 0;
}
function assembly_index_NBodySystem_constructor($0, $1) {
$0 = $0 | 0;
$1 = $1 | 0;
var $3 = 0, $2 = 0, $4 = 0.0, $5 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0, $8 = 0;
$3 = $1;
$8 = HEAP32[($3 + 4 | 0) >> 2] | 0;
var $2 = 0, $3 = 0, $5 = 0, $4 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $9 = 0, $9 = 0, $11 = 0, $12 = 0;
$2 = $1;
$9 = HEAP32[($2 + 4 | 0) >> 2] | 0;
continue_0 : do {
if (($2 | 0) < ($8 | 0)) {
$3 = $lib_array_Array_Body____get($1 | 0, $2 | 0) | 0;
$4 = +HEAPF64[($3 + 48 | 0) >> 3];
$5 = $5 + +HEAPF64[($3 + 24 | 0) >> 3] * $4;
$6 = $6 + +HEAPF64[($3 + 32 | 0) >> 3] * $4;
$7 = $7 + +HEAPF64[($3 + 40 | 0) >> 3] * $4;
$2 = $2 + 1 | 0;
if (($3 | 0) < ($9 | 0)) {
$2 = $3;
$5 = $1;
$5 = HEAPU32[$5 >> 2] | 0;
if ($2 >>> 0 < ((HEAP32[$5 >> 2] | 0) >>> 2 | 0) >>> 0) $11 = HEAPU32[(($5 + ($2 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $11;
$4 = +HEAPF64[($2 + 48 | 0) >> 3];
$6 = $6 + +HEAPF64[($2 + 24 | 0) >> 3] * $4;
$7 = $7 + +HEAPF64[($2 + 32 | 0) >> 3] * $4;
$8 = $8 + +HEAPF64[($2 + 40 | 0) >> 3] * $4;
$3 = $3 + 1 | 0;
continue continue_0;
}
break continue_0;
} while (1);
if ($0) $8 = $0; else {
$2 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
HEAP32[$2 >> 2] = 0;
$0 = $2;
$8 = $0;
if ($0) $9 = $0; else {
$3 = $lib_allocator_arena_allocate_memory(4 | 0) | 0;
HEAP32[$3 >> 2] = 0;
$0 = $3;
$9 = $0;
}
HEAP32[$8 >> 2] = $1;
$1 = $lib_array_Array_Body____get(HEAPU32[$0 >> 2] | 0 | 0, 0 | 0) | 0;
HEAPF64[($1 + 24 | 0) >> 3] = -$5 / 39.47841760435743;
HEAPF64[($1 + 32 | 0) >> 3] = -$6 / 39.47841760435743;
HEAPF64[($1 + 40 | 0) >> 3] = -$7 / 39.47841760435743;
HEAP32[$9 >> 2] = $1;
$1 = HEAPU32[$0 >> 2] | 0;
$1 = HEAPU32[$1 >> 2] | 0;
if (0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $12 = HEAPU32[(($1 + 0 | 0) + 8 | 0) >> 2] | 0; else abort();
$1 = $12;
HEAPF64[($1 + 24 | 0) >> 3] = -$6 / 39.47841760435743;
HEAPF64[($1 + 32 | 0) >> 3] = -$7 / 39.47841760435743;
HEAPF64[($1 + 40 | 0) >> 3] = -$8 / 39.47841760435743;
return $0 | 0;
}
@ -733,59 +728,72 @@ function asmFunc(global, env, buffer) {
function assembly_index_getBody($0) {
$0 = $0 | 0;
var $1 = 0, $2 = 0;
var $1 = 0, $2 = 0, $3 = 0;
$1 = HEAPU32[assembly_index_system >> 2] | 0;
if ($0 >>> 0 < (HEAP32[($1 + 4 | 0) >> 2] | 0) >>> 0) $2 = $lib_array_Array_Body____get($1 | 0, $0 | 0) | 0; else $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;
}
function assembly_index_NBodySystem_advance($0, $1) {
$0 = $0 | 0;
$1 = +$1;
var $2 = 0, $3 = 0.0, $4 = 0.0, $5 = 0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $9 = 0, $10 = 0.0, $11 = 0.0, $12 = 0.0, $13 = 0, $14 = 0, $15 = 0.0, $16 = 0.0, $17 = 0.0, $18 = 0.0;
var $2 = 0, $4 = 0.0, $3 = 0, $5 = 0.0, $6 = 0, $7 = 0.0, $8 = 0.0, $9 = 0.0, $10 = 0.0, $11 = 0.0, $12 = 0.0, $13 = 0, $14 = 0, $19 = 0, $16 = 0, $15 = 0.0, $16 = 0.0, $17 = 0.0, $18 = 0.0, $21 = 0.0, $22 = 0;
$13 = HEAPU32[$0 >> 2] | 0;
$0 = $13;
$14 = HEAP32[($0 + 4 | 0) >> 2] | 0;
continue_0 : do {
if (($5 | 0) < ($14 | 0)) {
$0 = $lib_array_Array_Body____get($13 | 0, $5 | 0) | 0;
if (($6 | 0) < ($14 | 0)) {
$3 = $6;
$0 = $13;
$0 = HEAPU32[$0 >> 2] | 0;
if ($3 >>> 0 < ((HEAP32[$0 >> 2] | 0) >>> 2 | 0) >>> 0) $16 = HEAPU32[(($0 + ($3 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$0 = $16;
$15 = +HEAPF64[$0 >> 3];
$16 = +HEAPF64[($0 + 8 | 0) >> 3];
$17 = +HEAPF64[($0 + 16 | 0) >> 3];
$6 = +HEAPF64[($0 + 24 | 0) >> 3];
$7 = +HEAPF64[($0 + 32 | 0) >> 3];
$8 = +HEAPF64[($0 + 40 | 0) >> 3];
$7 = +HEAPF64[($0 + 24 | 0) >> 3];
$8 = +HEAPF64[($0 + 32 | 0) >> 3];
$9 = +HEAPF64[($0 + 40 | 0) >> 3];
$18 = +HEAPF64[($0 + 48 | 0) >> 3];
$9 = $5 + 1 | 0;
$3 = $6 + 1 | 0;
continue_1 : do {
if (($9 | 0) < ($14 | 0)) {
$2 = $lib_array_Array_Body____get($13 | 0, $9 | 0) | 0;
$10 = $15 - +HEAPF64[$2 >> 3];
if (($3 | 0) < ($14 | 0)) {
$21 = $15;
$19 = $3;
$2 = $13;
$2 = HEAPU32[$2 >> 2] | 0;
if ($19 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $22 = HEAPU32[(($2 + ($19 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $22;
$10 = $21 - +HEAPF64[$2 >> 3];
$11 = $16 - +HEAPF64[($2 + 8 | 0) >> 3];
$12 = $17 - +HEAPF64[($2 + 16 | 0) >> 3];
$3 = $10 * $10 + $11 * $11 + $12 * $12;
$4 = Math_sqrt($3);
$3 = $1 / ($3 * $4);
$4 = $18 * $3;
$3 = +HEAPF64[($2 + 48 | 0) >> 3] * $3;
$6 = $6 - $10 * $3;
$7 = $7 - $11 * $3;
$8 = $8 - $12 * $3;
HEAPF64[($2 + 24 | 0) >> 3] = +HEAPF64[($2 + 24 | 0) >> 3] + $10 * $4;
HEAPF64[($2 + 32 | 0) >> 3] = +HEAPF64[($2 + 32 | 0) >> 3] + $11 * $4;
HEAPF64[($2 + 40 | 0) >> 3] = +HEAPF64[($2 + 40 | 0) >> 3] + $12 * $4;
$9 = $9 + 1 | 0;
$4 = $10 * $10 + $11 * $11 + $12 * $12;
$5 = Math_sqrt($4);
$4 = $1 / ($4 * $5);
$5 = $18 * $4;
$4 = +HEAPF64[($2 + 48 | 0) >> 3] * $4;
$7 = $7 - $10 * $4;
$8 = $8 - $11 * $4;
$9 = $9 - $12 * $4;
HEAPF64[($2 + 24 | 0) >> 3] = +HEAPF64[($2 + 24 | 0) >> 3] + $10 * $5;
HEAPF64[($2 + 32 | 0) >> 3] = +HEAPF64[($2 + 32 | 0) >> 3] + $11 * $5;
HEAPF64[($2 + 40 | 0) >> 3] = +HEAPF64[($2 + 40 | 0) >> 3] + $12 * $5;
$3 = $3 + 1 | 0;
continue continue_1;
}
break continue_1;
} while (1);
HEAPF64[($0 + 24 | 0) >> 3] = $6;
HEAPF64[($0 + 32 | 0) >> 3] = $7;
HEAPF64[($0 + 40 | 0) >> 3] = $8;
HEAPF64[$0 >> 3] = +HEAPF64[$0 >> 3] + $1 * $6;
HEAPF64[($0 + 8 | 0) >> 3] = +HEAPF64[($0 + 8 | 0) >> 3] + $1 * $7;
HEAPF64[($0 + 16 | 0) >> 3] = +HEAPF64[($0 + 16 | 0) >> 3] + $1 * $8;
$5 = $5 + 1 | 0;
HEAPF64[($0 + 24 | 0) >> 3] = $7;
HEAPF64[($0 + 32 | 0) >> 3] = $8;
HEAPF64[($0 + 40 | 0) >> 3] = $9;
HEAPF64[$0 >> 3] = +HEAPF64[$0 >> 3] + $1 * $7;
HEAPF64[($0 + 8 | 0) >> 3] = +HEAPF64[($0 + 8 | 0) >> 3] + $1 * $8;
HEAPF64[($0 + 16 | 0) >> 3] = +HEAPF64[($0 + 16 | 0) >> 3] + $1 * $9;
$6 = $6 + 1 | 0;
continue continue_0;
}
break continue_0;
@ -794,40 +802,49 @@ 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.0;
var $1 = 0.0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $10 = 0.0, $11 = 0, $6 = 0.0, $9 = 0, $7 = 0.0, $8 = 0.0, $9 = 0.0, $13 = 0.0, $14 = 0.0, $15 = 0.0, $16 = 0.0, $17 = 0, $18 = 0.0, $19 = 0.0;
$4 = HEAPU32[$0 >> 2] | 0;
$0 = $4;
$5 = HEAP32[($0 + 4 | 0) >> 2] | 0;
continue_0 : do {
if (($2 | 0) < ($5 | 0)) {
$0 = $lib_array_Array_Body____get($4 | 0, $2 | 0) | 0;
if (($3 | 0) < ($5 | 0)) {
$2 = $3;
$0 = $4;
$0 = HEAPU32[$0 >> 2] | 0;
if ($2 >>> 0 < ((HEAP32[$0 >> 2] | 0) >>> 2 | 0) >>> 0) $9 = HEAPU32[(($0 + ($2 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$0 = $9;
$7 = +HEAPF64[$0 >> 3];
$8 = +HEAPF64[($0 + 8 | 0) >> 3];
$9 = +HEAPF64[($0 + 16 | 0) >> 3];
$11 = $1;
$13 = $1;
$10 = +HEAPF64[($0 + 48 | 0) >> 3];
$1 = +HEAPF64[($0 + 24 | 0) >> 3];
$12 = $1 * $1;
$14 = $1 * $1;
$1 = +HEAPF64[($0 + 32 | 0) >> 3];
$13 = $12 + $1 * $1;
$15 = $14 + $1 * $1;
$1 = +HEAPF64[($0 + 40 | 0) >> 3];
$1 = $11 + .5 * $10 * ($13 + $1 * $1);
$0 = $2 + 1 | 0;
$1 = $13 + .5 * $10 * ($15 + $1 * $1);
$0 = $3 + 1 | 0;
continue_1 : do {
if (($0 | 0) < ($5 | 0)) {
$3 = $lib_array_Array_Body____get($4 | 0, $0 | 0) | 0;
$6 = $7 - +HEAPF64[$3 >> 3];
$14 = $1;
$1 = $8 - +HEAPF64[($3 + 8 | 0) >> 3];
$15 = $6 * $6 + $1 * $1;
$1 = $9 - +HEAPF64[($3 + 16 | 0) >> 3];
$1 = $14 - $10 * +HEAPF64[($3 + 48 | 0) >> 3] / Math_sqrt($15 + $1 * $1);
$16 = $7;
$11 = $0;
$2 = $4;
$2 = HEAPU32[$2 >> 2] | 0;
if ($11 >>> 0 < ((HEAP32[$2 >> 2] | 0) >>> 2 | 0) >>> 0) $17 = HEAPU32[(($2 + ($11 << 2 | 0) | 0) + 8 | 0) >> 2] | 0; else abort();
$2 = $17;
$6 = $16 - +HEAPF64[$2 >> 3];
$18 = $1;
$1 = $8 - +HEAPF64[($2 + 8 | 0) >> 3];
$19 = $6 * $6 + $1 * $1;
$1 = $9 - +HEAPF64[($2 + 16 | 0) >> 3];
$1 = $18 - $10 * +HEAPF64[($2 + 48 | 0) >> 3] / Math_sqrt($19 + $1 * $1);
$0 = $0 + 1 | 0;
continue continue_1;
}
break continue_1;
} while (1);
$2 = $2 + 1 | 0;
$3 = $3 + 1 | 0;
continue continue_0;
}
break continue_0;

Binary file not shown.

View File

@ -2556,7 +2556,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 75)
(i32.const 81)
(i32.const 41)
)
(unreachable)
@ -2597,53 +2597,18 @@
(get_local $2)
)
)
(func $~lib/array/Array<Body>#__get (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(if
(i32.ge_u
(get_local $1)
(i32.shr_u
(i32.load
(tee_local $2
(i32.load
(get_local $0)
)
)
)
(i32.const 2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 64)
(i32.const 37)
)
(unreachable)
)
)
(i32.load offset=8
(i32.add
(get_local $2)
(i32.shl
(get_local $1)
(i32.const 2)
)
)
)
)
(func $assembly/index/NBodySystem#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $assembly/index/NBodySystem#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 f64)
(local $5 f64)
(local $5 i32)
(local $6 f64)
(local $7 f64)
(local $8 i32)
(set_local $8
(local $8 f64)
(local $9 i32)
(set_local $9
(i32.load offset=4
(tee_local $3
(tee_local $2
(get_local $1)
)
)
@ -2651,37 +2616,51 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $2)
(get_local $8)
(get_local $3)
(get_local $9)
)
(block
(set_local $4
(f64.load offset=48
(tee_local $3
(call $~lib/array/Array<Body>#__get
(get_local $1)
(get_local $2)
(tee_local $2
(if (result i32)
(i32.lt_u
(tee_local $2
(get_local $3)
)
(i32.shr_u
(i32.load
(tee_local $5
(i32.load
(tee_local $5
(get_local $1)
)
)
)
)
(i32.const 2)
)
)
(i32.load offset=8
(i32.add
(get_local $5)
(i32.shl
(get_local $2)
(i32.const 2)
)
)
)
(unreachable)
)
)
)
)
(set_local $5
(f64.add
(get_local $5)
(f64.mul
(f64.load offset=24
(get_local $3)
)
(get_local $4)
)
)
)
(set_local $6
(f64.add
(get_local $6)
(f64.mul
(f64.load offset=32
(get_local $3)
(f64.load offset=24
(get_local $2)
)
(get_local $4)
)
@ -2691,16 +2670,27 @@
(f64.add
(get_local $7)
(f64.mul
(f64.load offset=40
(get_local $3)
(f64.load offset=32
(get_local $2)
)
(get_local $4)
)
)
)
(set_local $2
(set_local $8
(f64.add
(get_local $8)
(f64.mul
(f64.load offset=40
(get_local $2)
)
(get_local $4)
)
)
)
(set_local $3
(i32.add
(get_local $2)
(get_local $3)
(i32.const 1)
)
)
@ -2714,7 +2704,7 @@
(get_local $0)
(block (result i32)
(i32.store
(tee_local $2
(tee_local $3
(call $~lib/allocator/arena/allocate_memory
(i32.const 4)
)
@ -2722,7 +2712,7 @@
(i32.const 0)
)
(tee_local $0
(get_local $2)
(get_local $3)
)
)
)
@ -2730,16 +2720,36 @@
)
(f64.store offset=24
(tee_local $1
(call $~lib/array/Array<Body>#__get
(i32.load
(get_local $0)
(if (result i32)
(i32.lt_u
(i32.const 0)
(i32.shr_u
(i32.load
(tee_local $1
(i32.load
(tee_local $1
(i32.load
(get_local $0)
)
)
)
)
)
(i32.const 2)
)
)
(i32.const 0)
(i32.load offset=8
(i32.add
(get_local $1)
(i32.const 0)
)
)
(unreachable)
)
)
(f64.div
(f64.neg
(get_local $5)
(get_local $6)
)
(f64.const 39.47841760435743)
)
@ -2748,7 +2758,7 @@
(get_local $1)
(f64.div
(f64.neg
(get_local $6)
(get_local $7)
)
(f64.const 39.47841760435743)
)
@ -2757,14 +2767,14 @@
(get_local $1)
(f64.div
(f64.neg
(get_local $7)
(get_local $8)
)
(f64.const 39.47841760435743)
)
)
(get_local $0)
)
(func $assembly/index/init (; 12 ;) (type $v)
(func $assembly/index/init (; 11 ;) (type $v)
(local $0 i32)
(set_global $assembly/index/system
(call $assembly/index/NBodySystem#constructor
@ -2850,7 +2860,7 @@
)
)
)
(func $assembly/index/getBody (; 13 ;) (type $ii) (param $0 i32) (result i32)
(func $assembly/index/getBody (; 12 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(if (result i32)
(i32.lt_u
@ -2863,22 +2873,43 @@
)
)
)
(call $~lib/array/Array<Body>#__get
(get_local $1)
(get_local $0)
(if (result i32)
(i32.lt_u
(get_local $0)
(i32.shr_u
(i32.load
(tee_local $1
(i32.load
(get_local $1)
)
)
)
(i32.const 2)
)
)
(i32.load offset=8
(i32.add
(get_local $1)
(i32.shl
(get_local $0)
(i32.const 2)
)
)
)
(unreachable)
)
(i32.const 0)
)
)
(func $assembly/index/NBodySystem#advance (; 14 ;) (type $iFv) (param $0 i32) (param $1 f64)
(func $assembly/index/NBodySystem#advance (; 13 ;) (type $iFv) (param $0 i32) (param $1 f64)
(local $2 i32)
(local $3 f64)
(local $3 i32)
(local $4 f64)
(local $5 i32)
(local $6 f64)
(local $5 f64)
(local $6 i32)
(local $7 f64)
(local $8 f64)
(local $9 i32)
(local $9 f64)
(local $10 f64)
(local $11 f64)
(local $12 f64)
@ -2888,6 +2919,7 @@
(local $16 f64)
(local $17 f64)
(local $18 f64)
(local $19 i32)
(set_local $14
(i32.load offset=4
(tee_local $0
@ -2902,16 +2934,41 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $5)
(get_local $6)
(get_local $14)
)
(block
(set_local $15
(f64.load
(tee_local $0
(call $~lib/array/Array<Body>#__get
(get_local $13)
(get_local $5)
(if (result i32)
(i32.lt_u
(tee_local $3
(get_local $6)
)
(i32.shr_u
(i32.load
(tee_local $0
(i32.load
(tee_local $0
(get_local $13)
)
)
)
)
(i32.const 2)
)
)
(i32.load offset=8
(i32.add
(get_local $0)
(i32.shl
(get_local $3)
(i32.const 2)
)
)
)
(unreachable)
)
)
)
@ -2926,17 +2983,17 @@
(get_local $0)
)
)
(set_local $6
(set_local $7
(f64.load offset=24
(get_local $0)
)
)
(set_local $7
(set_local $8
(f64.load offset=32
(get_local $0)
)
)
(set_local $8
(set_local $9
(f64.load offset=40
(get_local $0)
)
@ -2946,22 +3003,22 @@
(get_local $0)
)
)
(set_local $9
(set_local $3
(i32.add
(get_local $5)
(get_local $6)
(i32.const 1)
)
)
(loop $continue|1
(if
(i32.lt_s
(get_local $9)
(get_local $3)
(get_local $14)
)
(block
(set_local $4
(set_local $5
(f64.sqrt
(tee_local $3
(tee_local $4
(f64.add
(f64.add
(f64.mul
@ -2970,9 +3027,34 @@
(get_local $15)
(f64.load
(tee_local $2
(call $~lib/array/Array<Body>#__get
(get_local $13)
(get_local $9)
(if (result i32)
(i32.lt_u
(tee_local $19
(get_local $3)
)
(i32.shr_u
(i32.load
(tee_local $2
(i32.load
(tee_local $2
(get_local $13)
)
)
)
)
(i32.const 2)
)
)
(i32.load offset=8
(i32.add
(get_local $2)
(i32.shl
(get_local $19)
(i32.const 2)
)
)
)
(unreachable)
)
)
)
@ -3007,31 +3089,15 @@
)
)
)
(set_local $4
(set_local $5
(f64.mul
(get_local $18)
(tee_local $3
(tee_local $4
(f64.div
(get_local $1)
(f64.mul
(get_local $3)
(get_local $4)
)
)
)
)
)
(set_local $6
(f64.sub
(get_local $6)
(f64.mul
(get_local $10)
(tee_local $3
(f64.mul
(f64.load offset=48
(get_local $2)
)
(get_local $3)
(get_local $5)
)
)
)
@ -3041,17 +3107,33 @@
(f64.sub
(get_local $7)
(f64.mul
(get_local $11)
(get_local $3)
(get_local $10)
(tee_local $4
(f64.mul
(f64.load offset=48
(get_local $2)
)
(get_local $4)
)
)
)
)
)
(set_local $8
(f64.sub
(get_local $8)
(f64.mul
(get_local $11)
(get_local $4)
)
)
)
(set_local $9
(f64.sub
(get_local $9)
(f64.mul
(get_local $12)
(get_local $3)
(get_local $4)
)
)
)
@ -3063,7 +3145,7 @@
)
(f64.mul
(get_local $10)
(get_local $4)
(get_local $5)
)
)
)
@ -3075,7 +3157,7 @@
)
(f64.mul
(get_local $11)
(get_local $4)
(get_local $5)
)
)
)
@ -3087,13 +3169,13 @@
)
(f64.mul
(get_local $12)
(get_local $4)
(get_local $5)
)
)
)
(set_local $9
(set_local $3
(i32.add
(get_local $9)
(get_local $3)
(i32.const 1)
)
)
@ -3103,15 +3185,15 @@
)
(f64.store offset=24
(get_local $0)
(get_local $6)
(get_local $7)
)
(f64.store offset=32
(get_local $0)
(get_local $7)
(get_local $8)
)
(f64.store offset=40
(get_local $0)
(get_local $8)
(get_local $9)
)
(f64.store
(get_local $0)
@ -3121,7 +3203,7 @@
)
(f64.mul
(get_local $1)
(get_local $6)
(get_local $7)
)
)
)
@ -3133,7 +3215,7 @@
)
(f64.mul
(get_local $1)
(get_local $7)
(get_local $8)
)
)
)
@ -3145,13 +3227,13 @@
)
(f64.mul
(get_local $1)
(get_local $8)
(get_local $9)
)
)
)
(set_local $5
(set_local $6
(i32.add
(get_local $5)
(get_local $6)
(i32.const 1)
)
)
@ -3160,7 +3242,7 @@
)
)
)
(func $assembly/index/NBodySystem#energy (; 15 ;) (type $iF) (param $0 i32) (result f64)
(func $assembly/index/NBodySystem#energy (; 14 ;) (type $iF) (param $0 i32) (result f64)
(local $1 f64)
(local $2 i32)
(local $3 i32)
@ -3171,6 +3253,7 @@
(local $8 f64)
(local $9 f64)
(local $10 f64)
(local $11 i32)
(set_local $5
(i32.load offset=4
(tee_local $0
@ -3185,16 +3268,41 @@
(loop $continue|0
(if
(i32.lt_s
(get_local $2)
(get_local $3)
(get_local $5)
)
(block
(set_local $7
(f64.load
(tee_local $0
(call $~lib/array/Array<Body>#__get
(get_local $4)
(get_local $2)
(if (result i32)
(i32.lt_u
(tee_local $2
(get_local $3)
)
(i32.shr_u
(i32.load
(tee_local $0
(i32.load
(tee_local $0
(get_local $4)
)
)
)
)
(i32.const 2)
)
)
(i32.load offset=8
(i32.add
(get_local $0)
(i32.shl
(get_local $2)
(i32.const 2)
)
)
)
(unreachable)
)
)
)
@ -3254,7 +3362,7 @@
)
(set_local $0
(i32.add
(get_local $2)
(get_local $3)
(i32.const 1)
)
)
@ -3269,10 +3377,35 @@
(f64.sub
(get_local $7)
(f64.load
(tee_local $3
(call $~lib/array/Array<Body>#__get
(get_local $4)
(get_local $0)
(tee_local $2
(if (result i32)
(i32.lt_u
(tee_local $11
(get_local $0)
)
(i32.shr_u
(i32.load
(tee_local $2
(i32.load
(tee_local $2
(get_local $4)
)
)
)
)
(i32.const 2)
)
)
(i32.load offset=8
(i32.add
(get_local $2)
(i32.shl
(get_local $11)
(i32.const 2)
)
)
)
(unreachable)
)
)
)
@ -3285,7 +3418,7 @@
(f64.mul
(get_local $10)
(f64.load offset=48
(get_local $3)
(get_local $2)
)
)
(f64.sqrt
@ -3300,7 +3433,7 @@
(f64.sub
(get_local $8)
(f64.load offset=8
(get_local $3)
(get_local $2)
)
)
)
@ -3312,7 +3445,7 @@
(f64.sub
(get_local $9)
(f64.load offset=16
(get_local $3)
(get_local $2)
)
)
)
@ -3333,9 +3466,9 @@
)
)
)
(set_local $2
(set_local $3
(i32.add
(get_local $2)
(get_local $3)
(i32.const 1)
)
)
@ -3345,7 +3478,7 @@
)
(get_local $1)
)
(func $assembly/index/step (; 16 ;) (type $F) (result f64)
(func $assembly/index/step (; 15 ;) (type $F) (result f64)
(call $assembly/index/NBodySystem#advance
(get_global $assembly/index/system)
(f64.const 0.01)
@ -3354,7 +3487,7 @@
(get_global $assembly/index/system)
)
)
(func $assembly/index/bench (; 17 ;) (type $iv) (param $0 i32)
(func $assembly/index/bench (; 16 ;) (type $iv) (param $0 i32)
(local $1 i32)
(loop $continue|0
(if
@ -3378,7 +3511,7 @@
)
)
)
(func $start (; 18 ;) (type $v)
(func $start (; 17 ;) (type $v)
(set_global $~lib/allocator/arena/startOffset
(i32.and
(i32.add

View File

@ -3958,125 +3958,107 @@
(func $~lib/array/Array<Body>#__set (; 15 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
;;@ ~lib/array.ts:71:4
;;@ ~lib/array.ts:77:4
(set_local $3
;;@ ~lib/array.ts:71:17
;;@ ~lib/array.ts:77:17
(i32.load
(get_local $0)
)
)
;;@ ~lib/array.ts:72:4
;;@ ~lib/array.ts:78:4
(set_local $4
;;@ ~lib/array.ts:72:19
;;@ ~lib/array.ts:78:19
(i32.shr_u
(i32.load
(get_local $3)
)
;;@ ~lib/array.ts:72:41
;;@ ~lib/array.ts:78:41
(i32.const 2)
)
)
;;@ ~lib/array.ts:73:4
;;@ ~lib/array.ts:79:4
(if
;;@ ~lib/array.ts:73:8
;;@ ~lib/array.ts:79:8
(i32.ge_u
(get_local $1)
;;@ ~lib/array.ts:73:22
;;@ ~lib/array.ts:79:22
(get_local $4)
)
;;@ ~lib/array.ts:73:37
;;@ ~lib/array.ts:79:37
(block
;;@ ~lib/array.ts:74:6
;;@ ~lib/array.ts:80:6
(nop)
;;@ ~lib/array.ts:75:6
;;@ ~lib/array.ts:81:6
(if
;;@ ~lib/array.ts:75:10
;;@ ~lib/array.ts:81:10
(i32.ge_u
(get_local $1)
;;@ ~lib/array.ts:75:24
;;@ ~lib/array.ts:81:24
(i32.const 268435454)
)
;;@ ~lib/array.ts:75:41
;;@ ~lib/array.ts:81:41
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 75)
(i32.const 81)
(i32.const 41)
)
(unreachable)
)
)
;;@ ~lib/array.ts:76:6
;;@ ~lib/array.ts:82:6
(set_local $3
;;@ ~lib/array.ts:76:15
;;@ ~lib/array.ts:82:15
(call $~lib/internal/arraybuffer/reallocUnsafe
;;@ ~lib/array.ts:76:29
;;@ ~lib/array.ts:82:29
(get_local $3)
;;@ ~lib/array.ts:76:37
;;@ ~lib/array.ts:82:37
(i32.shl
(i32.add
;;@ ~lib/array.ts:76:38
;;@ ~lib/array.ts:82:38
(get_local $1)
;;@ ~lib/array.ts:76:46
;;@ ~lib/array.ts:82:46
(i32.const 1)
)
;;@ ~lib/array.ts:76:52
;;@ ~lib/array.ts:82:52
(i32.const 2)
)
)
)
;;@ ~lib/array.ts:77:6
;;@ ~lib/array.ts:83:6
(i32.store
(get_local $0)
;;@ ~lib/array.ts:77:21
;;@ ~lib/array.ts:83:21
(get_local $3)
)
;;@ ~lib/array.ts:78:6
;;@ ~lib/array.ts:84:6
(i32.store offset=4
(get_local $0)
;;@ ~lib/array.ts:78:21
;;@ ~lib/array.ts:84:21
(i32.add
(get_local $1)
;;@ ~lib/array.ts:78:29
;;@ ~lib/array.ts:84:29
(i32.const 1)
)
)
)
)
;;@ ~lib/array.ts:81:4
(block $~lib/internal/arraybuffer/storeUnsafe<Body>|inlined.0
(set_local $5
;;@ ~lib/array.ts:81:19
;;@ ~lib/array.ts:86:4
(i32.store offset=8
;;@ ~lib/array.ts:86:13
(i32.add
(get_local $3)
)
(set_local $6
;;@ ~lib/array.ts:81:27
(get_local $1)
)
(set_local $7
;;@ ~lib/array.ts:81:34
(get_local $2)
)
;;@ ~lib/internal/arraybuffer.ts:69:2
(i32.store offset=8
;;@ ~lib/internal/arraybuffer.ts:69:11
(i32.add
(get_local $5)
;;@ ~lib/internal/arraybuffer.ts:69:39
(i32.shl
;;@ ~lib/internal/arraybuffer.ts:69:40
(get_local $6)
;;@ ~lib/internal/arraybuffer.ts:69:56
(i32.const 2)
)
;;@ ~lib/array.ts:86:41
(i32.shl
;;@ ~lib/array.ts:86:42
(get_local $1)
;;@ ~lib/array.ts:86:58
(i32.const 2)
)
;;@ ~lib/internal/arraybuffer.ts:69:71
(get_local $7)
)
;;@ ~lib/array.ts:86:73
(get_local $2)
)
)
(func $~lib/array/Array<Body>#get:length (; 16 ;) (type $ii) (param $0 i32) (result i32)
@ -4090,9 +4072,6 @@
)
(func $~lib/array/Array<Body>#__get (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
;;@ ~lib/array.ts:62:4
(set_local $2
;;@ ~lib/array.ts:62:17
@ -4100,65 +4079,38 @@
(get_local $0)
)
)
;;@ ~lib/array.ts:63:4
(set_local $3
;;@ ~lib/array.ts:63:19
(i32.shr_u
(i32.load
(get_local $2)
)
;;@ ~lib/array.ts:63:41
(i32.const 2)
)
)
;;@ ~lib/array.ts:64:4
(if
;;@ ~lib/array.ts:64:8
(i32.ge_u
(get_local $1)
;;@ ~lib/array.ts:64:22
(get_local $3)
)
;;@ ~lib/array.ts:64:37
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 64)
(i32.const 37)
)
(unreachable)
)
)
;;@ ~lib/array.ts:66:38
;;@ ~lib/array.ts:66:20
(return
;;@ ~lib/array.ts:66:11
(block $~lib/internal/arraybuffer/loadUnsafe<Body>|inlined.0 (result i32)
(set_local $4
;;@ ~lib/array.ts:66:25
(get_local $2)
)
(set_local $5
;;@ ~lib/array.ts:66:33
;;@ ~lib/array.ts:63:11
(if (result i32)
(i32.lt_u
(get_local $1)
;;@ ~lib/array.ts:63:24
(i32.shr_u
;;@ ~lib/array.ts:63:30
(i32.load
(get_local $2)
)
;;@ ~lib/array.ts:63:52
(i32.const 2)
)
)
;;@ ~lib/internal/arraybuffer.ts:64:88
(br $~lib/internal/arraybuffer/loadUnsafe<Body>|inlined.0
;;@ ~lib/internal/arraybuffer.ts:64:9
(i32.load offset=8
;;@ ~lib/internal/arraybuffer.ts:64:17
(i32.add
(get_local $4)
;;@ ~lib/internal/arraybuffer.ts:64:45
(i32.shl
;;@ ~lib/internal/arraybuffer.ts:64:46
(get_local $5)
;;@ ~lib/internal/arraybuffer.ts:64:62
(i32.const 2)
)
;;@ ~lib/array.ts:64:8
(i32.load offset=8
;;@ ~lib/array.ts:64:16
(i32.add
(get_local $2)
;;@ ~lib/array.ts:64:44
(i32.shl
;;@ ~lib/array.ts:64:45
(get_local $1)
;;@ ~lib/array.ts:64:61
(i32.const 2)
)
)
)
;;@ ~lib/array.ts:66:8
(unreachable)
)
)
)