update n-body for comparison

This commit is contained in:
dcode 2019-03-19 10:09:06 +01:00
parent 7693b543f4
commit d42ef51cf0
6 changed files with 1198 additions and 1085 deletions

View File

@ -96,7 +96,7 @@ class NBodySystem {
py += b.vy * m;
pz += b.vz * m;
}
bodies[0].offsetMomentum(px, py, pz);
unchecked(bodies[0]).offsetMomentum(px, py, pz);
}
advance(dt: float): void {
@ -206,5 +206,5 @@ export function bench(steps: u32): void {
export function getBody(index: i32): Body | null {
var bodies = system.bodies;
return <u32>index < <u32>bodies.length ? bodies[index] : null;
return <u32>index < <u32>bodies.length ? unchecked(bodies[index]) : null;
}

View File

@ -20,32 +20,45 @@ function asmFunc(global, env, buffer) {
var abort = env.abort;
var nan = global.NaN;
var infinity = global.Infinity;
var assembly_index_system = 0;
var $lib_allocator_arena_startOffset = 0;
var $lib_allocator_arena_offset = 0;
var assembly_index_system = 0;
var i64toi32_i32$HIGH_BITS = 0;
function $lib_allocator_arena___memory_allocate($0) {
function $lib_memory_memory_allocate($0) {
$0 = $0 | 0;
var $1 = 0, $2 = 0, $3 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0, wasm2js_i32$2 = 0;
if ($0 >>> 0 > 1073741824 >>> 0) abort();
$1 = $lib_allocator_arena_offset;
$2 = (($1 + (wasm2js_i32$0 = $0, wasm2js_i32$1 = 1, wasm2js_i32$2 = $0 >>> 0 > 1 >>> 0, wasm2js_i32$2 ? wasm2js_i32$0 : wasm2js_i32$1) | 0) + 7 | 0) & 4294967288 | 0;
$3 = __wasm_current_memory();
if ($2 >>> 0 > ($3 << 16 | 0) >>> 0) {
$0 = ((($2 - $1 | 0) + 65535 | 0) & 4294901760 | 0) >>> 16 | 0;
if ((__wasm_grow_memory((wasm2js_i32$0 = $3, wasm2js_i32$1 = $0, wasm2js_i32$2 = ($3 | 0) > ($0 | 0), wasm2js_i32$2 ? wasm2js_i32$0 : wasm2js_i32$1) | 0) | 0) < (0 | 0)) if ((__wasm_grow_memory($0 | 0) | 0) < (0 | 0)) abort();;
$0 = (($1 + (wasm2js_i32$0 = $0, wasm2js_i32$1 = 1, wasm2js_i32$2 = $0 >>> 0 > 1 >>> 0, wasm2js_i32$2 ? wasm2js_i32$0 : wasm2js_i32$1) | 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((wasm2js_i32$0 = $2, wasm2js_i32$1 = $3, wasm2js_i32$2 = ($2 | 0) > ($3 | 0), wasm2js_i32$2 ? wasm2js_i32$0 : wasm2js_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;
}
function $lib_runtime_doAllocate($0) {
$0 = $0 | 0;
var $1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0;
$1 = $lib_memory_memory_allocate(1 << (32 - Math_clz32($0 + 7 | 0) | 0) | 0 | 0) | 0;
wasm2js_i32$0 = $1;
wasm2js_i32$1 = 2774420247;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $1;
wasm2js_i32$1 = $0;
HEAP32[(wasm2js_i32$0 + 4 | 0) >> 2] = wasm2js_i32$1;
return $1 + 8 | 0 | 0;
}
function assembly_index_NBodySystem_constructor($0) {
$0 = $0 | 0;
var $1 = 0, $2 = 0, $3 = 0.0, $4 = 0.0, $5 = 0.0, $6 = 0.0, $7 = 0, $49 = 0, wasm2js_i32$0 = 0, wasm2js_f64$0 = 0.0, wasm2js_i32$1 = 0;
$7 = HEAP32[($0 + 4 | 0) >> 2] | 0;
var $1 = 0, $2 = 0, $3 = 0.0, $4 = 0.0, $5 = 0.0, $6 = 0.0, $7 = 0, wasm2js_i32$0 = 0, wasm2js_f64$0 = 0.0, wasm2js_i32$1 = 0;
$7 = HEAP32[($0 + 12 | 0) >> 2] | 0;
repeat_0 : do {
if (($1 | 0) < ($7 | 0)) {
$2 = HEAPU32[(((HEAPU32[$0 >> 2] | 0) + ($1 << 2 | 0) | 0) + 8 | 0) >> 2] | 0;
$2 = HEAPU32[((HEAP32[($0 + 4 | 0) >> 2] | 0) + ($1 << 2 | 0) | 0) >> 2] | 0;
$3 = +HEAPF64[($2 + 48 | 0) >> 3];
$4 = $4 + +HEAPF64[($2 + 24 | 0) >> 3] * $3;
$5 = $5 + +HEAPF64[($2 + 32 | 0) >> 3] * $3;
@ -55,9 +68,7 @@ function asmFunc(global, env, buffer) {
}
break repeat_0;
} while (1);
$1 = HEAPU32[$0 >> 2] | 0;
if (0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $49 = HEAPU32[($1 + 8 | 0) >> 2] | 0; else abort();
$1 = $49;
$1 = HEAPU32[(HEAP32[($0 + 4 | 0) >> 2] | 0) >> 2] | 0;
wasm2js_i32$0 = $1;
wasm2js_f64$0 = -$4 / 39.47841760435743;
HEAPF64[(wasm2js_i32$0 + 24 | 0) >> 3] = wasm2js_f64$0;
@ -67,7 +78,10 @@ function asmFunc(global, env, buffer) {
wasm2js_i32$0 = $1;
wasm2js_f64$0 = -$6 / 39.47841760435743;
HEAPF64[(wasm2js_i32$0 + 40 | 0) >> 3] = wasm2js_f64$0;
$1 = $lib_allocator_arena___memory_allocate(4 | 0) | 0;
$1 = $lib_runtime_doAllocate(4 | 0) | 0;
wasm2js_i32$0 = $1 - 8 | 0;
wasm2js_i32$1 = 1;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $1;
wasm2js_i32$1 = $0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
@ -82,8 +96,11 @@ function asmFunc(global, env, buffer) {
$4 = +$4;
$5 = +$5;
$6 = +$6;
var $7 = 0, wasm2js_i32$0 = 0, wasm2js_f64$0 = 0.0;
$7 = $lib_allocator_arena___memory_allocate(56 | 0) | 0;
var $7 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0, wasm2js_f64$0 = 0.0;
$7 = $lib_runtime_doAllocate(56 | 0) | 0;
wasm2js_i32$0 = $7 - 8 | 0;
wasm2js_i32$1 = 2;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $7;
wasm2js_f64$0 = $0;
HEAPF64[wasm2js_i32$0 >> 3] = wasm2js_f64$0;
@ -108,9 +125,10 @@ function asmFunc(global, env, buffer) {
return $7 | 0;
}
function $lib_internal_memory_memset($0) {
function $lib_memory_memory_fill($0) {
$0 = $0 | 0;
var $1 = 0, $2 = 0, i64toi32_i32$1 = 0, i64toi32_i32$0 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0, wasm2js_i32$2 = 0, wasm2js_i32$3 = 0;
$lib_util_memory_memset_inlined_0 : {
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 0;
HEAP8[wasm2js_i32$0 >> 0] = wasm2js_i32$1;
@ -137,15 +155,16 @@ function asmFunc(global, env, buffer) {
wasm2js_i32$1 = 0;
HEAP8[wasm2js_i32$0 >> 0] = wasm2js_i32$1;
$1 = (0 - $0 | 0) & 3 | 0;
$0 = $1 + $0 | 0;
$2 = 20 - $1 | 0;
$0 = $0 + $1 | 0;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
$2 = (20 - $1 | 0) & 4294967292 | 0;
$2 = $2 & 4294967292 | 0;
wasm2js_i32$0 = ($2 + $0 | 0) - 4 | 0;
wasm2js_i32$1 = 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
if ($2 >>> 0 <= 8 >>> 0) return;
if ($2 >>> 0 <= 8 >>> 0) break $lib_util_memory_memset_inlined_0;
wasm2js_i32$0 = $0 + 4 | 0;
wasm2js_i32$1 = 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
@ -159,7 +178,7 @@ function asmFunc(global, env, buffer) {
wasm2js_i32$0 = $1 - 8 | 0;
wasm2js_i32$1 = 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
if ($2 >>> 0 <= 24 >>> 0) return;
if ($2 >>> 0 <= 24 >>> 0) break $lib_util_memory_memset_inlined_0;
wasm2js_i32$0 = $0 + 12 | 0;
wasm2js_i32$1 = 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
@ -228,15 +247,23 @@ function asmFunc(global, env, buffer) {
}
break continue_0;
} while (1);
};
}
function $lib_array_Array_Body__constructor() {
var $0 = 0, $1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0;
$1 = $lib_allocator_arena___memory_allocate(32 | 0) | 0;
wasm2js_i32$0 = $1;
wasm2js_i32$1 = 20;
function $lib_runtime_ArrayBufferView_constructor($0) {
$0 = $0 | 0;
var $1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0;
$1 = $lib_runtime_doAllocate(20 | 0) | 0;
$lib_memory_memory_fill($1 | 0);
wasm2js_i32$0 = $1 - 8 | 0;
wasm2js_i32$1 = 4;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
$0 = $lib_allocator_arena___memory_allocate(8 | 0) | 0;
if (($0 | 0) == (0 | 0)) {
$0 = $lib_runtime_doAllocate(12 | 0) | 0;
wasm2js_i32$0 = $0 - 8 | 0;
wasm2js_i32$1 = 5;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
}
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
@ -244,38 +271,55 @@ function asmFunc(global, env, buffer) {
wasm2js_i32$1 = 0;
HEAP32[(wasm2js_i32$0 + 4 | 0) >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 0;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = $1;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 5;
wasm2js_i32$1 = $1;
HEAP32[(wasm2js_i32$0 + 4 | 0) >> 2] = wasm2js_i32$1;
$lib_internal_memory_memset($1 + 8 | 0 | 0);
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 20;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
return $0 | 0;
}
function $lib_array_Array_Body__constructor() {
var $0 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0;
$0 = $lib_runtime_doAllocate(16 | 0) | 0;
wasm2js_i32$0 = $0 - 8 | 0;
wasm2js_i32$1 = 6;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
$0 = $lib_runtime_ArrayBufferView_constructor($0 | 0) | 0;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 0;
HEAP32[(wasm2js_i32$0 + 12 | 0) >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = 5;
HEAP32[(wasm2js_i32$0 + 12 | 0) >> 2] = wasm2js_i32$1;
return $0 | 0;
}
function assembly_index_init() {
var $0 = 0, $1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0;
$1 = $lib_array_Array_Body__constructor() | 0;
$0 = assembly_index_Body_constructor(+(0.0), +(0.0), +(0.0), +(0.0), +(0.0), +(0.0), +(39.47841760435743)) | 0;
wasm2js_i32$0 = HEAPU32[$1 >> 2] | 0;
wasm2js_i32$1 = $0;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
$0 = assembly_index_Body_constructor(+(4.841431442464721), +(-1.1603200440274284), +(-.10362204447112311), +(.606326392995832), +(2.81198684491626), +(-.02521836165988763), +(.03769367487038949)) | 0;
wasm2js_i32$0 = (HEAPU32[$1 >> 2] | 0) + 4 | 0;
wasm2js_i32$1 = $0;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
$0 = assembly_index_Body_constructor(+(8.34336671824458), +(4.124798564124305), +(-.4035234171143214), +(-1.0107743461787924), +(1.8256623712304119), +(.008415761376584154), +(.011286326131968767)) | 0;
wasm2js_i32$0 = (HEAPU32[$1 >> 2] | 0) + 8 | 0;
wasm2js_i32$1 = $0;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
$0 = assembly_index_Body_constructor(+(12.894369562139131), +(-15.111151401698631), +(-.22330757889265573), +(1.0827910064415354), +(.8687130181696082), +(-.010832637401363636), +(1.7237240570597112e-03)) | 0;
wasm2js_i32$0 = (HEAPU32[$1 >> 2] | 0) + 12 | 0;
wasm2js_i32$1 = $0;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
$0 = assembly_index_Body_constructor(+(15.379697114850917), +(-25.919314609987964), +(.17925877295037118), +(.979090732243898), +(.5946989986476762), +(-.034755955504078104), +(2.0336868699246304e-03)) | 0;
wasm2js_i32$0 = (HEAPU32[$1 >> 2] | 0) + 16 | 0;
wasm2js_i32$1 = $0;
$0 = HEAPU32[($1 + 4 | 0) >> 2] | 0;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = assembly_index_Body_constructor(+(0.0), +(0.0), +(0.0), +(0.0), +(0.0), +(0.0), +(39.47841760435743)) | 0;
HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = assembly_index_Body_constructor(+(4.841431442464721), +(-1.1603200440274284), +(-.10362204447112311), +(.606326392995832), +(2.81198684491626), +(-.02521836165988763), +(.03769367487038949)) | 0;
HEAP32[(wasm2js_i32$0 + 4 | 0) >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = assembly_index_Body_constructor(+(8.34336671824458), +(4.124798564124305), +(-.4035234171143214), +(-1.0107743461787924), +(1.8256623712304119), +(.008415761376584154), +(.011286326131968767)) | 0;
HEAP32[(wasm2js_i32$0 + 8 | 0) >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = assembly_index_Body_constructor(+(12.894369562139131), +(-15.111151401698631), +(-.22330757889265573), +(1.0827910064415354), +(.8687130181696082), +(-.010832637401363636), +(1.7237240570597112e-03)) | 0;
HEAP32[(wasm2js_i32$0 + 12 | 0) >> 2] = wasm2js_i32$1;
wasm2js_i32$0 = $0;
wasm2js_i32$1 = assembly_index_Body_constructor(+(15.379697114850917), +(-25.919314609987964), +(.17925877295037118), +(.979090732243898), +(.5946989986476762), +(-.034755955504078104), +(2.0336868699246304e-03)) | 0;
HEAP32[(wasm2js_i32$0 + 16 | 0) >> 2] = wasm2js_i32$1;
assembly_index_system = assembly_index_NBodySystem_constructor($1 | 0) | 0;
}
@ -283,10 +327,10 @@ function asmFunc(global, env, buffer) {
$0 = $0 | 0;
var $1 = 0, $2 = 0.0, $8 = 0.0, $3 = 0, $4 = 0.0, $5 = 0.0, $6 = 0.0, $7 = 0, $9 = 0.0, $10 = 0.0, $11 = 0.0, $12 = 0, $13 = 0, $18 = 0.0, $14 = 0.0, $15 = 0.0, $16 = 0.0, $17 = 0.0, wasm2js_i32$0 = 0, wasm2js_f64$0 = 0.0;
$12 = HEAPU32[$0 >> 2] | 0;
$13 = HEAP32[($12 + 4 | 0) >> 2] | 0;
$13 = HEAP32[($12 + 12 | 0) >> 2] | 0;
repeat_0 : do {
if ($3 >>> 0 < $13 >>> 0) {
$0 = HEAPU32[(((HEAPU32[$12 >> 2] | 0) + ($3 << 2 | 0) | 0) + 8 | 0) >> 2] | 0;
$0 = HEAPU32[((HEAP32[($12 + 4 | 0) >> 2] | 0) + ($3 << 2 | 0) | 0) >> 2] | 0;
$14 = +HEAPF64[$0 >> 3];
$15 = +HEAPF64[($0 + 8 | 0) >> 3];
$16 = +HEAPF64[($0 + 16 | 0) >> 3];
@ -297,7 +341,7 @@ function asmFunc(global, env, buffer) {
$7 = $3 + 1 | 0;
repeat_1 : do {
if ($7 >>> 0 < $13 >>> 0) {
$1 = HEAPU32[(((HEAPU32[$12 >> 2] | 0) + ($7 << 2 | 0) | 0) + 8 | 0) >> 2] | 0;
$1 = HEAPU32[((HEAP32[($12 + 4 | 0) >> 2] | 0) + ($7 << 2 | 0) | 0) >> 2] | 0;
$18 = $14 - +HEAPF64[$1 >> 3];
$2 = $18;
$9 = $15 - +HEAPF64[($1 + 8 | 0) >> 3];
@ -351,33 +395,35 @@ 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, $30 = 0.0, $39 = 0.0, $45 = 0.0, $69 = 0.0, $84 = 0.0;
var $1 = 0.0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $9 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $30 = 0.0, $39 = 0.0, $45 = 0.0, $10 = 0.0, $72 = 0.0, $86 = 0.0;
$4 = HEAPU32[$0 >> 2] | 0;
$5 = HEAP32[($4 + 4 | 0) >> 2] | 0;
$5 = HEAP32[($4 + 12 | 0) >> 2] | 0;
repeat_0 : do {
if ($2 >>> 0 < $5 >>> 0) {
$0 = HEAPU32[(((HEAPU32[$4 >> 2] | 0) + ($2 << 2 | 0) | 0) + 8 | 0) >> 2] | 0;
$7 = +HEAPF64[$0 >> 3];
$8 = +HEAPF64[($0 + 8 | 0) >> 3];
$9 = +HEAPF64[($0 + 16 | 0) >> 3];
$0 = HEAPU32[((HEAP32[($4 + 4 | 0) >> 2] | 0) + ($2 << 2 | 0) | 0) >> 2] | 0;
$6 = +HEAPF64[$0 >> 3];
$7 = +HEAPF64[($0 + 8 | 0) >> 3];
$8 = +HEAPF64[($0 + 16 | 0) >> 3];
$30 = $1;
$10 = +HEAPF64[($0 + 48 | 0) >> 3];
$9 = +HEAPF64[($0 + 48 | 0) >> 3];
$1 = +HEAPF64[($0 + 24 | 0) >> 3];
$39 = $1 * $1;
$1 = +HEAPF64[($0 + 32 | 0) >> 3];
$45 = $39 + $1 * $1;
$1 = +HEAPF64[($0 + 40 | 0) >> 3];
$1 = $30 + .5 * $10 * ($45 + $1 * $1);
$1 = $30 + .5 * $9 * ($45 + $1 * $1);
$0 = $2 + 1 | 0;
repeat_1 : do {
if ($0 >>> 0 < $5 >>> 0) {
$3 = HEAPU32[(((HEAPU32[$4 >> 2] | 0) + ($0 << 2 | 0) | 0) + 8 | 0) >> 2] | 0;
$6 = $7 - +HEAPF64[$3 >> 3];
$69 = $1;
$1 = $8 - +HEAPF64[($3 + 8 | 0) >> 3];
$84 = $6 * $6 + $1 * $1;
$1 = $9 - +HEAPF64[($3 + 16 | 0) >> 3];
$1 = $69 - $10 * +HEAPF64[($3 + 48 | 0) >> 3] / Math_sqrt($84 + $1 * $1);
$10 = $1;
$3 = HEAPU32[((HEAP32[($4 + 4 | 0) >> 2] | 0) + ($0 << 2 | 0) | 0) >> 2] | 0;
$1 = $6 - +HEAPF64[$3 >> 3];
$72 = $1 * $1;
$1 = $7 - +HEAPF64[($3 + 8 | 0) >> 3];
$1 = $72 + $1 * $1;
$86 = $1;
$1 = $8 - +HEAPF64[($3 + 16 | 0) >> 3];
$1 = $10 - $9 * +HEAPF64[($3 + 48 | 0) >> 3] / Math_sqrt($86 + $1 * $1);
$0 = $0 + 1 | 0;
continue repeat_1;
}
@ -412,18 +458,14 @@ function asmFunc(global, env, buffer) {
function assembly_index_getBody($0) {
$0 = $0 | 0;
var $1 = 0, $22 = 0, $20 = 0;
var $1 = 0, $14 = 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) $20 = HEAPU32[((($0 << 2 | 0) + $1 | 0) + 8 | 0) >> 2] | 0; else abort();
$22 = $20;
} else $22 = 0;
return $22 | 0;
if ($0 >>> 0 < (HEAP32[($1 + 12 | 0) >> 2] | 0) >>> 0) $14 = HEAPU32[((HEAP32[($1 + 4 | 0) >> 2] | 0) + ($0 << 2 | 0) | 0) >> 2] | 0; else $14 = 0;
return $14 | 0;
}
function start() {
$lib_allocator_arena_startOffset = 40;
$lib_allocator_arena_startOffset = 96;
$lib_allocator_arena_offset = $lib_allocator_arena_startOffset;
}
@ -493,7 +535,8 @@ const assignasmFunc = (
}
}
)(memasmFunc);
assignasmFunc(8, "DQAAAH4AbABpAGIALwBhAHIAcgBhAHkALgB0AHM=");
assignasmFunc(8, "AwAAAB4AAAB+AGwAaQBiAC8AcgB1AG4AdABpAG0AZQAuAHQAcw==");
assignasmFunc(48, "AwAAACYAAAB+AGwAaQBiAC8AYQByAHIAYQB5AGIAdQBmAGYAZQByAC4AdABz");
const retasmFunc = asmFunc({Math,Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,NaN,Infinity}, {abort:function() { throw new Error('abort'); }},memasmFunc);
export const memory = retasmFunc.memory;
export const init = retasmFunc.init;

Binary file not shown.

View File

@ -7,12 +7,13 @@
(type $FUNCSIG$iddddddd (func (param f64 f64 f64 f64 f64 f64 f64) (result i32)))
(type $FUNCSIG$i (func (result i32)))
(import "env" "memory" (memory $0 1))
(data (i32.const 8) "\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s")
(data (i32.const 8) "\03\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s")
(data (i32.const 48) "\03\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s")
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $assembly/index/system (mut i32) (i32.const 0))
(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))
(export "memory" (memory $0))
(export "table" (table $0))
(export "init" (func $assembly/index/init))
@ -20,7 +21,7 @@
(export "bench" (func $assembly/index/bench))
(export "getBody" (func $assembly/index/getBody))
(start $start)
(func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/memory/memory.allocate (; 0 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@ -43,15 +44,15 @@
i32.add
i32.const -8
i32.and
local.tee $2
local.tee $0
current_memory
local.tee $3
local.tee $2
i32.const 16
i32.shl
i32.gt_u
if
local.get $3
local.get $2
local.get $0
local.get $1
i32.sub
i32.const 65535
@ -60,16 +61,16 @@
i32.and
i32.const 16
i32.shr_u
local.tee $0
local.tee $3
local.get $2
local.get $3
local.get $0
i32.gt_s
select
grow_memory
i32.const 0
i32.lt_s
if
local.get $0
local.get $3
grow_memory
i32.const 0
i32.lt_s
@ -78,11 +79,32 @@
end
end
end
local.get $2
local.get $0
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $assembly/index/NBodySystem#constructor (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $~lib/runtime/doAllocate (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
i32.const 1
i32.const 32
local.get $0
i32.const 7
i32.add
i32.clz
i32.sub
i32.shl
call $~lib/memory/memory.allocate
local.tee $1
i32.const -1520547049
i32.store
local.get $1
local.get $0
i32.store offset=4
local.get $1
i32.const 8
i32.add
)
(func $assembly/index/NBodySystem#constructor (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 f64)
@ -91,7 +113,7 @@
(local $6 f64)
(local $7 i32)
local.get $0
i32.load offset=4
i32.load offset=12
local.set $7
loop $repeat|0
local.get $1
@ -99,12 +121,12 @@
i32.lt_s
if
local.get $0
i32.load
i32.load offset=4
local.get $1
i32.const 2
i32.shl
i32.add
i32.load offset=8
i32.load
local.tee $2
f64.load offset=48
local.set $3
@ -136,21 +158,10 @@
br $repeat|0
end
end
i32.const 0
local.get $0
i32.load offset=4
i32.load
local.tee $1
i32.load
i32.const 2
i32.shr_u
i32.lt_u
if (result i32)
local.get $1
i32.load offset=8
else
unreachable
end
local.tee $1
local.get $4
f64.neg
f64.const 39.47841760435743
@ -169,17 +180,27 @@
f64.div
f64.store offset=40
i32.const 4
call $~lib/allocator/arena/__memory_allocate
call $~lib/runtime/doAllocate
local.tee $1
i32.const 8
i32.sub
i32.const 1
i32.store
local.get $1
local.get $0
i32.store
local.get $1
)
(func $assembly/index/Body#constructor (; 2 ;) (type $FUNCSIG$iddddddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (result i32)
(func $assembly/index/Body#constructor (; 3 ;) (type $FUNCSIG$iddddddd) (param $0 f64) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (result i32)
(local $7 i32)
i32.const 56
call $~lib/allocator/arena/__memory_allocate
call $~lib/runtime/doAllocate
local.tee $7
i32.const 8
i32.sub
i32.const 2
i32.store
local.get $7
local.get $0
f64.store
local.get $7
@ -202,9 +223,10 @@
f64.store offset=48
local.get $7
)
(func $~lib/internal/memory/memset (; 3 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $~lib/memory/memory.fill (; 4 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 i32)
block $~lib/util/memory/memset|inlined.0
local.get $0
i32.const 0
i32.store8
@ -246,20 +268,22 @@
i32.sub
i32.const 0
i32.store8
i32.const 20
i32.const 0
local.get $0
i32.sub
i32.const 3
i32.and
local.tee $1
i32.sub
local.set $2
local.get $0
local.get $1
i32.add
local.tee $0
i32.const 0
i32.store
i32.const 20
local.get $1
i32.sub
local.get $2
i32.const -4
i32.and
local.tee $2
@ -272,9 +296,7 @@
local.get $2
i32.const 8
i32.le_u
if
return
end
br_if $~lib/util/memory/memset|inlined.0
local.get $0
i32.const 4
i32.add
@ -301,9 +323,7 @@
local.get $2
i32.const 24
i32.le_u
if
return
end
br_if $~lib/util/memory/memset|inlined.0
local.get $0
i32.const 12
i32.add
@ -394,40 +414,76 @@
br $continue|0
end
end
end
)
(func $~lib/array/Array<Body>#constructor (; 4 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
(func $~lib/runtime/ArrayBufferView#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
i32.const 32
call $~lib/allocator/arena/__memory_allocate
local.tee $1
i32.const 20
i32.store
call $~lib/runtime/doAllocate
local.tee $1
call $~lib/memory/memory.fill
local.get $1
i32.const 8
call $~lib/allocator/arena/__memory_allocate
i32.sub
i32.const 4
i32.store
local.get $0
i32.eqz
if
i32.const 12
call $~lib/runtime/doAllocate
local.tee $0
i32.const 8
i32.sub
i32.const 5
i32.store
end
local.get $0
i32.const 0
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
i32.const 0
i32.store offset=8
local.get $0
local.get $1
i32.store
local.get $0
local.get $1
i32.store offset=4
local.get $0
i32.const 20
i32.store offset=8
local.get $0
)
(func $~lib/array/Array<Body>#constructor (; 6 ;) (type $FUNCSIG$i) (result i32)
(local $0 i32)
i32.const 16
call $~lib/runtime/doAllocate
local.tee $0
i32.const 8
i32.sub
i32.const 6
i32.store
local.get $0
call $~lib/runtime/ArrayBufferView#constructor
local.tee $0
i32.const 0
i32.store
local.get $0
i32.const 0
i32.store offset=4
local.get $0
local.get $1
i32.store
i32.store offset=12
local.get $0
i32.const 5
i32.store offset=4
local.get $1
i32.const 8
i32.add
call $~lib/internal/memory/memset
i32.store offset=12
local.get $0
)
(func $assembly/index/init (; 5 ;) (type $FUNCSIG$v)
(func $assembly/index/init (; 7 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
call $~lib/array/Array<Body>#constructor
local.set $1
local.tee $1
i32.load offset=4
local.tee $0
f64.const 0
f64.const 0
f64.const 0
@ -436,11 +492,8 @@
f64.const 0
f64.const 39.47841760435743
call $assembly/index/Body#constructor
local.set $0
local.get $1
i32.load
i32.store
local.get $0
i32.store offset=8
f64.const 4.841431442464721
f64.const -1.1603200440274284
f64.const -0.10362204447112311
@ -449,13 +502,8 @@
f64.const -0.02521836165988763
f64.const 0.03769367487038949
call $assembly/index/Body#constructor
local.set $0
local.get $1
i32.load
i32.const 4
i32.add
i32.store offset=4
local.get $0
i32.store offset=8
f64.const 8.34336671824458
f64.const 4.124798564124305
f64.const -0.4035234171143214
@ -464,13 +512,8 @@
f64.const 0.008415761376584154
f64.const 0.011286326131968767
call $assembly/index/Body#constructor
local.set $0
local.get $1
i32.load
i32.const 8
i32.add
local.get $0
i32.store offset=8
local.get $0
f64.const 12.894369562139131
f64.const -15.111151401698631
f64.const -0.22330757889265573
@ -479,13 +522,8 @@
f64.const -0.010832637401363636
f64.const 1.7237240570597112e-03
call $assembly/index/Body#constructor
local.set $0
local.get $1
i32.load
i32.const 12
i32.add
i32.store offset=12
local.get $0
i32.store offset=8
f64.const 15.379697114850917
f64.const -25.919314609987964
f64.const 0.17925877295037118
@ -494,18 +532,12 @@
f64.const -0.034755955504078104
f64.const 2.0336868699246304e-03
call $assembly/index/Body#constructor
local.set $0
local.get $1
i32.load
i32.const 16
i32.add
local.get $0
i32.store offset=8
i32.store offset=16
local.get $1
call $assembly/index/NBodySystem#constructor
global.set $assembly/index/system
)
(func $assembly/index/NBodySystem#advance (; 6 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $assembly/index/NBodySystem#advance (; 8 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
(local $2 f64)
(local $3 i32)
@ -527,7 +559,7 @@
local.get $0
i32.load
local.tee $12
i32.load offset=4
i32.load offset=12
local.set $13
loop $repeat|0
local.get $3
@ -535,12 +567,12 @@
i32.lt_u
if
local.get $12
i32.load
i32.load offset=4
local.get $3
i32.const 2
i32.shl
i32.add
i32.load offset=8
i32.load
local.tee $0
f64.load
local.set $14
@ -573,12 +605,12 @@
if
local.get $14
local.get $12
i32.load
i32.load offset=4
local.get $7
i32.const 2
i32.shl
i32.add
i32.load offset=8
i32.load
local.tee $1
f64.load
f64.sub
@ -707,7 +739,7 @@
end
end
)
(func $assembly/index/NBodySystem#energy (; 7 ;) (type $FUNCSIG$di) (param $0 i32) (result f64)
(func $assembly/index/NBodySystem#energy (; 9 ;) (type $FUNCSIG$di) (param $0 i32) (result f64)
(local $1 f64)
(local $2 i32)
(local $3 i32)
@ -721,7 +753,7 @@
local.get $0
i32.load
local.tee $4
i32.load offset=4
i32.load offset=12
local.set $5
loop $repeat|0
local.get $2
@ -729,26 +761,26 @@
i32.lt_u
if
local.get $4
i32.load
i32.load offset=4
local.get $2
i32.const 2
i32.shl
i32.add
i32.load offset=8
i32.load
local.tee $0
f64.load
local.set $7
local.set $6
local.get $0
f64.load offset=8
local.set $8
local.set $7
local.get $0
f64.load offset=16
local.set $9
local.set $8
local.get $1
f64.const 0.5
local.get $0
f64.load offset=48
local.tee $10
local.tee $9
f64.mul
local.get $0
f64.load offset=24
@ -779,27 +811,23 @@
local.get $5
i32.lt_u
if
local.get $7
local.get $1
local.set $10
local.get $6
local.get $4
i32.load
i32.load offset=4
local.get $0
i32.const 2
i32.shl
i32.add
i32.load offset=8
i32.load
local.tee $3
f64.load
f64.sub
local.set $6
local.tee $1
local.get $1
local.get $10
local.get $3
f64.load offset=48
f64.mul
local.get $6
local.get $6
f64.mul
local.get $8
local.get $7
local.get $3
f64.load offset=8
f64.sub
@ -807,8 +835,15 @@
local.get $1
f64.mul
f64.add
local.set $1
local.get $10
local.get $9
local.get $3
f64.load offset=48
f64.mul
local.get $1
local.get $8
local.get $3
f64.load offset=16
f64.sub
local.tee $1
@ -835,13 +870,13 @@
end
local.get $1
)
(func $assembly/index/step (; 8 ;) (type $FUNCSIG$d) (result f64)
(func $assembly/index/step (; 10 ;) (type $FUNCSIG$d) (result f64)
global.get $assembly/index/system
call $assembly/index/NBodySystem#advance
global.get $assembly/index/system
call $assembly/index/NBodySystem#energy
)
(func $assembly/index/bench (; 9 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $assembly/index/bench (; 11 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
block $break|0
loop $repeat|0
@ -861,44 +896,33 @@
unreachable
end
)
(func $assembly/index/getBody (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(func $assembly/index/getBody (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
(local $1 i32)
local.get $0
global.get $assembly/index/system
i32.load
local.tee $1
i32.load offset=4
i32.load offset=12
i32.lt_u
if (result i32)
local.get $0
local.get $1
i32.load
local.tee $1
i32.load
i32.const 2
i32.shr_u
i32.lt_u
if (result i32)
i32.load offset=4
local.get $0
i32.const 2
i32.shl
local.get $1
i32.add
i32.load offset=8
else
unreachable
end
i32.load
else
i32.const 0
end
)
(func $start (; 11 ;) (type $FUNCSIG$v)
i32.const 40
(func $start (; 13 ;) (type $FUNCSIG$v)
i32.const 96
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $null (; 12 ;) (type $FUNCSIG$v)
(func $null (; 14 ;) (type $FUNCSIG$v)
nop
)
)

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,10 @@ import {
Token
} from "./tokenizer";
import {
BuiltinSymbols
} from "./builtins";
/** Indicates whether errors are reported or not. */
export enum ReportMode {
/** Report errors. */
@ -1208,6 +1212,14 @@ export class Resolver extends DiagnosticEmitter {
);
if (!target) return null;
if (target.kind == ElementKind.FUNCTION_PROTOTYPE) {
// `unchecked(expr: *): *` is special
if (
(<FunctionPrototype>target).internalName == BuiltinSymbols.unchecked &&
expression.arguments.length > 0
) {
return this.resolveExpression(expression.arguments[0], flow, contextualType, reportMode);
}
// otherwise resolve normally
let instance = this.resolveFunctionInclTypeArguments(
<FunctionPrototype>target,
expression.typeArguments,