diff --git a/examples/n-body/assembly/index.ts b/examples/n-body/assembly/index.ts index 9a37c2d6..8741406e 100644 --- a/examples/n-body/assembly/index.ts +++ b/examples/n-body/assembly/index.ts @@ -84,7 +84,7 @@ function Neptune(): Body { class NBodySystem { - constructor(public bodies: Body[]) { + constructor(public bodies: FixedArray) { var px: float = 0.0; var py: float = 0.0; var pz: float = 0.0; @@ -186,13 +186,15 @@ class NBodySystem { var system: NBodySystem; export function init(): void { - system = new NBodySystem([ - Sun(), - Jupiter(), - Saturn(), - Uranus(), - Neptune() - ]); + var bodies = new FixedArray(5); + unchecked(( + bodies[0] = Sun(), + bodies[1] = Jupiter(), + bodies[2] = Saturn(), + bodies[3] = Uranus(), + bodies[4] = Neptune() + )); + system = new NBodySystem(bodies); } export function step(): float { diff --git a/examples/n-body/build/index.asm.js b/examples/n-body/build/index.asm.js index f9dbb20d..a06bcd50 100644 --- a/examples/n-body/build/index.asm.js +++ b/examples/n-body/build/index.asm.js @@ -52,79 +52,6 @@ function asmFunc(global, env, buffer) { 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, 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[((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; - $6 = $6 + +HEAPF64[($2 + 40 | 0) >> 3] * $3; - $1 = $1 + 1 | 0; - continue repeat_0; - } - break repeat_0; - } while (1); - $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; - wasm2js_i32$0 = $1; - wasm2js_f64$0 = -$5 / 39.47841760435743; - HEAPF64[(wasm2js_i32$0 + 32 | 0) >> 3] = wasm2js_f64$0; - wasm2js_i32$0 = $1; - wasm2js_f64$0 = -$6 / 39.47841760435743; - HEAPF64[(wasm2js_i32$0 + 40 | 0) >> 3] = wasm2js_f64$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; - return $1 | 0; - } - - function assembly_index_Body_constructor($0, $1, $2, $3, $4, $5, $6) { - $0 = +$0; - $1 = +$1; - $2 = +$2; - $3 = +$3; - $4 = +$4; - $5 = +$5; - $6 = +$6; - 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; - wasm2js_i32$0 = $7; - wasm2js_f64$0 = $1; - HEAPF64[(wasm2js_i32$0 + 8 | 0) >> 3] = wasm2js_f64$0; - wasm2js_i32$0 = $7; - wasm2js_f64$0 = $2; - HEAPF64[(wasm2js_i32$0 + 16 | 0) >> 3] = wasm2js_f64$0; - wasm2js_i32$0 = $7; - wasm2js_f64$0 = $3; - HEAPF64[(wasm2js_i32$0 + 24 | 0) >> 3] = wasm2js_f64$0; - wasm2js_i32$0 = $7; - wasm2js_f64$0 = $4; - HEAPF64[(wasm2js_i32$0 + 32 | 0) >> 3] = wasm2js_f64$0; - wasm2js_i32$0 = $7; - wasm2js_f64$0 = $5; - HEAPF64[(wasm2js_i32$0 + 40 | 0) >> 3] = wasm2js_f64$0; - wasm2js_i32$0 = $7; - wasm2js_f64$0 = $6; - HEAPF64[(wasm2js_i32$0 + 48 | 0) >> 3] = wasm2js_f64$0; - return $7 | 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; @@ -250,87 +177,112 @@ function asmFunc(global, env, buffer) { }; } - function $lib_runtime_ArrayBufferView_constructor($0) { + function assembly_index_Body_constructor($0, $1, $2, $3, $4, $5, $6) { + $0 = +$0; + $1 = +$1; + $2 = +$2; + $3 = +$3; + $4 = +$4; + $5 = +$5; + $6 = +$6; + 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 = 3; + HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $0; + HEAPF64[wasm2js_i32$0 >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $1; + HEAPF64[(wasm2js_i32$0 + 8 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $2; + HEAPF64[(wasm2js_i32$0 + 16 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $3; + HEAPF64[(wasm2js_i32$0 + 24 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $4; + HEAPF64[(wasm2js_i32$0 + 32 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $5; + HEAPF64[(wasm2js_i32$0 + 40 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $7; + wasm2js_f64$0 = $6; + HEAPF64[(wasm2js_i32$0 + 48 | 0) >> 3] = wasm2js_f64$0; + return $7 | 0; + } + + function assembly_index_NBodySystem_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); + 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 = (HEAPU32[(($0 - 8 | 0) + 4 | 0) >> 2] | 0) >>> 2 | 0; + repeat_0 : do { + if (($1 | 0) < ($7 | 0)) { + $2 = HEAPU32[(($1 << 2 | 0) + $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; + $6 = $6 + +HEAPF64[($2 + 40 | 0) >> 3] * $3; + $1 = $1 + 1 | 0; + continue repeat_0; + } + break repeat_0; + } while (1); + $1 = HEAPU32[$0 >> 2] | 0; + wasm2js_i32$0 = $1; + wasm2js_f64$0 = -$4 / 39.47841760435743; + HEAPF64[(wasm2js_i32$0 + 24 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $1; + wasm2js_f64$0 = -$5 / 39.47841760435743; + HEAPF64[(wasm2js_i32$0 + 32 | 0) >> 3] = wasm2js_f64$0; + wasm2js_i32$0 = $1; + wasm2js_f64$0 = -$6 / 39.47841760435743; + HEAPF64[(wasm2js_i32$0 + 40 | 0) >> 3] = wasm2js_f64$0; + $1 = $lib_runtime_doAllocate(4 | 0) | 0; wasm2js_i32$0 = $1 - 8 | 0; wasm2js_i32$1 = 4; HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; - 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; + wasm2js_i32$0 = $1; + wasm2js_i32$1 = $0; HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; - wasm2js_i32$0 = $0; - 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 = $1; - HEAP32[(wasm2js_i32$0 + 4 | 0) >> 2] = wasm2js_i32$1; - 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; + return $1 | 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 = HEAPU32[($1 + 4 | 0) >> 2] | 0; + var $0 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; + $0 = $lib_runtime_doAllocate(20 | 0) | 0; + $lib_memory_memory_fill($0 | 0); + wasm2js_i32$0 = $0 - 8 | 0; + wasm2js_i32$1 = 2; + HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; 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$0 = $0 + 4 | 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; + HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + wasm2js_i32$0 = $0 + 8 | 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; + HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + wasm2js_i32$0 = $0 + 12 | 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; + HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + wasm2js_i32$0 = $0 + 16 | 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; + HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + assembly_index_system = assembly_index_NBodySystem_constructor($0 | 0) | 0; } function assembly_index_NBodySystem_advance($0) { $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 + 12 | 0) >> 2] | 0; + $13 = (HEAPU32[(($12 - 8 | 0) + 4 | 0) >> 2] | 0) >>> 2 | 0; repeat_0 : do { if ($3 >>> 0 < $13 >>> 0) { - $0 = HEAPU32[((HEAP32[($12 + 4 | 0) >> 2] | 0) + ($3 << 2 | 0) | 0) >> 2] | 0; + $0 = HEAPU32[(($3 << 2 | 0) + $12 | 0) >> 2] | 0; $14 = +HEAPF64[$0 >> 3]; $15 = +HEAPF64[($0 + 8 | 0) >> 3]; $16 = +HEAPF64[($0 + 16 | 0) >> 3]; @@ -341,7 +293,7 @@ function asmFunc(global, env, buffer) { $7 = $3 + 1 | 0; repeat_1 : do { if ($7 >>> 0 < $13 >>> 0) { - $1 = HEAPU32[((HEAP32[($12 + 4 | 0) >> 2] | 0) + ($7 << 2 | 0) | 0) >> 2] | 0; + $1 = HEAPU32[(($7 << 2 | 0) + $12 | 0) >> 2] | 0; $18 = $14 - +HEAPF64[$1 >> 3]; $2 = $18; $9 = $15 - +HEAPF64[($1 + 8 | 0) >> 3]; @@ -395,28 +347,28 @@ 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, $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; + var $1 = 0.0, $2 = 0, $3 = 0, $4 = 0, $5 = 0, $9 = 0.0, $6 = 0.0, $7 = 0.0, $8 = 0.0, $31 = 0.0, $40 = 0.0, $46 = 0.0, $10 = 0.0, $72 = 0.0, $86 = 0.0; $4 = HEAPU32[$0 >> 2] | 0; - $5 = HEAP32[($4 + 12 | 0) >> 2] | 0; + $5 = (HEAPU32[(($4 - 8 | 0) + 4 | 0) >> 2] | 0) >>> 2 | 0; repeat_0 : do { if ($2 >>> 0 < $5 >>> 0) { - $0 = HEAPU32[((HEAP32[($4 + 4 | 0) >> 2] | 0) + ($2 << 2 | 0) | 0) >> 2] | 0; + $0 = HEAPU32[(($2 << 2 | 0) + $4 | 0) >> 2] | 0; $6 = +HEAPF64[$0 >> 3]; $7 = +HEAPF64[($0 + 8 | 0) >> 3]; $8 = +HEAPF64[($0 + 16 | 0) >> 3]; - $30 = $1; + $31 = $1; $9 = +HEAPF64[($0 + 48 | 0) >> 3]; $1 = +HEAPF64[($0 + 24 | 0) >> 3]; - $39 = $1 * $1; + $40 = $1 * $1; $1 = +HEAPF64[($0 + 32 | 0) >> 3]; - $45 = $39 + $1 * $1; + $46 = $40 + $1 * $1; $1 = +HEAPF64[($0 + 40 | 0) >> 3]; - $1 = $30 + .5 * $9 * ($45 + $1 * $1); + $1 = $31 + .5 * $9 * ($46 + $1 * $1); $0 = $2 + 1 | 0; repeat_1 : do { if ($0 >>> 0 < $5 >>> 0) { $10 = $1; - $3 = HEAPU32[((HEAP32[($4 + 4 | 0) >> 2] | 0) + ($0 << 2 | 0) | 0) >> 2] | 0; + $3 = HEAPU32[(($0 << 2 | 0) + $4 | 0) >> 2] | 0; $1 = $6 - +HEAPF64[$3 >> 3]; $72 = $1 * $1; $1 = $7 - +HEAPF64[($3 + 8 | 0) >> 3]; @@ -458,14 +410,14 @@ function asmFunc(global, env, buffer) { function assembly_index_getBody($0) { $0 = $0 | 0; - var $1 = 0, $14 = 0; + var $1 = 0, $15 = 0; $1 = HEAPU32[assembly_index_system >> 2] | 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; + if ($0 >>> 0 < ((HEAPU32[(($1 - 8 | 0) + 4 | 0) >> 2] | 0) >>> 2 | 0) >>> 0) $15 = HEAPU32[(($0 << 2 | 0) + $1 | 0) >> 2] | 0; else $15 = 0; + return $15 | 0; } function start() { - $lib_allocator_arena_startOffset = 96; + $lib_allocator_arena_startOffset = 56; $lib_allocator_arena_offset = $lib_allocator_arena_startOffset; } @@ -535,8 +487,7 @@ const assignasmFunc = ( } } )(memasmFunc); -assignasmFunc(8, "AwAAAB4AAAB+AGwAaQBiAC8AcgB1AG4AdABpAG0AZQAuAHQAcw=="); -assignasmFunc(48, "AwAAACYAAAB+AGwAaQBiAC8AYQByAHIAYQB5AGIAdQBmAGYAZQByAC4AdABz"); +assignasmFunc(8, "AQAAACQAAAB+AGwAaQBiAC8AZgBpAHgAZQBkAGEAcgByAGEAeQAuAHQAcw=="); 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; diff --git a/examples/n-body/build/optimized.wasm b/examples/n-body/build/optimized.wasm index 8405b87c..47d60e67 100644 Binary files a/examples/n-body/build/optimized.wasm and b/examples/n-body/build/optimized.wasm differ diff --git a/examples/n-body/build/optimized.wat b/examples/n-body/build/optimized.wat index b11978f3..4c40794c 100644 --- a/examples/n-body/build/optimized.wat +++ b/examples/n-body/build/optimized.wat @@ -5,10 +5,8 @@ (type $FUNCSIG$di (func (param i32) (result f64))) (type $FUNCSIG$vi (func (param i32))) (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) "\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") + (data (i32.const 8) "\01\00\00\00$\00\00\00~\00l\00i\00b\00/\00f\00i\00x\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s") (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/index/system (mut i32) (i32.const 0)) @@ -104,126 +102,7 @@ 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) - (local $4 f64) - (local $5 f64) - (local $6 f64) - (local $7 i32) - local.get $0 - i32.load offset=12 - local.set $7 - loop $repeat|0 - local.get $1 - local.get $7 - i32.lt_s - if - local.get $0 - i32.load offset=4 - local.get $1 - i32.const 2 - i32.shl - i32.add - i32.load - local.tee $2 - f64.load offset=48 - local.set $3 - local.get $4 - local.get $2 - f64.load offset=24 - local.get $3 - f64.mul - f64.add - local.set $4 - local.get $5 - local.get $2 - f64.load offset=32 - local.get $3 - f64.mul - f64.add - local.set $5 - local.get $6 - local.get $2 - f64.load offset=40 - local.get $3 - f64.mul - f64.add - local.set $6 - local.get $1 - i32.const 1 - i32.add - local.set $1 - br $repeat|0 - end - end - local.get $0 - i32.load offset=4 - i32.load - local.tee $1 - local.get $4 - f64.neg - f64.const 39.47841760435743 - f64.div - f64.store offset=24 - local.get $1 - local.get $5 - f64.neg - f64.const 39.47841760435743 - f64.div - f64.store offset=32 - local.get $1 - local.get $6 - f64.neg - f64.const 39.47841760435743 - f64.div - f64.store offset=40 - i32.const 4 - 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 (; 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/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 - local.get $1 - f64.store offset=8 - local.get $7 - local.get $2 - f64.store offset=16 - local.get $7 - local.get $3 - f64.store offset=24 - local.get $7 - local.get $4 - f64.store offset=32 - local.get $7 - local.get $5 - f64.store offset=40 - local.get $7 - local.get $6 - f64.store offset=48 - local.get $7 - ) - (func $~lib/memory/memory.fill (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/memory/memory.fill (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 @@ -416,74 +295,139 @@ end end ) - (func $~lib/runtime/ArrayBufferView#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (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/runtime/doAllocate + local.tee $7 + i32.const 8 + i32.sub + i32.const 3 + i32.store + local.get $7 + local.get $0 + f64.store + local.get $7 + local.get $1 + f64.store offset=8 + local.get $7 + local.get $2 + f64.store offset=16 + local.get $7 + local.get $3 + f64.store offset=24 + local.get $7 + local.get $4 + f64.store offset=32 + local.get $7 + local.get $5 + f64.store offset=40 + local.get $7 + local.get $6 + f64.store offset=48 + local.get $7 + ) + (func $assembly/index/NBodySystem#constructor (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) - i32.const 20 + (local $2 i32) + (local $3 f64) + (local $4 f64) + (local $5 f64) + (local $6 f64) + (local $7 i32) + local.get $0 + i32.const 8 + i32.sub + i32.load offset=4 + i32.const 2 + i32.shr_u + local.set $7 + loop $repeat|0 + local.get $1 + local.get $7 + i32.lt_s + if + local.get $1 + i32.const 2 + i32.shl + local.get $0 + i32.add + i32.load + local.tee $2 + f64.load offset=48 + local.set $3 + local.get $4 + local.get $2 + f64.load offset=24 + local.get $3 + f64.mul + f64.add + local.set $4 + local.get $5 + local.get $2 + f64.load offset=32 + local.get $3 + f64.mul + f64.add + local.set $5 + local.get $6 + local.get $2 + f64.load offset=40 + local.get $3 + f64.mul + f64.add + local.set $6 + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $repeat|0 + end + end + local.get $0 + i32.load + local.tee $1 + local.get $4 + f64.neg + f64.const 39.47841760435743 + f64.div + f64.store offset=24 + local.get $1 + local.get $5 + f64.neg + f64.const 39.47841760435743 + f64.div + f64.store offset=32 + local.get $1 + local.get $6 + f64.neg + f64.const 39.47841760435743 + f64.div + f64.store offset=40 + i32.const 4 call $~lib/runtime/doAllocate local.tee $1 - call $~lib/memory/memory.fill - local.get $1 i32.const 8 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 + local.get $0 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#constructor (; 6 ;) (type $FUNCSIG$i) (result i32) + (func $assembly/index/init (; 5 ;) (type $FUNCSIG$v) (local $0 i32) - i32.const 16 + i32.const 20 call $~lib/runtime/doAllocate local.tee $0 + call $~lib/memory/memory.fill + local.get $0 i32.const 8 i32.sub - i32.const 6 + i32.const 2 i32.store local.get $0 - call $~lib/runtime/ArrayBufferView#constructor - local.tee $0 - i32.const 0 - i32.store offset=12 - local.get $0 - i32.const 5 - i32.store offset=12 - local.get $0 - ) - (func $assembly/index/init (; 7 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - call $~lib/array/Array#constructor - local.tee $1 - i32.load offset=4 - local.tee $0 f64.const 0 f64.const 0 f64.const 0 @@ -494,6 +438,8 @@ call $assembly/index/Body#constructor i32.store local.get $0 + i32.const 4 + i32.add f64.const 4.841431442464721 f64.const -1.1603200440274284 f64.const -0.10362204447112311 @@ -502,8 +448,10 @@ f64.const -0.02521836165988763 f64.const 0.03769367487038949 call $assembly/index/Body#constructor - i32.store offset=4 + i32.store local.get $0 + i32.const 8 + i32.add f64.const 8.34336671824458 f64.const 4.124798564124305 f64.const -0.4035234171143214 @@ -512,8 +460,10 @@ f64.const 0.008415761376584154 f64.const 0.011286326131968767 call $assembly/index/Body#constructor - i32.store offset=8 + i32.store local.get $0 + i32.const 12 + i32.add f64.const 12.894369562139131 f64.const -15.111151401698631 f64.const -0.22330757889265573 @@ -522,8 +472,10 @@ f64.const -0.010832637401363636 f64.const 1.7237240570597112e-03 call $assembly/index/Body#constructor - i32.store offset=12 + i32.store local.get $0 + i32.const 16 + i32.add f64.const 15.379697114850917 f64.const -25.919314609987964 f64.const 0.17925877295037118 @@ -532,12 +484,12 @@ f64.const -0.034755955504078104 f64.const 2.0336868699246304e-03 call $assembly/index/Body#constructor - i32.store offset=16 - local.get $1 + i32.store + local.get $0 call $assembly/index/NBodySystem#constructor global.set $assembly/index/system ) - (func $assembly/index/NBodySystem#advance (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $assembly/index/NBodySystem#advance (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) (local $2 f64) (local $3 i32) @@ -559,18 +511,21 @@ local.get $0 i32.load local.tee $12 - i32.load offset=12 + i32.const 8 + i32.sub + i32.load offset=4 + i32.const 2 + i32.shr_u local.set $13 loop $repeat|0 local.get $3 local.get $13 i32.lt_u if - local.get $12 - i32.load offset=4 local.get $3 i32.const 2 i32.shl + local.get $12 i32.add i32.load local.tee $0 @@ -604,11 +559,10 @@ i32.lt_u if local.get $14 - local.get $12 - i32.load offset=4 local.get $7 i32.const 2 i32.shl + local.get $12 i32.add i32.load local.tee $1 @@ -739,7 +693,7 @@ end end ) - (func $assembly/index/NBodySystem#energy (; 9 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) + (func $assembly/index/NBodySystem#energy (; 7 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) (local $1 f64) (local $2 i32) (local $3 i32) @@ -753,18 +707,21 @@ local.get $0 i32.load local.tee $4 - i32.load offset=12 + i32.const 8 + i32.sub + i32.load offset=4 + i32.const 2 + i32.shr_u local.set $5 loop $repeat|0 local.get $2 local.get $5 i32.lt_u if - local.get $4 - i32.load offset=4 local.get $2 i32.const 2 i32.shl + local.get $4 i32.add i32.load local.tee $0 @@ -814,11 +771,10 @@ local.get $1 local.set $10 local.get $6 - local.get $4 - i32.load offset=4 local.get $0 i32.const 2 i32.shl + local.get $4 i32.add i32.load local.tee $3 @@ -870,13 +826,13 @@ end local.get $1 ) - (func $assembly/index/step (; 10 ;) (type $FUNCSIG$d) (result f64) + (func $assembly/index/step (; 8 ;) (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 (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $assembly/index/bench (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) block $break|0 loop $repeat|0 @@ -896,33 +852,36 @@ unreachable end ) - (func $assembly/index/getBody (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $assembly/index/getBody (; 10 ;) (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=12 + i32.const 8 + i32.sub + i32.load offset=4 + i32.const 2 + i32.shr_u i32.lt_u if (result i32) - local.get $1 - i32.load offset=4 local.get $0 i32.const 2 i32.shl + local.get $1 i32.add i32.load else i32.const 0 end ) - (func $start (; 13 ;) (type $FUNCSIG$v) - i32.const 96 + (func $start (; 11 ;) (type $FUNCSIG$v) + i32.const 56 global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset ) - (func $null (; 14 ;) (type $FUNCSIG$v) + (func $null (; 12 ;) (type $FUNCSIG$v) nop ) ) diff --git a/examples/n-body/build/untouched.wat b/examples/n-body/build/untouched.wat index 0532282d..6712a537 100644 --- a/examples/n-body/build/untouched.wat +++ b/examples/n-body/build/untouched.wat @@ -1,20 +1,19 @@ (module (type $FUNCSIG$v (func)) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$iiddd (func (param i32 f64 f64 f64) (result i32))) - (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$iiddddddd (func (param i32 f64 f64 f64 f64 f64 f64 f64) (result i32))) - (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) + (type $FUNCSIG$iiddd (func (param i32 f64 f64 f64) (result i32))) (type $FUNCSIG$d (func (result f64))) (type $FUNCSIG$vid (func (param i32 f64))) (type $FUNCSIG$di (func (param i32) (result f64))) (import "env" "memory" (memory $0 1)) - (data (i32.const 8) "\02\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") - (data (i32.const 48) "\02\00\00\00&\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") + (data (i32.const 8) "\01\00\00\00$\00\00\00~\00l\00i\00b\00/\00f\00i\00x\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00") + (data (i32.const 56) "\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (table $0 1 funcref) (elem (i32.const 0) $null) @@ -25,10 +24,10 @@ (global $~lib/runtime/GC_IMPLEMENTED i32 (i32.const 0)) (global $~lib/runtime/HEADER_SIZE i32 (i32.const 8)) (global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) + (global $~lib/runtime/MAX_BYTELENGTH i32 (i32.const 1073741816)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) - (global $~lib/runtime/MAX_BYTELENGTH i32 (i32.const 1073741816)) (global $~lib/memory/HEAP_BASE i32 (i32.const 96)) (export "memory" (memory $0)) (export "table" (table $0)) @@ -37,32 +36,7 @@ (export "bench" (func $assembly/index/bench)) (export "getBody" (func $assembly/index/getBody)) (start $start) - (func $~lib/array/Array#get:length (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load offset=12 - ) - (func $assembly/index/Body#offsetMomentum (; 2 ;) (type $FUNCSIG$iiddd) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) - local.get $0 - local.get $1 - f64.neg - global.get $assembly/index/SOLAR_MASS - f64.div - f64.store offset=24 - local.get $0 - local.get $2 - f64.neg - global.get $assembly/index/SOLAR_MASS - f64.div - f64.store offset=32 - local.get $0 - local.get $3 - f64.neg - global.get $assembly/index/SOLAR_MASS - f64.div - f64.store offset=40 - local.get $0 - ) - (func $~lib/runtime/ADJUSTOBLOCK (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/runtime/ADJUSTOBLOCK (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 @@ -74,7 +48,7 @@ i32.sub i32.shl ) - (func $~lib/memory/memory.allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -159,7 +133,7 @@ end return ) - (func $~lib/runtime/doAllocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/runtime/doAllocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 call $~lib/runtime/ADJUSTOBLOCK @@ -175,194 +149,7 @@ global.get $~lib/runtime/HEADER_SIZE i32.add ) - (func $~lib/runtime/ALLOCATE (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - call $~lib/runtime/doAllocate - ) - (func $~lib/runtime/assertUnregistered (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.gt_u - i32.eqz - if - i32.const 0 - i32.const 16 - i32.const 192 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - global.get $~lib/runtime/HEADER_SIZE - i32.sub - i32.load - global.get $~lib/runtime/HEADER_MAGIC - i32.eq - i32.eqz - if - i32.const 0 - i32.const 16 - i32.const 193 - i32.const 2 - call $~lib/env/abort - unreachable - end - ) - (func $~lib/runtime/doRegister (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - call $~lib/runtime/assertUnregistered - local.get $0 - global.get $~lib/runtime/HEADER_SIZE - i32.sub - local.get $1 - i32.store - local.get $0 - ) - (func $assembly/index/NBodySystem#constructor (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 f64) - (local $3 f64) - (local $4 f64) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 f64) - f64.const 0 - local.set $2 - f64.const 0 - local.set $3 - f64.const 0 - local.set $4 - local.get $1 - call $~lib/array/Array#get:length - local.set $5 - block $break|0 - i32.const 0 - local.set $6 - loop $repeat|0 - local.get $6 - local.get $5 - i32.lt_s - i32.eqz - br_if $break|0 - block - local.get $1 - i32.load offset=4 - local.get $6 - i32.const 2 - i32.shl - i32.add - i32.load - local.set $7 - local.get $7 - f64.load offset=48 - local.set $8 - local.get $2 - local.get $7 - f64.load offset=24 - local.get $8 - f64.mul - f64.add - local.set $2 - local.get $3 - local.get $7 - f64.load offset=32 - local.get $8 - f64.mul - f64.add - local.set $3 - local.get $4 - local.get $7 - f64.load offset=40 - local.get $8 - f64.mul - f64.add - local.set $4 - end - local.get $6 - i32.const 1 - i32.add - local.set $6 - br $repeat|0 - unreachable - end - unreachable - end - local.get $1 - i32.load offset=4 - i32.load - local.get $2 - local.get $3 - local.get $4 - call $assembly/index/Body#offsetMomentum - drop - local.get $0 - i32.eqz - if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - i32.const 4 - call $~lib/runtime/ALLOCATE - local.set $6 - local.get $6 - i32.const 1 - call $~lib/runtime/doRegister - end - local.set $0 - end - local.get $0 - local.get $1 - i32.store - local.get $0 - ) - (func $assembly/index/Body#constructor (; 10 ;) (type $FUNCSIG$iiddddddd) (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) - local.get $0 - i32.eqz - if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - i32.const 56 - call $~lib/runtime/ALLOCATE - local.set $8 - local.get $8 - i32.const 3 - call $~lib/runtime/doRegister - end - local.set $0 - end - local.get $0 - local.get $1 - f64.store - local.get $0 - local.get $2 - f64.store offset=8 - local.get $0 - local.get $3 - f64.store offset=16 - local.get $0 - local.get $4 - f64.store offset=24 - local.get $0 - local.get $5 - f64.store offset=32 - local.get $0 - local.get $6 - f64.store offset=40 - local.get $0 - local.get $7 - f64.store offset=48 - local.get $0 - ) - (func $assembly/index/Sun (; 11 ;) (type $FUNCSIG$i) (result i32) - i32.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - f64.const 0 - global.get $assembly/index/SOLAR_MASS - call $assembly/index/Body#constructor - ) - (func $~lib/memory/memory.fill (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/memory/memory.fill (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -618,123 +405,148 @@ end end ) - (func $~lib/arraybuffer/ArrayBuffer#constructor (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $1 - global.get $~lib/runtime/MAX_BYTELENGTH + (func $~lib/runtime/assertUnregistered (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) + local.get $0 + global.get $~lib/memory/HEAP_BASE i32.gt_u + i32.eqz if i32.const 0 - i32.const 56 - i32.const 24 - i32.const 43 + i32.const 64 + i32.const 199 + i32.const 2 call $~lib/env/abort unreachable end - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - local.get $1 - local.set $2 - local.get $2 - call $~lib/runtime/doAllocate - end - local.set $3 - local.get $3 - i32.const 0 - local.get $1 - call $~lib/memory/memory.fill - block $~lib/runtime/REGISTER|inlined.0 (result i32) - local.get $3 - local.set $2 - local.get $2 - i32.const 4 - call $~lib/runtime/doRegister + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + i32.load + global.get $~lib/runtime/HEADER_MAGIC + i32.eq + i32.eqz + if + i32.const 0 + i32.const 64 + i32.const 200 + i32.const 2 + call $~lib/env/abort + unreachable end ) - (func $~lib/runtime/ArrayBufferView#constructor (; 14 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/runtime/doRegister (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + call $~lib/runtime/assertUnregistered + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + local.get $1 + i32.store + local.get $0 + ) + (func $~lib/fixedarray/FixedArray#constructor (; 7 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) (local $3 i32) (local $4 i32) local.get $1 global.get $~lib/runtime/MAX_BYTELENGTH - local.get $2 + i32.const 2 i32.shr_u i32.gt_u if i32.const 0 i32.const 16 - i32.const 227 - i32.const 57 + i32.const 12 + i32.const 60 call $~lib/env/abort unreachable end - i32.const 0 - local.get $1 - local.get $2 - i32.shl - local.tee $1 - call $~lib/arraybuffer/ArrayBuffer#constructor - local.set $3 - block (result i32) - local.get $0 - i32.eqz - if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - i32.const 12 - call $~lib/runtime/ALLOCATE - local.set $4 - local.get $4 - i32.const 5 - call $~lib/runtime/doRegister - end - local.set $0 - 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 - end - local.get $3 - i32.store - local.get $0 - local.get $3 - i32.store offset=4 - local.get $0 - local.get $1 - i32.store offset=8 - local.get $0 - ) - (func $~lib/array/Array#constructor (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - local.get $0 - if (result i32) - local.get $0 - else - i32.const 16 - call $~lib/runtime/ALLOCATE - local.set $2 - local.get $2 - i32.const 6 - call $~lib/runtime/doRegister - end local.get $1 i32.const 2 - call $~lib/runtime/ArrayBufferView#constructor - local.set $0 - local.get $0 + i32.shl + local.set $2 + block $~lib/runtime/ALLOCATE|inlined.0 (result i32) + local.get $2 + local.set $3 + local.get $3 + call $~lib/runtime/doAllocate + end + local.set $4 + local.get $4 i32.const 0 - i32.store offset=12 + local.get $2 + call $~lib/memory/memory.fill + block $~lib/runtime/REGISTER>|inlined.0 (result i32) + local.get $4 + local.set $3 + local.get $3 + i32.const 2 + call $~lib/runtime/doRegister + end + ) + (func $assembly/index/Body#constructor (; 8 ;) (type $FUNCSIG$iiddddddd) (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) + local.get $0 + i32.eqz + if + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.1 (result i32) + i32.const 56 + local.set $8 + local.get $8 + call $~lib/runtime/doAllocate + end + local.set $8 + local.get $8 + i32.const 3 + call $~lib/runtime/doRegister + end + local.set $0 + end local.get $0 local.get $1 - i32.store offset=12 + f64.store + local.get $0 + local.get $2 + f64.store offset=8 + local.get $0 + local.get $3 + f64.store offset=16 + local.get $0 + local.get $4 + f64.store offset=24 + local.get $0 + local.get $5 + f64.store offset=32 + local.get $0 + local.get $6 + f64.store offset=40 + local.get $0 + local.get $7 + f64.store offset=48 local.get $0 ) - (func $assembly/index/Jupiter (; 16 ;) (type $FUNCSIG$i) (result i32) + (func $assembly/index/Sun (; 9 ;) (type $FUNCSIG$i) (result i32) + i32.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + global.get $assembly/index/SOLAR_MASS + call $assembly/index/Body#constructor + ) + (func $~lib/fixedarray/FixedArray#__unchecked_set (; 10 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + local.get $0 + local.get $1 + i32.const 2 + i32.shl + i32.add + local.get $2 + i32.store + ) + (func $assembly/index/Jupiter (; 11 ;) (type $FUNCSIG$i) (result i32) i32.const 0 f64.const 4.841431442464721 f64.const -1.1603200440274284 @@ -753,7 +565,7 @@ f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/Saturn (; 17 ;) (type $FUNCSIG$i) (result i32) + (func $assembly/index/Saturn (; 12 ;) (type $FUNCSIG$i) (result i32) i32.const 0 f64.const 8.34336671824458 f64.const 4.124798564124305 @@ -772,7 +584,7 @@ f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/Uranus (; 18 ;) (type $FUNCSIG$i) (result i32) + (func $assembly/index/Uranus (; 13 ;) (type $FUNCSIG$i) (result i32) i32.const 0 f64.const 12.894369562139131 f64.const -15.111151401698631 @@ -791,7 +603,7 @@ f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/Neptune (; 19 ;) (type $FUNCSIG$i) (result i32) + (func $assembly/index/Neptune (; 14 ;) (type $FUNCSIG$i) (result i32) i32.const 0 f64.const 15.379697114850917 f64.const -25.919314609987964 @@ -810,39 +622,170 @@ f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/init (; 20 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - i32.const 0 - block (result i32) + (func $~lib/fixedarray/FixedArray#get:length (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + i32.load offset=4 + i32.const 2 + i32.shr_u + ) + (func $~lib/fixedarray/FixedArray#__unchecked_get (; 16 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load + ) + (func $assembly/index/Body#offsetMomentum (; 17 ;) (type $FUNCSIG$iiddd) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) + local.get $0 + local.get $1 + f64.neg + global.get $assembly/index/SOLAR_MASS + f64.div + f64.store offset=24 + local.get $0 + local.get $2 + f64.neg + global.get $assembly/index/SOLAR_MASS + f64.div + f64.store offset=32 + local.get $0 + local.get $3 + f64.neg + global.get $assembly/index/SOLAR_MASS + f64.div + f64.store offset=40 + local.get $0 + ) + (func $assembly/index/NBodySystem#constructor (; 18 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 f64) + (local $3 f64) + (local $4 f64) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 f64) + f64.const 0 + local.set $2 + f64.const 0 + local.set $3 + f64.const 0 + local.set $4 + local.get $1 + call $~lib/fixedarray/FixedArray#get:length + local.set $5 + block $break|0 i32.const 0 - i32.const 5 - call $~lib/array/Array#constructor - local.set $0 - local.get $0 - i32.load offset=4 - local.set $1 - local.get $1 - call $assembly/index/Sun - i32.store - local.get $1 - call $assembly/index/Jupiter - i32.store offset=4 - local.get $1 - call $assembly/index/Saturn - i32.store offset=8 - local.get $1 - call $assembly/index/Uranus - i32.store offset=12 - local.get $1 - call $assembly/index/Neptune - i32.store offset=16 - local.get $0 + local.set $6 + loop $repeat|0 + local.get $6 + local.get $5 + i32.lt_s + i32.eqz + br_if $break|0 + block + local.get $1 + local.get $6 + call $~lib/fixedarray/FixedArray#__unchecked_get + local.set $7 + local.get $7 + f64.load offset=48 + local.set $8 + local.get $2 + local.get $7 + f64.load offset=24 + local.get $8 + f64.mul + f64.add + local.set $2 + local.get $3 + local.get $7 + f64.load offset=32 + local.get $8 + f64.mul + f64.add + local.set $3 + local.get $4 + local.get $7 + f64.load offset=40 + local.get $8 + f64.mul + f64.add + local.set $4 + end + local.get $6 + i32.const 1 + i32.add + local.set $6 + br $repeat|0 + unreachable + end + unreachable end + local.get $1 + i32.const 0 + call $~lib/fixedarray/FixedArray#__unchecked_get + local.get $2 + local.get $3 + local.get $4 + call $assembly/index/Body#offsetMomentum + drop + local.get $0 + i32.eqz + if + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.2 (result i32) + i32.const 4 + local.set $6 + local.get $6 + call $~lib/runtime/doAllocate + end + local.set $6 + local.get $6 + i32.const 4 + call $~lib/runtime/doRegister + end + local.set $0 + end + local.get $0 + local.get $1 + i32.store + local.get $0 + ) + (func $assembly/index/init (; 19 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 0 + i32.const 5 + call $~lib/fixedarray/FixedArray#constructor + local.set $0 + local.get $0 + i32.const 0 + call $assembly/index/Sun + call $~lib/fixedarray/FixedArray#__unchecked_set + local.get $0 + i32.const 1 + call $assembly/index/Jupiter + call $~lib/fixedarray/FixedArray#__unchecked_set + local.get $0 + i32.const 2 + call $assembly/index/Saturn + call $~lib/fixedarray/FixedArray#__unchecked_set + local.get $0 + i32.const 3 + call $assembly/index/Uranus + call $~lib/fixedarray/FixedArray#__unchecked_set + local.get $0 + i32.const 4 + call $assembly/index/Neptune + call $~lib/fixedarray/FixedArray#__unchecked_set + i32.const 0 + local.get $0 call $assembly/index/NBodySystem#constructor global.set $assembly/index/system ) - (func $assembly/index/NBodySystem#advance (; 21 ;) (type $FUNCSIG$vid) (param $0 i32) (param $1 f64) + (func $assembly/index/NBodySystem#advance (; 20 ;) (type $FUNCSIG$vid) (param $0 i32) (param $1 f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -868,7 +811,7 @@ i32.load local.set $2 local.get $2 - call $~lib/array/Array#get:length + call $~lib/fixedarray/FixedArray#get:length local.set $3 block $break|0 i32.const 0 @@ -881,12 +824,8 @@ br_if $break|0 block local.get $2 - i32.load offset=4 local.get $4 - i32.const 2 - i32.shl - i32.add - i32.load + call $~lib/fixedarray/FixedArray#__unchecked_get local.set $5 local.get $5 f64.load @@ -922,12 +861,8 @@ br_if $break|1 block local.get $2 - i32.load offset=4 local.get $13 - i32.const 2 - i32.shl - i32.add - i32.load + call $~lib/fixedarray/FixedArray#__unchecked_get local.set $14 local.get $6 local.get $14 @@ -1074,7 +1009,7 @@ unreachable end ) - (func $assembly/index/NBodySystem#energy (; 22 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) + (func $assembly/index/NBodySystem#energy (; 21 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) (local $1 f64) (local $2 i32) (local $3 i32) @@ -1103,7 +1038,7 @@ i32.const 0 local.set $3 local.get $2 - call $~lib/array/Array#get:length + call $~lib/fixedarray/FixedArray#get:length local.set $4 end loop $repeat|0 @@ -1114,12 +1049,8 @@ br_if $break|0 block local.get $2 - i32.load offset=4 local.get $3 - i32.const 2 - i32.shl - i32.add - i32.load + call $~lib/fixedarray/FixedArray#__unchecked_get local.set $5 local.get $5 f64.load @@ -1173,12 +1104,8 @@ br_if $break|1 block local.get $2 - i32.load offset=4 local.get $13 - i32.const 2 - i32.shl - i32.add - i32.load + call $~lib/fixedarray/FixedArray#__unchecked_get local.set $14 local.get $6 local.get $14 @@ -1243,14 +1170,14 @@ end local.get $1 ) - (func $assembly/index/step (; 23 ;) (type $FUNCSIG$d) (result f64) + (func $assembly/index/step (; 22 ;) (type $FUNCSIG$d) (result f64) global.get $assembly/index/system f64.const 0.01 call $assembly/index/NBodySystem#advance global.get $assembly/index/system call $assembly/index/NBodySystem#energy ) - (func $assembly/index/bench (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $assembly/index/bench (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) block $break|0 i32.const 0 @@ -1274,28 +1201,24 @@ unreachable end ) - (func $assembly/index/getBody (; 25 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $assembly/index/getBody (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) global.get $assembly/index/system i32.load local.set $1 local.get $0 local.get $1 - call $~lib/array/Array#get:length + call $~lib/fixedarray/FixedArray#get:length i32.lt_u if (result i32) local.get $1 - i32.load offset=4 local.get $0 - i32.const 2 - i32.shl - i32.add - i32.load + call $~lib/fixedarray/FixedArray#__unchecked_get else i32.const 0 end ) - (func $start (; 26 ;) (type $FUNCSIG$v) + (func $start (; 25 ;) (type $FUNCSIG$v) global.get $~lib/memory/HEAP_BASE i32.const 7 i32.add @@ -1307,6 +1230,6 @@ global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset ) - (func $null (; 27 ;) (type $FUNCSIG$v) + (func $null (; 26 ;) (type $FUNCSIG$v) ) ) diff --git a/src/common.ts b/src/common.ts index 91d64faa..f53af582 100644 --- a/src/common.ts +++ b/src/common.ts @@ -175,6 +175,7 @@ export namespace LibrarySymbols { export const V128 = "V128"; export const String = "String"; export const Array = "Array"; + export const FixedArray = "FixedArray"; export const ArrayBufferView = "ArrayBufferView"; export const ArrayBuffer = "ArrayBuffer"; export const Math = "Math"; diff --git a/src/compiler.ts b/src/compiler.ts index 66a90417..452eb7f7 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -6445,17 +6445,16 @@ export class Compiler extends DiagnosticEmitter { case LiteralKind.ARRAY: { assert(!implicitNegate); let classType = contextualType.classReference; - if ( - classType && - classType.prototype == this.program.arrayPrototype - ) { - return this.compileArrayLiteral( - assert(classType.typeArguments)[0], - (expression).elementExpressions, - false, // TODO: isConst? - expression, - context - ); + if (classType) { + if (classType.prototype == this.program.arrayPrototype) { + return this.compileArrayLiteral( + assert(classType.typeArguments)[0], + (expression).elementExpressions, + false, // TODO: isConst? + expression, + context + ); + } } this.error( DiagnosticCode.Operation_not_supported, diff --git a/src/program.ts b/src/program.ts index 035b7678..c194322e 100644 --- a/src/program.ts +++ b/src/program.ts @@ -348,6 +348,8 @@ export class Program extends DiagnosticEmitter { arrayBufferInstance: Class | null = null; /** Array prototype reference. */ arrayPrototype: ClassPrototype | null = null; + /** Fixed array prototype reference. */ + fixedArrayPrototype: ClassPrototype | null = null; /** String instance reference. */ stringInstance: Class | null = null; /** Abort function reference, if present. */ @@ -798,6 +800,10 @@ export class Program extends DiagnosticEmitter { assert(element.kind == ElementKind.CLASS_PROTOTYPE); this.arrayPrototype = element; } + if (element = this.lookupGlobal(LibrarySymbols.FixedArray)) { + assert(element.kind == ElementKind.CLASS_PROTOTYPE); + this.fixedArrayPrototype = element; + } if (element = this.lookupGlobal(LibrarySymbols.abort)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); this.abortInstance = this.resolver.resolveFunction(element, null); diff --git a/std/assembly/array.ts b/std/assembly/array.ts index 554d1a15..ac91a75c 100644 --- a/std/assembly/array.ts +++ b/std/assembly/array.ts @@ -20,6 +20,7 @@ function ensureCapacity(array: ArrayBufferView, minCapacity: i32, alignLog2: u32 } export class Array extends ArrayBufferView { + [key: number]: T; // Implementing ArrayBufferView isn't strictly necessary here but is done to allow glue code // to work with typed and normal arrays interchangeably. Technically, normal arrays do not need @@ -65,7 +66,7 @@ export class Array extends ArrayBufferView { @operator("[]") // unchecked is built-in private __get(index: i32): T { - if (index >= this.dataLength >>> alignof()) throw new Error("Offset out of bounds"); + if (index >= this.dataLength >>> alignof()) throw new RangeError("Offset out of bounds"); return load(this.dataStart + (index << alignof())); } diff --git a/std/assembly/fixedarray.ts b/std/assembly/fixedarray.ts new file mode 100644 index 00000000..954c4e11 --- /dev/null +++ b/std/assembly/fixedarray.ts @@ -0,0 +1,48 @@ +import { ALLOCATE, REGISTER, MAX_BYTELENGTH, HEADER, HEADER_SIZE, LINK } from "./runtime"; + +// NOTE: DO NOT USE YET! + +// TODO: FixedArray with S being the static size, i.e. `new FixedArray`. +// Then hard-wire this special type to the compiler and do static length checks instead :) + +export class FixedArray { + [key: number]: T; + + constructor(length: i32) { + if (length > MAX_BYTELENGTH >>> alignof()) throw new RangeError("Invalid length"); + var outSize = length << alignof(); + var out = ALLOCATE(outSize); + memory.fill(out, 0, outSize); + return REGISTER>(out); + } + + get length(): i32 { + return changetype
(changetype(this) - HEADER_SIZE).payloadSize >>> alignof(); + } + + @operator("[]") private __get(index: i32): T { + if (index >= this.length) throw new RangeError("Offset out of bounds"); + return load(changetype(this) + (index << alignof())); + } + + @operator("[]=") private __set(index: i32, value: T): void { + if (index >= this.length) throw new RangeError("Offset out of bounds"); + store(changetype(this) + (index << alignof()), + isManaged() + ? LINK(value, this) + : value + ); + } + + @operator("{}") private __unchecked_get(index: i32): T { + return load(changetype(this) + (index << alignof())); + } + + @operator("{}=") private __unchecked_set(index: i32, value: T): void { + store(changetype(this) + (index << alignof()), + isManaged() + ? LINK(value, this) + : value + ); + } +} diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index 4b43f4ed..5b6ba56d 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -1205,6 +1205,13 @@ declare class Array { toString(): string; } +/** Class representing a fixed sequence of values of type `T`. */ +declare class FixedArray { + [key: number]: T; + readonly length: i32; + constructor(capacity?: i32); +} + /** Class representing a sequence of characters. */ declare class String { diff --git a/std/assembly/runtime.ts b/std/assembly/runtime.ts index b19f5adc..c0d78cf6 100644 --- a/std/assembly/runtime.ts +++ b/std/assembly/runtime.ts @@ -216,7 +216,6 @@ export const MAX_BYTELENGTH: i32 = MAX_SIZE_32 - HEADER_SIZE; /** Hard wired ArrayBufferView interface. */ export abstract class ArrayBufferView { - [key: number]: number; // @ts-ignore: decorator @unsafe diff --git a/std/assembly/typedarray.ts b/std/assembly/typedarray.ts index 93d7526b..a28f867c 100644 --- a/std/assembly/typedarray.ts +++ b/std/assembly/typedarray.ts @@ -2,6 +2,7 @@ import { ALLOCATE, REGISTER, ArrayBufferView } from "./runtime"; import { COMPARATOR, SORT as SORT_IMPL } from "./util/sort"; export class Int8Array extends ArrayBufferView { + [key: number]: i8; // @ts-ignore: decorator @lazy @@ -83,6 +84,7 @@ export class Int8Array extends ArrayBufferView { } export class Uint8Array extends ArrayBufferView { + [key: number]: u8; // @ts-ignore: decorator @lazy @@ -164,6 +166,7 @@ export class Uint8Array extends ArrayBufferView { } export class Uint8ClampedArray extends ArrayBufferView { + [key: number]: u8; // @ts-ignore: decorator @lazy @@ -245,6 +248,7 @@ export class Uint8ClampedArray extends ArrayBufferView { } export class Int16Array extends ArrayBufferView { + [key: number]: i16; // @ts-ignore: decorator @lazy @@ -326,6 +330,7 @@ export class Int16Array extends ArrayBufferView { } export class Uint16Array extends ArrayBufferView { + [key: number]: u16; // @ts-ignore: decorator @lazy @@ -407,6 +412,7 @@ export class Uint16Array extends ArrayBufferView { } export class Int32Array extends ArrayBufferView { + [key: number]: i32; // @ts-ignore: decorator @lazy @@ -488,6 +494,7 @@ export class Int32Array extends ArrayBufferView { } export class Uint32Array extends ArrayBufferView { + [key: number]: u32; // @ts-ignore: decorator @lazy @@ -569,6 +576,7 @@ export class Uint32Array extends ArrayBufferView { } export class Int64Array extends ArrayBufferView { + [key: number]: i64; // @ts-ignore: decorator @lazy @@ -650,6 +658,7 @@ export class Int64Array extends ArrayBufferView { } export class Uint64Array extends ArrayBufferView { + [key: number]: u64; // @ts-ignore: decorator @lazy @@ -731,6 +740,7 @@ export class Uint64Array extends ArrayBufferView { } export class Float32Array extends ArrayBufferView { + [key: number]: f32; // @ts-ignore: decorator @lazy @@ -812,6 +822,7 @@ export class Float32Array extends ArrayBufferView { } export class Float64Array extends ArrayBufferView { + [key: number]: f64; // @ts-ignore: decorator @lazy diff --git a/tests/compiler/nonNullAssertion.optimized.wat b/tests/compiler/nonNullAssertion.optimized.wat index 77e861e5..286ef2a7 100644 --- a/tests/compiler/nonNullAssertion.optimized.wat +++ b/tests/compiler/nonNullAssertion.optimized.wat @@ -40,7 +40,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/nonNullAssertion.untouched.wat b/tests/compiler/nonNullAssertion.untouched.wat index a30d61ce..05c15e4d 100644 --- a/tests/compiler/nonNullAssertion.untouched.wat +++ b/tests/compiler/nonNullAssertion.untouched.wat @@ -49,7 +49,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -77,7 +77,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array-access.optimized.wat b/tests/compiler/std/array-access.optimized.wat index 784af276..2cc5e90c 100644 --- a/tests/compiler/std/array-access.optimized.wat +++ b/tests/compiler/std/array-access.optimized.wat @@ -29,7 +29,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 27f875bb..5d8df860 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -34,7 +34,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -57,7 +57,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -87,7 +87,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -252,7 +252,7 @@ if i32.const 0 i32.const 16 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array-literal.optimized.wat b/tests/compiler/std/array-literal.optimized.wat index 77f6d07f..238ad2f4 100644 --- a/tests/compiler/std/array-literal.optimized.wat +++ b/tests/compiler/std/array-literal.optimized.wat @@ -39,7 +39,7 @@ if i32.const 0 i32.const 104 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -60,7 +60,7 @@ if i32.const 0 i32.const 104 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -436,7 +436,7 @@ if i32.const 0 i32.const 224 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array-literal.untouched.wat b/tests/compiler/std/array-literal.untouched.wat index 2b9c5083..94995810 100644 --- a/tests/compiler/std/array-literal.untouched.wat +++ b/tests/compiler/std/array-literal.untouched.wat @@ -53,7 +53,7 @@ if i32.const 0 i32.const 104 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -80,7 +80,7 @@ if i32.const 0 i32.const 104 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -545,7 +545,7 @@ if i32.const 0 i32.const 224 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 216f99a5..ade649cd 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -663,7 +663,7 @@ if i32.const 0 i32.const 16 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -1919,7 +1919,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2060,7 +2060,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2298,7 +2298,7 @@ if i32.const 0 i32.const 208 - i32.const 199 + i32.const 200 i32.const 20 call $~lib/env/abort unreachable @@ -2565,7 +2565,7 @@ if i32.const 0 i32.const 208 - i32.const 260 + i32.const 261 i32.const 20 call $~lib/env/abort unreachable @@ -3345,7 +3345,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -4096,7 +4096,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -4592,7 +4592,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -4690,7 +4690,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -5111,7 +5111,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -5436,7 +5436,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 9b64bcf3..dd435298 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -746,7 +746,7 @@ if i32.const 0 i32.const 16 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -2493,7 +2493,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2661,7 +2661,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2939,7 +2939,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2964,7 +2964,7 @@ if i32.const 0 i32.const 208 - i32.const 199 + i32.const 200 i32.const 20 call $~lib/env/abort unreachable @@ -3323,7 +3323,7 @@ if i32.const 0 i32.const 208 - i32.const 260 + i32.const 261 i32.const 20 call $~lib/env/abort unreachable @@ -4257,7 +4257,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -5299,7 +5299,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -5909,7 +5909,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -6048,7 +6048,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -6544,7 +6544,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -7048,7 +7048,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -7447,7 +7447,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -7623,7 +7623,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -7987,7 +7987,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -8060,7 +8060,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -8244,7 +8244,7 @@ if i32.const 0 i32.const 208 - i32.const 373 + i32.const 374 i32.const 4 call $~lib/env/abort unreachable @@ -8321,7 +8321,7 @@ if i32.const 0 i32.const 208 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/arraybuffer.optimized.wat b/tests/compiler/std/arraybuffer.optimized.wat index f9fd20d0..ca63c557 100644 --- a/tests/compiler/std/arraybuffer.optimized.wat +++ b/tests/compiler/std/arraybuffer.optimized.wat @@ -1552,7 +1552,7 @@ if i32.const 0 i32.const 64 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/arraybuffer.untouched.wat b/tests/compiler/std/arraybuffer.untouched.wat index d1855629..ff9b3ed3 100644 --- a/tests/compiler/std/arraybuffer.untouched.wat +++ b/tests/compiler/std/arraybuffer.untouched.wat @@ -2048,7 +2048,7 @@ if i32.const 0 i32.const 64 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/dataview.optimized.wat b/tests/compiler/std/dataview.optimized.wat index 6c1fe718..892b29ba 100644 --- a/tests/compiler/std/dataview.optimized.wat +++ b/tests/compiler/std/dataview.optimized.wat @@ -240,7 +240,7 @@ if i32.const 0 i32.const 104 - i32.const 111 + i32.const 113 i32.const 44 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/dataview.untouched.wat b/tests/compiler/std/dataview.untouched.wat index d66ae251..8338c1e3 100644 --- a/tests/compiler/std/dataview.untouched.wat +++ b/tests/compiler/std/dataview.untouched.wat @@ -489,7 +489,7 @@ if i32.const 0 i32.const 16 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -571,7 +571,7 @@ if i32.const 0 i32.const 104 - i32.const 111 + i32.const 113 i32.const 44 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/static-array.optimized.wat b/tests/compiler/std/static-array.optimized.wat index 0e885be7..f454ea81 100644 --- a/tests/compiler/std/static-array.optimized.wat +++ b/tests/compiler/std/static-array.optimized.wat @@ -36,7 +36,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -387,7 +387,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -428,7 +428,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -469,7 +469,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index 83797ee8..ad621033 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -52,7 +52,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -1965,7 +1965,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2019,7 +2019,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -2073,7 +2073,7 @@ if i32.const 0 i32.const 240 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 0d53a666..8df4d63e 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -3052,7 +3052,7 @@ if i32.const 0 i32.const 96 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -3504,7 +3504,7 @@ if i32.const 0 i32.const 1440 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 888a29ff..db33c25e 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -3777,7 +3777,7 @@ if i32.const 0 i32.const 96 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -4357,7 +4357,7 @@ if i32.const 0 i32.const 1440 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 2248e852..5eee3c92 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -465,7 +465,7 @@ if i32.const 0 i32.const 64 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -1078,7 +1078,7 @@ if i32.const 0 i32.const 152 - i32.const 435 + i32.const 441 i32.const 63 call $~lib/env/abort unreachable @@ -1102,7 +1102,7 @@ if i32.const 0 i32.const 152 - i32.const 429 + i32.const 435 i32.const 63 call $~lib/env/abort unreachable @@ -1212,7 +1212,7 @@ if i32.const 0 i32.const 152 - i32.const 840 + i32.const 851 i32.const 63 call $~lib/env/abort unreachable @@ -1750,7 +1750,7 @@ if i32.const 0 i32.const 152 - i32.const 834 + i32.const 845 i32.const 63 call $~lib/env/abort unreachable @@ -1771,7 +1771,7 @@ if i32.const 0 i32.const 152 - i32.const 192 + i32.const 195 i32.const 44 call $~lib/env/abort unreachable @@ -1803,7 +1803,7 @@ if i32.const 0 i32.const 152 - i32.const 186 + i32.const 189 i32.const 44 call $~lib/env/abort unreachable @@ -1822,7 +1822,7 @@ if i32.const 0 i32.const 152 - i32.const 30 + i32.const 31 i32.const 44 call $~lib/env/abort unreachable @@ -3035,7 +3035,7 @@ if i32.const 0 i32.const 152 - i32.const 24 + i32.const 25 i32.const 44 call $~lib/env/abort unreachable @@ -3054,7 +3054,7 @@ if i32.const 0 i32.const 216 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -3274,7 +3274,7 @@ if i32.const 0 i32.const 216 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -3414,7 +3414,7 @@ if i32.const 0 i32.const 152 - i32.const 111 + i32.const 113 i32.const 44 call $~lib/env/abort unreachable @@ -3537,7 +3537,7 @@ if i32.const 0 i32.const 152 - i32.const 273 + i32.const 277 i32.const 63 call $~lib/env/abort unreachable @@ -3633,7 +3633,7 @@ if i32.const 0 i32.const 152 - i32.const 354 + i32.const 359 i32.const 63 call $~lib/env/abort unreachable @@ -3800,7 +3800,7 @@ if i32.const 0 i32.const 152 - i32.const 516 + i32.const 523 i32.const 63 call $~lib/env/abort unreachable @@ -3854,7 +3854,7 @@ if i32.const 0 i32.const 152 - i32.const 597 + i32.const 605 i32.const 63 call $~lib/env/abort unreachable @@ -3954,7 +3954,7 @@ if i32.const 0 i32.const 152 - i32.const 678 + i32.const 687 i32.const 63 call $~lib/env/abort unreachable @@ -4008,7 +4008,7 @@ if i32.const 0 i32.const 152 - i32.const 759 + i32.const 769 i32.const 63 call $~lib/env/abort unreachable @@ -4998,7 +4998,7 @@ if i32.const 0 i32.const 152 - i32.const 105 + i32.const 107 i32.const 44 call $~lib/env/abort unreachable @@ -5236,7 +5236,7 @@ if i32.const 0 i32.const 152 - i32.const 267 + i32.const 271 i32.const 63 call $~lib/env/abort unreachable @@ -5372,7 +5372,7 @@ if i32.const 0 i32.const 152 - i32.const 348 + i32.const 353 i32.const 63 call $~lib/env/abort unreachable @@ -5621,7 +5621,7 @@ if i32.const 0 i32.const 152 - i32.const 510 + i32.const 517 i32.const 63 call $~lib/env/abort unreachable @@ -5762,7 +5762,7 @@ if i32.const 0 i32.const 152 - i32.const 591 + i32.const 599 i32.const 63 call $~lib/env/abort unreachable @@ -5898,7 +5898,7 @@ if i32.const 0 i32.const 152 - i32.const 672 + i32.const 681 i32.const 63 call $~lib/env/abort unreachable @@ -6039,7 +6039,7 @@ if i32.const 0 i32.const 152 - i32.const 753 + i32.const 763 i32.const 63 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 5e62bd2a..89f7791d 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -561,7 +561,7 @@ if i32.const 0 i32.const 64 - i32.const 234 + i32.const 233 i32.const 57 call $~lib/env/abort unreachable @@ -1454,7 +1454,7 @@ if i32.const 0 i32.const 152 - i32.const 435 + i32.const 441 i32.const 63 call $~lib/env/abort unreachable @@ -1478,7 +1478,7 @@ if i32.const 0 i32.const 152 - i32.const 429 + i32.const 435 i32.const 63 call $~lib/env/abort unreachable @@ -1615,7 +1615,7 @@ if i32.const 0 i32.const 152 - i32.const 840 + i32.const 851 i32.const 63 call $~lib/env/abort unreachable @@ -2290,7 +2290,7 @@ if i32.const 0 i32.const 152 - i32.const 834 + i32.const 845 i32.const 63 call $~lib/env/abort unreachable @@ -2311,7 +2311,7 @@ if i32.const 0 i32.const 152 - i32.const 192 + i32.const 195 i32.const 44 call $~lib/env/abort unreachable @@ -2343,7 +2343,7 @@ if i32.const 0 i32.const 152 - i32.const 186 + i32.const 189 i32.const 44 call $~lib/env/abort unreachable @@ -2362,7 +2362,7 @@ if i32.const 0 i32.const 152 - i32.const 30 + i32.const 31 i32.const 44 call $~lib/env/abort unreachable @@ -3947,7 +3947,7 @@ if i32.const 0 i32.const 152 - i32.const 24 + i32.const 25 i32.const 44 call $~lib/env/abort unreachable @@ -3968,7 +3968,7 @@ if i32.const 0 i32.const 216 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -4255,7 +4255,7 @@ if i32.const 0 i32.const 216 - i32.const 68 + i32.const 69 i32.const 61 call $~lib/env/abort unreachable @@ -4427,7 +4427,7 @@ if i32.const 0 i32.const 152 - i32.const 111 + i32.const 113 i32.const 44 call $~lib/env/abort unreachable @@ -4651,7 +4651,7 @@ if i32.const 0 i32.const 152 - i32.const 273 + i32.const 277 i32.const 63 call $~lib/env/abort unreachable @@ -4778,7 +4778,7 @@ if i32.const 0 i32.const 152 - i32.const 354 + i32.const 359 i32.const 63 call $~lib/env/abort unreachable @@ -5002,7 +5002,7 @@ if i32.const 0 i32.const 152 - i32.const 516 + i32.const 523 i32.const 63 call $~lib/env/abort unreachable @@ -5125,7 +5125,7 @@ if i32.const 0 i32.const 152 - i32.const 597 + i32.const 605 i32.const 63 call $~lib/env/abort unreachable @@ -5248,7 +5248,7 @@ if i32.const 0 i32.const 152 - i32.const 678 + i32.const 687 i32.const 63 call $~lib/env/abort unreachable @@ -5371,7 +5371,7 @@ if i32.const 0 i32.const 152 - i32.const 759 + i32.const 769 i32.const 63 call $~lib/env/abort unreachable @@ -6867,7 +6867,7 @@ if i32.const 0 i32.const 152 - i32.const 105 + i32.const 107 i32.const 44 call $~lib/env/abort unreachable @@ -7160,7 +7160,7 @@ if i32.const 0 i32.const 152 - i32.const 267 + i32.const 271 i32.const 63 call $~lib/env/abort unreachable @@ -7319,7 +7319,7 @@ if i32.const 0 i32.const 152 - i32.const 348 + i32.const 353 i32.const 63 call $~lib/env/abort unreachable @@ -7614,7 +7614,7 @@ if i32.const 0 i32.const 152 - i32.const 510 + i32.const 517 i32.const 63 call $~lib/env/abort unreachable @@ -7773,7 +7773,7 @@ if i32.const 0 i32.const 152 - i32.const 591 + i32.const 599 i32.const 63 call $~lib/env/abort unreachable @@ -7932,7 +7932,7 @@ if i32.const 0 i32.const 152 - i32.const 672 + i32.const 681 i32.const 63 call $~lib/env/abort unreachable @@ -8091,7 +8091,7 @@ if i32.const 0 i32.const 152 - i32.const 753 + i32.const 763 i32.const 63 call $~lib/env/abort unreachable