diff --git a/.travis.yml b/.travis.yml index 5380c6d469..061c816e56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ jobs: cd $TRAVIS_BUILD_DIR/tests/allocators/buddy && npm run build && cd .. && npm test buddy && cd $TRAVIS_BUILD_DIR/tests/allocators/tlsf && npm run build && cd .. && npm test tlsf; fi - env: Runs the tests on node.js LTS + env: Runs the tests on node.js LTS, also tests allocators - node_js: node script: - npm run all diff --git a/cli/asc.js b/cli/asc.js index 09f7afb577..0bbe4abf7a 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -419,7 +419,6 @@ exports.main = function main(argv, options, callback) { // Begin compilation const compilerOptions = assemblyscript.createOptions(); assemblyscript.setTarget(compilerOptions, 0); - assemblyscript.setNoTreeShaking(compilerOptions, args.noTreeShaking); assemblyscript.setNoAssert(compilerOptions, args.noAssert); assemblyscript.setImportMemory(compilerOptions, args.importMemory); assemblyscript.setImportTable(compilerOptions, args.importTable); diff --git a/cli/asc.json b/cli/asc.json index 004cfb414c..adbddf51aa 100644 --- a/cli/asc.json +++ b/cli/asc.json @@ -86,11 +86,6 @@ "type": "b", "default": false }, - "noTreeShaking": { - "description": "Disables compiler-level tree-shaking, compiling everything.", - "type": "b", - "default": false - }, "noAssert": { "description": "Replaces assertions with just their value without trapping.", "type": "b", diff --git a/examples/game-of-life/build/optimized.d.ts b/examples/game-of-life/build/optimized.d.ts index 2fbedcd9f5..62152f45be 100644 --- a/examples/game-of-life/build/optimized.d.ts +++ b/examples/game-of-life/build/optimized.d.ts @@ -8,8 +8,17 @@ declare module ASModule { type f32 = number; type f64 = number; type bool = any; + namespace JSMath { + function random(): f64; + } + var w: i32; + var h: i32; + var s: i32; function init(width: i32, height: i32): void; function step(): void; function fill(x: u32, y: u32, p: f64): void; + var BGR_ALIVE: u32; + var BGR_DEAD: u32; + var BIT_ROT: u32; } export default ASModule; diff --git a/examples/game-of-life/build/optimized.wasm b/examples/game-of-life/build/optimized.wasm index fe90350bf4..7178bc54c3 100644 Binary files a/examples/game-of-life/build/optimized.wasm and b/examples/game-of-life/build/optimized.wasm differ diff --git a/examples/game-of-life/build/optimized.wat b/examples/game-of-life/build/optimized.wat index a6711cb601..a93019af7c 100644 --- a/examples/game-of-life/build/optimized.wat +++ b/examples/game-of-life/build/optimized.wat @@ -1,14 +1,14 @@ (module - (type $iiv (func (param i32 i32))) + (type $ii_ (func (param i32 i32))) (type $F (func (result f64))) - (type $v (func)) - (type $iiFv (func (param i32 i32 f64))) + (type $_ (func)) + (type $iiF_ (func (param i32 i32 f64))) (import "env" "memory" (memory $0 0)) - (import "config" "BGR_ALIVE" (global $assembly/config/BGR_ALIVE i32)) (import "config" "BGR_DEAD" (global $assembly/config/BGR_DEAD i32)) + (import "config" "BGR_ALIVE" (global $assembly/config/BGR_ALIVE i32)) (import "config" "BIT_ROT" (global $assembly/config/BIT_ROT i32)) (import "Math" "random" (func $~lib/bindings/Math/random (result f64))) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/index/w (mut i32) (i32.const 0)) (global $assembly/index/h (mut i32) (i32.const 0)) @@ -18,72 +18,72 @@ (export "init" (func $assembly/index/init)) (export "step" (func $assembly/index/step)) (export "fill" (func $assembly/index/fill)) - (func $assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/index/init (; 1 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) - get_local $0 - set_global $assembly/index/w - get_local $1 - set_global $assembly/index/h - get_local $0 - get_local $1 + local.get $0 + global.set $assembly/index/w + local.get $1 + global.set $assembly/index/h + local.get $0 + local.get $1 i32.mul - set_global $assembly/index/s + global.set $assembly/index/s i32.const 0 - set_local $0 + local.set $0 loop $repeat|0 block $break|0 - get_local $0 - get_global $assembly/index/h + local.get $0 + global.get $assembly/index/h i32.ge_s br_if $break|0 i32.const 0 - set_local $1 + local.set $1 loop $repeat|1 block $break|1 - get_local $1 - get_global $assembly/index/w + local.get $1 + global.get $assembly/index/w i32.ge_s br_if $break|1 call $~lib/bindings/Math/random f64.const 0.1 f64.gt if (result i32) - get_global $assembly/config/BGR_DEAD + global.get $assembly/config/BGR_DEAD i32.const 16777215 i32.and else - get_global $assembly/config/BGR_ALIVE + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or end - set_local $2 - get_global $assembly/index/s - get_global $assembly/index/w - get_local $0 + local.set $2 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $0 i32.mul i32.add - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl - get_local $2 + local.get $2 i32.store - get_local $1 + local.get $1 i32.const 1 i32.add - set_local $1 + local.set $1 br $repeat|1 end end - get_local $0 + local.get $0 i32.const 1 i32.add - set_local $0 + local.set $0 br $repeat|0 end end ) - (func $assembly/index/step (; 2 ;) (type $v) + (func $assembly/index/step (; 2 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -92,53 +92,53 @@ (local $5 i32) (local $6 i32) (local $7 i32) - get_global $assembly/index/h + global.get $assembly/index/h i32.const 1 i32.sub - set_local $6 - get_global $assembly/index/w + local.set $6 + global.get $assembly/index/w i32.const 1 i32.sub - set_local $7 + local.set $7 loop $repeat|0 block $break|0 - get_local $0 - get_global $assembly/index/h + local.get $0 + global.get $assembly/index/h i32.ge_s br_if $break|0 - get_local $0 + local.get $0 i32.const 1 i32.sub - get_local $6 - get_local $0 + local.get $6 + local.get $0 select - set_local $4 + local.set $4 i32.const 0 - get_local $0 + local.get $0 i32.const 1 i32.add - get_local $0 - get_local $6 + local.get $0 + local.get $6 i32.eq select - set_local $5 + local.set $5 i32.const 0 - set_local $1 + local.set $1 loop $repeat|1 block $break|1 - get_local $1 - get_global $assembly/index/w + local.get $1 + global.get $assembly/index/w i32.ge_s br_if $break|1 - get_local $1 + local.get $1 i32.const 1 i32.sub - get_local $7 - get_local $1 + local.get $7 + local.get $1 select - tee_local $2 - get_global $assembly/index/w - get_local $4 + local.tee $2 + global.get $assembly/index/w + local.get $4 i32.mul i32.add i32.const 2 @@ -146,10 +146,10 @@ i32.load i32.const 1 i32.and - get_global $assembly/index/w - get_local $4 + global.get $assembly/index/w + local.get $4 i32.mul - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl @@ -158,16 +158,16 @@ i32.and i32.add i32.const 0 - get_local $1 + local.get $1 i32.const 1 i32.add - get_local $1 - get_local $7 + local.get $1 + local.get $7 i32.eq select - tee_local $3 - get_global $assembly/index/w - get_local $4 + local.tee $3 + global.get $assembly/index/w + local.get $4 i32.mul i32.add i32.const 2 @@ -176,10 +176,10 @@ i32.const 1 i32.and i32.add - get_global $assembly/index/w - get_local $0 + global.get $assembly/index/w + local.get $0 i32.mul - get_local $2 + local.get $2 i32.add i32.const 2 i32.shl @@ -187,10 +187,10 @@ i32.const 1 i32.and i32.add - get_global $assembly/index/w - get_local $0 + global.get $assembly/index/w + local.get $0 i32.mul - get_local $3 + local.get $3 i32.add i32.const 2 i32.shl @@ -198,10 +198,10 @@ i32.const 1 i32.and i32.add - get_global $assembly/index/w - get_local $5 + global.get $assembly/index/w + local.get $5 i32.mul - get_local $2 + local.get $2 i32.add i32.const 2 i32.shl @@ -209,10 +209,10 @@ i32.const 1 i32.and i32.add - get_global $assembly/index/w - get_local $5 + global.get $assembly/index/w + local.get $5 i32.mul - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl @@ -220,10 +220,10 @@ i32.const 1 i32.and i32.add - get_global $assembly/index/w - get_local $5 + global.get $assembly/index/w + local.get $5 i32.mul - get_local $3 + local.get $3 i32.add i32.const 2 i32.shl @@ -231,45 +231,45 @@ i32.const 1 i32.and i32.add - set_local $2 - get_global $assembly/index/w - get_local $0 + local.set $2 + global.get $assembly/index/w + local.get $0 i32.mul - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl i32.load - tee_local $3 + local.tee $3 i32.const 1 i32.and if - get_local $2 + local.get $2 i32.const 14 i32.and i32.const 2 i32.eq if - get_global $assembly/index/s - get_global $assembly/index/w - get_local $0 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $0 i32.mul i32.add - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl - get_local $3 + local.get $3 i32.const 16777215 i32.and - get_local $3 + local.get $3 i32.const 24 i32.shr_u - get_global $assembly/config/BIT_ROT + global.get $assembly/config/BIT_ROT i32.sub - tee_local $2 + local.tee $2 i32.const 0 - get_local $2 + local.get $2 i32.const 0 i32.gt_s select @@ -278,59 +278,59 @@ i32.or i32.store else - get_global $assembly/index/s - get_global $assembly/index/w - get_local $0 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $0 i32.mul i32.add - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl - get_global $assembly/config/BGR_DEAD + global.get $assembly/config/BGR_DEAD i32.const -16777216 i32.or i32.store end else - get_local $2 + local.get $2 i32.const 3 i32.eq if - get_global $assembly/index/s - get_global $assembly/index/w - get_local $0 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $0 i32.mul i32.add - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl - get_global $assembly/config/BGR_ALIVE + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or i32.store else - get_global $assembly/index/s - get_global $assembly/index/w - get_local $0 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $0 i32.mul i32.add - get_local $1 + local.get $1 i32.add i32.const 2 i32.shl - get_local $3 + local.get $3 i32.const 16777215 i32.and - get_local $3 + local.get $3 i32.const 24 i32.shr_u - get_global $assembly/config/BIT_ROT + global.get $assembly/config/BIT_ROT i32.sub - tee_local $2 + local.tee $2 i32.const 0 - get_local $2 + local.get $2 i32.const 0 i32.gt_s select @@ -340,89 +340,89 @@ i32.store end end - get_local $1 + local.get $1 i32.const 1 i32.add - set_local $1 + local.set $1 br $repeat|1 end end - get_local $0 + local.get $0 i32.const 1 i32.add - set_local $0 + local.set $0 br $repeat|0 end end ) - (func $assembly/index/fill (; 3 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64) + (func $assembly/index/fill (; 3 ;) (type $iiF_) (param $0 i32) (param $1 i32) (param $2 f64) (local $3 i32) loop $repeat|0 block $break|0 - get_local $3 - get_global $assembly/index/w + local.get $3 + global.get $assembly/index/w i32.ge_s br_if $break|0 call $~lib/bindings/Math/random - get_local $2 + local.get $2 f64.lt if - get_global $assembly/index/s - get_global $assembly/index/w - get_local $1 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $1 i32.mul i32.add - get_local $3 + local.get $3 i32.add i32.const 2 i32.shl - get_global $assembly/config/BGR_ALIVE + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or i32.store end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|0 end end i32.const 0 - set_local $3 + local.set $3 loop $repeat|1 block $break|1 - get_local $3 - get_global $assembly/index/h + local.get $3 + global.get $assembly/index/h i32.ge_s br_if $break|1 call $~lib/bindings/Math/random - get_local $2 + local.get $2 f64.lt if - get_global $assembly/index/s - get_global $assembly/index/w - get_local $3 + global.get $assembly/index/s + global.get $assembly/index/w + local.get $3 i32.mul i32.add - get_local $0 + local.get $0 i32.add i32.const 2 i32.shl - get_global $assembly/config/BGR_ALIVE + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or i32.store end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|1 end end ) - (func $null (; 4 ;) (type $v) + (func $null (; 4 ;) (type $_) nop ) ) diff --git a/examples/game-of-life/build/untouched.wat b/examples/game-of-life/build/untouched.wat index 9487f22076..2e3cbdb454 100644 --- a/examples/game-of-life/build/untouched.wat +++ b/examples/game-of-life/build/untouched.wat @@ -1,100 +1,106 @@ (module - (type $iiv (func (param i32 i32))) + (type $ii_ (func (param i32 i32))) (type $F (func (result f64))) - (type $v (func)) - (type $iiFv (func (param i32 i32 f64))) + (type $_ (func)) + (type $iiF_ (func (param i32 i32 f64))) (import "env" "memory" (memory $0 0)) - (import "config" "BGR_ALIVE" (global $assembly/config/BGR_ALIVE i32)) (import "config" "BGR_DEAD" (global $assembly/config/BGR_DEAD i32)) + (import "config" "BGR_ALIVE" (global $assembly/config/BGR_ALIVE i32)) (import "config" "BIT_ROT" (global $assembly/config/BIT_ROT i32)) (import "Math" "random" (func $~lib/bindings/Math/random (result f64))) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/index/w (mut i32) (i32.const 0)) (global $assembly/index/h (mut i32) (i32.const 0)) (global $assembly/index/s (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "init" (func $assembly/index/init)) (export "step" (func $assembly/index/step)) (export "fill" (func $assembly/index/fill)) - (func $assembly/index/init (; 1 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/index/init (; 1 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) - get_local $0 - set_global $assembly/index/w - get_local $1 - set_global $assembly/index/h - get_local $0 - get_local $1 + (local $5 i32) + (local $6 i32) + local.get $0 + global.set $assembly/index/w + local.get $1 + global.set $assembly/index/h + local.get $0 + local.get $1 i32.mul - set_global $assembly/index/s + global.set $assembly/index/s block $break|0 i32.const 0 - set_local $2 + local.set $2 loop $repeat|0 - get_local $2 - get_global $assembly/index/h + local.get $2 + global.get $assembly/index/h i32.lt_s i32.eqz br_if $break|0 block $break|1 i32.const 0 - set_local $3 + local.set $3 loop $repeat|1 - get_local $3 - get_global $assembly/index/w + local.get $3 + global.get $assembly/index/w i32.lt_s i32.eqz br_if $break|1 - block + block $assembly/index/set|inlined.0 + local.get $3 + local.set $4 + local.get $2 + local.set $5 call $~lib/bindings/Math/random f64.const 0.1 f64.gt if (result i32) - get_global $assembly/config/BGR_DEAD + global.get $assembly/config/BGR_DEAD i32.const 16777215 i32.and else - get_global $assembly/config/BGR_ALIVE + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or end - set_local $4 - get_global $assembly/index/s - get_local $2 - get_global $assembly/index/w + local.set $6 + global.get $assembly/index/s + local.get $5 + global.get $assembly/index/w i32.mul i32.add - get_local $3 + local.get $4 i32.add i32.const 2 i32.shl - get_local $4 + local.get $6 i32.store end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|1 unreachable end unreachable end - get_local $2 + local.get $2 i32.const 1 i32.add - set_local $2 + local.set $2 br $repeat|0 unreachable end unreachable end ) - (func $assembly/index/step (; 2 ;) (type $v) + (func $assembly/index/step (; 2 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -107,83 +113,92 @@ (local $9 i32) (local $10 i32) (local $11 i32) - get_global $assembly/index/h + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + global.get $assembly/index/h i32.const 1 i32.sub - set_local $0 - get_global $assembly/index/w + local.set $0 + global.get $assembly/index/w i32.const 1 i32.sub - set_local $1 + local.set $1 block $break|0 i32.const 0 - set_local $2 + local.set $2 loop $repeat|0 - get_local $2 - get_global $assembly/index/h + local.get $2 + global.get $assembly/index/h i32.lt_s i32.eqz br_if $break|0 block - get_local $2 + local.get $2 i32.const 0 i32.eq if (result i32) - get_local $0 + local.get $0 else - get_local $2 + local.get $2 i32.const 1 i32.sub end - set_local $3 - get_local $2 - get_local $0 + local.set $3 + local.get $2 + local.get $0 i32.eq if (result i32) i32.const 0 else - get_local $2 + local.get $2 i32.const 1 i32.add end - set_local $4 + local.set $4 block $break|1 i32.const 0 - set_local $5 + local.set $5 loop $repeat|1 - get_local $5 - get_global $assembly/index/w + local.get $5 + global.get $assembly/index/w i32.lt_s i32.eqz br_if $break|1 block - get_local $5 + local.get $5 i32.const 0 i32.eq if (result i32) - get_local $1 + local.get $1 else - get_local $5 + local.get $5 i32.const 1 i32.sub end - set_local $6 - get_local $5 - get_local $1 + local.set $6 + local.get $5 + local.get $1 i32.eq if (result i32) i32.const 0 else - get_local $5 + local.get $5 i32.const 1 i32.add end - set_local $7 + local.set $7 block $assembly/index/get|inlined.0 (result i32) - get_local $3 - get_global $assembly/index/w + local.get $6 + local.set $8 + local.get $3 + local.set $9 + local.get $9 + global.get $assembly/index/w i32.mul - get_local $6 + local.get $8 i32.add i32.const 2 i32.shl @@ -192,10 +207,14 @@ i32.const 1 i32.and block $assembly/index/get|inlined.1 (result i32) - get_local $3 - get_global $assembly/index/w + local.get $5 + local.set $9 + local.get $3 + local.set $8 + local.get $8 + global.get $assembly/index/w i32.mul - get_local $5 + local.get $9 i32.add i32.const 2 i32.shl @@ -205,10 +224,14 @@ i32.and i32.add block $assembly/index/get|inlined.2 (result i32) - get_local $3 - get_global $assembly/index/w + local.get $7 + local.set $8 + local.get $3 + local.set $9 + local.get $9 + global.get $assembly/index/w i32.mul - get_local $7 + local.get $8 i32.add i32.const 2 i32.shl @@ -218,10 +241,14 @@ i32.and i32.add block $assembly/index/get|inlined.3 (result i32) - get_local $2 - get_global $assembly/index/w + local.get $6 + local.set $9 + local.get $2 + local.set $8 + local.get $8 + global.get $assembly/index/w i32.mul - get_local $6 + local.get $9 i32.add i32.const 2 i32.shl @@ -231,10 +258,14 @@ i32.and i32.add block $assembly/index/get|inlined.4 (result i32) - get_local $2 - get_global $assembly/index/w + local.get $7 + local.set $8 + local.get $2 + local.set $9 + local.get $9 + global.get $assembly/index/w i32.mul - get_local $7 + local.get $8 i32.add i32.const 2 i32.shl @@ -244,10 +275,14 @@ i32.and i32.add block $assembly/index/get|inlined.5 (result i32) - get_local $4 - get_global $assembly/index/w + local.get $6 + local.set $9 + local.get $4 + local.set $8 + local.get $8 + global.get $assembly/index/w i32.mul - get_local $6 + local.get $9 i32.add i32.const 2 i32.shl @@ -257,10 +292,14 @@ i32.and i32.add block $assembly/index/get|inlined.6 (result i32) - get_local $4 - get_global $assembly/index/w + local.get $5 + local.set $8 + local.get $4 + local.set $9 + local.get $9 + global.get $assembly/index/w i32.mul - get_local $5 + local.get $8 i32.add i32.const 2 i32.shl @@ -270,10 +309,14 @@ i32.and i32.add block $assembly/index/get|inlined.7 (result i32) - get_local $4 - get_global $assembly/index/w + local.get $7 + local.set $9 + local.get $4 + local.set $8 + local.get $8 + global.get $assembly/index/w i32.mul - get_local $7 + local.get $9 i32.add i32.const 2 i32.shl @@ -282,193 +325,231 @@ i32.const 1 i32.and i32.add - set_local $8 + local.set $8 block $assembly/index/get|inlined.8 (result i32) - get_local $2 - get_global $assembly/index/w + local.get $5 + local.set $9 + local.get $2 + local.set $10 + local.get $10 + global.get $assembly/index/w i32.mul - get_local $5 + local.get $9 i32.add i32.const 2 i32.shl i32.load end - set_local $9 - get_local $9 + local.set $10 + local.get $10 i32.const 1 i32.and if - get_local $8 + local.get $8 i32.const 14 i32.and i32.const 2 i32.eq if - get_local $9 + local.get $5 + local.set $9 + local.get $2 + local.set $11 + local.get $10 + local.set $12 + local.get $12 i32.const 24 i32.shr_u - get_global $assembly/config/BIT_ROT + global.get $assembly/config/BIT_ROT i32.sub - tee_local $10 + local.tee $13 i32.const 0 - tee_local $11 - get_local $10 - get_local $11 + local.tee $14 + local.get $13 + local.get $14 i32.gt_s select - set_local $10 - block - get_local $10 + local.set $13 + block $assembly/index/set|inlined.1 + local.get $9 + local.set $14 + local.get $11 + local.set $15 + local.get $13 i32.const 24 i32.shl - get_local $9 + local.get $12 i32.const 16777215 i32.and i32.or - set_local $11 - get_global $assembly/index/s - get_local $2 - get_global $assembly/index/w + local.set $16 + global.get $assembly/index/s + local.get $15 + global.get $assembly/index/w i32.mul i32.add - get_local $5 + local.get $14 i32.add i32.const 2 i32.shl - get_local $11 + local.get $16 i32.store end else - get_global $assembly/config/BGR_DEAD + local.get $5 + local.set $13 + local.get $2 + local.set $12 + global.get $assembly/config/BGR_DEAD i32.const -16777216 i32.or - set_local $10 - get_global $assembly/index/s - get_local $2 - get_global $assembly/index/w + local.set $11 + global.get $assembly/index/s + local.get $12 + global.get $assembly/index/w i32.mul i32.add - get_local $5 + local.get $13 i32.add i32.const 2 i32.shl - get_local $10 + local.get $11 i32.store end else - get_local $8 + local.get $8 i32.const 3 i32.eq if - get_global $assembly/config/BGR_ALIVE + local.get $5 + local.set $11 + local.get $2 + local.set $12 + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or - set_local $10 - get_global $assembly/index/s - get_local $2 - get_global $assembly/index/w + local.set $13 + global.get $assembly/index/s + local.get $12 + global.get $assembly/index/w i32.mul i32.add - get_local $5 + local.get $11 i32.add i32.const 2 i32.shl - get_local $10 + local.get $13 i32.store else - get_local $9 + local.get $5 + local.set $13 + local.get $2 + local.set $12 + local.get $10 + local.set $11 + local.get $11 i32.const 24 i32.shr_u - get_global $assembly/config/BIT_ROT + global.get $assembly/config/BIT_ROT i32.sub - tee_local $10 + local.tee $9 i32.const 0 - tee_local $11 - get_local $10 - get_local $11 + local.tee $16 + local.get $9 + local.get $16 i32.gt_s select - set_local $10 - block - get_local $10 + local.set $9 + block $assembly/index/set|inlined.4 + local.get $13 + local.set $16 + local.get $12 + local.set $15 + local.get $9 i32.const 24 i32.shl - get_local $9 + local.get $11 i32.const 16777215 i32.and i32.or - set_local $11 - get_global $assembly/index/s - get_local $2 - get_global $assembly/index/w + local.set $14 + global.get $assembly/index/s + local.get $15 + global.get $assembly/index/w i32.mul i32.add - get_local $5 + local.get $16 i32.add i32.const 2 i32.shl - get_local $11 + local.get $14 i32.store end end end end - get_local $5 + local.get $5 i32.const 1 i32.add - set_local $5 + local.set $5 br $repeat|1 unreachable end unreachable end end - get_local $2 + local.get $2 i32.const 1 i32.add - set_local $2 + local.set $2 br $repeat|0 unreachable end unreachable end ) - (func $assembly/index/fill (; 3 ;) (type $iiFv) (param $0 i32) (param $1 i32) (param $2 f64) + (func $assembly/index/fill (; 3 ;) (type $iiF_) (param $0 i32) (param $1 i32) (param $2 f64) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) block $break|0 i32.const 0 - set_local $3 + local.set $3 loop $repeat|0 - get_local $3 - get_global $assembly/index/w + local.get $3 + global.get $assembly/index/w i32.lt_s i32.eqz br_if $break|0 call $~lib/bindings/Math/random - get_local $2 + local.get $2 f64.lt if - get_global $assembly/config/BGR_ALIVE + local.get $3 + local.set $4 + local.get $1 + local.set $5 + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or - set_local $4 - get_global $assembly/index/s - get_local $1 - get_global $assembly/index/w + local.set $6 + global.get $assembly/index/s + local.get $5 + global.get $assembly/index/w i32.mul i32.add - get_local $3 + local.get $4 i32.add i32.const 2 i32.shl - get_local $4 + local.get $6 i32.store end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|0 unreachable end @@ -476,43 +557,47 @@ end block $break|1 i32.const 0 - set_local $3 + local.set $3 loop $repeat|1 - get_local $3 - get_global $assembly/index/h + local.get $3 + global.get $assembly/index/h i32.lt_s i32.eqz br_if $break|1 call $~lib/bindings/Math/random - get_local $2 + local.get $2 f64.lt if - get_global $assembly/config/BGR_ALIVE + local.get $0 + local.set $6 + local.get $3 + local.set $5 + global.get $assembly/config/BGR_ALIVE i32.const -16777216 i32.or - set_local $4 - get_global $assembly/index/s - get_local $3 - get_global $assembly/index/w + local.set $4 + global.get $assembly/index/s + local.get $5 + global.get $assembly/index/w i32.mul i32.add - get_local $0 + local.get $6 i32.add i32.const 2 i32.shl - get_local $4 + local.get $4 i32.store end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|1 unreachable end unreachable end ) - (func $null (; 4 ;) (type $v) + (func $null (; 4 ;) (type $_) ) ) diff --git a/examples/i64-polyfill/build/optimized.d.ts b/examples/i64-polyfill/build/optimized.d.ts index 9a936f584b..cd5d44508a 100644 --- a/examples/i64-polyfill/build/optimized.d.ts +++ b/examples/i64-polyfill/build/optimized.d.ts @@ -8,6 +8,10 @@ declare module ASModule { type f32 = number; type f64 = number; type bool = any; + const NaN: f64; + const Infinity: f64; + var lo: u32; + var hi: u32; function getLo(): u32; function getHi(): u32; function clz(loLeft: u32, hiLeft: u32): void; diff --git a/examples/i64-polyfill/build/optimized.wat b/examples/i64-polyfill/build/optimized.wat index 031793a0dd..df27405e3d 100644 --- a/examples/i64-polyfill/build/optimized.wat +++ b/examples/i64-polyfill/build/optimized.wat @@ -1,10 +1,10 @@ (module (type $i (func (result i32))) - (type $iiv (func (param i32 i32))) - (type $iiiiv (func (param i32 i32 i32 i32))) - (type $v (func)) + (type $ii_ (func (param i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) + (type $_ (func)) (memory $0 0) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/i64/lo (mut i32) (i32.const 0)) (global $assembly/i64/hi (mut i32) (i32.const 0)) @@ -42,657 +42,657 @@ (export "ge_s" (func $assembly/i64/ge_s)) (export "ge_u" (func $assembly/i64/ge_u)) (func $assembly/i64/getLo (; 0 ;) (type $i) (result i32) - get_global $assembly/i64/lo + global.get $assembly/i64/lo ) (func $assembly/i64/getHi (; 1 ;) (type $i) (result i32) - get_global $assembly/i64/hi + global.get $assembly/i64/hi ) - (func $assembly/i64/clz (; 2 ;) (type $iiv) (param $0 i32) (param $1 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/clz (; 2 ;) (type $ii_) (param $0 i32) (param $1 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.clz - i32.wrap/i64 - set_global $assembly/i64/lo + i32.wrap_i64 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ctz (; 3 ;) (type $iiv) (param $0 i32) (param $1 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/ctz (; 3 ;) (type $ii_) (param $0 i32) (param $1 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ctz - i32.wrap/i64 - set_global $assembly/i64/lo + i32.wrap_i64 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/popcnt (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/popcnt (; 4 ;) (type $ii_) (param $0 i32) (param $1 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.popcnt - i32.wrap/i64 - set_global $assembly/i64/lo + i32.wrap_i64 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/eqz (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/eqz (; 5 ;) (type $ii_) (param $0 i32) (param $1 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.eqz - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/add (; 6 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/add (; 6 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.add - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/sub (; 7 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/sub (; 7 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.sub - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/mul (; 8 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/mul (; 8 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.mul - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/div_s (; 9 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/div_s (; 9 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.div_s - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/div_u (; 10 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/div_u (; 10 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.div_u - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rem_s (; 11 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rem_s (; 11 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rem_s - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rem_u (; 12 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rem_u (; 12 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rem_u - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/and (; 13 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/and (; 13 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.and - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/or (; 14 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/or (; 14 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.or - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/xor (; 15 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/xor (; 15 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.xor - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/shl (; 16 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/shl (; 16 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.shl - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/shr_s (; 17 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/shr_s (; 17 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.shr_s - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/shr_u (; 18 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/shr_u (; 18 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.shr_u - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rotl (; 19 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rotl (; 19 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rotl - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rotr (; 20 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rotr (; 20 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rotr - tee_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.tee $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/eq (; 21 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/eq (; 21 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.eq - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ne (; 22 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/ne (; 22 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ne - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/lt_s (; 23 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/lt_s (; 23 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.lt_s - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/lt_u (; 24 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/lt_u (; 24 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.lt_u - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/le_s (; 25 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/le_s (; 25 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.le_s - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/le_u (; 26 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/le_u (; 26 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.le_u - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/gt_s (; 27 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/gt_s (; 27 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.gt_s - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/gt_u (; 28 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/gt_u (; 28 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.gt_u - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ge_s (; 29 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/ge_s (; 29 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ge_s - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ge_u (; 30 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + (func $assembly/i64/ge_u (; 30 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ge_u - set_global $assembly/i64/lo + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $null (; 31 ;) (type $v) + (func $null (; 31 ;) (type $_) nop ) ) diff --git a/examples/i64-polyfill/build/untouched.wat b/examples/i64-polyfill/build/untouched.wat index 32fafb2f7f..6e5fc51482 100644 --- a/examples/i64-polyfill/build/untouched.wat +++ b/examples/i64-polyfill/build/untouched.wat @@ -1,16 +1,14 @@ (module (type $i (func (result i32))) - (type $iiv (func (param i32 i32))) - (type $iiiiv (func (param i32 i32 i32 i32))) - (type $v (func)) + (type $ii_ (func (param i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) + (type $_ (func)) (memory $0 0) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/i64/lo (mut i32) (i32.const 0)) (global $assembly/i64/hi (mut i32) (i32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $Infinity f64 (f64.const inf)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "getLo" (func $assembly/i64/getLo)) @@ -45,713 +43,713 @@ (export "ge_s" (func $assembly/i64/ge_s)) (export "ge_u" (func $assembly/i64/ge_u)) (func $assembly/i64/getLo (; 0 ;) (type $i) (result i32) - get_global $assembly/i64/lo + global.get $assembly/i64/lo ) (func $assembly/i64/getHi (; 1 ;) (type $i) (result i32) - get_global $assembly/i64/hi + global.get $assembly/i64/hi ) - (func $assembly/i64/clz (; 2 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/i64/clz (; 2 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.clz - set_local $2 - get_local $2 - i32.wrap/i64 - set_global $assembly/i64/lo + local.set $2 + local.get $2 + i32.wrap_i64 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ctz (; 3 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/i64/ctz (; 3 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ctz - set_local $2 - get_local $2 - i32.wrap/i64 - set_global $assembly/i64/lo + local.set $2 + local.get $2 + i32.wrap_i64 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/popcnt (; 4 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/i64/popcnt (; 4 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.popcnt - set_local $2 - get_local $2 - i32.wrap/i64 - set_global $assembly/i64/lo + local.set $2 + local.get $2 + i32.wrap_i64 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/eqz (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/i64/eqz (; 5 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.eqz - set_local $2 - get_local $2 - set_global $assembly/i64/lo + local.set $2 + local.get $2 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/add (; 6 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/add (; 6 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.add - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/sub (; 7 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/sub (; 7 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.sub - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/mul (; 8 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/mul (; 8 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.mul - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/div_s (; 9 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/div_s (; 9 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.div_s - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/div_u (; 10 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/div_u (; 10 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.div_u - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rem_s (; 11 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rem_s (; 11 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rem_s - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rem_u (; 12 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rem_u (; 12 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rem_u - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/and (; 13 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/and (; 13 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.and - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/or (; 14 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/or (; 14 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.or - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/xor (; 15 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/xor (; 15 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.xor - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/shl (; 16 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/shl (; 16 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.shl - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/shr_s (; 17 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/shr_s (; 17 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.shr_s - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/shr_u (; 18 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/shr_u (; 18 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.shr_u - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rotl (; 19 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rotl (; 19 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rotl - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/rotr (; 20 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/rotr (; 20 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i64) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.rotr - set_local $4 - get_local $4 - i32.wrap/i64 - set_global $assembly/i64/lo - get_local $4 + local.set $4 + local.get $4 + i32.wrap_i64 + global.set $assembly/i64/lo + local.get $4 i64.const 32 i64.shr_u - i32.wrap/i64 - set_global $assembly/i64/hi + i32.wrap_i64 + global.set $assembly/i64/hi ) - (func $assembly/i64/eq (; 21 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/eq (; 21 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.eq - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ne (; 22 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/ne (; 22 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ne - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/lt_s (; 23 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/lt_s (; 23 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.lt_s - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/lt_u (; 24 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/lt_u (; 24 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.lt_u - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/le_s (; 25 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/le_s (; 25 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.le_s - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/le_u (; 26 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/le_u (; 26 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.le_u - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/gt_s (; 27 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/gt_s (; 27 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.gt_s - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/gt_u (; 28 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/gt_u (; 28 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.gt_u - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ge_s (; 29 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/ge_s (; 29 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ge_s - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $assembly/i64/ge_u (; 30 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/i64/ge_u (; 30 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) - get_local $0 - i64.extend_u/i32 - get_local $1 - i64.extend_u/i32 + local.get $0 + i64.extend_i32_u + local.get $1 + i64.extend_i32_u i64.const 32 i64.shl i64.or - get_local $2 - i64.extend_u/i32 - get_local $3 - i64.extend_u/i32 + local.get $2 + i64.extend_i32_u + local.get $3 + i64.extend_i32_u i64.const 32 i64.shl i64.or i64.ge_u - set_local $4 - get_local $4 - set_global $assembly/i64/lo + local.set $4 + local.get $4 + global.set $assembly/i64/lo i32.const 0 - set_global $assembly/i64/hi + global.set $assembly/i64/hi ) - (func $null (; 31 ;) (type $v) + (func $null (; 31 ;) (type $_) ) ) diff --git a/examples/mandelbrot/build/optimized.d.ts b/examples/mandelbrot/build/optimized.d.ts index 6dffd81256..58fe356b06 100644 --- a/examples/mandelbrot/build/optimized.d.ts +++ b/examples/mandelbrot/build/optimized.d.ts @@ -8,6 +8,12 @@ declare module ASModule { type f32 = number; type f64 = number; type bool = any; + namespace JSMath { + function log(x: f64): f64; + function log2(x: f64): f64; + } + var NUM_COLORS: i32; function computeLine(y: u32, width: u32, height: u32, limit: u32): void; + function clamp(value: f64, minValue: f64, maxValue: f64): f64; } export default ASModule; diff --git a/examples/mandelbrot/build/optimized.wat b/examples/mandelbrot/build/optimized.wat index 7897c937bc..cc1f0a94cb 100644 --- a/examples/mandelbrot/build/optimized.wat +++ b/examples/mandelbrot/build/optimized.wat @@ -1,16 +1,16 @@ (module - (type $iiiiv (func (param i32 i32 i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) (type $FF (func (param f64) (result f64))) - (type $v (func)) + (type $_ (func)) (import "env" "memory" (memory $0 0)) (import "Math" "log" (func $~lib/bindings/Math/log (param f64) (result f64))) (import "Math" "log2" (func $~lib/bindings/Math/log2 (param f64) (result f64))) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (export "memory" (memory $0)) (export "table" (table $0)) (export "computeLine" (func $assembly/index/computeLine)) - (func $assembly/index/computeLine (; 2 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/index/computeLine (; 2 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 f64) (local $5 f64) (local $6 f64) @@ -24,188 +24,188 @@ (local $14 f64) f64.const 10 f64.const 3 - get_local $1 - f64.convert_u/i32 - tee_local $8 + local.get $1 + f64.convert_i32_u + local.tee $8 f64.mul f64.const 4 - get_local $2 - f64.convert_u/i32 - tee_local $4 + local.get $2 + f64.convert_i32_u + local.tee $4 f64.mul f64.min f64.div - set_local $9 - get_local $0 - f64.convert_u/i32 - get_local $4 + local.set $9 + local.get $0 + f64.convert_i32_u + local.get $4 f64.const 0.5 f64.mul f64.sub - get_local $9 + local.get $9 f64.mul - set_local $10 - get_local $8 + local.set $10 + local.get $8 f64.const 0.625 f64.mul - get_local $9 + local.get $9 f64.mul - set_local $12 - get_local $0 - get_local $1 + local.set $12 + local.get $0 + local.get $1 i32.mul i32.const 1 i32.shl - set_local $0 + local.set $0 f64.const 1 - get_local $3 - f64.convert_u/i32 - tee_local $6 + local.get $3 + f64.convert_i32_u + local.tee $6 f64.div - set_local $13 + local.set $13 f64.const 8 - get_local $6 + local.get $6 f64.min - set_local $8 + local.set $8 loop $repeat|0 - get_local $7 - get_local $1 + local.get $7 + local.get $1 i32.lt_u if - get_local $7 - f64.convert_u/i32 - get_local $9 + local.get $7 + f64.convert_i32_u + local.get $9 f64.mul - get_local $12 + local.get $12 f64.sub - set_local $11 + local.set $11 f64.const 0 - set_local $4 + local.set $4 f64.const 0 - set_local $5 + local.set $5 i32.const 0 - set_local $2 + local.set $2 loop $continue|1 - get_local $4 - get_local $4 + local.get $4 + local.get $4 f64.mul - tee_local $14 - get_local $5 - get_local $5 + local.tee $14 + local.get $5 + local.get $5 f64.mul - tee_local $6 + local.tee $6 f64.add f64.const 4 f64.le if block $break|1 f64.const 2 - get_local $4 + local.get $4 f64.mul - get_local $5 + local.get $5 f64.mul - get_local $10 + local.get $10 f64.add - set_local $5 - get_local $14 - get_local $6 + local.set $5 + local.get $14 + local.get $6 f64.sub - get_local $11 + local.get $11 f64.add - set_local $4 - get_local $2 - get_local $3 + local.set $4 + local.get $2 + local.get $3 i32.ge_u br_if $break|1 - get_local $2 + local.get $2 i32.const 1 i32.add - set_local $2 + local.set $2 br $continue|1 end end end loop $continue|2 - get_local $2 - f64.convert_u/i32 - get_local $8 + local.get $2 + f64.convert_i32_u + local.get $8 f64.lt if - get_local $4 - get_local $4 + local.get $4 + local.get $4 f64.mul - get_local $5 - get_local $5 + local.get $5 + local.get $5 f64.mul f64.sub - get_local $11 + local.get $11 f64.add - set_local $6 + local.set $6 f64.const 2 - get_local $4 + local.get $4 f64.mul - get_local $5 + local.get $5 f64.mul - get_local $10 + local.get $10 f64.add - set_local $5 - get_local $6 - set_local $4 - get_local $2 + local.set $5 + local.get $6 + local.set $4 + local.get $2 i32.const 1 i32.add - set_local $2 + local.set $2 br $continue|2 end end - get_local $7 + local.get $7 i32.const 1 i32.shl - get_local $0 + local.get $0 i32.add - get_local $4 - get_local $4 + local.get $4 + local.get $4 f64.mul - get_local $5 - get_local $5 + local.get $5 + local.get $5 f64.mul f64.add - tee_local $6 + local.tee $6 f64.const 1 f64.gt if (result i32) f64.const 2047 - get_local $2 + local.get $2 i32.const 1 i32.add - f64.convert_u/i32 + f64.convert_i32_u f64.const 0.5 - get_local $6 + local.get $6 call $~lib/bindings/Math/log f64.mul call $~lib/bindings/Math/log2 f64.sub - get_local $13 + local.get $13 f64.mul f64.const 0 f64.max f64.const 1 f64.min f64.mul - i32.trunc_u/f64 + i32.trunc_f64_u else i32.const 2047 end i32.store16 - get_local $7 + local.get $7 i32.const 1 i32.add - set_local $7 + local.set $7 br $repeat|0 end end ) - (func $null (; 3 ;) (type $v) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/examples/mandelbrot/build/untouched.wat b/examples/mandelbrot/build/untouched.wat index d4e960dbb0..596d599d37 100644 --- a/examples/mandelbrot/build/untouched.wat +++ b/examples/mandelbrot/build/untouched.wat @@ -1,26 +1,26 @@ (module - (type $iiiiv (func (param i32 i32 i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) (type $FF (func (param f64) (result f64))) (type $FFFF (func (param f64 f64 f64) (result f64))) - (type $v (func)) + (type $_ (func)) (import "env" "memory" (memory $0 0)) (import "Math" "log" (func $~lib/bindings/Math/log (param f64) (result f64))) (import "Math" "log2" (func $~lib/bindings/Math/log2 (param f64) (result f64))) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/index/NUM_COLORS i32 (i32.const 2048)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "computeLine" (func $assembly/index/computeLine)) (func $assembly/index/clamp (; 2 ;) (type $FFFF) (param $0 f64) (param $1 f64) (param $2 f64) (result f64) - get_local $0 - get_local $1 + local.get $0 + local.get $1 f64.max - get_local $2 + local.get $2 f64.min ) - (func $assembly/index/computeLine (; 3 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $assembly/index/computeLine (; 3 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 f64) (local $5 f64) (local $6 f64) @@ -39,121 +39,121 @@ (local $19 f64) (local $20 i32) (local $21 f64) - get_local $1 - f64.convert_u/i32 + local.get $1 + f64.convert_i32_u f64.const 1 f64.const 1.6 f64.div f64.mul - set_local $4 - get_local $2 - f64.convert_u/i32 + local.set $4 + local.get $2 + f64.convert_i32_u f64.const 1 f64.const 2 f64.div f64.mul - set_local $5 + local.set $5 f64.const 10 f64.const 3 - get_local $1 - f64.convert_u/i32 + local.get $1 + f64.convert_i32_u f64.mul f64.const 4 - get_local $2 - f64.convert_u/i32 + local.get $2 + f64.convert_i32_u f64.mul f64.min f64.div - set_local $6 - get_local $0 - f64.convert_u/i32 - get_local $5 + local.set $6 + local.get $0 + f64.convert_i32_u + local.get $5 f64.sub - get_local $6 + local.get $6 f64.mul - set_local $7 - get_local $4 - get_local $6 + local.set $7 + local.get $4 + local.get $6 f64.mul - set_local $8 - get_local $0 - get_local $1 + local.set $8 + local.get $0 + local.get $1 i32.mul i32.const 1 i32.shl - set_local $9 + local.set $9 f64.const 1 - get_local $3 - f64.convert_u/i32 + local.get $3 + f64.convert_i32_u f64.div - set_local $10 + local.set $10 f64.const 8 - get_local $3 - f64.convert_u/i32 + local.get $3 + f64.convert_i32_u f64.min - set_local $11 + local.set $11 block $break|0 i32.const 0 - set_local $12 + local.set $12 loop $repeat|0 - get_local $12 - get_local $1 + local.get $12 + local.get $1 i32.lt_u i32.eqz br_if $break|0 block - get_local $12 - f64.convert_u/i32 - get_local $6 + local.get $12 + f64.convert_i32_u + local.get $6 f64.mul - get_local $8 + local.get $8 f64.sub - set_local $13 + local.set $13 f64.const 0 - set_local $14 + local.set $14 f64.const 0 - set_local $15 + local.set $15 i32.const 0 - set_local $18 + local.set $18 block $break|1 loop $continue|1 - get_local $14 - get_local $14 + local.get $14 + local.get $14 f64.mul - tee_local $16 - get_local $15 - get_local $15 + local.tee $16 + local.get $15 + local.get $15 f64.mul - tee_local $17 + local.tee $17 f64.add f64.const 4 f64.le if block f64.const 2 - get_local $14 + local.get $14 f64.mul - get_local $15 + local.get $15 f64.mul - get_local $7 + local.get $7 f64.add - set_local $15 - get_local $16 - get_local $17 + local.set $15 + local.get $16 + local.get $17 f64.sub - get_local $13 + local.get $13 f64.add - set_local $14 - get_local $18 - get_local $3 + local.set $14 + local.get $18 + local.get $3 i32.ge_u if br $break|1 end - get_local $18 + local.get $18 i32.const 1 i32.add - set_local $18 + local.set $18 end br $continue|1 end @@ -161,100 +161,100 @@ end block $break|2 loop $continue|2 - get_local $18 - f64.convert_u/i32 - get_local $11 + local.get $18 + f64.convert_i32_u + local.get $11 f64.lt if block - get_local $14 - get_local $14 + local.get $14 + local.get $14 f64.mul - get_local $15 - get_local $15 + local.get $15 + local.get $15 f64.mul f64.sub - get_local $13 + local.get $13 f64.add - set_local $19 + local.set $19 f64.const 2 - get_local $14 + local.get $14 f64.mul - get_local $15 + local.get $15 f64.mul - get_local $7 + local.get $7 f64.add - set_local $15 - get_local $19 - set_local $14 - get_local $18 + local.set $15 + local.get $19 + local.set $14 + local.get $18 i32.const 1 i32.add - set_local $18 + local.set $18 end br $continue|2 end end end - get_global $assembly/index/NUM_COLORS + global.get $assembly/index/NUM_COLORS i32.const 1 i32.sub - set_local $20 - get_local $14 - get_local $14 + local.set $20 + local.get $14 + local.get $14 f64.mul - get_local $15 - get_local $15 + local.get $15 + local.get $15 f64.mul f64.add - set_local $19 - get_local $19 + local.set $19 + local.get $19 f64.const 1 f64.gt if f64.const 0.5 - get_local $19 + local.get $19 call $~lib/bindings/Math/log f64.mul call $~lib/bindings/Math/log2 - set_local $21 - get_global $assembly/index/NUM_COLORS + local.set $21 + global.get $assembly/index/NUM_COLORS i32.const 1 i32.sub - f64.convert_s/i32 - get_local $18 + f64.convert_i32_s + local.get $18 i32.const 1 i32.add - f64.convert_u/i32 - get_local $21 + f64.convert_i32_u + local.get $21 f64.sub - get_local $10 + local.get $10 f64.mul f64.const 0 f64.const 1 call $assembly/index/clamp f64.mul - i32.trunc_u/f64 - set_local $20 + i32.trunc_f64_u + local.set $20 end - get_local $9 - get_local $12 + local.get $9 + local.get $12 i32.const 1 i32.shl i32.add - get_local $20 + local.get $20 i32.store16 end - get_local $12 + local.get $12 i32.const 1 i32.add - set_local $12 + local.set $12 br $repeat|0 unreachable end unreachable end ) - (func $null (; 4 ;) (type $v) + (func $null (; 4 ;) (type $_) ) ) diff --git a/examples/n-body/build/index.asm.js b/examples/n-body/build/index.asm.js index adcfbe12fc..0095ab8b9f 100644 --- a/examples/n-body/build/index.asm.js +++ b/examples/n-body/build/index.asm.js @@ -39,6 +39,41 @@ function asmFunc(global, env, buffer) { return $1 | 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; + repeat_0 : do { + if (($1 | 0) < ($7 | 0)) { + $2 = HEAPU32[(((HEAPU32[$0 >> 2] | 0) + ($1 << 2 | 0) | 0) + 8 | 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; + if (0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $49 = HEAPU32[($1 + 8 | 0) >> 2] | 0; else abort(); + $1 = $49; + 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_allocator_arena___memory_allocate(4 | 0) | 0; + 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; @@ -223,41 +258,6 @@ function asmFunc(global, env, buffer) { return $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; - repeat_0 : do { - if (($1 | 0) < ($7 | 0)) { - $2 = HEAPU32[(((HEAPU32[$0 >> 2] | 0) + ($1 << 2 | 0) | 0) + 8 | 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; - if (0 >>> 0 < ((HEAP32[$1 >> 2] | 0) >>> 2 | 0) >>> 0) $49 = HEAPU32[($1 + 8 | 0) >> 2] | 0; else abort(); - $1 = $49; - 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_allocator_arena___memory_allocate(4 | 0) | 0; - wasm2js_i32$0 = $1; - wasm2js_i32$1 = $0; - HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; - 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; diff --git a/examples/n-body/build/optimized.wasm b/examples/n-body/build/optimized.wasm index 4c496e18b5..9fad966f5d 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 a4c1fbf407..5d7d6a67a1 100644 --- a/examples/n-body/build/optimized.wat +++ b/examples/n-body/build/optimized.wat @@ -1,17 +1,17 @@ (module - (type $v (func)) + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $F (func (result f64))) (type $iF (func (param i32) (result f64))) - (type $iv (func (param i32))) + (type $i_ (func (param i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$iddddddd (func (param f64 f64 f64 f64 f64 f64 f64) (result i32))) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$i (func (result i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$vi (func (param 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") - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) @@ -27,17 +27,17 @@ (local $1 i32) (local $2 i32) (local $3 i32) - get_local $0 + local.get $0 i32.const 1073741824 i32.gt_u if unreachable end - get_global $~lib/allocator/arena/offset - tee_local $1 - get_local $0 + global.get $~lib/allocator/arena/offset + local.tee $1 + local.get $0 i32.const 1 - get_local $0 + local.get $0 i32.const 1 i32.gt_u select @@ -46,16 +46,16 @@ i32.add i32.const -8 i32.and - tee_local $2 + local.tee $2 current_memory - tee_local $3 + local.tee $3 i32.const 16 i32.shl i32.gt_u if - get_local $3 - get_local $2 - get_local $1 + local.get $3 + local.get $2 + local.get $1 i32.sub i32.const 65535 i32.add @@ -63,16 +63,16 @@ i32.and i32.const 16 i32.shr_u - tee_local $0 - get_local $3 - get_local $0 + local.tee $0 + local.get $3 + local.get $0 i32.gt_s select grow_memory i32.const 0 i32.lt_s if - get_local $0 + local.get $0 grow_memory i32.const 0 i32.lt_s @@ -81,383 +81,383 @@ end end end - get_local $2 - set_global $~lib/allocator/arena/offset - get_local $1 + local.get $2 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $assembly/index/NBodySystem#constructor (; 1 ;) (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=4 + local.set $7 + loop $repeat|0 + local.get $1 + local.get $7 + i32.lt_s + if + local.get $0 + i32.load + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load offset=8 + 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 + i32.const 0 + local.get $0 + 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 + 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/allocator/arena/__memory_allocate + local.tee $1 + local.get $0 + i32.store + local.get $1 ) - (func $assembly/index/Body#constructor (; 1 ;) (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 (; 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) (local $7 i32) i32.const 56 call $~lib/allocator/arena/__memory_allocate - tee_local $7 - get_local $0 + local.tee $7 + local.get $0 f64.store - get_local $7 - get_local $1 + local.get $7 + local.get $1 f64.store offset=8 - get_local $7 - get_local $2 + local.get $7 + local.get $2 f64.store offset=16 - get_local $7 - get_local $3 + local.get $7 + local.get $3 f64.store offset=24 - get_local $7 - get_local $4 + local.get $7 + local.get $4 f64.store offset=32 - get_local $7 - get_local $5 + local.get $7 + local.get $5 f64.store offset=40 - get_local $7 - get_local $6 + local.get $7 + local.get $6 f64.store offset=48 - get_local $7 + local.get $7 ) - (func $~lib/internal/memory/memset (; 2 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/internal/memory/memset (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) - get_local $1 + local.get $1 i32.eqz if return end - get_local $0 + local.get $0 i32.const 0 i32.store8 - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.add i32.const 1 i32.sub i32.const 0 i32.store8 - get_local $1 + local.get $1 i32.const 2 i32.le_u if return end - get_local $0 + local.get $0 i32.const 1 i32.add i32.const 0 i32.store8 - get_local $0 + local.get $0 i32.const 2 i32.add i32.const 0 i32.store8 - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.add - tee_local $2 + local.tee $2 i32.const 2 i32.sub i32.const 0 i32.store8 - get_local $2 + local.get $2 i32.const 3 i32.sub i32.const 0 i32.store8 - get_local $1 + local.get $1 i32.const 6 i32.le_u if return end - get_local $0 + local.get $0 i32.const 3 i32.add i32.const 0 i32.store8 - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.add i32.const 4 i32.sub i32.const 0 i32.store8 - get_local $1 + local.get $1 i32.const 8 i32.le_u if return end i32.const 0 - get_local $0 + local.get $0 i32.sub i32.const 3 i32.and - tee_local $2 - get_local $0 + local.tee $2 + local.get $0 i32.add - tee_local $0 + local.tee $0 i32.const 0 i32.store - get_local $1 - get_local $2 + local.get $1 + local.get $2 i32.sub i32.const -4 i32.and - tee_local $1 - get_local $0 + local.tee $1 + local.get $0 i32.add i32.const 4 i32.sub i32.const 0 i32.store - get_local $1 + local.get $1 i32.const 8 i32.le_u if return end - get_local $0 + local.get $0 i32.const 4 i32.add i32.const 0 i32.store - get_local $0 + local.get $0 i32.const 8 i32.add i32.const 0 i32.store - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.add - tee_local $2 + local.tee $2 i32.const 12 i32.sub i32.const 0 i32.store - get_local $2 + local.get $2 i32.const 8 i32.sub i32.const 0 i32.store - get_local $1 + local.get $1 i32.const 24 i32.le_u if return end - get_local $0 + local.get $0 i32.const 12 i32.add i32.const 0 i32.store - get_local $0 + local.get $0 i32.const 16 i32.add i32.const 0 i32.store - get_local $0 + local.get $0 i32.const 20 i32.add i32.const 0 i32.store - get_local $0 + local.get $0 i32.const 24 i32.add i32.const 0 i32.store - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.add - tee_local $2 + local.tee $2 i32.const 28 i32.sub i32.const 0 i32.store - get_local $2 + local.get $2 i32.const 24 i32.sub i32.const 0 i32.store - get_local $2 + local.get $2 i32.const 20 i32.sub i32.const 0 i32.store - get_local $2 + local.get $2 i32.const 16 i32.sub i32.const 0 i32.store - get_local $0 + local.get $0 i32.const 4 i32.and i32.const 24 i32.add - tee_local $2 - get_local $0 + local.tee $2 + local.get $0 i32.add - set_local $0 - get_local $1 - get_local $2 + local.set $0 + local.get $1 + local.get $2 i32.sub - set_local $1 + local.set $1 loop $continue|0 - get_local $1 + local.get $1 i32.const 32 i32.ge_u if - get_local $0 + local.get $0 i64.const 0 i64.store - get_local $0 + local.get $0 i32.const 8 i32.add i64.const 0 i64.store - get_local $0 + local.get $0 i32.const 16 i32.add i64.const 0 i64.store - get_local $0 + local.get $0 i32.const 24 i32.add i64.const 0 i64.store - get_local $1 + local.get $1 i32.const 32 i32.sub - set_local $1 - get_local $0 + local.set $1 + local.get $0 i32.const 32 i32.add - set_local $0 + local.set $0 br $continue|0 end end ) - (func $~lib/array/Array#constructor (; 3 ;) (type $FUNCSIG$i) (result i32) + (func $~lib/array/Array#constructor (; 4 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) (local $1 i32) i32.const 32 call $~lib/allocator/arena/__memory_allocate - tee_local $1 + local.tee $1 i32.const 20 i32.store i32.const 8 call $~lib/allocator/arena/__memory_allocate - tee_local $0 + local.tee $0 i32.const 0 i32.store - get_local $0 + local.get $0 i32.const 0 i32.store offset=4 - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.store - get_local $0 + local.get $0 i32.const 5 i32.store offset=4 - get_local $1 + local.get $1 i32.const 8 i32.add i32.const 20 call $~lib/internal/memory/memset - get_local $0 - ) - (func $assembly/index/NBodySystem#constructor (; 4 ;) (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) - get_local $0 - i32.load offset=4 - set_local $7 - loop $repeat|0 - get_local $1 - get_local $7 - i32.lt_s - if - get_local $0 - i32.load - get_local $1 - i32.const 2 - i32.shl - i32.add - i32.load offset=8 - tee_local $2 - f64.load offset=48 - set_local $3 - get_local $4 - get_local $2 - f64.load offset=24 - get_local $3 - f64.mul - f64.add - set_local $4 - get_local $5 - get_local $2 - f64.load offset=32 - get_local $3 - f64.mul - f64.add - set_local $5 - get_local $6 - get_local $2 - f64.load offset=40 - get_local $3 - f64.mul - f64.add - set_local $6 - get_local $1 - i32.const 1 - i32.add - set_local $1 - br $repeat|0 - end - end - i32.const 0 - get_local $0 - i32.load - tee_local $1 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - get_local $1 - i32.load offset=8 - else - unreachable - end - tee_local $1 - get_local $4 - f64.neg - f64.const 39.47841760435743 - f64.div - f64.store offset=24 - get_local $1 - get_local $5 - f64.neg - f64.const 39.47841760435743 - f64.div - f64.store offset=32 - get_local $1 - get_local $6 - f64.neg - f64.const 39.47841760435743 - f64.div - f64.store offset=40 - i32.const 4 - call $~lib/allocator/arena/__memory_allocate - tee_local $1 - get_local $0 - i32.store - get_local $1 + local.get $0 ) - (func $assembly/index/init (; 5 ;) (type $v) + (func $assembly/index/init (; 5 ;) (type $_) (local $0 i32) (local $1 i32) call $~lib/array/Array#constructor - set_local $1 + local.set $1 f64.const 0 f64.const 0 f64.const 0 @@ -466,10 +466,10 @@ f64.const 0 f64.const 39.47841760435743 call $assembly/index/Body#constructor - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.load - get_local $0 + local.get $0 i32.store offset=8 f64.const 4.841431442464721 f64.const -1.1603200440274284 @@ -479,12 +479,12 @@ f64.const -0.02521836165988763 f64.const 0.03769367487038949 call $assembly/index/Body#constructor - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.load i32.const 4 i32.add - get_local $0 + local.get $0 i32.store offset=8 f64.const 8.34336671824458 f64.const 4.124798564124305 @@ -494,12 +494,12 @@ f64.const 0.008415761376584154 f64.const 0.011286326131968767 call $assembly/index/Body#constructor - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.load i32.const 8 i32.add - get_local $0 + local.get $0 i32.store offset=8 f64.const 12.894369562139131 f64.const -15.111151401698631 @@ -509,12 +509,12 @@ f64.const -0.010832637401363636 f64.const 1.7237240570597112e-03 call $assembly/index/Body#constructor - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.load i32.const 12 i32.add - get_local $0 + local.get $0 i32.store offset=8 f64.const 15.379697114850917 f64.const -25.919314609987964 @@ -524,16 +524,16 @@ f64.const -0.034755955504078104 f64.const 2.0336868699246304e-03 call $assembly/index/Body#constructor - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.load i32.const 16 i32.add - get_local $0 + local.get $0 i32.store offset=8 - get_local $1 + local.get $1 call $assembly/index/NBodySystem#constructor - set_global $assembly/index/system + global.set $assembly/index/system ) (func $assembly/index/NBodySystem#advance (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) (local $1 i32) @@ -554,185 +554,185 @@ (local $16 f64) (local $17 f64) (local $18 f64) - get_local $0 + local.get $0 i32.load - tee_local $12 + local.tee $12 i32.load offset=4 - set_local $13 + local.set $13 loop $repeat|0 - get_local $3 - get_local $13 + local.get $3 + local.get $13 i32.lt_u if - get_local $12 + local.get $12 i32.load - get_local $3 + local.get $3 i32.const 2 i32.shl i32.add i32.load offset=8 - tee_local $0 + local.tee $0 f64.load - set_local $14 - get_local $0 + local.set $14 + local.get $0 f64.load offset=8 - set_local $15 - get_local $0 + local.set $15 + local.get $0 f64.load offset=16 - set_local $16 - get_local $0 + local.set $16 + local.get $0 f64.load offset=24 - set_local $4 - get_local $0 + local.set $4 + local.get $0 f64.load offset=32 - set_local $5 - get_local $0 + local.set $5 + local.get $0 f64.load offset=40 - set_local $6 - get_local $0 + local.set $6 + local.get $0 f64.load offset=48 - set_local $17 - get_local $3 + local.set $17 + local.get $3 i32.const 1 i32.add - set_local $7 + local.set $7 loop $repeat|1 - get_local $7 - get_local $13 + local.get $7 + local.get $13 i32.lt_u if - get_local $14 - get_local $12 + local.get $14 + local.get $12 i32.load - get_local $7 + local.get $7 i32.const 2 i32.shl i32.add i32.load offset=8 - tee_local $1 + local.tee $1 f64.load f64.sub - tee_local $18 - tee_local $2 - get_local $2 + local.tee $18 + local.tee $2 + local.get $2 f64.mul - get_local $15 - get_local $1 + local.get $15 + local.get $1 f64.load offset=8 f64.sub - tee_local $9 - get_local $9 + local.tee $9 + local.get $9 f64.mul f64.add - get_local $16 - get_local $1 + local.get $16 + local.get $1 f64.load offset=16 f64.sub - tee_local $10 - get_local $10 + local.tee $10 + local.get $10 f64.mul f64.add - tee_local $8 + local.tee $8 f64.sqrt - set_local $11 - get_local $4 - get_local $2 - get_local $1 + local.set $11 + local.get $4 + local.get $2 + local.get $1 f64.load offset=48 f64.const 0.01 - get_local $8 - get_local $11 + local.get $8 + local.get $11 f64.mul f64.div - tee_local $11 + local.tee $11 f64.mul - tee_local $8 + local.tee $8 f64.mul f64.sub - set_local $4 - get_local $5 - get_local $9 - get_local $8 + local.set $4 + local.get $5 + local.get $9 + local.get $8 f64.mul f64.sub - set_local $5 - get_local $6 - get_local $10 - get_local $8 + local.set $5 + local.get $6 + local.get $10 + local.get $8 f64.mul f64.sub - set_local $6 - get_local $1 - get_local $1 + local.set $6 + local.get $1 + local.get $1 f64.load offset=24 - get_local $18 - get_local $17 - get_local $11 + local.get $18 + local.get $17 + local.get $11 f64.mul - tee_local $2 + local.tee $2 f64.mul f64.add f64.store offset=24 - get_local $1 - get_local $1 + local.get $1 + local.get $1 f64.load offset=32 - get_local $9 - get_local $2 + local.get $9 + local.get $2 f64.mul f64.add f64.store offset=32 - get_local $1 - get_local $1 + local.get $1 + local.get $1 f64.load offset=40 - get_local $10 - get_local $2 + local.get $10 + local.get $2 f64.mul f64.add f64.store offset=40 - get_local $7 + local.get $7 i32.const 1 i32.add - set_local $7 + local.set $7 br $repeat|1 end end - get_local $0 - get_local $4 + local.get $0 + local.get $4 f64.store offset=24 - get_local $0 - get_local $5 + local.get $0 + local.get $5 f64.store offset=32 - get_local $0 - get_local $6 + local.get $0 + local.get $6 f64.store offset=40 - get_local $0 - get_local $0 + local.get $0 + local.get $0 f64.load f64.const 0.01 - get_local $4 + local.get $4 f64.mul f64.add f64.store - get_local $0 - get_local $0 + local.get $0 + local.get $0 f64.load offset=8 f64.const 0.01 - get_local $5 + local.get $5 f64.mul f64.add f64.store offset=8 - get_local $0 - get_local $0 + local.get $0 + local.get $0 f64.load offset=16 f64.const 0.01 - get_local $6 + local.get $6 f64.mul f64.add f64.store offset=16 - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|0 end end @@ -748,143 +748,143 @@ (local $8 f64) (local $9 f64) (local $10 f64) - get_local $0 + local.get $0 i32.load - tee_local $4 + local.tee $4 i32.load offset=4 - set_local $5 + local.set $5 loop $repeat|0 - get_local $2 - get_local $5 + local.get $2 + local.get $5 i32.lt_u if - get_local $4 + local.get $4 i32.load - get_local $2 + local.get $2 i32.const 2 i32.shl i32.add i32.load offset=8 - tee_local $0 + local.tee $0 f64.load - set_local $7 - get_local $0 + local.set $7 + local.get $0 f64.load offset=8 - set_local $8 - get_local $0 + local.set $8 + local.get $0 f64.load offset=16 - set_local $9 - get_local $1 + local.set $9 + local.get $1 f64.const 0.5 - get_local $0 + local.get $0 f64.load offset=48 - tee_local $10 + local.tee $10 f64.mul - get_local $0 + local.get $0 f64.load offset=24 - tee_local $1 - get_local $1 + local.tee $1 + local.get $1 f64.mul - get_local $0 + local.get $0 f64.load offset=32 - tee_local $1 - get_local $1 + local.tee $1 + local.get $1 f64.mul f64.add - get_local $0 + local.get $0 f64.load offset=40 - tee_local $1 - get_local $1 + local.tee $1 + local.get $1 f64.mul f64.add f64.mul f64.add - set_local $1 - get_local $2 + local.set $1 + local.get $2 i32.const 1 i32.add - set_local $0 + local.set $0 loop $repeat|1 - get_local $0 - get_local $5 + local.get $0 + local.get $5 i32.lt_u if - get_local $7 - get_local $4 + local.get $7 + local.get $4 i32.load - get_local $0 + local.get $0 i32.const 2 i32.shl i32.add i32.load offset=8 - tee_local $3 + local.tee $3 f64.load f64.sub - set_local $6 - get_local $1 - get_local $10 - get_local $3 + local.set $6 + local.get $1 + local.get $10 + local.get $3 f64.load offset=48 f64.mul - get_local $6 - get_local $6 + local.get $6 + local.get $6 f64.mul - get_local $8 - get_local $3 + local.get $8 + local.get $3 f64.load offset=8 f64.sub - tee_local $1 - get_local $1 + local.tee $1 + local.get $1 f64.mul f64.add - get_local $9 - get_local $3 + local.get $9 + local.get $3 f64.load offset=16 f64.sub - tee_local $1 - get_local $1 + local.tee $1 + local.get $1 f64.mul f64.add f64.sqrt f64.div f64.sub - set_local $1 - get_local $0 + local.set $1 + local.get $0 i32.const 1 i32.add - set_local $0 + local.set $0 br $repeat|1 end end - get_local $2 + local.get $2 i32.const 1 i32.add - set_local $2 + local.set $2 br $repeat|0 end end - get_local $1 + local.get $1 ) (func $assembly/index/step (; 8 ;) (type $F) (result f64) - get_global $assembly/index/system + global.get $assembly/index/system call $assembly/index/NBodySystem#advance - get_global $assembly/index/system + global.get $assembly/index/system call $assembly/index/NBodySystem#energy ) - (func $assembly/index/bench (; 9 ;) (type $iv) (param $0 i32) + (func $assembly/index/bench (; 9 ;) (type $i_) (param $0 i32) (local $1 i32) block $break|0 loop $repeat|0 - get_local $1 - get_local $0 + local.get $1 + local.get $0 i32.ge_u br_if $break|0 - get_global $assembly/index/system + global.get $assembly/index/system call $assembly/index/NBodySystem#advance - get_local $1 + local.get $1 i32.const 1 i32.add - set_local $1 + local.set $1 br $repeat|0 unreachable end @@ -893,26 +893,26 @@ ) (func $assembly/index/getBody (; 10 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - get_local $0 - get_global $assembly/index/system + local.get $0 + global.get $assembly/index/system i32.load - tee_local $1 + local.tee $1 i32.load offset=4 i32.lt_u if (result i32) - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.load - tee_local $1 + local.tee $1 i32.load i32.const 2 i32.shr_u i32.lt_u if (result i32) - get_local $0 + local.get $0 i32.const 2 i32.shl - get_local $1 + local.get $1 i32.add i32.load offset=8 else @@ -922,13 +922,13 @@ i32.const 0 end ) - (func $start (; 11 ;) (type $v) + (func $start (; 11 ;) (type $_) i32.const 40 - set_global $~lib/allocator/arena/startOffset - get_global $~lib/allocator/arena/startOffset - set_global $~lib/allocator/arena/offset + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset ) - (func $null (; 12 ;) (type $v) + (func $null (; 12 ;) (type $_) nop ) ) diff --git a/examples/n-body/build/untouched.wat b/examples/n-body/build/untouched.wat index afebe9ce6a..f22eda160b 100644 --- a/examples/n-body/build/untouched.wat +++ b/examples/n-body/build/untouched.wat @@ -1,35 +1,29 @@ (module - (type $v (func)) - (type $i (func (result i32))) - (type $iFFFFFFFi (func (param i32 f64 f64 f64 f64 f64 f64 f64) (result i32))) - (type $ii (func (param i32) (result i32))) + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) - (type $iiiiv (func (param i32 i32 i32 i32))) - (type $iiiv (func (param i32 i32 i32))) (type $iFFFi (func (param i32 f64 f64 f64) (result i32))) + (type $ii (func (param i32) (result i32))) + (type $i (func (result i32))) + (type $iFFFFFFFi (func (param i32 f64 f64 f64 f64 f64 f64 f64) (result i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) + (type $iii_ (func (param i32 i32 i32))) (type $F (func (result f64))) - (type $iFv (func (param i32 f64))) + (type $iF_ (func (param i32 f64))) (type $iF (func (param i32) (result f64))) - (type $iv (func (param i32))) + (type $i_ (func (param 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\00") (data (i32.const 40) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $~lib/math/NativeMath.PI f64 (f64.const 3.141592653589793)) (global $assembly/index/SOLAR_MASS f64 (f64.const 39.47841760435743)) (global $assembly/index/DAYS_PER_YEAR f64 (f64.const 365.24)) (global $assembly/index/system (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $HEAP_BASE i32 (i32.const 100)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 100)) (export "memory" (memory $0)) (export "table" (table $0)) (export "init" (func $assembly/index/init)) @@ -37,48 +31,137 @@ (export "bench" (func $assembly/index/bench)) (export "getBody" (func $assembly/index/getBody)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $start:assembly/index (; 2 ;) (type $_) + call $start:~lib/allocator/arena + ) + (func $~lib/array/Array#__unchecked_get (; 3 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + local.get $0 + i32.load + local.set $2 + local.get $1 + local.set $3 + i32.const 0 + local.set $4 + local.get $2 + local.get $3 + i32.const 2 + i32.shl + i32.add + local.get $4 + i32.add + i32.load offset=8 + ) + (func $~lib/array/Array#__get (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $0 + i32.load + local.set $2 + local.get $1 + local.get $2 + i32.load + i32.const 2 + i32.shr_u + i32.lt_u + if (result i32) + local.get $2 + local.set $3 + local.get $1 + local.set $4 + i32.const 0 + local.set $5 + local.get $3 + local.get $4 + i32.const 2 + i32.shl + i32.add + local.get $5 + i32.add + i32.load offset=8 + else + unreachable + end + ) + (func $assembly/index/Body#offsetMomentum (; 5 ;) (type $iFFFi) (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/allocator/arena/__memory_allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) - get_local $0 - get_global $~lib/internal/allocator/MAX_SIZE_32 + local.get $0 + i32.const 1073741824 i32.gt_u if unreachable end - get_global $~lib/allocator/arena/offset - set_local $1 - get_local $1 - get_local $0 - tee_local $2 + global.get $~lib/allocator/arena/offset + local.set $1 + local.get $1 + local.get $0 + local.tee $2 i32.const 1 - tee_local $3 - get_local $2 - get_local $3 + local.tee $3 + local.get $2 + local.get $3 i32.gt_u select i32.add - get_global $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - get_global $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and - set_local $4 + local.set $4 current_memory - set_local $5 - get_local $4 - get_local $5 + local.set $5 + local.get $4 + local.get $5 i32.const 16 i32.shl i32.gt_u if - get_local $4 - get_local $1 + local.get $4 + local.get $1 i32.sub i32.const 65535 i32.add @@ -88,22 +171,22 @@ i32.and i32.const 16 i32.shr_u - set_local $2 - get_local $5 - tee_local $3 - get_local $2 - tee_local $6 - get_local $3 - get_local $6 + local.set $2 + local.get $5 + local.tee $3 + local.get $2 + local.tee $6 + local.get $3 + local.get $6 i32.gt_s select - set_local $3 - get_local $3 + local.set $3 + local.get $3 grow_memory i32.const 0 i32.lt_s if - get_local $2 + local.get $2 grow_memory i32.const 0 i32.lt_s @@ -112,53 +195,136 @@ end end end - get_local $4 - set_global $~lib/allocator/arena/offset - get_local $1 + local.get $4 + global.set $~lib/allocator/arena/offset + local.get $1 ) - (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) - get_local $0 + (func $~lib/memory/memory.allocate (; 7 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $assembly/index/Body#constructor (; 3 ;) (type $iFFFFFFFi) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (param $7 f64) (result i32) - (local $8 i32) - get_local $0 - if (result i32) - get_local $0 - else - block (result i32) - i32.const 56 - call $~lib/memory/memory.allocate - set_local $8 - get_local $8 - get_local $1 - f64.store - get_local $8 - get_local $2 - f64.store offset=8 - get_local $8 - get_local $3 - f64.store offset=16 - get_local $8 - get_local $4 - f64.store offset=24 - get_local $8 - get_local $5 - f64.store offset=32 - get_local $8 - get_local $6 - f64.store offset=40 - get_local $8 - get_local $7 - f64.store offset=48 - get_local $8 + (func $assembly/index/NBodySystem#constructor (; 8 ;) (type $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 + block $~lib/array/Array#get:length|inlined.0 (result i32) + local.get $1 + local.set $5 + local.get $5 + i32.load offset=4 + end + local.set $6 + block $break|0 + i32.const 0 + local.set $5 + loop $repeat|0 + local.get $5 + local.get $6 + i32.lt_s + i32.eqz + br_if $break|0 + block + local.get $1 + local.get $5 + call $~lib/array/Array#__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 $5 + i32.const 1 + i32.add + local.set $5 + br $repeat|0 + unreachable end - tee_local $0 + unreachable end - tee_local $0 + local.get $1 + i32.const 0 + call $~lib/array/Array#__get + local.get $2 + local.get $3 + local.get $4 + call $assembly/index/Body#offsetMomentum + drop + local.get $0 + i32.eqz + if + i32.const 4 + call $~lib/memory/memory.allocate + local.set $0 + end + local.get $0 + local.get $1 + i32.store + local.get $0 ) - (func $assembly/index/Sun (; 4 ;) (type $i) (result i32) + (func $assembly/index/Body#constructor (; 9 ;) (type $iFFFFFFFi) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 f64) (param $6 f64) (param $7 f64) (result i32) + local.get $0 + i32.eqz + if + i32.const 56 + call $~lib/memory/memory.allocate + 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 (; 10 ;) (type $i) (result i32) i32.const 0 f64.const 0 f64.const 0 @@ -166,90 +332,90 @@ f64.const 0 f64.const 0 f64.const 0 - get_global $assembly/index/SOLAR_MASS + global.get $assembly/index/SOLAR_MASS call $assembly/index/Body#constructor ) - (func $assembly/index/Jupiter (; 5 ;) (type $i) (result i32) + (func $assembly/index/Jupiter (; 11 ;) (type $i) (result i32) i32.const 0 f64.const 4.841431442464721 f64.const -1.1603200440274284 f64.const -0.10362204447112311 f64.const 0.001660076642744037 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 0.007699011184197404 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const -6.90460016972063e-05 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 9.547919384243266e-04 - get_global $assembly/index/SOLAR_MASS + global.get $assembly/index/SOLAR_MASS f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/Saturn (; 6 ;) (type $i) (result i32) + (func $assembly/index/Saturn (; 12 ;) (type $i) (result i32) i32.const 0 f64.const 8.34336671824458 f64.const 4.124798564124305 f64.const -0.4035234171143214 f64.const -0.002767425107268624 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 0.004998528012349172 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 2.3041729757376393e-05 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 2.858859806661308e-04 - get_global $assembly/index/SOLAR_MASS + global.get $assembly/index/SOLAR_MASS f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/Uranus (; 7 ;) (type $i) (result i32) + (func $assembly/index/Uranus (; 13 ;) (type $i) (result i32) i32.const 0 f64.const 12.894369562139131 f64.const -15.111151401698631 f64.const -0.22330757889265573 f64.const 0.002964601375647616 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 2.3784717395948095e-03 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const -2.9658956854023756e-05 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 4.366244043351563e-05 - get_global $assembly/index/SOLAR_MASS + global.get $assembly/index/SOLAR_MASS f64.mul call $assembly/index/Body#constructor ) - (func $assembly/index/Neptune (; 8 ;) (type $i) (result i32) + (func $assembly/index/Neptune (; 14 ;) (type $i) (result i32) i32.const 0 f64.const 15.379697114850917 f64.const -25.919314609987964 f64.const 0.17925877295037118 f64.const 2.6806777249038932e-03 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 0.001628241700382423 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const -9.515922545197159e-05 - get_global $assembly/index/DAYS_PER_YEAR + global.get $assembly/index/DAYS_PER_YEAR f64.mul f64.const 5.1513890204661145e-05 - get_global $assembly/index/SOLAR_MASS + global.get $assembly/index/SOLAR_MASS f64.mul call $assembly/index/Body#constructor ) - (func $~lib/internal/arraybuffer/computeSize (; 9 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 15 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 - get_local $0 - get_global $~lib/internal/arraybuffer/HEADER_SIZE + local.get $0 + i32.const 8 i32.add i32.const 1 i32.sub @@ -257,11 +423,11 @@ i32.sub i32.shl ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 16 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - get_local $0 - get_global $~lib/internal/arraybuffer/MAX_BLENGTH + local.get $0 + i32.const 1073741816 i32.le_u i32.eqz if @@ -273,279 +439,280 @@ unreachable end block $~lib/memory/memory.allocate|inlined.0 (result i32) - get_local $0 + local.get $0 call $~lib/internal/arraybuffer/computeSize - set_local $2 - get_local $2 + local.set $2 + local.get $2 call $~lib/allocator/arena/__memory_allocate br $~lib/memory/memory.allocate|inlined.0 end - set_local $1 - get_local $1 - get_local $0 + local.set $1 + local.get $1 + local.get $0 i32.store - get_local $1 + local.get $1 ) - (func $~lib/internal/memory/memset (; 11 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 17 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) - get_local $2 + local.get $2 i32.eqz if return end - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.store8 - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 1 i32.sub - get_local $1 + local.get $1 i32.store8 - get_local $2 + local.get $2 i32.const 2 i32.le_u if return end - get_local $0 + local.get $0 i32.const 1 i32.add - get_local $1 + local.get $1 i32.store8 - get_local $0 + local.get $0 i32.const 2 i32.add - get_local $1 + local.get $1 i32.store8 - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 2 i32.sub - get_local $1 + local.get $1 i32.store8 - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 3 i32.sub - get_local $1 + local.get $1 i32.store8 - get_local $2 + local.get $2 i32.const 6 i32.le_u if return end - get_local $0 + local.get $0 i32.const 3 i32.add - get_local $1 + local.get $1 i32.store8 - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 4 i32.sub - get_local $1 + local.get $1 i32.store8 - get_local $2 + local.get $2 i32.const 8 i32.le_u if return end i32.const 0 - get_local $0 + local.get $0 i32.sub i32.const 3 i32.and - set_local $3 - get_local $0 - get_local $3 + local.set $3 + local.get $0 + local.get $3 i32.add - set_local $0 - get_local $2 - get_local $3 + local.set $0 + local.get $2 + local.get $3 i32.sub - set_local $2 - get_local $2 + local.set $2 + local.get $2 i32.const -4 i32.and - set_local $2 + local.set $2 i32.const -1 i32.const 255 i32.div_u - get_local $1 + local.get $1 i32.const 255 i32.and i32.mul - set_local $4 - get_local $0 - get_local $4 + local.set $4 + local.get $0 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 4 i32.sub - get_local $4 + local.get $4 i32.store - get_local $2 + local.get $2 i32.const 8 i32.le_u if return end - get_local $0 + local.get $0 i32.const 4 i32.add - get_local $4 + local.get $4 i32.store - get_local $0 + local.get $0 i32.const 8 i32.add - get_local $4 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 12 i32.sub - get_local $4 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 8 i32.sub - get_local $4 + local.get $4 i32.store - get_local $2 + local.get $2 i32.const 24 i32.le_u if return end - get_local $0 + local.get $0 i32.const 12 i32.add - get_local $4 + local.get $4 i32.store - get_local $0 + local.get $0 i32.const 16 i32.add - get_local $4 + local.get $4 i32.store - get_local $0 + local.get $0 i32.const 20 i32.add - get_local $4 + local.get $4 i32.store - get_local $0 + local.get $0 i32.const 24 i32.add - get_local $4 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 28 i32.sub - get_local $4 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 24 i32.sub - get_local $4 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 20 i32.sub - get_local $4 + local.get $4 i32.store - get_local $0 - get_local $2 + local.get $0 + local.get $2 i32.add i32.const 16 i32.sub - get_local $4 + local.get $4 i32.store i32.const 24 - get_local $0 + local.get $0 i32.const 4 i32.and i32.add - set_local $3 - get_local $0 - get_local $3 + local.set $3 + local.get $0 + local.get $3 i32.add - set_local $0 - get_local $2 - get_local $3 + local.set $0 + local.get $2 + local.get $3 i32.sub - set_local $2 - get_local $4 - i64.extend_u/i32 - get_local $4 - i64.extend_u/i32 + local.set $2 + local.get $4 + i64.extend_i32_u + local.get $4 + i64.extend_i32_u i64.const 32 i64.shl i64.or - set_local $5 + local.set $5 block $break|0 loop $continue|0 - get_local $2 + local.get $2 i32.const 32 i32.ge_u if block - get_local $0 - get_local $5 + local.get $0 + local.get $5 i64.store - get_local $0 + local.get $0 i32.const 8 i32.add - get_local $5 + local.get $5 i64.store - get_local $0 + local.get $0 i32.const 16 i32.add - get_local $5 + local.get $5 i64.store - get_local $0 + local.get $0 i32.const 24 i32.add - get_local $5 + local.get $5 i64.store - get_local $2 + local.get $2 i32.const 32 i32.sub - set_local $2 - get_local $0 + local.set $2 + local.get $0 i32.const 32 i32.add - set_local $0 + local.set $0 end br $continue|0 end end end ) - (func $~lib/array/Array#constructor (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - get_local $1 + (local $6 i32) + local.get $1 i32.const 268435454 i32.gt_u if @@ -556,258 +723,108 @@ call $~lib/env/abort unreachable end - get_local $1 + local.get $1 i32.const 2 i32.shl - set_local $2 - get_local $2 + local.set $2 + local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe - set_local $3 - get_local $0 - if (result i32) - get_local $0 - else - block (result i32) + local.set $3 + block (result i32) + local.get $0 + i32.eqz + if i32.const 8 call $~lib/memory/memory.allocate - set_local $4 - get_local $4 - i32.const 0 - i32.store - get_local $4 - i32.const 0 - i32.store offset=4 - get_local $4 + local.set $0 end - tee_local $0 + local.get $0 + i32.const 0 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 end - tee_local $0 - get_local $3 + local.get $3 i32.store - get_local $0 - get_local $1 + local.get $0 + local.get $1 i32.store offset=4 - get_local $3 - get_global $~lib/internal/arraybuffer/HEADER_SIZE - i32.add - set_local $4 - i32.const 0 - set_local $5 - get_local $4 - get_local $5 - get_local $2 - call $~lib/internal/memory/memset - get_local $0 + block $~lib/memory/memory.fill|inlined.0 + local.get $3 + i32.const 8 + i32.add + local.set $4 + i32.const 0 + local.set $5 + local.get $2 + local.set $6 + local.get $4 + local.get $5 + local.get $6 + call $~lib/internal/memory/memset + end + local.get $0 ) - (func $~lib/array/Array#__unchecked_set (; 13 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__unchecked_set (; 19 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) - get_local $0 + (local $5 i32) + (local $6 i32) + local.get $0 i32.load - set_local $3 + local.set $3 + local.get $1 + local.set $4 + local.get $2 + local.set $5 i32.const 0 - set_local $4 - get_local $3 - get_local $1 + local.set $6 + local.get $3 + local.get $4 i32.const 2 i32.shl i32.add - get_local $4 + local.get $6 i32.add - get_local $2 + local.get $5 i32.store offset=8 ) - (func $~lib/array/Array#__unchecked_get (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - get_local $0 - i32.load - set_local $2 - i32.const 0 - set_local $3 - get_local $2 - get_local $1 - i32.const 2 - i32.shl - i32.add - get_local $3 - i32.add - i32.load offset=8 - ) - (func $~lib/array/Array#__get (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - get_local $0 - i32.load - set_local $2 - get_local $1 - get_local $2 - i32.load - i32.const 2 - i32.shr_u - i32.lt_u - if (result i32) - i32.const 0 - set_local $3 - get_local $2 - get_local $1 - i32.const 2 - i32.shl - i32.add - get_local $3 - i32.add - i32.load offset=8 - else - unreachable - end - ) - (func $assembly/index/Body#offsetMomentum (; 16 ;) (type $iFFFi) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f64) (result i32) - get_local $0 - get_local $1 - f64.neg - get_global $assembly/index/SOLAR_MASS - f64.div - f64.store offset=24 - get_local $0 - get_local $2 - f64.neg - get_global $assembly/index/SOLAR_MASS - f64.div - f64.store offset=32 - get_local $0 - get_local $3 - f64.neg - get_global $assembly/index/SOLAR_MASS - f64.div - f64.store offset=40 - get_local $0 - ) - (func $assembly/index/NBodySystem#constructor (; 17 ;) (type $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 - set_local $2 - f64.const 0 - set_local $3 - f64.const 0 - set_local $4 - block $~lib/array/Array#get:length|inlined.0 (result i32) - get_local $1 - i32.load offset=4 - end - set_local $5 - block $break|0 - i32.const 0 - set_local $6 - loop $repeat|0 - get_local $6 - get_local $5 - i32.lt_s - i32.eqz - br_if $break|0 - block - get_local $1 - get_local $6 - call $~lib/array/Array#__unchecked_get - set_local $7 - get_local $7 - f64.load offset=48 - set_local $8 - get_local $2 - get_local $7 - f64.load offset=24 - get_local $8 - f64.mul - f64.add - set_local $2 - get_local $3 - get_local $7 - f64.load offset=32 - get_local $8 - f64.mul - f64.add - set_local $3 - get_local $4 - get_local $7 - f64.load offset=40 - get_local $8 - f64.mul - f64.add - set_local $4 - end - get_local $6 - i32.const 1 - i32.add - set_local $6 - br $repeat|0 - unreachable - end - unreachable - end - get_local $1 - i32.const 0 - call $~lib/array/Array#__get - get_local $2 - get_local $3 - get_local $4 - call $assembly/index/Body#offsetMomentum - drop - get_local $0 - if (result i32) - get_local $0 - else - block (result i32) - i32.const 4 - call $~lib/memory/memory.allocate - set_local $6 - get_local $6 - get_local $1 - i32.store - get_local $6 - end - tee_local $0 - end - tee_local $0 - ) - (func $assembly/index/init (; 18 ;) (type $v) + (func $assembly/index/init (; 20 ;) (type $_) (local $0 i32) i32.const 0 block (result i32) i32.const 0 i32.const 5 call $~lib/array/Array#constructor - set_local $0 - get_local $0 + local.set $0 + local.get $0 i32.const 0 call $assembly/index/Sun call $~lib/array/Array#__unchecked_set - get_local $0 + local.get $0 i32.const 1 call $assembly/index/Jupiter call $~lib/array/Array#__unchecked_set - get_local $0 + local.get $0 i32.const 2 call $assembly/index/Saturn call $~lib/array/Array#__unchecked_set - get_local $0 + local.get $0 i32.const 3 call $assembly/index/Uranus call $~lib/array/Array#__unchecked_set - get_local $0 + local.get $0 i32.const 4 call $assembly/index/Neptune call $~lib/array/Array#__unchecked_set - get_local $0 + local.get $0 end call $assembly/index/NBodySystem#constructor - set_global $assembly/index/system + global.set $assembly/index/system ) - (func $assembly/index/NBodySystem#advance (; 19 ;) (type $iFv) (param $0 i32) (param $1 f64) + (func $assembly/index/NBodySystem#advance (; 21 ;) (type $iF_) (param $0 i32) (param $1 f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -829,209 +846,213 @@ (local $20 f64) (local $21 f64) (local $22 f64) - get_local $0 + local.get $0 i32.load - set_local $2 + local.set $2 block $~lib/array/Array#get:length|inlined.1 (result i32) - get_local $2 + local.get $2 + local.set $3 + local.get $3 i32.load offset=4 end - set_local $3 + local.set $4 block $break|0 i32.const 0 - set_local $4 + local.set $3 loop $repeat|0 - get_local $4 - get_local $3 + local.get $3 + local.get $4 i32.lt_u i32.eqz br_if $break|0 block - get_local $2 - get_local $4 + local.get $2 + local.get $3 call $~lib/array/Array#__unchecked_get - set_local $5 - get_local $5 + local.set $5 + local.get $5 f64.load - set_local $6 - get_local $5 + local.set $6 + local.get $5 f64.load offset=8 - set_local $7 - get_local $5 + local.set $7 + local.get $5 f64.load offset=16 - set_local $8 - get_local $5 + local.set $8 + local.get $5 f64.load offset=24 - set_local $9 - get_local $5 + local.set $9 + local.get $5 f64.load offset=32 - set_local $10 - get_local $5 + local.set $10 + local.get $5 f64.load offset=40 - set_local $11 - get_local $5 + local.set $11 + local.get $5 f64.load offset=48 - set_local $12 + local.set $12 block $break|1 - get_local $4 + local.get $3 i32.const 1 i32.add - set_local $13 + local.set $13 loop $repeat|1 - get_local $13 - get_local $3 + local.get $13 + local.get $4 i32.lt_u i32.eqz br_if $break|1 block - get_local $2 - get_local $13 + local.get $2 + local.get $13 call $~lib/array/Array#__unchecked_get - set_local $14 - get_local $6 - get_local $14 + local.set $14 + local.get $6 + local.get $14 f64.load f64.sub - set_local $15 - get_local $7 - get_local $14 + local.set $15 + local.get $7 + local.get $14 f64.load offset=8 f64.sub - set_local $16 - get_local $8 - get_local $14 + local.set $16 + local.get $8 + local.get $14 f64.load offset=16 f64.sub - set_local $17 - get_local $15 - get_local $15 + local.set $17 + local.get $15 + local.get $15 f64.mul - get_local $16 - get_local $16 + local.get $16 + local.get $16 f64.mul f64.add - get_local $17 - get_local $17 + local.get $17 + local.get $17 f64.mul f64.add - set_local $18 + local.set $18 block $~lib/math/NativeMath.sqrt|inlined.0 (result f64) - get_local $18 + local.get $18 + local.set $19 + local.get $19 f64.sqrt end - set_local $19 - get_local $1 - get_local $18 - get_local $19 + local.set $19 + local.get $1 + local.get $18 + local.get $19 f64.mul f64.div - set_local $20 - get_local $12 - get_local $20 + local.set $20 + local.get $12 + local.get $20 f64.mul - set_local $21 - get_local $14 + local.set $21 + local.get $14 f64.load offset=48 - get_local $20 + local.get $20 f64.mul - set_local $22 - get_local $9 - get_local $15 - get_local $22 + local.set $22 + local.get $9 + local.get $15 + local.get $22 f64.mul f64.sub - set_local $9 - get_local $10 - get_local $16 - get_local $22 + local.set $9 + local.get $10 + local.get $16 + local.get $22 f64.mul f64.sub - set_local $10 - get_local $11 - get_local $17 - get_local $22 + local.set $10 + local.get $11 + local.get $17 + local.get $22 f64.mul f64.sub - set_local $11 - get_local $14 - get_local $14 + local.set $11 + local.get $14 + local.get $14 f64.load offset=24 - get_local $15 - get_local $21 + local.get $15 + local.get $21 f64.mul f64.add f64.store offset=24 - get_local $14 - get_local $14 + local.get $14 + local.get $14 f64.load offset=32 - get_local $16 - get_local $21 + local.get $16 + local.get $21 f64.mul f64.add f64.store offset=32 - get_local $14 - get_local $14 + local.get $14 + local.get $14 f64.load offset=40 - get_local $17 - get_local $21 + local.get $17 + local.get $21 f64.mul f64.add f64.store offset=40 end - get_local $13 + local.get $13 i32.const 1 i32.add - set_local $13 + local.set $13 br $repeat|1 unreachable end unreachable end - get_local $5 - get_local $9 + local.get $5 + local.get $9 f64.store offset=24 - get_local $5 - get_local $10 + local.get $5 + local.get $10 f64.store offset=32 - get_local $5 - get_local $11 + local.get $5 + local.get $11 f64.store offset=40 - get_local $5 - get_local $5 + local.get $5 + local.get $5 f64.load - get_local $1 - get_local $9 + local.get $1 + local.get $9 f64.mul f64.add f64.store - get_local $5 - get_local $5 + local.get $5 + local.get $5 f64.load offset=8 - get_local $1 - get_local $10 + local.get $1 + local.get $10 f64.mul f64.add f64.store offset=8 - get_local $5 - get_local $5 + local.get $5 + local.get $5 f64.load offset=16 - get_local $1 - get_local $11 + local.get $1 + local.get $11 f64.mul f64.add f64.store offset=16 end - get_local $4 + local.get $3 i32.const 1 i32.add - set_local $4 + local.set $3 br $repeat|0 unreachable end unreachable end ) - (func $assembly/index/NBodySystem#energy (; 20 ;) (type $iF) (param $0 i32) (result f64) + (func $assembly/index/NBodySystem#energy (; 22 ;) (type $iF) (param $0 i32) (result f64) (local $1 f64) (local $2 i32) (local $3 i32) @@ -1051,212 +1072,207 @@ (local $17 f64) (local $18 f64) f64.const 0 - set_local $1 - get_local $0 + local.set $1 + local.get $0 i32.load - set_local $2 + local.set $2 block $break|0 block i32.const 0 - set_local $3 + local.set $3 block $~lib/array/Array#get:length|inlined.2 (result i32) - get_local $2 + local.get $2 + local.set $4 + local.get $4 i32.load offset=4 end - set_local $4 + local.set $4 end loop $repeat|0 - get_local $3 - get_local $4 + local.get $3 + local.get $4 i32.lt_u i32.eqz br_if $break|0 block - get_local $2 - get_local $3 + local.get $2 + local.get $3 call $~lib/array/Array#__unchecked_get - set_local $5 - get_local $5 + local.set $5 + local.get $5 f64.load - set_local $6 - get_local $5 + local.set $6 + local.get $5 f64.load offset=8 - set_local $7 - get_local $5 + local.set $7 + local.get $5 f64.load offset=16 - set_local $8 - get_local $5 + local.set $8 + local.get $5 f64.load offset=24 - set_local $9 - get_local $5 + local.set $9 + local.get $5 f64.load offset=32 - set_local $10 - get_local $5 + local.set $10 + local.get $5 f64.load offset=40 - set_local $11 - get_local $5 + local.set $11 + local.get $5 f64.load offset=48 - set_local $12 - get_local $1 + local.set $12 + local.get $1 f64.const 0.5 - get_local $12 + local.get $12 f64.mul - get_local $9 - get_local $9 + local.get $9 + local.get $9 f64.mul - get_local $10 - get_local $10 + local.get $10 + local.get $10 f64.mul f64.add - get_local $11 - get_local $11 + local.get $11 + local.get $11 f64.mul f64.add f64.mul f64.add - set_local $1 + local.set $1 block $break|1 - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $13 + local.set $13 loop $repeat|1 - get_local $13 - get_local $4 + local.get $13 + local.get $4 i32.lt_u i32.eqz br_if $break|1 block - get_local $2 - get_local $13 + local.get $2 + local.get $13 call $~lib/array/Array#__unchecked_get - set_local $14 - get_local $6 - get_local $14 + local.set $14 + local.get $6 + local.get $14 f64.load f64.sub - set_local $15 - get_local $7 - get_local $14 + local.set $15 + local.get $7 + local.get $14 f64.load offset=8 f64.sub - set_local $16 - get_local $8 - get_local $14 + local.set $16 + local.get $8 + local.get $14 f64.load offset=16 f64.sub - set_local $17 + local.set $17 block $~lib/math/NativeMath.sqrt|inlined.1 (result f64) - get_local $15 - get_local $15 + local.get $15 + local.get $15 f64.mul - get_local $16 - get_local $16 + local.get $16 + local.get $16 f64.mul f64.add - get_local $17 - get_local $17 + local.get $17 + local.get $17 f64.mul f64.add - set_local $18 - get_local $18 + local.set $18 + local.get $18 f64.sqrt end - set_local $18 - get_local $1 - get_local $12 - get_local $14 + local.set $18 + local.get $1 + local.get $12 + local.get $14 f64.load offset=48 f64.mul - get_local $18 + local.get $18 f64.div f64.sub - set_local $1 + local.set $1 end - get_local $13 + local.get $13 i32.const 1 i32.add - set_local $13 + local.set $13 br $repeat|1 unreachable end unreachable end end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|0 unreachable end unreachable end - get_local $1 + local.get $1 ) - (func $assembly/index/step (; 21 ;) (type $F) (result f64) - get_global $assembly/index/system + (func $assembly/index/step (; 23 ;) (type $F) (result f64) + global.get $assembly/index/system f64.const 0.01 call $assembly/index/NBodySystem#advance - get_global $assembly/index/system + global.get $assembly/index/system call $assembly/index/NBodySystem#energy ) - (func $assembly/index/bench (; 22 ;) (type $iv) (param $0 i32) + (func $assembly/index/bench (; 24 ;) (type $i_) (param $0 i32) (local $1 i32) block $break|0 i32.const 0 - set_local $1 + local.set $1 loop $repeat|0 - get_local $1 - get_local $0 + local.get $1 + local.get $0 i32.lt_u i32.eqz br_if $break|0 - get_global $assembly/index/system + global.get $assembly/index/system f64.const 0.01 call $assembly/index/NBodySystem#advance - get_local $1 + local.get $1 i32.const 1 i32.add - set_local $1 + local.set $1 br $repeat|0 unreachable end unreachable end ) - (func $assembly/index/getBody (; 23 ;) (type $ii) (param $0 i32) (result i32) + (func $assembly/index/getBody (; 25 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - get_global $assembly/index/system + (local $2 i32) + global.get $assembly/index/system i32.load - set_local $1 - get_local $0 + local.set $1 + local.get $0 block $~lib/array/Array#get:length|inlined.4 (result i32) - get_local $1 + local.get $1 + local.set $2 + local.get $2 i32.load offset=4 end i32.lt_u if (result i32) - get_local $1 - get_local $0 + local.get $1 + local.get $0 call $~lib/array/Array#__get else i32.const 0 end ) - (func $start (; 24 ;) (type $v) - get_global $HEAP_BASE - get_global $~lib/internal/allocator/AL_MASK - i32.add - get_global $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - set_global $~lib/allocator/arena/startOffset - get_global $~lib/allocator/arena/startOffset - set_global $~lib/allocator/arena/offset - nop + (func $start (; 26 ;) (type $_) + call $start:assembly/index ) - (func $null (; 25 ;) (type $v) + (func $null (; 27 ;) (type $_) ) ) diff --git a/examples/pson/build/optimized.wat b/examples/pson/build/optimized.wat index dc8e49aa72..daac220ae9 100644 --- a/examples/pson/build/optimized.wat +++ b/examples/pson/build/optimized.wat @@ -1,9 +1,9 @@ (module - (type $v (func)) - (type $iv (func (param i32))) - (type $iiv (func (param i32 i32))) - (type $fv (func (param f32))) - (type $Fv (func (param f64))) + (type $_ (func)) + (type $i_ (func (param i32))) + (type $ii_ (func (param i32 i32))) + (type $f_ (func (param f32))) + (type $F_ (func (param f64))) (type $i (func (result i32))) (type $I (func (result i64))) (import "pson" "onNull" (func $assembly/pson/onNull)) @@ -21,7 +21,7 @@ (import "pson" "onString" (func $assembly/pson/onString (param i32 i32))) (import "pson" "onBinary" (func $assembly/pson/onBinary (param i32 i32))) (memory $0 0) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/pson/offset (mut i32) (i32.const 0)) (export "memory" (memory $0)) @@ -47,36 +47,36 @@ (local $2 i32) (local $3 i32) loop $continue|0 - get_global $assembly/pson/offset - tee_local $1 + global.get $assembly/pson/offset + local.tee $1 i32.const 1 i32.add - set_global $assembly/pson/offset - get_local $0 - get_local $1 + global.set $assembly/pson/offset + local.get $0 + local.get $1 i32.load8_u - tee_local $3 + local.tee $3 i32.const 127 i32.and block (result i32) - get_local $2 - tee_local $1 + local.get $2 + local.tee $1 i32.const 1 i32.add - set_local $2 - get_local $1 + local.set $2 + local.get $1 i32.const 7 i32.mul end i32.shl i32.or - set_local $0 - get_local $3 + local.set $0 + local.get $3 i32.const 128 i32.and br_if $continue|0 end - get_local $0 + local.get $0 ) (func $assembly/pson/readVarint64 (; 15 ;) (type $I) (result i64) (local $0 i64) @@ -84,41 +84,46 @@ (local $2 i64) (local $3 i64) loop $continue|0 - get_global $assembly/pson/offset - tee_local $1 + global.get $assembly/pson/offset + local.tee $1 i32.const 1 i32.add - set_global $assembly/pson/offset - get_local $2 - tee_local $3 + global.set $assembly/pson/offset + local.get $2 + local.tee $3 i64.const 1 i64.add - set_local $2 - get_local $0 - get_local $1 + local.set $2 + local.get $0 + local.get $1 i32.load8_u - tee_local $1 + local.tee $1 i32.const 127 i32.and - i64.extend_u/i32 - get_local $3 + i64.extend_i32_u + local.get $3 i64.const 7 i64.mul i64.shl i64.or - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.const 128 i32.and br_if $continue|0 end - get_local $0 + local.get $0 ) - (func $assembly/pson/decodeValue (; 16 ;) (type $v) + (func $assembly/pson/decodeValue (; 16 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i64) block $break|0 + global.get $assembly/pson/offset + local.tee $1 + i32.const 1 + i32.add + global.set $assembly/pson/offset block $case16|0 block $case15|0 block $case14|0 @@ -134,77 +139,25 @@ block $case3|0 block $case2|0 block $case1|0 - block (result i32) - get_global $assembly/pson/offset - tee_local $0 - i32.const 1 - i32.add - set_global $assembly/pson/offset - get_local $0 - i32.load8_u - tee_local $1 - tee_local $0 - i32.const 240 - i32.ne - end - if - get_local $0 - i32.const 241 - i32.eq - br_if $case1|0 - get_local $0 - i32.const 242 - i32.eq - br_if $case2|0 - get_local $0 - i32.const 243 - i32.eq - br_if $case3|0 - get_local $0 - i32.const 244 - i32.eq - br_if $case4|0 - get_local $0 - i32.const 245 - i32.eq - br_if $case5|0 - get_local $0 - i32.const 246 - i32.eq - br_if $case6|0 - get_local $0 - i32.const 247 - i32.eq - br_if $case7|0 - get_local $0 - i32.const 248 - i32.eq - br_if $case8|0 - get_local $0 - i32.const 249 - i32.eq - br_if $case9|0 - get_local $0 - i32.const 250 - i32.eq - br_if $case10|0 - get_local $0 - i32.const 251 - i32.eq - br_if $case11|0 - get_local $0 - i32.const 252 - i32.eq - br_if $case12|0 - get_local $0 + block $case0|0 + block $tablify|0 + local.get $1 + i32.load8_u + local.tee $0 + local.tee $1 + i32.const 240 + i32.sub + br_table $case0|0 $case1|0 $case2|0 $case3|0 $case4|0 $case5|0 $case6|0 $case7|0 $case8|0 $case9|0 $case10|0 $case11|0 $case12|0 $tablify|0 + end + local.get $1 i32.const 253 i32.eq - get_local $0 + local.get $1 i32.const 254 i32.eq i32.or br_if $case14|0 - get_local $0 + local.get $1 i32.const 255 i32.eq br_if $case15|0 @@ -229,16 +182,16 @@ br $break|0 end call $assembly/pson/readVarint32 - tee_local $1 + local.tee $0 call $assembly/pson/onObject loop $continue|1 block (result i32) - get_local $1 - tee_local $0 + local.get $0 + local.tee $1 i32.const 1 i32.sub - set_local $1 - get_local $0 + local.set $0 + local.get $1 end if call $assembly/pson/decodeValue @@ -249,16 +202,16 @@ br $break|0 end call $assembly/pson/readVarint32 - tee_local $1 + local.tee $0 call $assembly/pson/onArray loop $continue|2 block (result i32) - get_local $1 - tee_local $0 + local.get $0 + local.tee $1 i32.const 1 i32.sub - set_local $1 - get_local $0 + local.set $0 + local.get $1 end if call $assembly/pson/decodeValue @@ -268,11 +221,11 @@ br $break|0 end call $assembly/pson/readVarint32 - tee_local $1 + local.tee $0 i32.const 1 i32.shr_u i32.const 0 - get_local $1 + local.get $0 i32.const 1 i32.and i32.sub @@ -281,104 +234,104 @@ br $break|0 end call $assembly/pson/readVarint64 - tee_local $2 + local.tee $2 i64.const 1 i64.shr_u i64.const 0 - get_local $2 + local.get $2 i64.const 1 i64.and i64.sub i64.xor - tee_local $2 - i32.wrap/i64 - get_local $2 + local.tee $2 + i32.wrap_i64 + local.get $2 i64.const 32 i64.shr_u - i32.wrap/i64 + i32.wrap_i64 call $assembly/pson/onLong br $break|0 end - get_global $assembly/pson/offset + global.get $assembly/pson/offset f32.load call $assembly/pson/onFloat - get_global $assembly/pson/offset + global.get $assembly/pson/offset i32.const 4 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 end - get_global $assembly/pson/offset + global.get $assembly/pson/offset f64.load call $assembly/pson/onDouble - get_global $assembly/pson/offset + global.get $assembly/pson/offset i32.const 8 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 end call $assembly/pson/readVarint32 - set_local $1 - get_global $assembly/pson/offset - get_local $1 + local.set $0 + global.get $assembly/pson/offset + local.get $0 call $assembly/pson/onString - get_global $assembly/pson/offset - get_local $1 + global.get $assembly/pson/offset + local.get $0 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 end unreachable end call $assembly/pson/readVarint32 - set_local $1 - get_global $assembly/pson/offset - get_local $1 + local.set $0 + global.get $assembly/pson/offset + local.get $0 call $assembly/pson/onBinary - get_global $assembly/pson/offset - get_local $1 + global.get $assembly/pson/offset + local.get $0 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 end - get_local $1 + local.get $0 i32.const 239 i32.gt_u if unreachable end i32.const 0 - get_local $1 + local.get $0 i32.const 1 i32.and i32.sub - get_local $1 + local.get $0 i32.const 1 i32.shr_u i32.xor call $assembly/pson/onInteger end ) - (func $assembly/pson/decode (; 17 ;) (type $iv) (param $0 i32) + (func $assembly/pson/decode (; 17 ;) (type $i_) (param $0 i32) i32.const 0 - set_global $assembly/pson/offset + global.set $assembly/pson/offset loop $continue|0 - get_global $assembly/pson/offset - get_local $0 + global.get $assembly/pson/offset + local.get $0 i32.lt_u if call $assembly/pson/decodeValue br $continue|0 end end - get_global $assembly/pson/offset - get_local $0 + global.get $assembly/pson/offset + local.get $0 i32.ne if unreachable end ) - (func $null (; 18 ;) (type $v) + (func $null (; 18 ;) (type $_) nop ) ) diff --git a/examples/pson/build/untouched.wat b/examples/pson/build/untouched.wat index 5272f3551d..345b818a21 100644 --- a/examples/pson/build/untouched.wat +++ b/examples/pson/build/untouched.wat @@ -1,9 +1,9 @@ (module - (type $v (func)) - (type $iv (func (param i32))) - (type $iiv (func (param i32 i32))) - (type $fv (func (param f32))) - (type $Fv (func (param f64))) + (type $_ (func)) + (type $i_ (func (param i32))) + (type $ii_ (func (param i32 i32))) + (type $f_ (func (param f32))) + (type $F_ (func (param f64))) (type $i (func (result i32))) (type $I (func (result i64))) (import "pson" "onNull" (func $assembly/pson/onNull)) @@ -21,28 +21,10 @@ (import "pson" "onString" (func $assembly/pson/onString (param i32 i32))) (import "pson" "onBinary" (func $assembly/pson/onBinary (param i32 i32))) (memory $0 0) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) (global $assembly/pson/offset (mut i32) (i32.const 0)) - (global $assembly/pson/Token.ZERO i32 (i32.const 0)) - (global $assembly/pson/Token.MAX i32 (i32.const 239)) - (global $assembly/pson/Token.NULL i32 (i32.const 240)) - (global $assembly/pson/Token.TRUE i32 (i32.const 241)) - (global $assembly/pson/Token.FALSE i32 (i32.const 242)) - (global $assembly/pson/Token.EOBJECT i32 (i32.const 243)) - (global $assembly/pson/Token.EARRAY i32 (i32.const 244)) - (global $assembly/pson/Token.ESTRING i32 (i32.const 245)) - (global $assembly/pson/Token.OBJECT i32 (i32.const 246)) - (global $assembly/pson/Token.ARRAY i32 (i32.const 247)) - (global $assembly/pson/Token.INTEGER i32 (i32.const 248)) - (global $assembly/pson/Token.LONG i32 (i32.const 249)) - (global $assembly/pson/Token.FLOAT i32 (i32.const 250)) - (global $assembly/pson/Token.DOUBLE i32 (i32.const 251)) - (global $assembly/pson/Token.STRING i32 (i32.const 252)) - (global $assembly/pson/Token.STRING_ADD i32 (i32.const 253)) - (global $assembly/pson/Token.STRING_GET i32 (i32.const 254)) - (global $assembly/pson/Token.BINARY i32 (i32.const 255)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "onNull" (func $assembly/pson/onNull)) @@ -66,47 +48,47 @@ (local $2 i32) (local $3 i32) i32.const 0 - set_local $0 + local.set $0 i32.const 0 - set_local $1 + local.set $1 block $break|0 loop $continue|0 block block (result i32) - get_global $assembly/pson/offset - tee_local $3 + global.get $assembly/pson/offset + local.tee $3 i32.const 1 i32.add - set_global $assembly/pson/offset - get_local $3 + global.set $assembly/pson/offset + local.get $3 end i32.load8_u - set_local $2 - get_local $0 - get_local $2 + local.set $2 + local.get $0 + local.get $2 i32.const 127 i32.and i32.const 7 block (result i32) - get_local $1 - tee_local $3 + local.get $1 + local.tee $3 i32.const 1 i32.add - set_local $1 - get_local $3 + local.set $1 + local.get $3 end i32.mul i32.shl i32.or - set_local $0 + local.set $0 end - get_local $2 + local.get $2 i32.const 128 i32.and br_if $continue|0 end end - get_local $0 + local.get $0 ) (func $assembly/pson/readVarint64 (; 15 ;) (type $I) (result i64) (local $0 i64) @@ -115,64 +97,64 @@ (local $3 i32) (local $4 i64) i64.const 0 - set_local $0 + local.set $0 i64.const 0 - set_local $1 + local.set $1 block $break|0 loop $continue|0 block block (result i32) - get_global $assembly/pson/offset - tee_local $3 + global.get $assembly/pson/offset + local.tee $3 i32.const 1 i32.add - set_global $assembly/pson/offset - get_local $3 + global.set $assembly/pson/offset + local.get $3 end i32.load8_u - set_local $2 - get_local $0 - get_local $2 + local.set $2 + local.get $0 + local.get $2 i32.const 127 i32.and - i64.extend_u/i32 + i64.extend_i32_u i64.const 7 block (result i64) - get_local $1 - tee_local $4 + local.get $1 + local.tee $4 i64.const 1 i64.add - set_local $1 - get_local $4 + local.set $1 + local.get $4 end i64.mul i64.shl i64.or - set_local $0 + local.set $0 end - get_local $2 + local.get $2 i32.const 128 i32.and br_if $continue|0 end end - get_local $0 + local.get $0 ) - (func $assembly/pson/decodeValue (; 16 ;) (type $v) + (func $assembly/pson/decodeValue (; 16 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i64) block (result i32) - get_global $assembly/pson/offset - tee_local $0 + global.get $assembly/pson/offset + local.tee $0 i32.const 1 i32.add - set_global $assembly/pson/offset - get_local $0 + global.set $assembly/pson/offset + local.get $0 end i32.load8_u - set_local $1 + local.set $1 block $break|0 block $case16|0 block $case15|0 @@ -191,70 +173,70 @@ block $case2|0 block $case1|0 block $case0|0 - get_local $1 - set_local $0 - get_local $0 - get_global $assembly/pson/Token.NULL + local.get $1 + local.set $0 + local.get $0 + i32.const 240 i32.eq br_if $case0|0 - get_local $0 - get_global $assembly/pson/Token.TRUE + local.get $0 + i32.const 241 i32.eq br_if $case1|0 - get_local $0 - get_global $assembly/pson/Token.FALSE + local.get $0 + i32.const 242 i32.eq br_if $case2|0 - get_local $0 - get_global $assembly/pson/Token.EOBJECT + local.get $0 + i32.const 243 i32.eq br_if $case3|0 - get_local $0 - get_global $assembly/pson/Token.EARRAY + local.get $0 + i32.const 244 i32.eq br_if $case4|0 - get_local $0 - get_global $assembly/pson/Token.ESTRING + local.get $0 + i32.const 245 i32.eq br_if $case5|0 - get_local $0 - get_global $assembly/pson/Token.OBJECT + local.get $0 + i32.const 246 i32.eq br_if $case6|0 - get_local $0 - get_global $assembly/pson/Token.ARRAY + local.get $0 + i32.const 247 i32.eq br_if $case7|0 - get_local $0 - get_global $assembly/pson/Token.INTEGER + local.get $0 + i32.const 248 i32.eq br_if $case8|0 - get_local $0 - get_global $assembly/pson/Token.LONG + local.get $0 + i32.const 249 i32.eq br_if $case9|0 - get_local $0 - get_global $assembly/pson/Token.FLOAT + local.get $0 + i32.const 250 i32.eq br_if $case10|0 - get_local $0 - get_global $assembly/pson/Token.DOUBLE + local.get $0 + i32.const 251 i32.eq br_if $case11|0 - get_local $0 - get_global $assembly/pson/Token.STRING + local.get $0 + i32.const 252 i32.eq br_if $case12|0 - get_local $0 - get_global $assembly/pson/Token.STRING_ADD + local.get $0 + i32.const 253 i32.eq br_if $case13|0 - get_local $0 - get_global $assembly/pson/Token.STRING_GET + local.get $0 + i32.const 254 i32.eq br_if $case14|0 - get_local $0 - get_global $assembly/pson/Token.BINARY + local.get $0 + i32.const 255 i32.eq br_if $case15|0 br $case16|0 @@ -303,17 +285,17 @@ end block call $assembly/pson/readVarint32 - tee_local $2 + local.tee $2 call $assembly/pson/onObject block $break|1 loop $continue|1 block (result i32) - get_local $2 - tee_local $0 + local.get $2 + local.tee $0 i32.const 1 i32.sub - set_local $2 - get_local $0 + local.set $2 + local.get $0 end if block @@ -331,17 +313,17 @@ end block call $assembly/pson/readVarint32 - tee_local $2 + local.tee $2 call $assembly/pson/onArray block $break|2 loop $continue|2 block (result i32) - get_local $2 - tee_local $0 + local.get $2 + local.tee $0 i32.const 1 i32.sub - set_local $2 - get_local $0 + local.set $2 + local.get $0 end if call $assembly/pson/decodeValue @@ -356,11 +338,11 @@ end block call $assembly/pson/readVarint32 - tee_local $2 + local.tee $2 i32.const 1 i32.shr_u i32.const 0 - get_local $2 + local.get $2 i32.const 1 i32.and i32.sub @@ -373,22 +355,22 @@ end block call $assembly/pson/readVarint64 - tee_local $3 + local.tee $3 i64.const 1 i64.shr_u i64.const 0 - get_local $3 + local.get $3 i64.const 1 i64.and i64.sub i64.xor - set_local $3 - get_local $3 - i32.wrap/i64 - get_local $3 + local.set $3 + local.get $3 + i32.wrap_i64 + local.get $3 i64.const 32 i64.shr_u - i32.wrap/i64 + i32.wrap_i64 call $assembly/pson/onLong br $break|0 unreachable @@ -396,26 +378,26 @@ unreachable end block - get_global $assembly/pson/offset + global.get $assembly/pson/offset f32.load call $assembly/pson/onFloat - get_global $assembly/pson/offset + global.get $assembly/pson/offset i32.const 4 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 unreachable end unreachable end block - get_global $assembly/pson/offset + global.get $assembly/pson/offset f64.load call $assembly/pson/onDouble - get_global $assembly/pson/offset + global.get $assembly/pson/offset i32.const 8 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 unreachable end @@ -423,14 +405,14 @@ end block call $assembly/pson/readVarint32 - set_local $2 - get_global $assembly/pson/offset - get_local $2 + local.set $2 + global.get $assembly/pson/offset + local.get $2 call $assembly/pson/onString - get_global $assembly/pson/offset - get_local $2 + global.get $assembly/pson/offset + local.get $2 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 unreachable end @@ -446,31 +428,31 @@ end block call $assembly/pson/readVarint32 - set_local $2 - get_global $assembly/pson/offset - get_local $2 + local.set $2 + global.get $assembly/pson/offset + local.get $2 call $assembly/pson/onBinary - get_global $assembly/pson/offset - get_local $2 + global.get $assembly/pson/offset + local.get $2 i32.add - set_global $assembly/pson/offset + global.set $assembly/pson/offset br $break|0 unreachable end unreachable end block - get_local $1 - get_global $assembly/pson/Token.MAX + local.get $1 + i32.const 239 i32.gt_u if unreachable end - get_local $1 + local.get $1 i32.const 1 i32.shr_u i32.const 0 - get_local $1 + local.get $1 i32.const 1 i32.and i32.sub @@ -482,13 +464,13 @@ unreachable end ) - (func $assembly/pson/decode (; 17 ;) (type $iv) (param $0 i32) + (func $assembly/pson/decode (; 17 ;) (type $i_) (param $0 i32) i32.const 0 - set_global $assembly/pson/offset + global.set $assembly/pson/offset block $break|0 loop $continue|0 - get_global $assembly/pson/offset - get_local $0 + global.get $assembly/pson/offset + local.get $0 i32.lt_u if call $assembly/pson/decodeValue @@ -496,13 +478,13 @@ end end end - get_global $assembly/pson/offset - get_local $0 + global.get $assembly/pson/offset + local.get $0 i32.ne if unreachable end ) - (func $null (; 18 ;) (type $v) + (func $null (; 18 ;) (type $_) ) ) diff --git a/lib/parse/build/index.wat b/lib/parse/build/index.wat index 164090ef15..811a714b29 100644 --- a/lib/parse/build/index.wat +++ b/lib/parse/build/index.wat @@ -1,14 +1,14 @@ (module - (type $iiv (func (param i32 i32))) + (type $ii_ (func (param i32 i32))) (type $ii (func (param i32) (result i32))) (type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) - (type $iiiv (func (param i32 i32 i32))) - (type $iiiiiiv (func (param i32 i32 i32 i32 i32 i32))) - (type $iiiiiv (func (param i32 i32 i32 i32 i32))) - (type $iiiiv (func (param i32 i32 i32 i32))) - (type $v (func)) + (type $iii_ (func (param i32 i32 i32))) + (type $iiiiii_ (func (param i32 i32 i32 i32 i32 i32))) + (type $iiiii_ (func (param i32 i32 i32 i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) + (type $_ (func)) (type $I (func (result i64))) - (type $iv (func (param i32))) + (type $i_ (func (param i32))) (type $FUNCSIG$i (func (result i32))) (import "env" "memory" (memory $0 0)) (import "options" "onSection" (func $assembly/options/onSection (param i32 i32 i32 i32 i32) (result i32))) @@ -30,9 +30,8 @@ (import "options" "onFunctionName" (func $assembly/options/onFunctionName (param i32 i32 i32))) (import "options" "onLocalName" (func $assembly/options/onLocalName (param i32 i32 i32 i32))) (import "options" "onSourceMappingURL" (func $assembly/options/onSourceMappingURL (param i32 i32))) - (table $0 1 anyfunc) + (table $0 1 funcref) (elem (i32.const 0) $null) - (global $assembly/index/off (mut i32) (i32.const 0)) (global $src/common/SectionId.Custom (mut i32) (i32.const 0)) (global $src/common/SectionId.Type (mut i32) (i32.const 1)) (global $src/common/SectionId.Import (mut i32) (i32.const 2)) @@ -49,15 +48,16 @@ (global $src/common/ExternalKind.Table (mut i32) (i32.const 1)) (global $src/common/ExternalKind.Memory (mut i32) (i32.const 2)) (global $src/common/ExternalKind.Global (mut i32) (i32.const 3)) + (global $src/common/NameType.Module (mut i32) (i32.const 0)) + (global $src/common/NameType.Function (mut i32) (i32.const 1)) + (global $src/common/NameType.Local (mut i32) (i32.const 2)) (global $src/common/Opcode.end (mut i32) (i32.const 11)) (global $src/common/Opcode.get_global (mut i32) (i32.const 35)) (global $src/common/Opcode.i32_const (mut i32) (i32.const 65)) (global $src/common/Opcode.i64_const (mut i32) (i32.const 66)) (global $src/common/Opcode.f32_const (mut i32) (i32.const 67)) (global $src/common/Opcode.f64_const (mut i32) (i32.const 68)) - (global $src/common/NameType.Module (mut i32) (i32.const 0)) - (global $src/common/NameType.Function (mut i32) (i32.const 1)) - (global $src/common/NameType.Local (mut i32) (i32.const 2)) + (global $assembly/index/off (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "parse" (func $assembly/index/parse)) @@ -66,38 +66,38 @@ (local $1 i32) (local $2 i32) (local $3 i32) - get_global $assembly/index/off - set_local $0 + global.get $assembly/index/off + local.set $0 loop $continue|0 - get_local $0 - tee_local $1 + local.get $0 + local.tee $1 i32.const 1 i32.add - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.load8_u - tee_local $1 + local.tee $1 i32.const 127 i32.and - get_local $3 + local.get $3 i32.shl - get_local $2 + local.get $2 i32.or - set_local $2 - get_local $1 + local.set $2 + local.get $1 i32.const 128 i32.and if - get_local $3 + local.get $3 i32.const 7 i32.add - set_local $3 + local.set $3 br $continue|0 end end - get_local $0 - set_global $assembly/index/off - get_local $2 + local.get $0 + global.set $assembly/index/off + local.get $2 ) (func $assembly/index/readVarint (; 20 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) @@ -105,56 +105,56 @@ (local $3 i32) (local $4 i32) (local $5 i32) - get_global $assembly/index/off - set_local $2 + global.get $assembly/index/off + local.set $2 loop $continue|0 - get_local $2 - tee_local $4 + local.get $2 + local.tee $4 i32.const 1 i32.add - set_local $2 - get_local $4 + local.set $2 + local.get $4 i32.load8_u - tee_local $5 + local.tee $5 i32.const 127 i32.and - get_local $1 + local.get $1 i32.shl - get_local $3 + local.get $3 i32.or - set_local $3 - get_local $1 + local.set $3 + local.get $1 i32.const 7 i32.add - set_local $1 - get_local $5 + local.set $1 + local.get $5 i32.const 128 i32.and br_if $continue|0 end - get_local $2 - set_global $assembly/index/off + local.get $2 + global.set $assembly/index/off i32.const -1 - get_local $1 + local.get $1 i32.shl - get_local $3 + local.get $3 i32.or - set_local $2 - get_local $1 - get_local $0 + local.set $2 + local.get $1 + local.get $0 i32.lt_u - tee_local $4 + local.tee $4 if - get_local $5 + local.get $5 i32.const 64 i32.and i32.const 0 i32.ne - set_local $4 + local.set $4 end - get_local $2 - get_local $3 - get_local $4 + local.get $2 + local.get $3 + local.get $4 select ) (func $assembly/index/readVarint64 (; 21 ;) (type $I) (result i64) @@ -164,95 +164,95 @@ (local $3 i32) (local $4 i64) (local $5 i64) - get_global $assembly/index/off - set_local $3 + global.get $assembly/index/off + local.set $3 loop $continue|0 - get_local $3 - tee_local $2 + local.get $3 + local.tee $2 i32.const 1 i32.add - set_local $3 - get_local $2 + local.set $3 + local.get $2 i64.load8_u - tee_local $4 + local.tee $4 i64.const 127 i64.and - get_local $0 + local.get $0 i64.shl - get_local $1 + local.get $1 i64.or - set_local $1 - get_local $0 + local.set $1 + local.get $0 i64.const 7 i64.add - set_local $0 - get_local $4 + local.set $0 + local.get $4 i64.const 128 i64.and i64.const 0 i64.ne br_if $continue|0 end - get_local $3 - set_global $assembly/index/off + local.get $3 + global.set $assembly/index/off i64.const -1 - get_local $0 + local.get $0 i64.shl - get_local $1 + local.get $1 i64.or - set_local $5 - get_local $0 + local.set $5 + local.get $0 i64.const 64 i64.lt_u - tee_local $2 + local.tee $2 if - get_local $4 + local.get $4 i64.const 64 i64.and i64.const 0 i64.ne - set_local $2 + local.set $2 end - get_local $5 - get_local $1 - get_local $2 + local.get $5 + local.get $1 + local.get $2 select ) - (func $assembly/index/skipInitExpr (; 22 ;) (type $v) + (func $assembly/index/skipInitExpr (; 22 ;) (type $_) (local $0 i32) (local $1 i32) - get_global $assembly/index/off - tee_local $1 + global.get $assembly/index/off + local.tee $1 i32.load8_u - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.const 1 i32.add - set_global $assembly/index/off + global.set $assembly/index/off block $break|0 block $case5|0 block $case4|0 block $case3|0 block $case2|0 block $case1|0 - get_global $src/common/Opcode.i32_const - get_local $0 + global.get $src/common/Opcode.i32_const + local.get $0 i32.ne if - get_global $src/common/Opcode.i64_const - get_local $0 + global.get $src/common/Opcode.i64_const + local.get $0 i32.eq br_if $case1|0 - get_global $src/common/Opcode.f32_const - get_local $0 + global.get $src/common/Opcode.f32_const + local.get $0 i32.eq br_if $case2|0 - get_global $src/common/Opcode.f64_const - get_local $0 + global.get $src/common/Opcode.f64_const + local.get $0 i32.eq br_if $case3|0 - get_global $src/common/Opcode.get_global - get_local $0 + global.get $src/common/Opcode.get_global + local.get $0 i32.eq br_if $case4|0 br $case5|0 @@ -266,24 +266,24 @@ drop br $break|0 end - get_global $assembly/index/off - tee_local $0 + global.get $assembly/index/off + local.tee $0 i32.load drop - get_local $0 + local.get $0 i32.const 4 i32.add - set_global $assembly/index/off + global.set $assembly/index/off br $break|0 end - get_global $assembly/index/off - tee_local $0 + global.get $assembly/index/off + local.tee $0 i64.load drop - get_local $0 + local.get $0 i32.const 8 i32.add - set_global $assembly/index/off + global.set $assembly/index/off br $break|0 end call $assembly/index/readVaruint @@ -292,22 +292,22 @@ end unreachable end - get_global $assembly/index/off - tee_local $1 + global.get $assembly/index/off + local.tee $1 i32.load8_u - set_local $0 - get_local $1 + local.set $0 + local.get $1 i32.const 1 i32.add - set_global $assembly/index/off - get_global $src/common/Opcode.end - get_local $0 + global.set $assembly/index/off + global.get $src/common/Opcode.end + local.get $0 i32.ne if unreachable end ) - (func $assembly/index/parse (; 23 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $assembly/index/parse (; 23 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -321,79 +321,79 @@ (local $12 i32) (local $13 i32) (local $14 i32) - get_local $0 - set_global $assembly/index/off - get_global $assembly/index/off - tee_local $0 + local.get $0 + global.set $assembly/index/off + global.get $assembly/index/off + local.tee $0 i32.load - set_local $6 - get_local $0 + local.set $6 + local.get $0 i32.const 4 i32.add - set_global $assembly/index/off - get_local $6 + global.set $assembly/index/off + local.get $6 i32.const 1836278016 i32.ne if unreachable end - get_global $assembly/index/off - tee_local $0 + global.get $assembly/index/off + local.tee $0 i32.load - set_local $6 - get_local $0 + local.set $6 + local.get $0 i32.const 4 i32.add - set_global $assembly/index/off - get_local $6 + global.set $assembly/index/off + local.get $6 i32.const 1 i32.ne if unreachable end loop $continue|0 - get_global $assembly/index/off - get_local $1 + global.get $assembly/index/off + local.get $1 i32.lt_u if call $assembly/index/readVaruint - set_local $2 + local.set $2 call $assembly/index/readVaruint - set_local $8 + local.set $8 i32.const 0 - set_local $4 + local.set $4 i32.const 0 - set_local $0 - get_local $2 + local.set $0 + local.get $2 if - get_local $2 - get_global $src/common/SectionId.Data + local.get $2 + global.get $src/common/SectionId.Data i32.gt_u if unreachable end else - get_global $assembly/index/off - set_local $5 + global.get $assembly/index/off + local.set $5 call $assembly/index/readVaruint - tee_local $0 - get_global $assembly/index/off - tee_local $4 + local.tee $0 + global.get $assembly/index/off + local.tee $4 i32.add - set_global $assembly/index/off - get_local $8 - get_global $assembly/index/off - get_local $5 + global.set $assembly/index/off + local.get $8 + global.get $assembly/index/off + local.get $5 i32.sub i32.sub - set_local $8 + local.set $8 end - get_local $2 - get_global $assembly/index/off - tee_local $5 - get_local $8 - get_local $4 - get_local $0 + local.get $2 + global.get $assembly/index/off + local.tee $5 + local.get $8 + local.get $4 + local.get $0 call $assembly/options/onSection if block $break|1 @@ -407,194 +407,194 @@ block $case3|1 block $case2|1 block $case1|1 - get_global $src/common/SectionId.Type - get_local $2 + global.get $src/common/SectionId.Type + local.get $2 i32.ne if - get_global $src/common/SectionId.Import - get_local $2 + global.get $src/common/SectionId.Import + local.get $2 i32.eq br_if $case1|1 - get_global $src/common/SectionId.Function - get_local $2 + global.get $src/common/SectionId.Function + local.get $2 i32.eq br_if $case2|1 - get_global $src/common/SectionId.Table - get_local $2 + global.get $src/common/SectionId.Table + local.get $2 i32.eq br_if $case3|1 - get_global $src/common/SectionId.Memory - get_local $2 + global.get $src/common/SectionId.Memory + local.get $2 i32.eq br_if $case4|1 - get_global $src/common/SectionId.Global - get_local $2 + global.get $src/common/SectionId.Global + local.get $2 i32.eq br_if $case5|1 - get_global $src/common/SectionId.Export - get_local $2 + global.get $src/common/SectionId.Export + local.get $2 i32.eq br_if $case6|1 - get_global $src/common/SectionId.Start - get_local $2 + global.get $src/common/SectionId.Start + local.get $2 i32.eq br_if $case7|1 - get_global $src/common/SectionId.Custom - get_local $2 + global.get $src/common/SectionId.Custom + local.get $2 i32.eq br_if $case8|1 - get_global $src/common/SectionId.Element - get_local $2 + global.get $src/common/SectionId.Element + local.get $2 i32.eq br_if $case11|1 - get_global $src/common/SectionId.Code - get_local $2 + global.get $src/common/SectionId.Code + local.get $2 i32.eq br_if $case11|1 - get_global $src/common/SectionId.Data - get_local $2 + global.get $src/common/SectionId.Data + local.get $2 i32.eq br_if $case11|1 br $case12|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|2 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if - get_local $3 + local.get $3 i32.const 7 call $assembly/index/readVarint i32.const 127 i32.and call $assembly/options/onType call $assembly/index/readVaruint - set_local $5 + local.set $5 i32.const 0 - set_local $7 + local.set $7 loop $repeat|3 - get_local $7 - get_local $5 + local.get $7 + local.get $5 i32.lt_u if - get_local $3 - get_local $7 + local.get $3 + local.get $7 i32.const 7 call $assembly/index/readVarint i32.const 127 i32.and call $assembly/options/onTypeParam - get_local $7 + local.get $7 i32.const 1 i32.add - set_local $7 + local.set $7 br $repeat|3 end end call $assembly/index/readVaruint - set_local $7 + local.set $7 i32.const 0 - set_local $4 + local.set $4 loop $repeat|4 - get_local $4 - get_local $7 + local.get $4 + local.get $7 i32.lt_u if - get_local $3 - get_local $4 + local.get $3 + local.get $4 i32.const 7 call $assembly/index/readVarint i32.const 127 i32.and call $assembly/options/onTypeReturn - get_local $4 + local.get $4 i32.const 1 i32.add - set_local $4 + local.set $4 br $repeat|4 end end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|2 end end br $break|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|5 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if call $assembly/index/readVaruint - set_local $7 - get_local $7 - get_global $assembly/index/off - tee_local $5 + local.set $7 + local.get $7 + global.get $assembly/index/off + local.tee $5 i32.add - set_global $assembly/index/off + global.set $assembly/index/off call $assembly/index/readVaruint - set_local $9 - get_local $9 - get_global $assembly/index/off - tee_local $4 + local.set $9 + local.get $9 + global.get $assembly/index/off + local.tee $4 i32.add - set_global $assembly/index/off - get_global $assembly/index/off - tee_local $6 + global.set $assembly/index/off + global.get $assembly/index/off + local.tee $6 i32.load8_u - set_local $0 - get_local $6 + local.set $0 + local.get $6 i32.const 1 i32.add - set_global $assembly/index/off - get_local $3 - get_local $0 - get_local $5 - get_local $7 - get_local $4 - get_local $9 + global.set $assembly/index/off + local.get $3 + local.get $0 + local.get $5 + local.get $7 + local.get $4 + local.get $9 call $assembly/options/onImport block $break|6 block $case4|6 block $case3|6 block $case2|6 block $case1|6 - get_local $0 - tee_local $6 - get_global $src/common/ExternalKind.Function + local.get $0 + local.tee $6 + global.get $src/common/ExternalKind.Function i32.ne if - get_global $src/common/ExternalKind.Table - get_local $6 + global.get $src/common/ExternalKind.Table + local.get $6 i32.eq br_if $case1|6 - get_global $src/common/ExternalKind.Memory - get_local $6 + global.get $src/common/ExternalKind.Memory + local.get $6 i32.eq br_if $case2|6 - get_global $src/common/ExternalKind.Global - get_local $6 + global.get $src/common/ExternalKind.Global + local.get $6 i32.eq br_if $case3|6 br $case4|6 end - get_local $11 - tee_local $10 + local.get $11 + local.tee $10 i32.const 1 i32.add - set_local $11 - get_local $10 + local.set $11 + local.get $10 call $assembly/index/readVaruint call $assembly/options/onFunctionImport br $break|6 @@ -603,18 +603,18 @@ call $assembly/index/readVarint i32.const 127 i32.and - set_local $6 + local.set $6 call $assembly/index/readVaruint - set_local $10 - get_local $12 - tee_local $0 + local.set $10 + local.get $12 + local.tee $0 i32.const 1 i32.add - set_local $12 - get_local $0 - get_local $6 + local.set $12 + local.get $0 + local.get $6 call $assembly/index/readVaruint - get_local $10 + local.get $10 i32.const 1 i32.and if (result i32) @@ -622,20 +622,20 @@ else i32.const -1 end - get_local $10 + local.get $10 call $assembly/options/onTableImport br $break|6 end call $assembly/index/readVaruint - set_local $8 - get_local $13 - tee_local $6 + local.set $8 + local.get $13 + local.tee $6 i32.const 1 i32.add - set_local $13 - get_local $6 + local.set $13 + local.get $6 call $assembly/index/readVaruint - get_local $8 + local.get $8 i32.const 1 i32.and if (result i32) @@ -643,16 +643,16 @@ else i32.const 65535 end - get_local $8 + local.get $8 call $assembly/options/onMemoryImport br $break|6 end - get_local $14 - tee_local $8 + local.get $14 + local.tee $8 i32.const 1 i32.add - set_local $14 - get_local $8 + local.set $14 + local.get $8 i32.const 7 call $assembly/index/readVarint i32.const 127 @@ -663,65 +663,65 @@ end unreachable end - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|5 end end br $break|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|7 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if - get_local $11 - tee_local $4 + local.get $11 + local.tee $4 i32.const 1 i32.add - set_local $11 - get_local $4 + local.set $11 + local.get $4 call $assembly/index/readVaruint call $assembly/options/onFunction - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|7 end end br $break|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|8 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if call $assembly/index/readVaruint i32.const 127 i32.and - set_local $0 + local.set $0 call $assembly/index/readVaruint - set_local $4 - get_local $12 - tee_local $7 + local.set $4 + local.get $12 + local.tee $7 i32.const 1 i32.add - set_local $12 - get_local $7 - get_local $0 + local.set $12 + local.get $7 + local.get $0 call $assembly/index/readVaruint - get_local $4 + local.get $4 i32.const 1 i32.and if (result i32) @@ -729,36 +729,36 @@ else i32.const -1 end - get_local $4 + local.get $4 call $assembly/options/onTable - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|8 end end br $break|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|9 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if call $assembly/index/readVaruint - set_local $5 - get_local $13 - tee_local $0 + local.set $5 + local.get $13 + local.tee $0 i32.const 1 i32.add - set_local $13 - get_local $0 + local.set $13 + local.get $0 call $assembly/index/readVaruint - get_local $5 + local.get $5 i32.const 1 i32.and if (result i32) @@ -766,86 +766,86 @@ else i32.const 65535 end - get_local $5 + local.get $5 call $assembly/options/onMemory - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|9 end end br $break|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|10 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if i32.const 7 call $assembly/index/readVarint i32.const 127 i32.and - set_local $4 + local.set $4 call $assembly/index/readVaruint - set_local $9 + local.set $9 call $assembly/index/skipInitExpr - get_local $14 - tee_local $5 + local.get $14 + local.tee $5 i32.const 1 i32.add - set_local $14 - get_local $5 - get_local $4 - get_local $9 + local.set $14 + local.get $5 + local.get $4 + local.get $9 call $assembly/options/onGlobal - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|10 end end br $break|1 end call $assembly/index/readVaruint - set_local $2 + local.set $2 i32.const 0 - set_local $3 + local.set $3 loop $repeat|11 - get_local $3 - get_local $2 + local.get $3 + local.get $2 i32.lt_u if call $assembly/index/readVaruint - set_local $9 - get_local $9 - get_global $assembly/index/off - tee_local $4 + local.set $9 + local.get $9 + global.get $assembly/index/off + local.tee $4 i32.add - set_global $assembly/index/off - get_global $assembly/index/off - tee_local $0 + global.set $assembly/index/off + global.get $assembly/index/off + local.tee $0 i32.load8_u - set_local $6 - get_local $0 + local.set $6 + local.get $0 i32.const 1 i32.add - set_global $assembly/index/off - get_local $3 - get_local $6 + global.set $assembly/index/off + local.get $3 + local.get $6 call $assembly/index/readVaruint - get_local $4 - get_local $9 + local.get $4 + local.get $9 call $assembly/options/onExport - get_local $3 + local.get $3 i32.const 1 i32.add - set_local $3 + local.set $3 br $repeat|11 end end @@ -855,126 +855,126 @@ call $assembly/options/onStart br $break|1 end - get_local $0 + local.get $0 i32.const 4 i32.eq - tee_local $2 + local.tee $2 if (result i32) - get_local $4 + local.get $4 i32.load i32.const 1701667182 i32.eq else - get_local $2 + local.get $2 end if call $assembly/index/readVaruint - set_local $2 + local.set $2 call $assembly/index/readVaruint - set_local $3 - get_global $assembly/index/off - set_local $0 + local.set $3 + global.get $assembly/index/off + local.set $0 block $break|12 block $case3|12 block $case2|12 block $case1|12 - get_local $2 - tee_local $5 - get_global $src/common/NameType.Module + local.get $2 + local.tee $5 + global.get $src/common/NameType.Module i32.ne if - get_global $src/common/NameType.Function - get_local $5 + global.get $src/common/NameType.Function + local.get $5 i32.eq br_if $case1|12 - get_global $src/common/NameType.Local - get_local $5 + global.get $src/common/NameType.Local + local.get $5 i32.eq br_if $case2|12 br $case3|12 end call $assembly/index/readVaruint - set_local $5 - get_global $assembly/index/off - get_local $5 + local.set $5 + global.get $assembly/index/off + local.get $5 call $assembly/options/onModuleName br $break|12 end call $assembly/index/readVaruint - set_local $4 + local.set $4 i32.const 0 - set_local $5 + local.set $5 loop $repeat|13 - get_local $5 - get_local $4 + local.get $5 + local.get $4 i32.lt_u if call $assembly/index/readVaruint - set_local $9 + local.set $9 call $assembly/index/readVaruint - set_local $7 - get_local $7 - get_global $assembly/index/off - tee_local $2 + local.set $7 + local.get $7 + global.get $assembly/index/off + local.tee $2 i32.add - set_global $assembly/index/off - get_local $9 - get_local $2 - get_local $7 + global.set $assembly/index/off + local.get $9 + local.get $2 + local.get $7 call $assembly/options/onFunctionName - get_local $5 + local.get $5 i32.const 1 i32.add - set_local $5 + local.set $5 br $repeat|13 end end br $break|12 end call $assembly/index/readVaruint - set_local $4 + local.set $4 i32.const 0 - set_local $5 + local.set $5 loop $repeat|14 - get_local $5 - get_local $4 + local.get $5 + local.get $4 i32.lt_u if call $assembly/index/readVaruint - set_local $2 + local.set $2 call $assembly/index/readVaruint - set_local $7 + local.set $7 i32.const 0 - set_local $9 + local.set $9 loop $repeat|15 - get_local $9 - get_local $7 + local.get $9 + local.get $7 i32.lt_u if call $assembly/index/readVaruint - set_local $10 + local.set $10 call $assembly/index/readVaruint - tee_local $8 - get_global $assembly/index/off - tee_local $6 + local.tee $8 + global.get $assembly/index/off + local.tee $6 i32.add - set_global $assembly/index/off - get_local $2 - get_local $10 - get_local $6 - get_local $8 + global.set $assembly/index/off + local.get $2 + local.get $10 + local.get $6 + local.get $8 call $assembly/options/onLocalName - get_local $9 + local.get $9 i32.const 1 i32.add - set_local $9 + local.set $9 br $repeat|15 end end - get_local $5 + local.get $5 i32.const 1 i32.add - set_local $5 + local.set $5 br $repeat|14 end end @@ -982,79 +982,79 @@ end unreachable end - get_local $0 - get_local $3 + local.get $0 + local.get $3 i32.add - set_global $assembly/index/off + global.set $assembly/index/off br $break|1 else block (result i32) - get_local $0 + local.get $0 i32.const 16 i32.eq - tee_local $0 + local.tee $0 if - get_local $4 + local.get $4 i64.load i64.const 7011371672682196851 i64.eq - set_local $0 + local.set $0 end - get_local $0 + local.get $0 end if (result i32) - get_local $4 + local.get $4 i32.const 8 i32.add i64.load i64.const 5499551997695193200 i64.eq else - get_local $0 + local.get $0 end if call $assembly/index/readVaruint - tee_local $0 - get_global $assembly/index/off - tee_local $3 + local.tee $0 + global.get $assembly/index/off + local.tee $3 i32.add - set_global $assembly/index/off - get_local $3 - get_local $0 + global.set $assembly/index/off + local.get $3 + local.get $0 call $assembly/options/onSourceMappingURL end end - get_local $5 - get_local $8 + local.get $5 + local.get $8 i32.add - set_global $assembly/index/off + global.set $assembly/index/off br $break|1 end - get_global $assembly/index/off - get_local $8 + global.get $assembly/index/off + local.get $8 i32.add - set_global $assembly/index/off + global.set $assembly/index/off br $break|1 end unreachable end else - get_global $assembly/index/off - get_local $8 + global.get $assembly/index/off + local.get $8 i32.add - set_global $assembly/index/off + global.set $assembly/index/off end br $continue|0 end end - get_global $assembly/index/off - get_local $1 + global.get $assembly/index/off + local.get $1 i32.ne if unreachable end ) - (func $null (; 24 ;) (type $v) + (func $null (; 24 ;) (type $_) nop ) ) diff --git a/package.json b/package.json index 930d3e2768..1485bf8025 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "assemblyscript", - "version": "0.5.0", + "version": "0.6.0", "author": "Daniel Wirtz ", "license": "Apache-2.0", "repository": { diff --git a/src/ast.ts b/src/ast.ts index a3290e11b5..a5d25b98cb 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -5,9 +5,8 @@ import { CommonFlags, + CommonSymbols, PATH_DELIMITER, - STATIC_DELIMITER, - INSTANCE_DELIMITER, LIBRARY_PREFIX } from "./common"; @@ -32,6 +31,7 @@ export enum NodeKind { // types TYPE, + TYPENAME, TYPEPARAMETER, PARAMETER, SIGNATURE, @@ -142,30 +142,37 @@ export abstract class Node { kind: NodeKind; /** Source range. */ range: Range; - /** Parent node. */ - parent: Node | null = null; - /** Common flags indicating specific traits. */ - flags: CommonFlags = CommonFlags.NONE; - - /** Tests if this node has the specified flag or flags. */ - is(flag: CommonFlags): bool { return (this.flags & flag) == flag; } - /** Tests if this node has one of the specified flags. */ - isAny(flag: CommonFlags): bool { return (this.flags & flag) != 0; } - /** Sets a specific flag or flags. */ - set(flag: CommonFlags): void { this.flags |= flag; } // types - static createType( + static createTypeName( name: IdentifierExpression, + range: Range + ): TypeName { + var typeName = new TypeName(); + typeName.range = range; + typeName.identifier = name; + typeName.next = null; + return typeName; + } + + static createSimpleTypeName( + name: string, + range: Range + ): TypeName { + return Node.createTypeName(Node.createIdentifierExpression(name, range), range); + } + + static createType( + name: TypeName, typeArguments: CommonTypeNode[] | null, isNullable: bool, range: Range ): TypeNode { var type = new TypeNode(); type.range = range; - type.name = name; name.parent = type; - type.typeArguments = typeArguments; if (typeArguments) setParent(typeArguments, type); + type.name = name; + type.typeArguments = typeArguments; type.isNullable = isNullable; return type; } @@ -174,7 +181,7 @@ export abstract class Node { range: Range ): TypeNode { return Node.createType( - Node.createIdentifierExpression("", range), + Node.createSimpleTypeName("", range), null, false, range @@ -189,9 +196,9 @@ export abstract class Node { ): TypeParameterNode { var elem = new TypeParameterNode(); elem.range = range; - elem.name = name; name.parent = elem; - elem.extendsType = extendsType; if (extendsType) extendsType.parent = elem; - elem.defaultType = defaultType; if (defaultType) defaultType.parent = elem; + elem.name = name; + elem.extendsType = extendsType; + elem.defaultType = defaultType; return elem; } @@ -204,9 +211,9 @@ export abstract class Node { ): ParameterNode { var elem = new ParameterNode(); elem.range = range; - elem.name = name; name.parent = elem; - elem.type = type; if (type) type.parent = elem; - elem.initializer = initializer; if (initializer) initializer.parent = elem; + elem.name = name; + elem.type = type; + elem.initializer = initializer; elem.parameterKind = kind; return elem; } @@ -220,9 +227,9 @@ export abstract class Node { ): SignatureNode { var sig = new SignatureNode(); sig.range = range; - sig.parameters = parameters; setParent(parameters, sig); - sig.returnType = returnType; returnType.parent = sig; - sig.explicitThisType = explicitThisType; if (explicitThisType) explicitThisType.parent = sig; + sig.parameters = parameters; + sig.returnType = returnType; + sig.explicitThisType = explicitThisType; sig.isNullable = isNullable; return sig; } @@ -236,8 +243,8 @@ export abstract class Node { ): DecoratorNode { var stmt = new DecoratorNode(); stmt.range = range; - stmt.name = name; name.parent = stmt; - stmt.arguments = args; if (args) setParent(args, stmt); + stmt.name = name; + stmt.arguments = args; stmt.decoratorKind = decoratorNameToKind(name); return stmt; } @@ -258,11 +265,14 @@ export abstract class Node { static createIdentifierExpression( name: string, - range: Range + range: Range, + isQuoted: bool = false ): IdentifierExpression { var expr = new IdentifierExpression(); expr.range = range; - expr.text = name; + expr.text = name; // TODO: extract from range + expr.symbol = name; // TODO: Symbol.for(name) + expr.isQuoted = isQuoted; return expr; } @@ -281,7 +291,7 @@ export abstract class Node { ): ArrayLiteralExpression { var expr = new ArrayLiteralExpression(); expr.range = range; - expr.elementExpressions = elements; setParentIfNotNull(elements, expr); + expr.elementExpressions = elements; return expr; } @@ -294,8 +304,8 @@ export abstract class Node { var expr = new AssertionExpression(); expr.range = range; expr.assertionKind = assertionKind; - expr.expression = expression; expression.parent = expr; - expr.toType = toType; if (toType) toType.parent = expr; + expr.expression = expression; + expr.toType = toType; return expr; } @@ -308,8 +318,8 @@ export abstract class Node { var expr = new BinaryExpression(); expr.range = range; expr.operator = operator; - expr.left = left; left.parent = expr; - expr.right = right; right.parent = expr; + expr.left = left; + expr.right = right; return expr; } @@ -321,9 +331,9 @@ export abstract class Node { ): CallExpression { var expr = new CallExpression(); expr.range = range; - expr.expression = expression; expression.parent = expr; - expr.typeArguments = typeArgs; if (typeArgs) setParent(typeArgs, expr); - expr.arguments = args; setParent(args, expr); + expr.expression = expression; + expr.typeArguments = typeArgs; + expr.arguments = args; return expr; } @@ -342,7 +352,7 @@ export abstract class Node { ): CommaExpression { var expr = new CommaExpression(); expr.range = range; - expr.expressions = expressions; setParent(expressions, expr); + expr.expressions = expressions; return expr; } @@ -361,8 +371,8 @@ export abstract class Node { ): ElementAccessExpression { var expr = new ElementAccessExpression(); expr.range = range; - expr.expression = expression; expression.parent = expr; - expr.elementExpression = element; element.parent = expr; + expr.expression = expression; + expr.elementExpression = element; return expr; } @@ -388,7 +398,6 @@ export abstract class Node { declaration: FunctionDeclaration ): FunctionExpression { var expr = new FunctionExpression(); - expr.flags = declaration.flags & CommonFlags.ARROW; expr.range = declaration.range; expr.declaration = declaration; return expr; @@ -401,8 +410,8 @@ export abstract class Node { ): InstanceOfExpression { var expr = new InstanceOfExpression(); expr.range = range; - expr.expression = expression; expression.parent = expr; - expr.isType = isType; isType.parent = expr; + expr.expression = expression; + expr.isType = isType; return expr; } @@ -424,9 +433,9 @@ export abstract class Node { ): NewExpression { var expr = new NewExpression(); expr.range = range; - expr.expression = expression; expression.parent = expr; - expr.typeArguments = typeArgs; if (typeArgs) setParent(typeArgs, expr); - expr.arguments = args; setParent(args, expr); + expr.expression = expression; + expr.typeArguments = typeArgs; + expr.arguments = args; return expr; } @@ -456,7 +465,7 @@ export abstract class Node { ): ParenthesizedExpression { var expr = new ParenthesizedExpression(); expr.range = range; - expr.expression = expression; expression.parent = expr; + expr.expression = expression; return expr; } @@ -467,8 +476,8 @@ export abstract class Node { ): PropertyAccessExpression { var expr = new PropertyAccessExpression(); expr.range = range; - expr.expression = expression; expression.parent = expr; - expr.property = property; property.parent = expr; + expr.expression = expression; + expr.property = property; return expr; } @@ -492,9 +501,9 @@ export abstract class Node { ): TernaryExpression { var expr = new TernaryExpression(); expr.range = range; - expr.condition = condition; condition.parent = expr; - expr.ifThen = ifThen; ifThen.parent = expr; - expr.ifElse = ifElse; ifElse.parent = expr; + expr.condition = condition; + expr.ifThen = ifThen; + expr.ifElse = ifElse; return expr; } @@ -540,7 +549,7 @@ export abstract class Node { var expr = new UnaryPostfixExpression(); expr.range = range; expr.operator = operator; - expr.operand = operand; operand.parent = expr; + expr.operand = operand; return expr; } @@ -552,7 +561,7 @@ export abstract class Node { var expr = new UnaryPrefixExpression(); expr.range = range; expr.operator = operator; - expr.operand = operand; operand.parent = expr; + expr.operand = operand; return expr; } @@ -564,7 +573,7 @@ export abstract class Node { ): BlockStatement { var stmt = new BlockStatement(); stmt.range = range; - stmt.statements = statements; setParent(statements, stmt); + stmt.statements = statements; return stmt; } @@ -574,13 +583,13 @@ export abstract class Node { ): BreakStatement { var stmt = new BreakStatement(); stmt.range = range; - stmt.label = label; if (label) label.parent = stmt; + stmt.label = label; return stmt; } static createClassDeclaration( identifier: IdentifierExpression, - typeParameters: TypeParameterNode[], + typeParameters: TypeParameterNode[] | null, extendsType: TypeNode | null, // can't be a function implementsTypes: TypeNode[] | null, // can't be functions members: DeclarationStatement[], @@ -591,12 +600,12 @@ export abstract class Node { var stmt = new ClassDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = identifier; identifier.parent = stmt; - stmt.typeParameters = typeParameters; setParent(typeParameters, stmt); - stmt.extendsType = extendsType; if (extendsType) extendsType.parent = stmt; - stmt.implementsTypes = implementsTypes; if (implementsTypes) setParent(implementsTypes, stmt); - stmt.members = members; setParent(members, stmt); - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = identifier; + stmt.typeParameters = typeParameters; + stmt.extendsType = extendsType; + stmt.implementsTypes = implementsTypes; + stmt.members = members; + stmt.decorators = decorators; return stmt; } @@ -606,7 +615,7 @@ export abstract class Node { ): ContinueStatement { var stmt = new ContinueStatement(); stmt.range = range; - stmt.label = label; if (label) label.parent = stmt; + stmt.label = label; return stmt; } @@ -617,8 +626,8 @@ export abstract class Node { ): DoStatement { var stmt = new DoStatement(); stmt.range = range; - stmt.statement = statement; statement.parent = stmt; - stmt.condition = condition; condition.parent = stmt; + stmt.statement = statement; + stmt.condition = condition; return stmt; } @@ -640,9 +649,9 @@ export abstract class Node { var stmt = new EnumDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.values = members; setParent(members, stmt); - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.values = members; + stmt.decorators = decorators; return stmt; } @@ -655,21 +664,20 @@ export abstract class Node { var stmt = new EnumValueDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.value = value; if (value) value.parent = stmt; + stmt.name = name; + stmt.value = value; return stmt; } static createExportStatement( members: ExportMember[] | null, path: StringLiteralExpression | null, - flags: CommonFlags, + isDeclare: bool, range: Range ): ExportStatement { var stmt = new ExportStatement(); stmt.range = range; - stmt.flags = flags; - stmt.members = members; if (members) setParent(members, stmt); + stmt.members = members; stmt.path = path; if (path) { let normalizedPath = normalizePath(path.value); @@ -686,6 +694,7 @@ export abstract class Node { stmt.normalizedPath = null; stmt.internalPath = null; } + stmt.isDeclare = isDeclare; return stmt; } @@ -696,8 +705,8 @@ export abstract class Node { ): ExportImportStatement { var stmt = new ExportImportStatement(); stmt.range = range; - stmt.name = name; name.parent = stmt; - stmt.externalName = externalName; externalName.parent = stmt; + stmt.name = name; + stmt.externalName = externalName; return stmt; } @@ -708,13 +717,9 @@ export abstract class Node { ): ExportMember { var elem = new ExportMember(); elem.range = range; - elem.name = name; name.parent = elem; - if (!externalName) { - externalName = name; - } else { - externalName.parent = elem; - } - elem.externalName = externalName; + elem.localName = name; + if (!externalName) externalName = name; + elem.exportedName = externalName; return elem; } @@ -723,7 +728,7 @@ export abstract class Node { ): ExpressionStatement { var stmt = new ExpressionStatement(); stmt.range = expression.range; - stmt.expression = expression; expression.parent = stmt; + stmt.expression = expression; return stmt; } @@ -735,9 +740,9 @@ export abstract class Node { ): IfStatement { var stmt = new IfStatement(); stmt.range = range; - stmt.condition = condition; condition.parent = stmt; - stmt.ifTrue = ifTrue; ifTrue.parent = stmt; - stmt.ifFalse = ifFalse; if (ifFalse) ifFalse.parent = stmt; + stmt.condition = condition; + stmt.ifTrue = ifTrue; + stmt.ifFalse = ifFalse; return stmt; } @@ -748,7 +753,7 @@ export abstract class Node { ): ImportStatement { var stmt = new ImportStatement(); stmt.range = range; - stmt.declarations = decls; if (decls) setParent(decls, stmt); + stmt.declarations = decls; stmt.namespaceName = null; stmt.path = path; var normalizedPath = normalizePath(path.value); @@ -786,25 +791,21 @@ export abstract class Node { } static createImportDeclaration( - externalName: IdentifierExpression, + foreignName: IdentifierExpression, name: IdentifierExpression | null, range: Range ): ImportDeclaration { var elem = new ImportDeclaration(); elem.range = range; - elem.externalName = externalName; externalName.parent = elem; - if (!name) { - name = externalName; - } else { - name.parent = elem; - } + elem.foreignName = foreignName; + if (!name) name = foreignName; elem.name = name; return elem; } static createInterfaceDeclaration( name: IdentifierExpression, - typeParameters: TypeParameterNode[], + typeParameters: TypeParameterNode[] | null, extendsType: TypeNode | null, // can't be a function members: DeclarationStatement[], decorators: DecoratorNode[] | null, @@ -814,11 +815,11 @@ export abstract class Node { var stmt = new InterfaceDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt); - stmt.extendsType = extendsType; if (extendsType) extendsType.parent = stmt; - stmt.members = members; setParent(members, stmt); - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.typeParameters = typeParameters; + stmt.extendsType = extendsType; + stmt.members = members; + stmt.decorators = decorators; return stmt; } @@ -833,10 +834,10 @@ export abstract class Node { var stmt = new FieldDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.type = type; if (type) type.parent = stmt; - stmt.initializer = initializer; if (initializer) initializer.parent = stmt; - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.type = type; + stmt.initializer = initializer; + stmt.decorators = decorators; return stmt; } @@ -849,10 +850,10 @@ export abstract class Node { ): ForStatement { var stmt = new ForStatement(); stmt.range = range; - stmt.initializer = initializer; if (initializer) initializer.parent = stmt; - stmt.condition = condition; if (condition) condition.parent = stmt; - stmt.incrementor = incrementor; if (incrementor) incrementor.parent = stmt; - stmt.statement = statement; statement.parent = stmt; + stmt.initializer = initializer; + stmt.condition = condition; + stmt.incrementor = incrementor; + stmt.statement = statement; return stmt; } @@ -868,11 +869,11 @@ export abstract class Node { var stmt = new FunctionDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt); - stmt.signature = signature; signature.parent = stmt; - stmt.body = body; if (body) body.parent = stmt; - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.typeParameters = typeParameters; + stmt.signature = signature; + stmt.body = body; + stmt.decorators = decorators; return stmt; } @@ -883,8 +884,8 @@ export abstract class Node { ): IndexSignatureDeclaration { var elem = new IndexSignatureDeclaration(); elem.range = range; - elem.keyType = keyType; keyType.parent = elem; - elem.valueType = valueType; valueType.parent = elem; + elem.keyType = keyType; + elem.valueType = valueType; return elem; } @@ -900,11 +901,11 @@ export abstract class Node { var stmt = new MethodDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt); - stmt.signature = signature; signature.parent = stmt; - stmt.body = body; if (body) body.parent = stmt; - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.typeParameters = typeParameters; + stmt.signature = signature; + stmt.body = body; + stmt.decorators = decorators; return stmt; } @@ -918,9 +919,9 @@ export abstract class Node { var stmt = new NamespaceDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.members = members; setParent(members, stmt); - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.members = members; + stmt.decorators = decorators; return stmt; } @@ -930,7 +931,7 @@ export abstract class Node { ): ReturnStatement { var stmt = new ReturnStatement(); stmt.range = range; - stmt.value = value; if (value) value.parent = stmt; + stmt.value = value; return stmt; } @@ -941,8 +942,8 @@ export abstract class Node { ): SwitchStatement { var stmt = new SwitchStatement(); stmt.range = range; - stmt.condition = condition; condition.parent = stmt; - stmt.cases = cases; setParent(cases, stmt); + stmt.condition = condition; + stmt.cases = cases; return stmt; } @@ -953,8 +954,8 @@ export abstract class Node { ): SwitchCase { var elem = new SwitchCase(); elem.range = range; - elem.label = label; if (label) label.parent = elem; - elem.statements = statements; setParent(statements, elem); + elem.label = label; + elem.statements = statements; return elem; } @@ -964,7 +965,7 @@ export abstract class Node { ): ThrowStatement { var stmt = new ThrowStatement(); stmt.range = range; - stmt.value = value; value.parent = stmt; + stmt.value = value; return stmt; } @@ -977,13 +978,10 @@ export abstract class Node { ): TryStatement { var stmt = new TryStatement(); stmt.range = range; - stmt.statements = statements; setParent(statements, stmt); + stmt.statements = statements; stmt.catchVariable = catchVariable; - if (catchVariable) catchVariable.parent = stmt; stmt.catchStatements = catchStatements; - if (catchStatements) setParent(catchStatements, stmt); stmt.finallyStatements = finallyStatements; - if (finallyStatements) setParent(finallyStatements, stmt); return stmt; } @@ -998,24 +996,22 @@ export abstract class Node { var stmt = new TypeDeclaration(); stmt.range = range; stmt.flags = flags; - stmt.name = name; name.parent = stmt; - stmt.typeParameters = typeParameters; if (typeParameters) setParent(typeParameters, stmt); - stmt.type = alias; alias.parent = stmt; - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.name = name; + stmt.typeParameters = typeParameters; + stmt.type = alias; + stmt.decorators = decorators; return stmt; } static createVariableStatement( declarations: VariableDeclaration[], decorators: DecoratorNode[] | null, - flags: CommonFlags, range: Range ): VariableStatement { var stmt = new VariableStatement(); stmt.range = range; - stmt.flags = flags; - stmt.declarations = declarations; setParent(declarations, stmt); - stmt.decorators = decorators; if (decorators) setParent(decorators, stmt); + stmt.declarations = declarations; + stmt.decorators = decorators; return stmt; } @@ -1030,9 +1026,9 @@ export abstract class Node { var elem = new VariableDeclaration(); elem.range = range; elem.flags = flags; - elem.name = name; name.parent = elem; - elem.type = type; if (type) type.parent = elem; - elem.initializer = initializer; if (initializer) initializer.parent = elem; + elem.name = name; + elem.type = type; + elem.initializer = initializer; elem.decorators = decorators; // inherited return elem; } @@ -1054,8 +1050,8 @@ export abstract class Node { ): WhileStatement { var stmt = new WhileStatement(); stmt.range = range; - stmt.condition = condition; condition.parent = stmt; - stmt.statement = statement; statement.parent = stmt; + stmt.condition = condition; + stmt.statement = statement; return stmt; } } @@ -1069,12 +1065,22 @@ export abstract class CommonTypeNode extends Node { isNullable: bool; } +/** Represents a type name. */ +export class TypeName extends Node { + kind = NodeKind.TYPENAME; + + /** Identifier of this part. */ + identifier: IdentifierExpression; + /** Next part of the type name or `null` if this is the last part. */ + next: TypeName | null; +} + /** Represents a type annotation. */ export class TypeNode extends CommonTypeNode { kind = NodeKind.TYPE; - /** Identifier reference. */ - name: IdentifierExpression; + /** Type name. */ + name: TypeName; /** Type argument references. */ typeArguments: CommonTypeNode[] | null; } @@ -1115,6 +1121,15 @@ export class ParameterNode extends Node { initializer: Expression | null; /** Implicit field declaration, if applicable. */ implicitFieldDeclaration: FieldDeclaration | null = null; + /** Common flags indicating specific traits. */ + flags: CommonFlags = CommonFlags.NONE; + + /** Tests if this node has the specified flag or flags. */ + is(flag: CommonFlags): bool { return (this.flags & flag) == flag; } + /** Tests if this node has one of the specified flags. */ + isAny(flag: CommonFlags): bool { return (this.flags & flag) != 0; } + /** Sets a specific flag or flags. */ + set(flag: CommonFlags): void { this.flags |= flag; } } /** Represents a function signature. */ @@ -1143,7 +1158,9 @@ export enum DecoratorKind { SEALED, INLINE, EXTERNAL, - BUILTIN + BUILTIN, + LAZY, + START } /** Returns the kind of the specified decorator. Defaults to {@link DecoratorKind.CUSTOM}. */ @@ -1169,12 +1186,17 @@ export function decoratorNameToKind(name: Expression): DecoratorKind { if (nameStr == "inline") return DecoratorKind.INLINE; break; } + case CharCode.l: { + if (nameStr == "lazy") return DecoratorKind.LAZY; + break; + } case CharCode.o: { if (nameStr == "operator") return DecoratorKind.OPERATOR; break; } case CharCode.s: { if (nameStr == "sealed") return DecoratorKind.SEALED; + if (nameStr == "start") return DecoratorKind.START; break; } case CharCode.u: { @@ -1253,6 +1275,10 @@ export class IdentifierExpression extends Expression { /** Textual name. */ text: string; + /** Symbol. */ + symbol: string; // TODO: symbol + /** Whether quoted or not. */ + isQuoted: bool; } /** Indicates the kind of a literal. */ @@ -1344,6 +1370,7 @@ export class CommaExpression extends Expression { export class ConstructorExpression extends IdentifierExpression { kind = NodeKind.CONSTRUCTOR; text = "constructor"; + symbol = CommonSymbols.constructor; } /** Represents an element access expression, e.g., array access. */ @@ -1399,6 +1426,7 @@ export class NewExpression extends CallExpression { export class NullExpression extends IdentifierExpression { kind = NodeKind.NULL; text = "null"; + symbol = CommonSymbols.null_; } /** Represents an object literal expression. */ @@ -1463,24 +1491,28 @@ export class StringLiteralExpression extends LiteralExpression { export class SuperExpression extends IdentifierExpression { kind = NodeKind.SUPER; text = "super"; + symbol = CommonSymbols.super_; } /** Represents a `this` expression. */ export class ThisExpression extends IdentifierExpression { kind = NodeKind.THIS; text = "this"; + symbol = CommonSymbols.this_; } /** Represents a `true` expression. */ export class TrueExpression extends IdentifierExpression { kind = NodeKind.TRUE; text = "true"; + symbol = CommonSymbols.true_; } /** Represents a `false` expression. */ export class FalseExpression extends IdentifierExpression { kind = NodeKind.FALSE; text = "false"; + symbol = CommonSymbols.false_; } /** Base class of all unary expressions. */ @@ -1504,20 +1536,6 @@ export class UnaryPrefixExpression extends UnaryExpression { // statements -export function isLastStatement(statement: Statement): bool { - var parent = assert(statement.parent); - if (parent.kind == NodeKind.BLOCK) { - let statements = (parent).statements; - if (statements[statements.length - 1] === statement) { - switch (assert(parent.parent).kind) { - case NodeKind.FUNCTIONDECLARATION: - case NodeKind.METHODDECLARATION: return true; - } - } - } - return false; -} - /** Base class of all statement nodes. */ export abstract class Statement extends Node { } @@ -1577,69 +1595,19 @@ export class Source extends Node { /** Base class of all declaration statements. */ export abstract class DeclarationStatement extends Statement { - /** Simple name being declared. */ name: IdentifierExpression; /** Array of decorators. */ decorators: DecoratorNode[] | null = null; + /** Common flags indicating specific traits. */ + flags: CommonFlags = CommonFlags.NONE; - protected cachedProgramLevelInternalName: string | null = null; - protected cachedFileLevelInternalName: string | null = null; - - /** Gets the mangled program-level internal name of this declaration. */ - get programLevelInternalName(): string { - if (!this.cachedProgramLevelInternalName) { - this.cachedProgramLevelInternalName = mangleInternalName(this, true); - } - return this.cachedProgramLevelInternalName; - } - - /** Gets the mangled file-level internal name of this declaration. */ - get fileLevelInternalName(): string { - if (!this.cachedFileLevelInternalName) { - this.cachedFileLevelInternalName = mangleInternalName(this, false); - } - return this.cachedFileLevelInternalName; - } - - /** Tests if this is a top-level declaration within its source file. */ - get isTopLevel(): bool { - var parent = this.parent; - if (!parent) { - return false; - } - if (parent.kind == NodeKind.VARIABLE && !(parent = parent.parent)) { - return false; - } - return parent.kind == NodeKind.SOURCE; - } - - /** Tests if this declaration is a top-level export within its source file. */ - get isTopLevelExport(): bool { - var parent = this.parent; - if (!parent || (parent.kind == NodeKind.VARIABLE && !(parent = parent.parent))) { - return false; - } - if (parent.kind == NodeKind.NAMESPACEDECLARATION) { - return this.is(CommonFlags.EXPORT) && (parent).isTopLevelExport; - } - if (parent.kind == NodeKind.CLASSDECLARATION) { - return this.is(CommonFlags.STATIC) && (parent).isTopLevelExport; - } - return parent.kind == NodeKind.SOURCE && this.is(CommonFlags.EXPORT); - } - - /** Tests if this declaration needs an explicit export. */ - needsExplicitExport(member: ExportMember): bool { - // This is necessary because module-level exports are automatically created - // for top level declarations of all sorts. This function essentially tests - // that there isn't a otherwise duplicate top-level export already. - return ( - member.name.text != member.externalName.text || // if aliased - this.range.source != member.range.source || // if a re-export - !this.isTopLevelExport // if not top-level - ); - } + /** Tests if this node has the specified flag or flags. */ + is(flag: CommonFlags): bool { return (this.flags & flag) == flag; } + /** Tests if this node has one of the specified flags. */ + isAny(flag: CommonFlags): bool { return (this.flags & flag) != 0; } + /** Sets a specific flag or flags. */ + set(flag: CommonFlags): void { this.flags |= flag; } } /** Represents an index signature declaration. */ @@ -1682,7 +1650,7 @@ export class ClassDeclaration extends DeclarationStatement { kind = NodeKind.CLASSDECLARATION; /** Accepted type parameters. */ - typeParameters: TypeParameterNode[]; + typeParameters: TypeParameterNode[] | null; /** Base class type being extended, if any. */ extendsType: TypeNode | null; // can't be a function /** Interface types being implemented, if any. */ @@ -1728,7 +1696,7 @@ export class EnumDeclaration extends DeclarationStatement { } /** Represents a value of an `enum` declaration. */ -export class EnumValueDeclaration extends DeclarationStatement { +export class EnumValueDeclaration extends VariableLikeDeclarationStatement { kind = NodeKind.ENUMVALUEDECLARATION; // name is inherited @@ -1750,17 +1718,17 @@ export class ExportImportStatement extends Node { export class ExportMember extends Node { kind = NodeKind.EXPORTMEMBER; - /** Identifier being exported. */ - name: IdentifierExpression; - /** Identifier seen when imported again. */ - externalName: IdentifierExpression; + /** Local identifier. */ + localName: IdentifierExpression; + /** Exported identifier. */ + exportedName: IdentifierExpression; } /** Represents an `export` statement. */ export class ExportStatement extends Statement { kind = NodeKind.EXPORT; - /** Array of members if a set of named exports, or `null` if a filespace export. */ + /** Array of members if a set of named exports, or `null` if a file export. */ members: ExportMember[] | null; /** Path being exported from, if applicable. */ path: StringLiteralExpression | null; @@ -1768,6 +1736,8 @@ export class ExportStatement extends Statement { normalizedPath: string | null; /** Mangled internal path being referenced, if `path` is set. */ internalPath: string | null; + /** Whether this is a declared export. */ + isDeclare: bool; } /** Represents an expression that is used as a statement. */ @@ -1782,7 +1752,7 @@ export class ExpressionStatement extends Statement { export class FieldDeclaration extends VariableLikeDeclarationStatement { kind = NodeKind.FIELDDECLARATION; - /** Parameter index within the constructor, if applicable. */ + /** Parameter index if declared as a constructor parameter, otherwise `-1`. */ parameterIndex: i32 = -1; } @@ -1818,6 +1788,13 @@ export class FunctionDeclaration extends DeclarationStatement { var typeParameters = this.typeParameters; return typeParameters != null && typeParameters.length > 0; } + + /** Clones this function declaration. */ + clone(): FunctionDeclaration { + return Node.createFunctionDeclaration( + this.name, this.typeParameters, this.signature, this.body, this.decorators, this.flags, this.range + ); + } } /** Represents an `if` statement. */ @@ -1837,7 +1814,7 @@ export class ImportDeclaration extends DeclarationStatement { kind = NodeKind.IMPORTDECLARATION; /** Identifier being imported. */ - externalName: IdentifierExpression; + foreignName: IdentifierExpression; } /** Represents an `import` statement. */ @@ -1978,55 +1955,8 @@ export function findDecorator(kind: DecoratorKind, decorators: DecoratorNode[] | return null; } -/** Mangles a declaration's name to an internal name. */ -export function mangleInternalName(declaration: DeclarationStatement, asGlobal: bool = false): string { - var name = declaration.name.text; - var parent = declaration.parent; - if (!parent) return name; - if ( - declaration.kind == NodeKind.VARIABLEDECLARATION && - parent.kind == NodeKind.VARIABLE - ) { // skip over - if (!(parent = parent.parent)) return name; - } - if (parent.kind == NodeKind.CLASSDECLARATION) { - return mangleInternalName(parent, asGlobal) + ( - declaration.is(CommonFlags.STATIC) - ? STATIC_DELIMITER - : INSTANCE_DELIMITER - ) + name; - } - if ( - parent.kind == NodeKind.NAMESPACEDECLARATION || - parent.kind == NodeKind.ENUMDECLARATION - ) { - return mangleInternalName(parent, asGlobal) + - STATIC_DELIMITER + name; - } - return asGlobal - ? name - : declaration.range.source.internalPath + PATH_DELIMITER + name; -} - /** Mangles an external to an internal path. */ export function mangleInternalPath(path: string): string { if (path.endsWith(".ts")) path = path.substring(0, path.length - 3); return path; } - -// Helpers - -/** Sets the parent node on an array of nodes. */ -function setParent(nodes: Node[], parent: Node): void { - for (let i = 0, k = nodes.length; i < k; ++i) { - nodes[i].parent = parent; - } -} - -/** Sets the parent node on an array of nullable nodes. */ -function setParentIfNotNull(nodes: (Node | null)[], parent: Node): void { - for (let i = 0, k = nodes.length; i < k; ++i) { - let node = nodes[i]; - if (node) node.parent = parent; - } -} diff --git a/src/builtins.ts b/src/builtins.ts index d90d70fa98..4a6e3d7950 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -50,21 +50,224 @@ import { FunctionPrototype, Class, Field, - OperatorKind, - FlowFlags, Global, DecoratorFlags, - Element + ClassPrototype } from "./program"; +import { + FlowFlags +} from "./flow"; + import { ReportMode } from "./resolver"; import { - CommonFlags + CommonFlags, CommonSymbols } from "./common"; +/** Symbols of various compiler built-ins. */ +export namespace BuiltinSymbols { + // std/builtins.ts + export const isInteger = "~lib/builtins/isInteger"; + export const isFloat = "~lib/builtins/isFloat"; + export const isSigned = "~lib/builtins/isSigned"; + export const isReference = "~lib/builtins/isReference"; + export const isString = "~lib/builtins/isString"; + export const isArray = "~lib/builtins/isArray"; + export const isDefined = "~lib/builtins/isDefined"; + export const isConstant = "~lib/builtins/isConstant"; + export const isManaged = "~lib/builtins/isManaged"; + export const clz = "~lib/builtins/clz"; + export const ctz = "~lib/builtins/ctz"; + export const popcnt = "~lib/builtins/popcnt"; + export const rotl = "~lib/builtins/rotl"; + export const rotr = "~lib/builtins/rotr"; + export const abs = "~lib/builtins/abs"; + export const max = "~lib/builtins/max"; + export const min = "~lib/builtins/min"; + export const ceil = "~lib/builtins/ceil"; + export const floor = "~lib/builtins/floor"; + export const copysign = "~lib/builtins/copysign"; + export const nearest = "~lib/builtins/nearest"; + export const reinterpret = "~lib/builtins/reinterpret"; + export const sqrt = "~lib/builtins/sqrt"; + export const trunc = "~lib/builtins/trunc"; + export const load = "~lib/builtins/load"; + export const store = "~lib/builtins/store"; + export const atomic_load = "~lib/builtins/atomic.load"; + export const atomic_store = "~lib/builtins/atomic.store"; + export const atomic_add = "~lib/builtins/atomic.add"; + export const atomic_sub = "~lib/builtins/atomic.sub"; + export const atomic_and = "~lib/builtins/atomic.and"; + export const atomic_or = "~lib/builtins/atomic.or"; + export const atomic_xor = "~lib/builtins/atomic.xor"; + export const atomic_xchg = "~lib/builtins/atomic.xchg"; + export const atomic_cmpxchg = "~lib/builtins/atomic.cmpxchg"; + export const atomic_wait = "~lib/builtins/atomic.wait"; + export const atomic_notify = "~lib/builtins/atomic.notify"; + export const sizeof = "~lib/builtins/sizeof"; + export const alignof = "~lib/builtins/alignof"; + export const offsetof = "~lib/builtins/offsetof"; + export const select = "~lib/builtins/select"; + export const unreachable = "~lib/builtins/unreachable"; + export const changetype = "~lib/builtins/changetype"; + export const assert = "~lib/builtins/assert"; + export const unchecked = "~lib/builtins/unchecked"; + export const call_indirect = "~lib/builtins/call_indirect"; + export const instantiate = "~lib/builtins/instantiate"; + export const i8 = "~lib/builtins/i8"; + export const i16 = "~lib/builtins/i16"; + export const i32 = "~lib/builtins/i32"; + export const i64 = "~lib/builtins/i64"; + export const isize = "~lib/builtins/isize"; + export const u8 = "~lib/builtins/u8"; + export const u16 = "~lib/builtins/u16"; + export const u32 = "~lib/builtins/u32"; + export const u64 = "~lib/builtins/u64"; + export const usize = "~lib/builtins/usize"; + export const bool = "~lib/builtins/bool"; + export const f32 = "~lib/builtins/f32"; + export const f64 = "~lib/builtins/f64"; + export const v128 = "~lib/builtins/v128"; + export const void_ = "~lib/builtins/void"; + export const i32_clz = "~lib/builtins/i32.clz"; + export const i64_clz = "~lib/builtins/i64.clz"; + export const i32_ctz = "~lib/builtins/i32.ctz"; + export const i64_ctz = "~lib/builtins/i64.ctz"; + export const i32_popcnt = "~lib/builtins/i32.popcnt"; + export const i64_popcnt = "~lib/builtins/i64.popcnt"; + export const i32_rotl = "~lib/builtins/i32.rotl"; + export const i64_rotl = "~lib/builtins/i64.rotl"; + export const i32_rotr = "~lib/builtins/i32.rotr"; + export const i64_rotr = "~lib/builtins/i64.rotr"; + export const f32_abs = "~lib/builtins/f32.abs"; + export const f64_abs = "~lib/builtins/f64.abs"; + export const f32_max = "~lib/builtins/f32.max"; + export const f64_max = "~lib/builtins/f64.max"; + export const f32_min = "~lib/builtins/f32.min"; + export const f64_min = "~lib/builtins/f64.min"; + export const f32_ceil = "~lib/builtins/f32.ceil"; + export const f64_ceil = "~lib/builtins/f64.ceil"; + export const f32_floor = "~lib/builtins/f32.floor"; + export const f64_floor = "~lib/builtins/f64.floor"; + export const f32_copysign = "~lib/builtins/f32.copysign"; + export const f64_copysign = "~lib/builtins/f64.copysign"; + export const f32_nearest = "~lib/builtins/f32.nearest"; + export const f64_nearest = "~lib/builtins/f64.nearest"; + export const i32_reinterpret_f32 = "~lib/builtins/i32.reinterpret_f32"; + export const i64_reinterpret_f64 = "~lib/builtins/i64.reinterpret_f64"; + export const f32_reinterpret_i32 = "~lib/builtins/f32.reinterpret_i32"; + export const f64_reinterpret_i64 = "~lib/builtins/f64.reinterpret_i64"; + export const f32_sqrt = "~lib/builtins/f32.sqrt"; + export const f64_sqrt = "~lib/builtins/f64.sqrt"; + export const f32_trunc = "~lib/builtins/f32.trunc"; + export const f64_trunc = "~lib/builtins/f64.trunc"; + export const i32_load8_s = "~lib/builtins/i32.load8_s"; + export const i32_load8_u = "~lib/builtins/i32.load8_u"; + export const i32_load16_s = "~lib/builtins/i32.load16_s"; + export const i32_load16_u = "~lib/builtins/i32.load16_u"; + export const i32_load = "~lib/builtins/i32.load"; + export const i64_load8_s = "~lib/builtins/i64.load8_s"; + export const i64_load8_u = "~lib/builtins/i64.load8_u"; + export const i64_load16_s = "~lib/builtins/i64.load16_s"; + export const i64_load16_u = "~lib/builtins/i64.load16_u"; + export const i64_load32_s = "~lib/builtins/i64.load32_s"; + export const i64_load32_u = "~lib/builtins/i64.load32_u"; + export const i64_load = "~lib/builtins/i64.load"; + export const f32_load = "~lib/builtins/f32.load"; + export const f64_load = "~lib/builtins/f64.load"; + export const i32_store8 = "~lib/builtins/i32.store8"; + export const i32_store16 = "~lib/builtins/i32.store16"; + export const i32_store = "~lib/builtins/i32.store"; + export const i64_store8 = "~lib/builtins/i64.store8"; + export const i64_store16 = "~lib/builtins/i64.store16"; + export const i64_store32 = "~lib/builtins/i64.store32"; + export const i64_store = "~lib/builtins/i64.store"; + export const f32_store = "~lib/builtins/f32.store"; + export const f64_store = "~lib/builtins/f64.store"; + export const i32_atomic_load8_u = "~lib/builtins/i32.atomic.load8_u"; + export const i32_atomic_load16_u = "~lib/builtins/i32.atomic.load16_u"; + export const i32_atomic_load = "~lib/builtins/i32.atomic.load"; + export const i64_atomic_load8_u = "~lib/builtins/i64.atomic.load8_u"; + export const i64_atomic_load16_u = "~lib/builtins/i64.atomic.load16_u"; + export const i64_atomic_load32_u = "~lib/builtins/i64.atomic.load32_u"; + export const i64_atomic_load = "~lib/builtins/i64.atomic.load"; + export const i32_atomic_store8 = "~lib/builtins/i32.atomic.store8"; + export const i32_atomic_store16 = "~lib/builtins/i32.atomic.store16"; + export const i32_atomic_store = "~lib/builtins/i32.atomic.store"; + export const i64_atomic_store8 = "~lib/builtins/i64.atomic.store8"; + export const i64_atomic_store16 = "~lib/builtins/i64.atomic.store16"; + export const i64_atomic_store32 = "~lib/builtins/i64.atomic.store32"; + export const i64_atomic_store = "~lib/builtins/i64.atomic.store"; + export const i32_atomic_rmw8_u_add = "~lib/builtins/i32.atomic.rmw8_u.add"; + export const i32_atomic_rmw16_u_add = "~lib/builtins/i32.atomic.rmw16_u.add"; + export const i32_atomic_rmw_add = "~lib/builtins/i32.atomic.rmw.add"; + export const i64_atomic_rmw8_u_add = "~lib/builtins/i64.atomic.rmw8_u.add"; + export const i64_atomic_rmw16_u_add = "~lib/builtins/i64.atomic.rmw16_u.add"; + export const i64_atomic_rmw32_u_add = "~lib/builtins/i64.atomic.rmw32_u.add"; + export const i64_atomic_rmw_add = "~lib/builtins/i64.atomic.rmw.add"; + export const i32_atomic_rmw8_u_sub = "~lib/builtins/i32.atomic.rmw8_u.sub"; + export const i32_atomic_rmw16_u_sub = "~lib/builtins/i32.atomic.rmw16_u.sub"; + export const i32_atomic_rmw_sub = "~lib/builtins/i32.atomic.rmw.sub"; + export const i64_atomic_rmw8_u_sub = "~lib/builtins/i64.atomic.rmw8_u.sub"; + export const i64_atomic_rmw16_u_sub = "~lib/builtins/i64.atomic.rmw16_u.sub"; + export const i64_atomic_rmw32_u_sub = "~lib/builtins/i64.atomic.rmw32_u.sub"; + export const i64_atomic_rmw_sub = "~lib/builtins/i64.atomic.rmw.sub"; + export const i32_atomic_rmw8_u_and = "~lib/builtins/i32.atomic.rmw8_u.and"; + export const i32_atomic_rmw16_u_and = "~lib/builtins/i32.atomic.rmw16_u.and"; + export const i32_atomic_rmw_and = "~lib/builtins/i32.atomic.rmw.and"; + export const i64_atomic_rmw8_u_and = "~lib/builtins/i64.atomic.rmw8_u.and"; + export const i64_atomic_rmw16_u_and = "~lib/builtins/i64.atomic.rmw16_u.and"; + export const i64_atomic_rmw32_u_and = "~lib/builtins/i64.atomic.rmw32_u.and"; + export const i64_atomic_rmw_and = "~lib/builtins/i64.atomic.rmw.and"; + export const i32_atomic_rmw8_u_or = "~lib/builtins/i32.atomic.rmw8_u.or"; + export const i32_atomic_rmw16_u_or = "~lib/builtins/i32.atomic.rmw16_u.or"; + export const i32_atomic_rmw_or = "~lib/builtins/i32.atomic.rmw.or"; + export const i64_atomic_rmw8_u_or = "~lib/builtins/i64.atomic.rmw8_u.or"; + export const i64_atomic_rmw16_u_or = "~lib/builtins/i64.atomic.rmw16_u.or"; + export const i64_atomic_rmw32_u_or = "~lib/builtins/i64.atomic.rmw32_u.or"; + export const i64_atomic_rmw_or = "~lib/builtins/i64.atomic.rmw.or"; + export const i32_atomic_rmw8_u_xor = "~lib/builtins/i32.atomic.rmw8_u.xor"; + export const i32_atomic_rmw16_u_xor = "~lib/builtins/i32.atomic.rmw16_u.xor"; + export const i32_atomic_rmw_xor = "~lib/builtins/i32.atomic.rmw.xor"; + export const i64_atomic_rmw8_u_xor = "~lib/builtins/i64.atomic.rmw8_u.xor"; + export const i64_atomic_rmw16_u_xor = "~lib/builtins/i64.atomic.rmw16_u.xor"; + export const i64_atomic_rmw32_u_xor = "~lib/builtins/i64.atomic.rmw32_u.xor"; + export const i64_atomic_rmw_xor = "~lib/builtins/i64.atomic.rmw.xor"; + export const i32_atomic_rmw8_u_xchg = "~lib/builtins/i32.atomic.rmw8_u.xchg"; + export const i32_atomic_rmw16_u_xchg = "~lib/builtins/i32.atomic.rmw16_u.xchg"; + export const i32_atomic_rmw_xchg = "~lib/builtins/i32.atomic.rmw.xchg"; + export const i64_atomic_rmw8_u_xchg = "~lib/builtins/i64.atomic.rmw8_u.xchg"; + export const i64_atomic_rmw16_u_xchg = "~lib/builtins/i64.atomic.rmw16_u.xchg"; + export const i64_atomic_rmw32_u_xchg = "~lib/builtins/i64.atomic.rmw32_u.xchg"; + export const i64_atomic_rmw_xchg = "~lib/builtins/i64.atomic.rmw.xchg"; + export const i32_atomic_rmw8_u_cmpxchg = "~lib/builtins/i32.atomic.rmw8_u.cmpxchg"; + export const i32_atomic_rmw16_u_cmpxchg = "~lib/builtins/i32.atomic.rmw16_u.cmpxchg"; + export const i32_atomic_rmw_cmpxchg = "~lib/builtins/i32.atomic.rmw.cmpxchg"; + export const i64_atomic_rmw8_u_cmpxchg = "~lib/builtins/i64.atomic.rmw8_u.cmpxchg"; + export const i64_atomic_rmw16_u_cmpxchg = "~lib/builtins/i64.atomic.rmw16_u.cmpxchg"; + export const i64_atomic_rmw32_u_cmpxchg = "~lib/builtins/i64.atomic.rmw32_u.cmpxchg"; + export const i64_atomic_rmw_cmpxchg = "~lib/builtins/i64.atomic.rmw.cmpxchg"; + export const i32_wait = "~lib/builtins/i32.wait"; + export const i64_wait = "~lib/builtins/i64.wait"; + export const i32_notify = "~lib/builtins/i32.notify"; + export const i64_notify = "~lib/builtins/i64.notify"; + // std/diagnostics.ts + export const ERROR = "~lib/diagnostics/ERROR"; + export const WARNING = "~lib/diagnostics/WARNING"; + export const INFO = "~lib/diagnostics/INFO"; + // std/memory.ts + export const HEAP_BASE = "~lib/memory/HEAP_BASE"; + export const memory_size = "~lib/memory/memory.size"; + export const memory_grow = "~lib/memory/memory.grow"; + export const memory_copy = "~lib/memory/memory.copy"; + export const memory_fill = "~lib/memory/memory.fill"; + // std/gc.ts + export const iterateRoots = "~lib/gc/iterateRoots"; +} + /** Compiles a call to a built-in function. */ export function compileCall( compiler: Compiler, @@ -89,7 +292,7 @@ export function compileCall( // types - case "isInteger": { // isInteger() / isInteger(value: T) -> bool + case BuiltinSymbols.isInteger: { // isInteger() / isInteger(value: T) -> bool let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); @@ -97,7 +300,7 @@ export function compileCall( ? module.createI32(1) : module.createI32(0); } - case "isFloat": { // isFloat() / isFloat(value: T) -> bool + case BuiltinSymbols.isFloat: { // isFloat() / isFloat(value: T) -> bool let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); @@ -105,7 +308,7 @@ export function compileCall( ? module.createI32(1) : module.createI32(0); } - case "isSigned": { // isSigned() / isSigned(value: T) -> bool + case BuiltinSymbols.isSigned: { // isSigned() / isSigned(value: T) -> bool let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); @@ -113,7 +316,7 @@ export function compileCall( ? module.createI32(1) : module.createI32(0); } - case "isReference": { // isReference() / isReference(value: T) -> bool + case BuiltinSymbols.isReference: { // isReference() / isReference(value: T) -> bool let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); @@ -121,7 +324,7 @@ export function compileCall( ? module.createI32(1) : module.createI32(0); } - case "isString": { // isString() / isString(value: T) -> bool + case BuiltinSymbols.isString: { // isString() / isString(value: T) -> bool let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); @@ -132,16 +335,20 @@ export function compileCall( } return module.createI32(0); } - case "isArray": { // isArray() / isArray(value: T) -> bool + case BuiltinSymbols.isArray: { // isArray() / isArray(value: T) -> bool let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.bool; if (!type) return module.createUnreachable(); - let classType = type.classReference; - return ( - classType !== null && classType.prototype.extends(compiler.program.arrayPrototype) - ) ? module.createI32(1) : module.createI32(0); + let classReference = type.classReference; + if (!classReference) return module.createI32(0); + let classPrototype = classReference.prototype; + return module.createI32( + (classPrototype).extends(compiler.program.arrayPrototype) + ? 1 + : 0 + ); } - case "isDefined": { // isDefined(expression) -> bool + case BuiltinSymbols.isDefined: { // isDefined(expression) -> bool compiler.currentType = Type.bool; if (typeArguments) { compiler.error( @@ -164,7 +371,7 @@ export function compileCall( ); return module.createI32(element ? 1 : 0); } - case "isConstant": { // isConstant(expression) -> bool + case BuiltinSymbols.isConstant: { // isConstant(expression) -> bool compiler.currentType = Type.bool; if (typeArguments) { compiler.error( @@ -183,7 +390,7 @@ export function compileCall( compiler.currentType = Type.bool; return module.createI32(getExpressionId(expr) == ExpressionId.Const ? 1 : 0); } - case "isManaged": { // isManaged() -> bool + case BuiltinSymbols.isManaged: { // isManaged() -> bool if (!compiler.program.hasGC) { compiler.currentType = Type.bool; return module.createI32(0); @@ -199,7 +406,7 @@ export function compileCall( // math - case "clz": { // clz(value: T) -> T + case BuiltinSymbols.clz: { // clz(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -279,7 +486,7 @@ export function compileCall( } return ret; } - case "ctz": { // ctz(value: T) -> T + case BuiltinSymbols.ctz: { // ctz(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -359,7 +566,7 @@ export function compileCall( } return ret; } - case "popcnt": { // popcnt(value: T) -> T + case BuiltinSymbols.popcnt: { // popcnt(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -439,7 +646,7 @@ export function compileCall( } return ret; } - case "rotl": { // rotl(value: T, shift: T) -> T + case BuiltinSymbols.rotl: { // rotl(value: T, shift: T) -> T if (operands.length != 2) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -524,7 +731,7 @@ export function compileCall( } return ret; // possibly overflows } - case "rotr": { // rotr(value: T, shift: T) -> T + case BuiltinSymbols.rotr: { // rotr(value: T, shift: T) -> T if (operands.length != 2) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -609,7 +816,7 @@ export function compileCall( } return ret; // possibly overflowws } - case "abs": { // abs(value: T) -> T + case BuiltinSymbols.abs: { // abs(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -761,7 +968,7 @@ export function compileCall( } return ret; } - case "max": { // max(left: T, right: T) -> T + case BuiltinSymbols.max: { // max(left: T, right: T) -> T if (operands.length != 2) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -933,7 +1140,7 @@ export function compileCall( } return ret; } - case "min": { // min(left: T, right: T) -> T + case BuiltinSymbols.min: { // min(left: T, right: T) -> T if (operands.length != 2) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1105,7 +1312,7 @@ export function compileCall( } return ret; } - case "ceil": { // ceil(value: T) -> T + case BuiltinSymbols.ceil: { // ceil(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1170,7 +1377,7 @@ export function compileCall( } return ret; } - case "floor": { // floor(value: T) -> T + case BuiltinSymbols.floor: { // floor(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1235,7 +1442,7 @@ export function compileCall( } return ret; } - case "copysign": { // copysign(left: T, right: T) -> T + case BuiltinSymbols.copysign: { // copysign(left: T, right: T) -> T if (operands.length != 2) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1286,7 +1493,7 @@ export function compileCall( } return ret; } - case "nearest": { // nearest(value: T) -> T + case BuiltinSymbols.nearest: { // nearest(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1351,7 +1558,7 @@ export function compileCall( } return ret; } - case "reinterpret": { // reinterpret(value: *) -> T + case BuiltinSymbols.reinterpret: { // reinterpret(value: *) -> T if (operands.length != 1) { if (!(typeArguments && typeArguments.length == 1)) { if (typeArguments && typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1437,7 +1644,7 @@ export function compileCall( compiler.currentType = typeArguments[0]; return ret; } - case "sqrt": { // sqrt(value: T) -> T + case BuiltinSymbols.sqrt: { // sqrt(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1488,7 +1695,7 @@ export function compileCall( } return ret; } - case "trunc": { // trunc(value: T) -> T + case BuiltinSymbols.trunc: { // trunc(value: T) -> T if (operands.length != 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -1558,7 +1765,7 @@ export function compileCall( // memory access - case "load": { // load(offset: usize, constantOffset?: usize) -> * + case BuiltinSymbols.load: { // load(offset: usize, constantOffset?: usize) -> * if (operands.length < 1 || operands.length > 2) { if (!(typeArguments && typeArguments.length == 1)) { compiler.error( @@ -1610,7 +1817,7 @@ export function compileCall( offset ); } - case "store": { // store(offset: usize, value: *, constantOffset?: usize) -> void + case BuiltinSymbols.store: { // store(offset: usize, value: *, constantOffset?: usize) -> void compiler.currentType = Type.void; if (operands.length < 2 || operands.length > 3) { if (!(typeArguments && typeArguments.length == 1)) { @@ -1679,7 +1886,7 @@ export function compileCall( compiler.currentType = Type.void; return module.createStore(typeArguments[0].byteSize, arg0, arg1, type.toNativeType(), offset); } - case "atomic.load": { // load(offset: usize, constantOffset?: usize) -> * + case BuiltinSymbols.atomic_load: { // load(offset: usize, constantOffset?: usize) -> * if (!compiler.options.hasFeature(Feature.THREADS)) break; if (operands.length < 1 || operands.length > 2) { if (!(typeArguments && typeArguments.length == 1)) { @@ -1731,7 +1938,7 @@ export function compileCall( offset ); } - case "atomic.store": { // store(offset: usize, value: *, constantOffset?: usize) -> void + case BuiltinSymbols.atomic_store: { // store(offset: usize, value: *, constantOffset?: usize) -> void if (!compiler.options.hasFeature(Feature.THREADS)) break; compiler.currentType = Type.void; if (operands.length < 2 || operands.length > 3) { @@ -1801,12 +2008,12 @@ export function compileCall( compiler.currentType = Type.void; return module.createAtomicStore(typeArguments[0].byteSize, arg0, arg1, type.toNativeType(), offset); } - case "atomic.add": // add(ptr: usize, value: T, constantOffset?: usize): T; - case "atomic.sub": // sub(ptr: usize, value: T, constantOffset?: usize): T; - case "atomic.and": // and(ptr: usize, value: T, constantOffset?: usize): T; - case "atomic.or": // or(ptr: usize, value: T, constantOffset?: usize): T; - case "atomic.xor": // xor(ptr: usize, value: T, constantOffset?: usize): T; - case "atomic.xchg": // xchg(ptr: usize, value: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_add: // add(ptr: usize, value: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_sub: // sub(ptr: usize, value: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_and: // and(ptr: usize, value: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_or: // or(ptr: usize, value: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_xor: // xor(ptr: usize, value: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_xchg: // xchg(ptr: usize, value: T, constantOffset?: usize): T; { if (!compiler.options.hasFeature(Feature.THREADS)) break; if (operands.length < 2 || operands.length > 3) { @@ -1876,13 +2083,13 @@ export function compileCall( return module.createUnreachable(); } let RMWOp: AtomicRMWOp | null = null; - switch (prototype.simpleName) { - case "add": { RMWOp = AtomicRMWOp.Add; break; } - case "sub": { RMWOp = AtomicRMWOp.Sub; break; } - case "and": { RMWOp = AtomicRMWOp.And; break; } - case "or": { RMWOp = AtomicRMWOp.Or; break; } - case "xor": { RMWOp = AtomicRMWOp.Xor; break; } - case "xchg": { RMWOp = AtomicRMWOp.Xchg; break; } + switch (prototype.internalName) { + case BuiltinSymbols.atomic_add: { RMWOp = AtomicRMWOp.Add; break; } + case BuiltinSymbols.atomic_sub: { RMWOp = AtomicRMWOp.Sub; break; } + case BuiltinSymbols.atomic_and: { RMWOp = AtomicRMWOp.And; break; } + case BuiltinSymbols.atomic_or: { RMWOp = AtomicRMWOp.Or; break; } + case BuiltinSymbols.atomic_xor: { RMWOp = AtomicRMWOp.Xor; break; } + case BuiltinSymbols.atomic_xchg: { RMWOp = AtomicRMWOp.Xchg; break; } } compiler.currentType = typeArguments[0]; if (RMWOp !== null) { @@ -1897,7 +2104,7 @@ export function compileCall( return module.createUnreachable(); } } - case "atomic.cmpxchg": { // cmpxchg(ptr: usize, expected:T, replacement: T, constantOffset?: usize): T; + case BuiltinSymbols.atomic_cmpxchg: { // cmpxchg(ptr: usize, expected: T, replacement: T, cOff?: usize): T if (!compiler.options.hasFeature(Feature.THREADS)) break; if (operands.length < 3 || operands.length > 4) { if (!(typeArguments && typeArguments.length == 1)) { @@ -1985,7 +2192,7 @@ export function compileCall( typeArguments[0].byteSize, offset, arg0, arg1, arg2, type.toNativeType() ); } - case "atomic.wait": { // wait(ptr: usize, expected:T, timeout: i64): i32; + case BuiltinSymbols.atomic_wait: { // wait(ptr: usize, expected:T, timeout: i64): i32; if (!compiler.options.hasFeature(Feature.THREADS)) break; let hasError = typeArguments == null; if (operands.length != 3) { @@ -2056,7 +2263,7 @@ export function compileCall( arg0, arg1, arg2, type.toNativeType() ); } - case "atomic.notify": { // notify(ptr: usize, count: u32): u32; + case BuiltinSymbols.atomic_notify: { // notify(ptr: usize, count: u32): u32; if (!compiler.options.hasFeature(Feature.THREADS)) break; let hasError = typeArguments == null; if (operands.length != 2) { @@ -2095,7 +2302,7 @@ export function compileCall( arg0, arg1 ); } - case "sizeof": { // sizeof() -> usize + case BuiltinSymbols.sizeof: { // sizeof() -> usize compiler.currentType = compiler.options.usizeType; if (operands.length != 0) { if (!(typeArguments && typeArguments.length == 1)) { @@ -2136,7 +2343,7 @@ export function compileCall( } return ret; } - case "alignof": { // alignof() -> usize + case BuiltinSymbols.alignof: { // alignof() -> usize compiler.currentType = compiler.options.usizeType; if (operands.length != 0) { if (!(typeArguments && typeArguments.length == 1)) { @@ -2165,7 +2372,7 @@ export function compileCall( case 2: { alignLog2 = 1; break; } case 4: { alignLog2 = 2; break; } case 8: { alignLog2 = 3; break; } - default: { assert(false); return module.createUnreachable(); } + default: { assert(false, "unexected byte size"); return module.createUnreachable(); } } if (compiler.options.isWasm64) { // implicitly wrap if contextual type is a 32-bit integer @@ -2186,7 +2393,7 @@ export function compileCall( } return ret; } - case "offsetof": { // offsetof(fieldName?: string) -> usize + case BuiltinSymbols.offsetof: { // offsetof(fieldName?: string) -> usize compiler.currentType = compiler.options.usizeType; if (operands.length > 1) { if (!(typeArguments && typeArguments.length == 1)) { @@ -2262,7 +2469,7 @@ export function compileCall( // control flow - case "select": { // select(ifTrue: T, ifFalse: T, condition: bool) -> T + case BuiltinSymbols.select: { // select(ifTrue: T, ifFalse: T, condition: bool) -> T if (operands.length != 3) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -2323,7 +2530,7 @@ export function compileCall( } return ret; } - case "unreachable": { // unreachable() -> * + case BuiltinSymbols.unreachable: { // unreachable() -> * if (operands.length != 0) { compiler.error( DiagnosticCode.Expected_0_arguments_but_got_1, @@ -2341,7 +2548,7 @@ export function compileCall( // host operations - case "memory.size": { // memory.size() -> i32 + case BuiltinSymbols.memory_size: { // memory.size() -> i32 compiler.currentType = Type.i32; if (operands.length != 0) { compiler.error( @@ -2357,7 +2564,7 @@ export function compileCall( } return module.createHost(HostOp.CurrentMemory); } - case "memory.grow": { // memory.grow(pages: i32) -> i32 + case BuiltinSymbols.memory_grow: { // memory.grow(pages: i32) -> i32 compiler.currentType = Type.i32; if (operands.length != 1) { compiler.error( @@ -2377,7 +2584,7 @@ export function compileCall( return module.createHost(HostOp.GrowMemory, null, [ arg0 ]); } // see: https://github.com/WebAssembly/bulk-memory-operations - case "memory.copy": { // memory.copy(dest: usize, src: usize: n: usize) -> void + case BuiltinSymbols.memory_copy: { // memory.copy(dest: usize, src: usize: n: usize) -> void if (!compiler.options.hasFeature(Feature.BULK_MEMORY)) { let instance = compiler.resolver.resolveFunction(prototype, null); // reports compiler.currentType = Type.void; @@ -2420,7 +2627,7 @@ export function compileCall( compiler.currentType = Type.void; return module.createMemoryCopy(arg0, arg1, arg2); } - case "memory.fill": { // memory.fill(dest: usize, value: u8, n: usize) -> void + case BuiltinSymbols.memory_fill: { // memory.fill(dest: usize, value: u8, n: usize) -> void if (!compiler.options.hasFeature(Feature.BULK_MEMORY)) { let instance = compiler.resolver.resolveFunction(prototype, null); // reports compiler.currentType = Type.void; @@ -2466,7 +2673,7 @@ export function compileCall( // other - case "changetype": { // changetype(value: *) -> T + case BuiltinSymbols.changetype: { // changetype(value: *) -> T if (!(typeArguments && typeArguments.length == 1)) { if (typeArguments && typeArguments.length) compiler.currentType = typeArguments[0]; compiler.error( @@ -2500,7 +2707,7 @@ export function compileCall( // compiler.warning(DiagnosticCode.Operation_is_unsafe, reportNode.range); return arg0; // any usize to any usize } - case "assert": { // assert(isTrueish: T, message?: string) -> T with T != null + case BuiltinSymbols.assert: { // assert(isTrueish: T, message?: string) -> T with T != null if (operands.length < 1 || operands.length > 2) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0].nonNullableType; @@ -2712,7 +2919,7 @@ export function compileCall( } return ret; } - case "unchecked": { + case BuiltinSymbols.unchecked: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2732,7 +2939,7 @@ export function compileCall( flow.unset(FlowFlags.UNCHECKED_CONTEXT); return ret; } - case "call_indirect": { // call_indirect(target: Function | u32, ...args: *[]) -> T + case BuiltinSymbols.call_indirect: { // call_indirect(target: Function | u32, ...args: *[]) -> T if (operands.length < 1) { if (typeArguments) { if (typeArguments.length) compiler.currentType = typeArguments[0]; @@ -2791,7 +2998,7 @@ export function compileCall( // thus must be used with care. it exists because it *might* be useful in specific scenarios. return module.createCallIndirect(arg0, operandExprs, typeName); } - case "instantiate": { + case BuiltinSymbols.instantiate: { if (!(typeArguments && typeArguments.length == 1)) { if (typeArguments && typeArguments.length) compiler.currentType = typeArguments[0]; compiler.error( @@ -2813,21 +3020,21 @@ export function compileCall( // user-defined diagnostic macros - case "ERROR": { + case BuiltinSymbols.ERROR: { compiler.error( DiagnosticCode.User_defined_0, reportNode.range, (operands.length ? operands[0] : reportNode).range.toString() ); return module.createUnreachable(); } - case "WARNING": { + case BuiltinSymbols.WARNING: { compiler.warning( DiagnosticCode.User_defined_0, reportNode.range, (operands.length ? operands[0] : reportNode).range.toString() ); return module.createNop(); } - case "INFO": { + case BuiltinSymbols.INFO: { compiler.info( DiagnosticCode.User_defined_0, reportNode.range, (operands.length ? operands[0] : reportNode).range.toString() @@ -2837,7 +3044,7 @@ export function compileCall( // conversions - case "i8": { + case BuiltinSymbols.i8: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2859,7 +3066,7 @@ export function compileCall( WrapMode.NONE ); } - case "i16": { + case BuiltinSymbols.i16: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2881,7 +3088,7 @@ export function compileCall( WrapMode.NONE ); } - case "i32": { + case BuiltinSymbols.i32: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2903,7 +3110,7 @@ export function compileCall( WrapMode.NONE ); } - case "i64": { + case BuiltinSymbols.i64: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2925,7 +3132,7 @@ export function compileCall( WrapMode.NONE ); } - case "isize": { + case BuiltinSymbols.isize: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2951,7 +3158,7 @@ export function compileCall( WrapMode.NONE ); } - case "u8": { + case BuiltinSymbols.u8: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2973,7 +3180,7 @@ export function compileCall( WrapMode.NONE ); } - case "u16": { + case BuiltinSymbols.u16: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -2995,7 +3202,7 @@ export function compileCall( WrapMode.NONE ); } - case "u32": { + case BuiltinSymbols.u32: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3017,7 +3224,7 @@ export function compileCall( WrapMode.NONE ); } - case "u64": { + case BuiltinSymbols.u64: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3039,7 +3246,7 @@ export function compileCall( WrapMode.NONE ); } - case "usize": { + case BuiltinSymbols.usize: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3061,7 +3268,7 @@ export function compileCall( WrapMode.NONE ); } - case "bool": { + case BuiltinSymbols.bool: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3083,7 +3290,7 @@ export function compileCall( WrapMode.NONE ); } - case "f32": { + case BuiltinSymbols.f32: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3105,7 +3312,7 @@ export function compileCall( WrapMode.NONE ); } - case "f64": { + case BuiltinSymbols.f64: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3127,10 +3334,11 @@ export function compileCall( WrapMode.NONE ); } + // TODO: v128 // gc - case "iterateRoots": { + case BuiltinSymbols.iterateRoots: { if (typeArguments) { compiler.error( DiagnosticCode.Type_0_is_not_generic, @@ -3200,156 +3408,131 @@ function deferASMCall( // and, or, xor, shl, shr_u, shr_s // eq, eqz, ne, lt_s, lt_u, le_s, le_u, gt_s, gt_u, ge_s, ge_u - case "i32.clz": return deferASM("clz", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.clz": return deferASM("clz", compiler, Type.i64, operands, Type.i64, reportNode); - - case "i32.ctz": return deferASM("ctz", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.ctz": return deferASM("ctz", compiler, Type.i64, operands, Type.i64, reportNode); - - case "i32.popcnt": return deferASM("popcnt", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.popcnt": return deferASM("popcnt", compiler, Type.i64, operands, Type.i64, reportNode); - - case "i32.rotl": return deferASM("rotl", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.rotl": return deferASM("rotl", compiler, Type.i64, operands, Type.i64, reportNode); - - case "i32.rotr": return deferASM("rotr", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.rotr": return deferASM("rotr", compiler, Type.i64, operands, Type.i64, reportNode); - - case "f32.abs": return deferASM("abs", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.abs": return deferASM("abs", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.max": return deferASM("max", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.max": return deferASM("max", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.min": return deferASM("min", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.min": return deferASM("min", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.ceil": return deferASM("ceil", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.ceil": return deferASM("ceil", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.floor": return deferASM("floor", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.floor": return deferASM("floor", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.copysign": return deferASM("copysign", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.copysign": return deferASM("copysign", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.nearest": return deferASM("nearest", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.nearest": return deferASM("nearest", compiler, Type.f64, operands, Type.f64, reportNode); - - case "i32.reinterpret_f32": return deferASM("reinterpret", compiler, Type.i32, operands, Type.f32, reportNode); - case "i64.reinterpret_f64": return deferASM("reinterpret", compiler, Type.i64, operands, Type.f64, reportNode); - case "f32.reinterpret_i32": return deferASM("reinterpret", compiler, Type.f32, operands, Type.i32, reportNode); - case "f64.reinterpret_i64": return deferASM("reinterpret", compiler, Type.f64, operands, Type.i64, reportNode); - - case "f32.sqrt": return deferASM("sqrt", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.sqrt": return deferASM("sqrt", compiler, Type.f64, operands, Type.f64, reportNode); - - case "f32.trunc": return deferASM("trunc", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.trunc": return deferASM("trunc", compiler, Type.f64, operands, Type.f64, reportNode); - - case "i32.load8_s": return deferASM("load", compiler, Type.i8, operands, Type.i32, reportNode); - case "i32.load8_u": return deferASM("load", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.load16_s": return deferASM("load", compiler, Type.i16, operands, Type.i32, reportNode); - case "i32.load16_u": return deferASM("load", compiler, Type.u16, operands, Type.u32, reportNode); - case "i32.load": return deferASM("load", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.load8_s": return deferASM("load", compiler, Type.i8, operands, Type.i64, reportNode); - case "i64.load8_u": return deferASM("load", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.load16_s": return deferASM("load", compiler, Type.i16, operands, Type.i64, reportNode); - case "i64.load16_u": return deferASM("load", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.load32_s": return deferASM("load", compiler, Type.i32, operands, Type.i64, reportNode); - case "i64.load32_u": return deferASM("load", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.load": return deferASM("load", compiler, Type.i64, operands, Type.i64, reportNode); - case "f32.load": return deferASM("load", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.load": return deferASM("load", compiler, Type.f64, operands, Type.f64, reportNode); - - case "i32.store8": return deferASM("store", compiler, Type.i8, operands, Type.i32, reportNode); - case "i32.store16": return deferASM("store", compiler, Type.i16, operands, Type.i32, reportNode); - case "i32.store": return deferASM("store", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.store8": return deferASM("store", compiler, Type.i8, operands, Type.i64, reportNode); - case "i64.store16": return deferASM("store", compiler, Type.i16, operands, Type.i64, reportNode); - case "i64.store32": return deferASM("store", compiler, Type.i32, operands, Type.i64, reportNode); - case "i64.store": return deferASM("store", compiler, Type.i64, operands, Type.i64, reportNode); - case "f32.store": return deferASM("store", compiler, Type.f32, operands, Type.f32, reportNode); - case "f64.store": return deferASM("store", compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.i32_clz: return deferASM(BuiltinSymbols.clz, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_clz: return deferASM(BuiltinSymbols.clz, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_ctz: return deferASM(BuiltinSymbols.ctz, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_ctz: return deferASM(BuiltinSymbols.ctz, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_popcnt: return deferASM(BuiltinSymbols.popcnt, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_popcnt: return deferASM(BuiltinSymbols.popcnt, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_rotl: return deferASM(BuiltinSymbols.rotl, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_rotl: return deferASM(BuiltinSymbols.rotl, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_rotr: return deferASM(BuiltinSymbols.rotr, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_rotr: return deferASM(BuiltinSymbols.rotr, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.f32_abs: return deferASM(BuiltinSymbols.abs, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_abs: return deferASM(BuiltinSymbols.abs, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_max: return deferASM(BuiltinSymbols.max, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_max: return deferASM(BuiltinSymbols.max, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_min: return deferASM(BuiltinSymbols.min, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_min: return deferASM(BuiltinSymbols.min, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_ceil: return deferASM(BuiltinSymbols.ceil, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_ceil: return deferASM(BuiltinSymbols.ceil, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_floor: return deferASM(BuiltinSymbols.floor, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_floor: return deferASM(BuiltinSymbols.floor, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_copysign: return deferASM(BuiltinSymbols.copysign, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_copysign: return deferASM(BuiltinSymbols.copysign, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_nearest: return deferASM(BuiltinSymbols.nearest, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_nearest: return deferASM(BuiltinSymbols.nearest, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.i32_reinterpret_f32: return deferASM(BuiltinSymbols.reinterpret, compiler, Type.i32, operands, Type.f32, reportNode); + case BuiltinSymbols.i64_reinterpret_f64: return deferASM(BuiltinSymbols.reinterpret, compiler, Type.i64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_reinterpret_i32: return deferASM(BuiltinSymbols.reinterpret, compiler, Type.f32, operands, Type.i32, reportNode); + case BuiltinSymbols.f64_reinterpret_i64: return deferASM(BuiltinSymbols.reinterpret, compiler, Type.f64, operands, Type.i64, reportNode); + case BuiltinSymbols.f32_sqrt: return deferASM(BuiltinSymbols.sqrt, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_sqrt: return deferASM(BuiltinSymbols.sqrt, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.f32_trunc: return deferASM(BuiltinSymbols.trunc, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_trunc: return deferASM(BuiltinSymbols.trunc, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.i32_load8_s: return deferASM(BuiltinSymbols.load, compiler, Type.i8, operands, Type.i32, reportNode); + case BuiltinSymbols.i32_load8_u: return deferASM(BuiltinSymbols.load, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_load16_s: return deferASM(BuiltinSymbols.load, compiler, Type.i16, operands, Type.i32, reportNode); + case BuiltinSymbols.i32_load16_u: return deferASM(BuiltinSymbols.load, compiler, Type.u16, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_load: return deferASM(BuiltinSymbols.load, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_load8_s: return deferASM(BuiltinSymbols.load, compiler, Type.i8, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_load8_u: return deferASM(BuiltinSymbols.load, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_load16_s: return deferASM(BuiltinSymbols.load, compiler, Type.i16, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_load16_u: return deferASM(BuiltinSymbols.load, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_load32_s: return deferASM(BuiltinSymbols.load, compiler, Type.i32, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_load32_u: return deferASM(BuiltinSymbols.load, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_load: return deferASM(BuiltinSymbols.load, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.f32_load: return deferASM(BuiltinSymbols.load, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_load: return deferASM(BuiltinSymbols.load, compiler, Type.f64, operands, Type.f64, reportNode); + case BuiltinSymbols.i32_store8: return deferASM(BuiltinSymbols.store, compiler, Type.i8, operands, Type.i32, reportNode); + case BuiltinSymbols.i32_store16: return deferASM(BuiltinSymbols.store, compiler, Type.i16, operands, Type.i32, reportNode); + case BuiltinSymbols.i32_store: return deferASM(BuiltinSymbols.store, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_store8: return deferASM(BuiltinSymbols.store, compiler, Type.i8, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_store16: return deferASM(BuiltinSymbols.store, compiler, Type.i16, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_store32: return deferASM(BuiltinSymbols.store, compiler, Type.i32, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_store: return deferASM(BuiltinSymbols.store, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.f32_store: return deferASM(BuiltinSymbols.store, compiler, Type.f32, operands, Type.f32, reportNode); + case BuiltinSymbols.f64_store: return deferASM(BuiltinSymbols.store, compiler, Type.f64, operands, Type.f64, reportNode); } if (compiler.options.hasFeature(Feature.THREADS)) { switch (prototype.internalName) { - case "i32.atomic.load8_u": return deferASM("atomic.load", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.load16_u": return deferASM("atomic.load", compiler, Type.u16, operands, Type.u32, reportNode); - case "i32.atomic.load": return deferASM("atomic.load", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.atomic.load8_u": return deferASM("atomic.load", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.load16_u": return deferASM("atomic.load", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.load32_u": return deferASM("atomic.load", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.load": return deferASM("atomic.load", compiler, Type.i64, operands, Type.i64, reportNode); - - case "i32.atomic.store8": return deferASM("atomic.store", compiler, Type.i8, operands, Type.i32, reportNode); - case "i32.atomic.store16": return deferASM("atomic.store", compiler, Type.i16, operands, Type.i32, reportNode); - case "i32.atomic.store": return deferASM("atomic.store", compiler, Type.i32, operands, Type.i32, reportNode); - case "i64.atomic.store8": return deferASM("atomic.store", compiler, Type.i8, operands, Type.i64, reportNode); - case "i64.atomic.store16": return deferASM("atomic.store", compiler, Type.i16, operands, Type.i64, reportNode); - case "i64.atomic.store32": return deferASM("atomic.store", compiler, Type.i32, operands, Type.i64, reportNode); - case "i64.atomic.store": return deferASM("atomic.store", compiler, Type.i64, operands, Type.i64, reportNode); - - case "i32.atomic.rmw8_u.add": return deferASM("atomic.add", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.add": return deferASM("atomic.add", compiler, Type.u16, operands, Type.u32, reportNode); - case "i32.atomic.rmw.add": return deferASM("atomic.add", compiler, Type.u32, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.add": return deferASM("atomic.add", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.add": return deferASM("atomic.add", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.add": return deferASM("atomic.add", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.add": return deferASM("atomic.add", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.atomic.rmw8_u.sub": return deferASM("atomic.sub", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.sub": return deferASM("atomic.sub", compiler, Type.u16, operands, Type.u32, reportNode); - case "i32.atomic.rmw.sub": return deferASM("atomic.sub", compiler, Type.u32, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.sub": return deferASM("atomic.sub", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.sub": return deferASM("atomic.sub", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.sub": return deferASM("atomic.sub", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.sub": return deferASM("atomic.sub", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.atomic.rmw8_u.and": return deferASM("atomic.and", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.and": return deferASM("atomic.and", compiler, Type.u16, operands, Type.u32, reportNode); - case "i32.atomic.rmw.and": return deferASM("atomic.and", compiler, Type.u32, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.and": return deferASM("atomic.and", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.and": return deferASM("atomic.and", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.and": return deferASM("atomic.and", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.and": return deferASM("atomic.and", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.atomic.rmw8_u.or": return deferASM("atomic.or", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.or": return deferASM("atomic.or", compiler, Type.u16, operands, Type.u32, reportNode); - case "i32.atomic.rmw.or": return deferASM("atomic.or", compiler, Type.u32, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.or": return deferASM("atomic.or", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.or": return deferASM("atomic.or", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.or": return deferASM("atomic.or", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.or": return deferASM("atomic.or", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.atomic.rmw8_u.xor": return deferASM("atomic.xor", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.xor": return deferASM("atomic.xor", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw.xor": return deferASM("atomic.xor", compiler, Type.u8, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.xor": return deferASM("atomic.xor", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.xor": return deferASM("atomic.xor", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.xor": return deferASM("atomic.xor", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.xor": return deferASM("atomic.xor", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.atomic.rmw8_u.xchg": return deferASM("atomic.xchg", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.xchg": return deferASM("atomic.xchg", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw.xchg": return deferASM("atomic.xchg", compiler, Type.u8, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.xchg": return deferASM("atomic.xchg", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.xchg": return deferASM("atomic.xchg", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.xchg": return deferASM("atomic.xchg", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.xchg": return deferASM("atomic.xchg", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.atomic.rmw8_u.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw16_u.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u8, operands, Type.u32, reportNode); - case "i32.atomic.rmw.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u8, operands, Type.u32, reportNode); - case "i64.atomic.rmw8_u.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u8, operands, Type.u64, reportNode); - case "i64.atomic.rmw16_u.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u16, operands, Type.u64, reportNode); - case "i64.atomic.rmw32_u.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u32, operands, Type.u64, reportNode); - case "i64.atomic.rmw.cmpxchg": return deferASM("atomic.cmpxchg", compiler, Type.u64, operands, Type.u64, reportNode); - - case "i32.wait": return deferASM("atomic.wait", compiler, Type.i32, operands, Type.u32, reportNode); - case "i64.wait": return deferASM("atomic.wait", compiler, Type.i64, operands, Type.i64, reportNode); - case "i32.notify": return deferASM("atomic.notify", compiler, Type.i32, operands, Type.u32, reportNode); - case "i64.notify": return deferASM("atomic.notify", compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_atomic_load8_u: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_load16_u: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.u16, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_load: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_atomic_load8_u: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_load16_u: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_load32_u: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_load: return deferASM(BuiltinSymbols.atomic_load, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_atomic_store8: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i8, operands, Type.i32, reportNode); + case BuiltinSymbols.i32_atomic_store16: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i16, operands, Type.i32, reportNode); + case BuiltinSymbols.i32_atomic_store: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i32, operands, Type.i32, reportNode); + case BuiltinSymbols.i64_atomic_store8: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i8, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_atomic_store16: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i16, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_atomic_store32: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i32, operands, Type.i64, reportNode); + case BuiltinSymbols.i64_atomic_store: return deferASM(BuiltinSymbols.atomic_store, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u16, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u32, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_add: return deferASM(BuiltinSymbols.atomic_add, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u16, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u32, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_sub: return deferASM(BuiltinSymbols.atomic_sub, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u16, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u32, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_and: return deferASM(BuiltinSymbols.atomic_and, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u16, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u32, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_or: return deferASM(BuiltinSymbols.atomic_or, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_xor: return deferASM(BuiltinSymbols.atomic_xor, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_xchg: return deferASM(BuiltinSymbols.atomic_xchg, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_atomic_rmw8_u_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw16_u_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i32_atomic_rmw_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u8, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_atomic_rmw8_u_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u8, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw16_u_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u16, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw32_u_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u32, operands, Type.u64, reportNode); + case BuiltinSymbols.i64_atomic_rmw_cmpxchg: return deferASM(BuiltinSymbols.atomic_cmpxchg, compiler, Type.u64, operands, Type.u64, reportNode); + case BuiltinSymbols.i32_wait: return deferASM(BuiltinSymbols.atomic_wait, compiler, Type.i32, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_wait: return deferASM(BuiltinSymbols.atomic_wait, compiler, Type.i64, operands, Type.i64, reportNode); + case BuiltinSymbols.i32_notify: return deferASM(BuiltinSymbols.atomic_notify, compiler, Type.i32, operands, Type.u32, reportNode); + case BuiltinSymbols.i64_notify: return deferASM(BuiltinSymbols.atomic_notify, compiler, Type.i64, operands, Type.i64, reportNode); } } /* tslint:enable:max-line-length */ @@ -3365,19 +3548,8 @@ function deferASM( valueType: Type, reportNode: CallExpression ): ExpressionRef { - // Built-in wasm functions can be namespaced like atomic.{OPERATION} - // Split name by '.' to find member function prototype - // FIXME: This is slower than it needs to be due to the way resolving works atm - var names = name.split("."); - var prototype: Element = assert(compiler.program.elementsLookup.get(names[0])); - if (names.length > 1) { - for (let i = 1; i < names.length; i++) { - const subName = names[i]; - if (prototype && prototype.members) { - prototype = assert(prototype.members.get(subName)); - } - } - } + assert(compiler.program.elementsByName.has(name)); + var prototype = compiler.program.elementsByName.get(name)!; assert(prototype.kind == ElementKind.FUNCTION_PROTOTYPE); return compileCall(compiler, prototype, [ typeArgument ], operands, valueType, reportNode); } @@ -3475,15 +3647,15 @@ export function compileAbort( var program = compiler.program; var module = compiler.module; - var stringType = program.typesLookup.get("string"); - if (!stringType) return module.createUnreachable(); + var stringInstance = compiler.program.stringInstance; + if (!stringInstance) return module.createUnreachable(); var abortInstance = program.abortInstance; if (!(abortInstance && compiler.compileFunction(abortInstance))) return module.createUnreachable(); var messageArg = message != null - ? compiler.compileExpression(message, stringType, ConversionKind.IMPLICIT, WrapMode.NONE) - : stringType.toNativeZero(module); + ? compiler.compileExpression(message, stringInstance.type, ConversionKind.IMPLICIT, WrapMode.NONE) + : stringInstance.type.toNativeZero(module); var filenameArg = compiler.ensureStaticString(reportNode.range.source.normalizedPath); @@ -3507,7 +3679,7 @@ export function compileIterateRoots(compiler: Compiler): void { var module = compiler.module; var exprs = new Array(); - for (let element of compiler.program.elementsLookup.values()) { + for (let element of compiler.program.elementsByName.values()) { if (element.kind != ElementKind.GLOBAL) continue; let global = element; let classReference = global.type.classReference; @@ -3567,9 +3739,9 @@ export function ensureGCHook( if (existingIndex != -1) return existingIndex; } - // check if the class implements a custom GC function (only valid for internals) + // check if the class implements a custom GC function (only valid for library elements) var members = classInstance.members; - if (classInstance.prototype.declaration.range.source.isLibrary) { + if (classInstance.isDeclaredInLibrary) { if (members !== null && members.has("__gc")) { let gcPrototype = assert(members.get("__gc")); assert(gcPrototype.kind == ElementKind.FUNCTION_PROTOTYPE); diff --git a/src/common.ts b/src/common.ts index 925a88b850..c62186c49e 100644 --- a/src/common.ts +++ b/src/common.ts @@ -98,5 +98,84 @@ export const INNER_DELIMITER = "~"; export const LIBRARY_SUBST = "~lib"; /** Library directory prefix. */ export const LIBRARY_PREFIX = LIBRARY_SUBST + PATH_DELIMITER; -/** Prefix used to indicate a filespace element. */ -export const FILESPACE_PREFIX = "file:"; +/** Path index suffix. */ +export const INDEX_SUFFIX = PATH_DELIMITER + "index"; + +/** Common compiler symbols. */ +export namespace CommonSymbols { + // special + export const EMPTY = ""; + // types + export const i8 = "i8"; + export const i16 = "i16"; + export const i32 = "i32"; + export const i64 = "i64"; + export const isize = "isize"; + export const u8 = "u8"; + export const u16 = "u16"; + export const u32 = "u32"; + export const u64 = "u64"; + export const usize = "usize"; + export const bool = "bool"; + export const f32 = "f32"; + export const f64 = "f64"; + export const v128 = "v128"; + export const void_ = "void"; + export const number = "number"; + export const boolean = "boolean"; + export const string = "string"; + export const native = "native"; + // aliases + export const null_ = "null"; + export const true_ = "true"; + export const false_ = "false"; + // objects + export const this_ = "this"; + export const super_ = "super"; + export const constructor = "constructor"; +} + +/** Common standard library symbols. */ +export namespace LibrarySymbols { + // constants + export const ASC_TARGET = "ASC_TARGET"; + export const ASC_NO_TREESHAKING = "ASC_NO_TREESHAKING"; + export const ASC_NO_ASSERT = "ASC_NO_ASSERT"; + export const ASC_MEMORY_BASE = "ASC_MEMORY_BASE"; + export const ASC_OPTIMIZE_LEVEL = "ASC_OPTIMIZE_LEVEL"; + export const ASC_SHRINK_LEVEL = "ASC_SHRINK_LEVEL"; + export const ASC_FEATURE_MUTABLE_GLOBAL = "ASC_FEATURE_MUTABLE_GLOBAL"; + export const ASC_FEATURE_SIGN_EXTENSION = "ASC_FEATURE_SIGN_EXTENSION"; + export const ASC_FEATURE_BULK_MEMORY = "ASC_FEATURE_BULK_MEMORY"; + export const ASC_FEATURE_SIMD = "ASC_FEATURE_SIMD"; + // classes + export const I8 = "I8"; + export const I16 = "I16"; + export const I32 = "I32"; + export const I64 = "I64"; + export const Isize = "Isize"; + export const U8 = "U8"; + export const U16 = "U16"; + export const U32 = "U32"; + export const U64 = "U64"; + export const Usize = "Usize"; + export const Bool = "Bool"; + export const F32 = "F32"; + export const F64 = "F64"; + export const V128 = "V128"; + export const String = "String"; + export const Array = "Array"; + export const ArrayBuffer = "ArrayBuffer"; + export const Math = "Math"; + export const Mathf = "Mathf"; + // runtime + export const memory = "memory"; + export const allocate = "allocate"; + export const abort = "abort"; + export const main = "main"; + // other + export const length = "length"; + export const byteLength = "byteLength"; + export const pow = "pow"; + export const mod = "mod"; +} diff --git a/src/compiler.ts b/src/compiler.ts index 763a979337..27c84db723 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -7,7 +7,8 @@ import { compileCall as compileBuiltinCall, compileAbort, compileIterateRoots, - ensureGCHook + ensureGCHook, + BuiltinSymbols } from "./builtins"; import { @@ -33,7 +34,6 @@ import { getConstValueI64High, getConstValueF32, getConstValueF64, - getGetLocalIndex, getBlockChildCount, getBlockChild, getBlockName, @@ -42,12 +42,14 @@ import { import { CommonFlags, - PATH_DELIMITER, - INNER_DELIMITER, INSTANCE_DELIMITER, STATIC_DELIMITER, GETTER_PREFIX, - SETTER_PREFIX + SETTER_PREFIX, + LibrarySymbols, + CommonSymbols, + INDEX_SUFFIX, + LIBRARY_PREFIX } from "./common"; import { @@ -63,17 +65,22 @@ import { FunctionTarget, Global, Local, - Namespace, EnumValue, Property, VariableLikeElement, - FlowFlags, ConstantValueKind, - Flow, OperatorKind, - DecoratorFlags + DecoratorFlags, + PropertyPrototype, + File, + mangleInternalName } from "./program"; +import { + FlowFlags, + Flow +} from "./flow"; + import { Resolver, ReportMode } from "./resolver"; @@ -87,7 +94,6 @@ import { Node, NodeKind, TypeNode, - Source, Range, DecoratorKind, AssertionKind, @@ -103,7 +109,6 @@ import { EnumDeclaration, ExportStatement, ExpressionStatement, - FunctionDeclaration, ForStatement, IfStatement, ImportStatement, @@ -114,7 +119,6 @@ import { SwitchStatement, ThrowStatement, TryStatement, - VariableDeclaration, VariableStatement, VoidStatement, WhileStatement, @@ -142,8 +146,8 @@ import { UnaryPrefixExpression, nodeIsConstantValue, - isLastStatement, - findDecorator + findDecorator, + FieldDeclaration } from "./ast"; import { @@ -178,8 +182,6 @@ export class Options { /** WebAssembly target. Defaults to {@link Target.WASM32}. */ target: Target = Target.WASM32; - /** If true, compiles everything instead of just reachable code. */ - noTreeShaking: bool = false; /** If true, replaces assertions with nops. */ noAssert: bool = false; /** If true, imports the memory provided by the embedder. */ @@ -279,10 +281,8 @@ export class Compiler extends DiagnosticEmitter { currentEnum: Enum | null = null; /** Current type in compilation. */ currentType: Type = Type.void; - /** Start function being compiled. */ - startFunctionInstance: Function; /** Start function statements. */ - startFunctionBody: ExpressionRef[]; + currentBody: ExpressionRef[]; /** Counting memory offset. */ memoryOffset: I64; /** Memory segments being compiled. */ @@ -327,24 +327,24 @@ export class Compiler extends DiagnosticEmitter { // initialize lookup maps, built-ins, imports, exports, etc. program.initialize(options); - // set up the start function - var startFunctionInstance = new Function(program.startFunction, "start", new Signature([], Type.void)); - this.startFunctionInstance = startFunctionInstance; + // set up the main start function + var startFunctionInstance = program.makeNativeFunction("start", new Signature([], Type.void)); + startFunctionInstance.internalName = "start"; var startFunctionBody = new Array(); - this.startFunctionBody = startFunctionBody; this.currentFlow = startFunctionInstance.flow; + this.currentBody = startFunctionBody; // add a mutable heap base dummy if (options.isWasm64) { module.addGlobal( - "HEAP_BASE", + BuiltinSymbols.HEAP_BASE, NativeType.I64, true, module.createI64(0, 0) ); } else { module.addGlobal( - "HEAP_BASE", + BuiltinSymbols.HEAP_BASE, NativeType.I32, false, module.createI32(0) @@ -352,13 +352,17 @@ export class Compiler extends DiagnosticEmitter { } // compile entry file(s) while traversing reachable elements - var sources = program.sources; - for (let i = 0, k = sources.length; i < k; ++i) { - if (sources[i].isEntry) this.compileSource(sources[i]); + var files = program.filesByName; + for (let file of files.values()) { + if (file.source.isEntry) { + this.compileFile(file); + this.compileExports(file); + } } // compile the start function if not empty or called by main - if (startFunctionBody.length || program.mainFunction !== null) { + var explicitStartFunction = program.explicitStartFunction; + if (startFunctionBody.length || explicitStartFunction) { let signature = startFunctionInstance.signature; let funcRef = module.addFunction( startFunctionInstance.internalName, @@ -371,24 +375,24 @@ export class Compiler extends DiagnosticEmitter { module.createBlock(null, startFunctionBody) ); startFunctionInstance.finalize(module, funcRef); - if (!program.mainFunction) module.setStart(funcRef); + if (!explicitStartFunction) module.setStart(funcRef); } // update the heap base pointer var memoryOffset = this.memoryOffset; memoryOffset = i64_align(memoryOffset, options.usizeType.byteSize); this.memoryOffset = memoryOffset; - module.removeGlobal("HEAP_BASE"); + module.removeGlobal(BuiltinSymbols.HEAP_BASE); if (options.isWasm64) { module.addGlobal( - "HEAP_BASE", + BuiltinSymbols.HEAP_BASE, NativeType.I64, false, module.createI64(i64_low(memoryOffset), i64_high(memoryOffset)) ); } else { module.addGlobal( - "HEAP_BASE", + BuiltinSymbols.HEAP_BASE, NativeType.I32, false, module.createI32(i64_low(memoryOffset)) @@ -419,8 +423,8 @@ export class Compiler extends DiagnosticEmitter { if (options.importTable) module.addTableImport("0", "env", "table"); // set up module exports - for (let [name, moduleExport] of program.moduleLevelExports) { - this.makeModuleExport(name, moduleExport.element); + for (let file of this.program.filesByName.values()) { + if (file.source.isEntry) this.makeModuleExports(file); } // set up gc @@ -429,42 +433,65 @@ export class Compiler extends DiagnosticEmitter { return module; } + /** Applies the respective module exports for the specified file. */ + private makeModuleExports(file: File): void { + var members = file.exports; + if (members) for (let [name, member] of members) this.makeModuleExport(name, member); + var exportsStar = file.exportsStar; + if (exportsStar) { + for (let i = 0, k = exportsStar.length; i < k; ++i) this.makeModuleExports(exportsStar[i]); + } + } + /** Applies the respective module export(s) for the specified element. */ private makeModuleExport(name: string, element: Element, prefix: string = ""): void { + switch (element.kind) { - // traverse members - var members = element.members; - if (members) { - let subPrefix = prefix + name + (element.kind == ElementKind.CLASS - ? INSTANCE_DELIMITER - : STATIC_DELIMITER - ); - if (element.kind == ElementKind.NAMESPACE) { - for (let member of members.values()) { - if (!member.is(CommonFlags.EXPORT)) continue; - this.makeModuleExport(member.simpleName, member, subPrefix); + // traverse instances + case ElementKind.FUNCTION_PROTOTYPE: { + let instances = (element).instances; + if (instances) { + for (let instance of instances.values()) { + let instanceName = name; + if (instance.is(CommonFlags.GENERIC)) { + let fullName = instance.internalName; + instanceName += fullName.substring(fullName.lastIndexOf("<")); + } + this.makeModuleExport(instanceName, instance, prefix); + } } - } else { - for (let member of members.values()) { - if (member.is(CommonFlags.PRIVATE)) continue; - this.makeModuleExport(member.simpleName, member, subPrefix); + break; + } + case ElementKind.CLASS_PROTOTYPE: { + let instances = (element).instances; + if (instances) { + for (let instance of instances.values()) { + let instanceName = name; + if (instance.is(CommonFlags.GENERIC)) { + let fullName = instance.internalName; + instanceName += fullName.substring(fullName.lastIndexOf("<")); + } + this.makeModuleExport(instanceName, instance, prefix); + } } + break; + } + case ElementKind.PROPERTY_PROTOTYPE: { + let getter = (element).getterPrototype; + let setter = (element).setterPrototype; + if (getter) this.makeModuleExport(GETTER_PREFIX + name, getter, prefix); + if (setter) this.makeModuleExport(SETTER_PREFIX + name, setter, prefix); + break; } - } - - switch (element.kind) { - // export global + // export concrete elements case ElementKind.GLOBAL: { let isConst = element.is(CommonFlags.CONST) || element.is(CommonFlags.STATIC | CommonFlags.READONLY); if (!isConst && !this.options.hasFeature(Feature.MUTABLE_GLOBAL)) { - let declaration = (element).declaration; - if (declaration) { - this.error( - DiagnosticCode.Cannot_export_a_mutable_global, - declaration.name.range - ); - } + this.error( + DiagnosticCode.Cannot_export_a_mutable_global, + (element).identifierNode.range + ); } else { this.module.addGlobalExport(element.internalName, prefix + name); } @@ -472,20 +499,15 @@ export class Compiler extends DiagnosticEmitter { } case ElementKind.ENUMVALUE: { if (!assert(element.parent).is(CommonFlags.CONST) && !this.options.hasFeature(Feature.MUTABLE_GLOBAL)) { - let declaration = (element).declaration; - if (declaration) { - this.error( - DiagnosticCode.Cannot_export_a_mutable_global, - declaration.name.range - ); - } + this.error( + DiagnosticCode.Cannot_export_a_mutable_global, + (element).identifierNode.range + ); } else { this.module.addGlobalExport(element.internalName, prefix + name); } break; } - - // export function case ElementKind.FUNCTION: { let instance = element; let signature = instance.signature; @@ -497,17 +519,13 @@ export class Compiler extends DiagnosticEmitter { if (instance.is(CommonFlags.COMPILED)) this.module.addFunctionExport(instance.internalName, prefix + name); break; } - - // export getter and setter case ElementKind.PROPERTY: { - let getter = assert((element).getterPrototype); - this.makeModuleExport(GETTER_PREFIX + name, getter, prefix); - let setter = (element).setterPrototype; + let getter = (element).getterInstance; + if (getter) this.makeModuleExport(GETTER_PREFIX + name, getter, prefix); + let setter = (element).setterInstance; if (setter) this.makeModuleExport(SETTER_PREFIX + name, setter, prefix); break; } - - // export a getter and a setter case ElementKind.FIELD: { let module = this.module; let type = (element).type; @@ -552,201 +570,214 @@ export class Compiler extends DiagnosticEmitter { break; } - // skip prototype and export instances + // just traverse members below + case ElementKind.ENUM: + case ElementKind.CLASS: + case ElementKind.NAMESPACE: + case ElementKind.FILE: + case ElementKind.TYPEDEFINITION: break; + + default: assert(false); // unexpected module export + } + + // traverse members + var members = element.members; + if (members) { + let subPrefix = prefix + name + (element.kind == ElementKind.CLASS + ? INSTANCE_DELIMITER + : STATIC_DELIMITER + ); + if ( + element.kind == ElementKind.NAMESPACE || + element.kind == ElementKind.FILE + ) { + for (let member of members.values()) { + if (!member.is(CommonFlags.EXPORT)) continue; + this.makeModuleExport(member.name, member, subPrefix); + } + } else { + for (let member of members.values()) { + if (member.is(CommonFlags.PRIVATE)) continue; + this.makeModuleExport(member.name, member, subPrefix); + } + } + } + } + + // general + + /** Compiles any element. */ + compileElement(element: Element, compileMembers: bool = true): void { + switch (element.kind) { + case ElementKind.GLOBAL: { + this.compileGlobal(element); + break; + } + case ElementKind.ENUM: { + this.compileEnum(element); + break; + } case ElementKind.FUNCTION_PROTOTYPE: { - for (let instances of (element).instances.values()) { - for (let instance of instances.values()) { - let instanceName = name; - if (instance.is(CommonFlags.GENERIC)) { - let fullName = instance.internalName; - instanceName += fullName.substring(fullName.lastIndexOf("<")); - } - this.makeModuleExport(instanceName, instance, prefix); - } + if (!element.is(CommonFlags.GENERIC)) { + this.compileFunctionUsingTypeArguments(element, []); } break; } case ElementKind.CLASS_PROTOTYPE: { - for (let instance of (element).instances.values()) { - let instanceName = name; - if (instance.is(CommonFlags.GENERIC)) { - let fullName = instance.internalName; - instanceName += fullName.substring(fullName.lastIndexOf("<")); - } - let ctor = instance.constructorInstance; - if (ctor) this.makeModuleExport(instanceName + INSTANCE_DELIMITER + ctor.simpleName, ctor, prefix); - this.makeModuleExport(instanceName, instance, prefix); + if (!element.is(CommonFlags.GENERIC)) { + this.compileClassUsingTypeArguments(element, []); } break; } - - // all possible members already handled above - case ElementKind.ENUM: - case ElementKind.CLASS: - case ElementKind.NAMESPACE: break; - - default: assert(false); + case ElementKind.PROPERTY_PROTOTYPE: { + let getterPrototype = (element).getterPrototype; + if (getterPrototype) { + this.compileFunctionUsingTypeArguments(getterPrototype, []); + } + let setterPrototype = (element).setterPrototype; + if (setterPrototype) { + this.compileFunctionUsingTypeArguments(setterPrototype, []); + } + break; + } + case ElementKind.NAMESPACE: + case ElementKind.TYPEDEFINITION: + case ElementKind.ENUMVALUE: break; + default: assert(false, ElementKind[element.kind]); } + if (compileMembers) this.compileMembers(element); } - // sources + /** Compiles an element's members. */ + compileMembers(element: Element): void { + var members = element.members; + if (members) for (let element of members.values()) this.compileElement(element); + } + + /** Compiles a file's exports. */ + compileExports(file: File): void { + var exports = file.exports; + if (exports) for (let element of exports.values()) this.compileElement(element); + var exportsStar = file.exportsStar; + if (exportsStar) for (let exportStar of exportsStar) this.compileFile(exportStar); + } - /** Compiles a source by looking it up by path first. */ - compileSourceByPath(normalizedPathWithoutExtension: string, reportNode: Node): void { - var source = this.program.lookupSourceByPath(normalizedPathWithoutExtension); - if (source) this.compileSource(source); - else { + // files + + /** Compiles the file matching the specified path. */ + compileFileByPath(normalizedPathWithoutExtension: string, reportNode: Node): void { + var file: File; + var filesByName = this.program.filesByName; + var pathWithIndex: string; + if (filesByName.has(normalizedPathWithoutExtension)) { + file = filesByName.get(normalizedPathWithoutExtension)!; + } else if (filesByName.has(pathWithIndex = normalizedPathWithoutExtension + INDEX_SUFFIX)) { + file = filesByName.get(pathWithIndex)!; + } else { this.error( DiagnosticCode.File_0_not_found, reportNode.range, normalizedPathWithoutExtension ); + return; } + this.compileFile(file); } - /** Compiles a source. */ - compileSource(source: Source): void { - if (source.is(CommonFlags.COMPILED)) return; - source.set(CommonFlags.COMPILED); + /** Compiles the specified file. */ + compileFile(file: File): void { + if (file.is(CommonFlags.COMPILED)) return; + file.set(CommonFlags.COMPILED); + + // compile top-level statements within the file's start function + var startFunction = file.startFunction; + var previousBody = this.currentBody; + var startFunctionBody = new Array(); + this.currentBody = startFunctionBody; // compile top-level statements - var noTreeShaking = this.options.noTreeShaking; - var isEntry = source.isEntry; - var startFunctionInstance = this.startFunctionInstance; - var startFunctionBody = this.startFunctionBody; - var statements = source.statements; - for (let i = 0, k = statements.length; i < k; ++i) { - let statement = statements[i]; - switch (statement.kind) { - case NodeKind.CLASSDECLARATION: { - if ( - (noTreeShaking || (isEntry && statement.is(CommonFlags.EXPORT))) && - !(statement).isGeneric - ) { - this.compileClassDeclaration(statement, []); - } - break; - } - case NodeKind.INTERFACEDECLARATION: break; - case NodeKind.ENUMDECLARATION: { - if (noTreeShaking || (isEntry && statement.is(CommonFlags.EXPORT))) { - this.compileEnumDeclaration(statement); - } - break; - } - case NodeKind.FUNCTIONDECLARATION: { - if ( - (noTreeShaking || (isEntry && statement.is(CommonFlags.EXPORT))) && - !(statement).isGeneric - ) { - this.compileFunctionDeclaration(statement, []); - } - break; - } - case NodeKind.IMPORT: { - this.compileSourceByPath( - (statement).normalizedPath, - (statement).path - ); - break; - } - case NodeKind.NAMESPACEDECLARATION: { - if (noTreeShaking || (isEntry && statement.is(CommonFlags.EXPORT))) { - this.compileNamespaceDeclaration(statement); - } - break; - } - case NodeKind.VARIABLE: { // global, always compiled as initializers might have side effects - let variableInit = this.compileVariableStatement(statement); - if (variableInit) startFunctionBody.push(variableInit); - break; - } - case NodeKind.EXPORT: { - if ((statement).normalizedPath != null) { - this.compileSourceByPath( - (statement).normalizedPath, - (statement).path - ); - } - if (noTreeShaking || isEntry) { - this.compileExportStatement(statement); - } - break; - } - default: { // otherwise a top-level statement that is part of the start function's body - let previousFlow = this.currentFlow; - this.currentFlow = startFunctionInstance.flow; - startFunctionBody.push( - this.compileStatement(statement) - ); - this.currentFlow = previousFlow; - break; - } - } + var previousFlow = this.currentFlow; + this.currentFlow = startFunction.flow; + for (let statements = file.source.statements, i = 0, k = statements.length; i < k; ++i) { + this.compileTopLevelStatement(statements[i], startFunctionBody); + } + this.currentFlow = previousFlow; + this.currentBody = previousBody; + + // if top-level statements are present, make the per-file start function and call it in start + if (startFunctionBody.length) { + let module = this.module; + let locals = startFunction.localsByIndex; + let numLocals = locals.length; + let varTypes = new Array(numLocals); + for (let i = 0; i < numLocals; ++i) varTypes[i] = locals[i].type.toNativeType(); + module.addFunction( + startFunction.internalName, + this.ensureFunctionType(startFunction.signature.parameterTypes, startFunction.signature.returnType), + varTypes, + startFunctionBody.length > 1 + ? module.createBlock(null, startFunctionBody) + : startFunctionBody[0] + ); + previousBody.push( + module.createCall(startFunction.internalName, null, NativeType.None) + ); } } // globals - compileGlobalDeclaration(declaration: VariableDeclaration): Global | null { - // look up the initialized program element - var element = assert(this.program.elementsLookup.get(declaration.fileLevelInternalName)); - assert(element.kind == ElementKind.GLOBAL); - if (!this.compileGlobal(element)) return null; // reports - return element; - } - compileGlobal(global: Global): bool { if (global.is(CommonFlags.COMPILED)) return true; global.set(CommonFlags.COMPILED); var module = this.module; - var declaration = global.declaration; var initExpr: ExpressionRef = 0; + var typeNode = global.typeNode; + var initializerNode = global.initializerNode; if (!global.is(CommonFlags.RESOLVED)) { - if (declaration) { - // resolve now if annotated - if (declaration.type) { - let resolvedType = this.resolver.resolveType(declaration.type); // reports - if (!resolvedType) return false; - if (resolvedType == Type.void) { - this.error( - DiagnosticCode.Type_expected, - declaration.type.range - ); - return false; - } - global.type = resolvedType; - global.set(CommonFlags.RESOLVED); - - // infer from initializer if not annotated - } else if (declaration.initializer) { // infer type using void/NONE for literal inference - initExpr = this.compileExpressionRetainType( // reports - declaration.initializer, - Type.void, - WrapMode.WRAP + // resolve now if annotated + if (typeNode) { + let resolvedType = this.resolver.resolveType(typeNode, global.parent); // reports + if (!resolvedType) return false; + if (resolvedType == Type.void) { + this.error( + DiagnosticCode.Type_expected, + typeNode.range ); - if (this.currentType == Type.void) { - this.error( - DiagnosticCode.Type_0_is_not_assignable_to_type_1, - declaration.initializer.range, this.currentType.toString(), "" - ); - return false; - } - global.type = this.currentType; - global.set(CommonFlags.RESOLVED); + return false; + } + global.setType(resolvedType); - // must either be annotated or have an initializer - } else { + // infer from initializer if not annotated + } else if (initializerNode) { // infer type using void/NONE for literal inference + let previousFlow = this.currentFlow; + if (global.hasDecorator(DecoratorFlags.LAZY)) { + this.currentFlow = global.file.startFunction.flow; + } + initExpr = this.compileExpressionRetainType( // reports + initializerNode, + Type.void, + WrapMode.WRAP + ); + this.currentFlow = previousFlow; + if (this.currentType == Type.void) { this.error( - DiagnosticCode.Type_expected, - declaration.name.range.atEnd + DiagnosticCode.Type_0_is_not_assignable_to_type_1, + initializerNode.range, this.currentType.toString(), "" ); return false; } + global.setType(this.currentType); + + // must either be annotated or have an initializer } else { - assert(false); // must have a declaration if resolved lazily + this.error( + DiagnosticCode.Type_expected, + global.identifierNode.range.atEnd + ); + return false; } } @@ -762,12 +793,7 @@ export class Compiler extends DiagnosticEmitter { // constant global if (isDeclaredConstant || this.options.hasFeature(Feature.MUTABLE_GLOBAL)) { global.set(CommonFlags.MODULE_IMPORT); - if (declaration) { - mangleImportName(global, declaration); - } else { - mangleImportName_moduleName = "env"; - mangleImportName_elementName = global.simpleName; - } + mangleImportName(global, global.declaration); module.addGlobalImport( global.internalName, mangleImportName_moduleName, @@ -781,7 +807,7 @@ export class Compiler extends DiagnosticEmitter { } else { this.error( DiagnosticCode.Operation_not_supported, - assert(declaration).range + global.declaration.range ); } return false; @@ -792,14 +818,19 @@ export class Compiler extends DiagnosticEmitter { var initializeInStart = false; // evaluate initializer if present - if (declaration !== null && declaration.initializer !== null) { + if (initializerNode) { if (!initExpr) { + let previousFlow = this.currentFlow; + if (global.hasDecorator(DecoratorFlags.LAZY)) { + this.currentFlow = global.file.startFunction.flow; + } initExpr = this.compileExpression( - declaration.initializer, + initializerNode, global.type, ConversionKind.IMPLICIT, WrapMode.WRAP ); + this.currentFlow = previousFlow; } if (getExpressionId(initExpr) != ExpressionId.Const) { @@ -808,7 +839,7 @@ export class Compiler extends DiagnosticEmitter { if (getExpressionId(initExpr) != ExpressionId.Const) { this.warning( DiagnosticCode.Compiling_constant_with_non_constant_initializer_as_mutable, - declaration.range + initializerNode.range ); initializeInStart = true; } @@ -863,10 +894,16 @@ export class Compiler extends DiagnosticEmitter { var internalName = global.internalName; if (initializeInStart) { // initialize to mutable zero and set the actual value in start + if (global.hasDecorator(DecoratorFlags.INLINE)) { + this.error( + DiagnosticCode.Decorator_0_is_not_valid_here, + global.identifierNode.range, "inline" + ); + } module.addGlobal(internalName, nativeType, true, global.type.toNativeZero(module)); - this.startFunctionBody.push(module.createSetGlobal(internalName, initExpr)); + this.currentBody.push(module.createSetGlobal(internalName, initExpr)); - } else { // compile normally + } else if (!global.hasDecorator(DecoratorFlags.INLINE)) { // compile normally module.addGlobal(internalName, nativeType, !isDeclaredConstant, initExpr); } return true; @@ -874,13 +911,6 @@ export class Compiler extends DiagnosticEmitter { // enums - compileEnumDeclaration(declaration: EnumDeclaration): Enum | null { - var element = assert(this.program.elementsLookup.get(declaration.fileLevelInternalName)); - assert(element.kind == ElementKind.ENUM); - if (!this.compileEnum(element)) return null; - return element; - } - compileEnum(element: Enum): bool { if (element.is(CommonFlags.COMPILED)) return true; element.set(CommonFlags.COMPILED); @@ -889,18 +919,23 @@ export class Compiler extends DiagnosticEmitter { this.currentEnum = element; var previousValue: EnumValue | null = null; var previousValueIsMut = false; + var isInline = element.is(CommonFlags.CONST) || element.hasDecorator(DecoratorFlags.INLINE); if (element.members) { for (let member of element.members.values()) { if (member.kind != ElementKind.ENUMVALUE) continue; // happens if an enum is also a namespace let initInStart = false; let val = member; - let valueDeclaration = val.declaration; + let valueNode = val.valueNode; val.set(CommonFlags.COMPILED); + let previousFlow = this.currentFlow; + if (element.hasDecorator(DecoratorFlags.LAZY)) { + this.currentFlow = element.file.startFunction.flow; + } let initExpr: ExpressionRef; - if (valueDeclaration.value) { + if (valueNode) { initExpr = this.compileExpression( - valueDeclaration.value, + valueNode, Type.i32, ConversionKind.IMPLICIT, WrapMode.NONE @@ -911,7 +946,7 @@ export class Compiler extends DiagnosticEmitter { if (getExpressionId(initExpr) != ExpressionId.Const) { this.error( DiagnosticCode.In_const_enum_declarations_member_initializer_must_be_constant_expression, - valueDeclaration.value.range + valueNode.range ); initInStart = true; } @@ -925,7 +960,7 @@ export class Compiler extends DiagnosticEmitter { if (previousValueIsMut) { this.error( DiagnosticCode.Enum_member_must_have_initializer, - valueDeclaration.range + (member).identifierNode.range.atEnd ); } initExpr = module.createBinary(BinaryOp.AddI32, @@ -937,18 +972,28 @@ export class Compiler extends DiagnosticEmitter { if (element.is(CommonFlags.CONST)) { this.error( DiagnosticCode.In_const_enum_declarations_member_initializer_must_be_constant_expression, - valueDeclaration.range + member.declaration.range ); } initInStart = true; } } + this.currentFlow = previousFlow; if (initInStart) { module.addGlobal(val.internalName, NativeType.I32, true, module.createI32(0)); - this.startFunctionBody.push(module.createSetGlobal(val.internalName, initExpr)); + this.currentBody.push( + module.createSetGlobal(val.internalName, initExpr) + ); previousValueIsMut = true; } else { - module.addGlobal(val.internalName, NativeType.I32, !element.is(CommonFlags.CONST), initExpr); + if (isInline) { + val.setConstantIntegerValue(i64_new(getConstValueI32(initExpr)), Type.i32); + if (val.is(CommonFlags.MODULE_EXPORT)) { + module.addGlobal(val.internalName, NativeType.I32, false, initExpr); + } + } else { + module.addGlobal(val.internalName, NativeType.I32, true, initExpr); + } previousValueIsMut = false; } previousValue = val; @@ -960,38 +1005,22 @@ export class Compiler extends DiagnosticEmitter { // functions - /** Compiles a top-level function given its declaration. */ - compileFunctionDeclaration( - declaration: FunctionDeclaration, - typeArguments: TypeNode[] - ): Function | null { - var element = assert(this.program.elementsLookup.get(declaration.fileLevelInternalName)); - assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - return this.compileFunctionUsingTypeArguments( // reports - element, - typeArguments, - makeMap(), - null, - (element).declaration.name - ); - } - /** Resolves the specified type arguments prior to compiling the resulting function instance. */ compileFunctionUsingTypeArguments( prototype: FunctionPrototype, typeArguments: TypeNode[], - contextualTypeArguments: Map, - outerScope: Flow | null, - reportNode: Node + contextualTypeArguments: Map = makeMap(), + alternativeReportNode: Node | null = null ): Function | null { + if (prototype.hasDecorator(DecoratorFlags.BUILTIN)) return null; var instance = this.resolver.resolveFunctionInclTypeArguments( prototype, typeArguments, + prototype.parent, // relative to itself contextualTypeArguments, - reportNode + alternativeReportNode || prototype.declaration ); if (!instance) return null; - instance.outerScope = outerScope; if (!this.compileFunction(instance)) return null; // reports return instance; } @@ -1030,18 +1059,17 @@ export class Compiler extends DiagnosticEmitter { /** Compiles the body of a function within the specified flow. */ private compileFunctionBody(instance: Function): ExpressionRef[] { var module = this.module; - var declaration = instance.prototype.declaration; - var body = assert(declaration.body); + var bodyNode = assert(instance.prototype.bodyNode); var returnType = instance.signature.returnType; var flow = this.currentFlow; // compile statements var stmts: BinaryenExportRef[]; - if (body.kind == NodeKind.BLOCK) { - stmts = this.compileStatements((body).statements); + if (bodyNode.kind == NodeKind.BLOCK) { + stmts = this.compileStatements((bodyNode).statements, true); } else { // must be an expression statement if not a block - assert(body.kind == NodeKind.EXPRESSION); + assert(bodyNode.kind == NodeKind.EXPRESSION); // must be an arrow function assert(instance.is(CommonFlags.ARROW)); @@ -1050,7 +1078,7 @@ export class Compiler extends DiagnosticEmitter { assert(!instance.isAny(CommonFlags.CONSTRUCTOR | CommonFlags.GET | CommonFlags.SET | CommonFlags.MAIN)); let stmt = this.compileExpression( - (body).expression, + (bodyNode).expression, returnType, ConversionKind.IMPLICIT, WrapMode.NONE @@ -1061,17 +1089,17 @@ export class Compiler extends DiagnosticEmitter { } // make the main function call `start` implicitly, but only once - if (instance.is(CommonFlags.MAIN)) { - module.addGlobal("~started", NativeType.I32, true, module.createI32(0)); + if (instance.prototype == this.program.explicitStartFunction) { + module.addGlobal(CompilerSymbols.started, NativeType.I32, true, module.createI32(0)); stmts.unshift( module.createIf( module.createUnary( UnaryOp.EqzI32, - module.createGetGlobal("~started", NativeType.I32) + module.createGetGlobal(CompilerSymbols.started, NativeType.I32) ), module.createBlock(null, [ module.createCall("start", null, NativeType.None), - module.createSetGlobal("~started", module.createI32(1)) + module.createSetGlobal(CompilerSymbols.started, module.createI32(1)) ]) ) ); @@ -1085,7 +1113,7 @@ export class Compiler extends DiagnosticEmitter { if (!flow.isAny(FlowFlags.ANY_TERMINATING)) { let thisLocalIndex = flow.is(FlowFlags.INLINE_CONTEXT) - ? assert(flow.lookupLocal("this")).index + ? assert(flow.lookupLocal(CommonSymbols.this_)).index : 0; // if `this` wasn't accessed before, allocate if necessary and initialize `this` @@ -1126,7 +1154,7 @@ export class Compiler extends DiagnosticEmitter { } else if (returnType != Type.void && !flow.is(FlowFlags.RETURNS)) { this.error( DiagnosticCode.A_function_whose_declared_type_is_not_void_must_return_a_value, - declaration.signature.returnType.range + instance.prototype.signatureNode.returnType.range ); } @@ -1141,26 +1169,26 @@ export class Compiler extends DiagnosticEmitter { var module = this.module; var signature = instance.signature; - var declaration = instance.prototype.declaration; - var body = declaration.body; + var bodyNode = instance.prototype.bodyNode; var typeRef = this.ensureFunctionType(signature.parameterTypes, signature.returnType, signature.thisType); var funcRef: FunctionRef; // concrete function - if (body) { + if (bodyNode) { // must not be ambient if (instance.is(CommonFlags.AMBIENT)) { this.error( DiagnosticCode.An_implementation_cannot_be_declared_in_ambient_contexts, - declaration.name.range + instance.identifierNode.range ); } // cannot have an annotated external name if (instance.hasDecorator(DecoratorFlags.EXTERNAL)) { - let decorator = assert(findDecorator(DecoratorKind.EXTERNAL, declaration.decorators)); + let decoratorNodes = instance.decoratorNodes; + let decorator = assert(findDecorator(DecoratorKind.EXTERNAL, decoratorNodes)); this.error( DiagnosticCode.Operation_not_supported, decorator.range @@ -1190,12 +1218,12 @@ export class Compiler extends DiagnosticEmitter { if (!instance.is(CommonFlags.AMBIENT)) { this.error( DiagnosticCode.Function_implementation_is_missing_or_not_immediately_following_the_declaration, - declaration.name.range + instance.identifierNode.range ); } instance.set(CommonFlags.MODULE_IMPORT); - mangleImportName(instance, declaration); // TODO: check for duplicates + mangleImportName(instance, instance.declaration); // TODO: check for duplicates // create the import funcRef = module.addFunctionImport( @@ -1210,198 +1238,18 @@ export class Compiler extends DiagnosticEmitter { return true; } - // namespaces - - compileNamespaceDeclaration(declaration: NamespaceDeclaration): void { - var members = declaration.members; - var noTreeShaking = this.options.noTreeShaking; - for (let i = 0, k = members.length; i < k; ++i) { - let member = members[i]; - switch (member.kind) { - case NodeKind.CLASSDECLARATION: { - if ( - (noTreeShaking || member.is(CommonFlags.EXPORT)) && - !(member).isGeneric - ) { - this.compileClassDeclaration(member, []); - } - break; - } - case NodeKind.INTERFACEDECLARATION: { - if ( - (noTreeShaking || member.is(CommonFlags.EXPORT)) && - !(member).isGeneric - ) { - this.compileInterfaceDeclaration(member, []); - } - break; - } - case NodeKind.ENUMDECLARATION: { - if (noTreeShaking || member.is(CommonFlags.EXPORT)) { - this.compileEnumDeclaration(member); - } - break; - } - case NodeKind.FUNCTIONDECLARATION: { - if ( - (noTreeShaking || member.is(CommonFlags.EXPORT)) && - !(member).isGeneric - ) { - this.compileFunctionDeclaration(member, []); - } - break; - } - case NodeKind.NAMESPACEDECLARATION: { - if (noTreeShaking || member.is(CommonFlags.EXPORT)) { - this.compileNamespaceDeclaration(member); - } - break; - } - case NodeKind.VARIABLE: { - if (noTreeShaking || member.is(CommonFlags.EXPORT)) { - let variableInit = this.compileVariableStatement(member, true); - if (variableInit) this.startFunctionBody.push(variableInit); - } - break; - } - default: assert(false); - } - } - } - - compileNamespace(ns: Namespace): void { - if (!ns.members) return; - - var noTreeShaking = this.options.noTreeShaking; - for (let element of ns.members.values()) { - switch (element.kind) { - case ElementKind.CLASS_PROTOTYPE: { - if ( - ( - noTreeShaking || - (element).is(CommonFlags.EXPORT) - ) && !(element).is(CommonFlags.GENERIC) - ) { - this.compileClassUsingTypeArguments( - element, - [], - makeMap() - ); - } - break; - } - case ElementKind.ENUM: { - this.compileEnum(element); - break; - } - case ElementKind.FUNCTION_PROTOTYPE: { - if ( - ( - noTreeShaking || (element).is(CommonFlags.EXPORT) - ) && !(element).is(CommonFlags.GENERIC) - ) { - if (element.hasDecorator(DecoratorFlags.BUILTIN)) break; - this.compileFunctionUsingTypeArguments( - element, - [], - makeMap(), - null, - (element).declaration.name - ); - } - break; - } - case ElementKind.GLOBAL: { - this.compileGlobal(element); - break; - } - case ElementKind.NAMESPACE: { - this.compileNamespace(element); - break; - } - } - } - } - - // exports - - compileExportStatement(statement: ExportStatement): void { - var fileLevelExports = this.program.fileLevelExports; - var members = statement.members; - if (!members) return; // filespace - for (let i = 0, k = members.length; i < k; ++i) { - let member = members[i]; - let element = fileLevelExports.get( - statement.range.source.internalPath + PATH_DELIMITER + member.externalName.text - ); - if (!element) continue; // reported in Program#initialize - switch (element.kind) { - case ElementKind.CLASS_PROTOTYPE: { - if (!(element).is(CommonFlags.GENERIC)) { - this.compileClassUsingTypeArguments( - element, - [], - makeMap() - ); - } - break; - } - case ElementKind.ENUM: { - this.compileEnum(element); - break; - } - case ElementKind.FUNCTION_PROTOTYPE: { - if ( - !(element).is(CommonFlags.GENERIC) && - statement.range.source.isEntry - ) { - this.compileFunctionUsingTypeArguments( - element, - [], - makeMap(), - null, - (element).declaration.name - ); - } - break; - } - case ElementKind.GLOBAL: { - this.compileGlobal(element); - break; - } - case ElementKind.NAMESPACE: { - this.compileNamespace(element); - break; - } - } - } - } - // classes - compileClassDeclaration( - declaration: ClassDeclaration, - typeArguments: TypeNode[] - ): void { - var element = assert(this.program.elementsLookup.get(declaration.fileLevelInternalName)); - assert(element.kind == ElementKind.CLASS_PROTOTYPE); - this.compileClassUsingTypeArguments( - element, - typeArguments, - makeMap(), - declaration - ); - } - compileClassUsingTypeArguments( prototype: ClassPrototype, typeArguments: TypeNode[], - contextualTypeArguments: Map, + contextualTypeArguments: Map = makeMap(), alternativeReportNode: Node | null = null ): void { var instance = this.resolver.resolveClassInclTypeArguments( prototype, typeArguments, + prototype.parent, // relative to itself contextualTypeArguments, alternativeReportNode || prototype.declaration ); @@ -1412,8 +1260,8 @@ export class Compiler extends DiagnosticEmitter { compileClass(instance: Class): bool { if (instance.is(CommonFlags.COMPILED)) return true; instance.set(CommonFlags.COMPILED); - - var staticMembers = instance.prototype.members; + var prototype = instance.prototype; + var staticMembers = (prototype).members; if (staticMembers) { for (let element of staticMembers.values()) { switch (element.kind) { @@ -1429,35 +1277,34 @@ export class Compiler extends DiagnosticEmitter { element, [], makeMap(), - null, - (element).declaration.name + (element).identifierNode ); } break; } - case ElementKind.PROPERTY: { - let getter = (element).getterPrototype; + case ElementKind.PROPERTY_PROTOTYPE: { + let getter = (element).getterPrototype; if (getter) { this.compileFunctionUsingTypeArguments( getter, [], makeMap(), - null, - getter.declaration.name + getter.identifierNode ); } - let setter = (element).setterPrototype; + let setter = (element).setterPrototype; if (setter) { this.compileFunctionUsingTypeArguments( setter, [], makeMap(), - null, - setter.declaration.name + setter.identifierNode ); } break; } + case ElementKind.PROPERTY: { + } } } } @@ -1475,37 +1322,20 @@ export class Compiler extends DiagnosticEmitter { element, [], makeMap(instance.contextualTypeArguments), - null, (element).declaration.name ); } break; } - case ElementKind.FIELD: { + case ElementKind.FIELD_PROTOTYPE: { element.set(CommonFlags.COMPILED); break; } case ElementKind.PROPERTY: { - let getter = (element).getterPrototype; - if (getter) { - this.compileFunctionUsingTypeArguments( - getter, - [], - makeMap(instance.contextualTypeArguments), - null, - getter.declaration.name - ); - } - let setter = (element).setterPrototype; - if (setter) { - this.compileFunctionUsingTypeArguments( - setter, - [], - makeMap(instance.contextualTypeArguments), - null, - setter.declaration.name - ); - } + let getter = (element).getterInstance; + if (getter) this.compileFunction(getter); + let setter = (element).setterInstance; + if (setter) this.compileFunction(setter); break; } } @@ -1559,7 +1389,77 @@ export class Compiler extends DiagnosticEmitter { // statements - compileStatement(statement: Statement): ExpressionRef { + compileTopLevelStatement(statement: Statement, body: ExpressionRef[]): void { + switch (statement.kind) { + case NodeKind.CLASSDECLARATION: { + let memberStatements = (statement).members; + for (let i = 0, k = memberStatements.length; i < k; ++i) { + this.compileTopLevelStatement(memberStatements[i], body); + } + break; + } + case NodeKind.ENUMDECLARATION: { + let element = this.program.getElementByDeclaration(statement); + assert(element.kind == ElementKind.ENUM); + if (!element.hasDecorator(DecoratorFlags.LAZY)) this.compileEnum(element); + break; + } + case NodeKind.NAMESPACEDECLARATION: { + let memberStatements = (statement).members; + for (let i = 0, k = memberStatements.length; i < k; ++i) { + this.compileTopLevelStatement(memberStatements[i], body); + } + break; + } + case NodeKind.VARIABLE: { + let declarations = (statement).declarations; + for (let i = 0, k = declarations.length; i < k; ++i) { + let element = this.program.getElementByDeclaration(declarations[i]); + assert(element.kind == ElementKind.GLOBAL); + if ( + !element.is(CommonFlags.AMBIENT) && // delay imports + !element.hasDecorator(DecoratorFlags.LAZY) + ) this.compileGlobal(element); + } + break; + } + case NodeKind.FIELDDECLARATION: { + let element = this.program.getElementByDeclaration(statement); + if (element.kind == ElementKind.GLOBAL) { // static + if (!element.hasDecorator(DecoratorFlags.LAZY)) this.compileGlobal(element); + } + break; + } + case NodeKind.EXPORT: { + if ((statement).normalizedPath != null) { + this.compileFileByPath( + (statement).normalizedPath, + (statement).path + ); + } + break; + } + case NodeKind.IMPORT: { + this.compileFileByPath( + (statement).normalizedPath, + (statement).path + ); + break; + } + case NodeKind.FUNCTIONDECLARATION: + case NodeKind.METHODDECLARATION: + case NodeKind.INTERFACEDECLARATION: + case NodeKind.INDEXSIGNATUREDECLARATION: + case NodeKind.TYPEDECLARATION: break; + default: { // otherwise a top-level statement that is part of the start function's body + let stmt = this.compileStatement(statement); + if (getExpressionId(stmt) != ExpressionId.Nop) body.push(stmt); + break; + } + } + } + + compileStatement(statement: Statement, isLastStatementInBody: bool = false): ExpressionRef { var module = this.module; var stmt: ExpressionRef; switch (statement.kind) { @@ -1596,7 +1496,7 @@ export class Compiler extends DiagnosticEmitter { break; } case NodeKind.RETURN: { - stmt = this.compileReturnStatement(statement); + stmt = this.compileReturnStatement(statement, isLastStatementInBody); break; } case NodeKind.SWITCH: { @@ -1625,12 +1525,13 @@ export class Compiler extends DiagnosticEmitter { break; } case NodeKind.TYPEDECLARATION: { - // type declarations must be top-level because function bodies are evaluated when - // reachaable only. - if (this.currentFlow.parentFunction == this.startFunctionInstance) { - return module.createNop(); - } - // otherwise fall-through + // TODO: integrate inner type declaration into flow + this.error( + DiagnosticCode.Operation_not_supported, + statement.range + ); + stmt = module.createUnreachable(); + break; } default: { assert(false); @@ -1641,13 +1542,13 @@ export class Compiler extends DiagnosticEmitter { return stmt; } - compileStatements(statements: Statement[]): ExpressionRef[] { + compileStatements(statements: Statement[], isBody: bool = false): ExpressionRef[] { var numStatements = statements.length; var stmts = new Array(numStatements); stmts.length = 0; var flow = this.currentFlow; for (let i = 0; i < numStatements; ++i) { - let stmt = this.compileStatement(statements[i]); + let stmt = this.compileStatement(statements[i], isBody && i == numStatements - 1); switch (getExpressionId(stmt)) { case ExpressionId.Block: { if (!getBlockName(stmt)) { @@ -1898,29 +1799,24 @@ export class Compiler extends DiagnosticEmitter { this.currentType ); + // Try to eliminate unnecesssary branches if the condition is constant + var condExprPrecomp = module.precomputeExpression(condExpr); if ( - !this.options.noTreeShaking || - actualFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) + getExpressionId(condExprPrecomp) == ExpressionId.Const && + getExpressionType(condExprPrecomp) == NativeType.I32 ) { - // Try to eliminate unnecesssary branches if the condition is constant - let condExprPrecomp = module.precomputeExpression(condExpr); - if ( - getExpressionId(condExprPrecomp) == ExpressionId.Const && - getExpressionType(condExprPrecomp) == NativeType.I32 - ) { - return getConstValueI32(condExprPrecomp) - ? this.compileStatement(ifTrue) - : ifFalse - ? this.compileStatement(ifFalse) - : module.createNop(); - - // Otherwise recompile to the original and let the optimizer decide - } else /* if (condExpr != condExprPrecomp) <- not guaranteed */ { - condExpr = this.makeIsTrueish( - this.compileExpressionRetainType(statement.condition, Type.bool, WrapMode.NONE), - this.currentType - ); - } + return getConstValueI32(condExprPrecomp) + ? this.compileStatement(ifTrue) + : ifFalse + ? this.compileStatement(ifFalse) + : module.createNop(); + + // Otherwise recompile to the original and let the optimizer decide + } else /* if (condExpr != condExprPrecomp) <- not guaranteed */ { + condExpr = this.makeIsTrueish( + this.compileExpressionRetainType(statement.condition, Type.bool, WrapMode.NONE), + this.currentType + ); } // Each arm initiates a branch @@ -1944,7 +1840,7 @@ export class Compiler extends DiagnosticEmitter { return module.createIf(condExpr, ifTrueExpr, ifFalseExpr); } - compileReturnStatement(statement: ReturnStatement): ExpressionRef { + compileReturnStatement(statement: ReturnStatement, isLastStatementInBody: bool): ExpressionRef { var module = this.module; var expr: ExpressionRef = 0; var flow = this.currentFlow; @@ -1984,7 +1880,7 @@ export class Compiler extends DiagnosticEmitter { } // If the last statement anyway, make it the block's return value - if (isLastStatement(statement)) return expr ? expr : module.createNop(); + if (isLastStatementInBody) return expr ? expr : module.createNop(); // When inlining, break to the end of the inlined function's block (no need to wrap) if (flow.is(FlowFlags.INLINE_CONTEXT)) return module.createBreak(assert(flow.inlineReturnLabel), 0, expr); @@ -2118,8 +2014,7 @@ export class Compiler extends DiagnosticEmitter { } compileTryStatement(statement: TryStatement): ExpressionRef { - // TODO - // can't yet support something like: try { return ... } finally { ... } + // TODO: can't yet support something like: try { return ... } finally { ... } // worthwhile to investigate lowering returns to block results (here)? this.error( DiagnosticCode.Operation_not_supported, @@ -2128,33 +2023,11 @@ export class Compiler extends DiagnosticEmitter { return this.module.createUnreachable(); } - /** - * Compiles a variable statement. Returns `0` if an initializer is not - * necessary. - */ - compileVariableStatement(statement: VariableStatement, isKnownGlobal: bool = false): ExpressionRef { - var program = this.program; + /** Compiles a variable statement. Returns `0` if an initializer is not necessary. */ + compileVariableStatement(statement: VariableStatement): ExpressionRef { var declarations = statement.declarations; var numDeclarations = declarations.length; var flow = this.currentFlow; - - // top-level variables and constants become globals - if (isKnownGlobal || ( - flow.parentFunction == this.startFunctionInstance && - statement.parent && statement.parent.kind == NodeKind.SOURCE - )) { - // NOTE that the above condition also covers top-level variables declared with 'let', even - // though such variables could also become start function locals if, and only if, not used - // within any function declared in the same source, which is unknown at this point. the only - // efficient way to deal with this would be to keep track of all occasions it is used and - // replace these instructions afterwards, dynamically. (TOOD: what about a Binaryen pass?) - for (let i = 0; i < numDeclarations; ++i) { - this.compileGlobalDeclaration(declarations[i]); - } - return 0; - } - - // other variables become locals var initializers = new Array(); var resolver = this.resolver; for (let i = 0; i < numDeclarations; ++i) { @@ -2165,6 +2038,7 @@ export class Compiler extends DiagnosticEmitter { if (declaration.type) { type = resolver.resolveType( // reports declaration.type, + flow.actualFunction, flow.contextualTypeArguments ); if (!type) continue; @@ -2202,32 +2076,34 @@ export class Compiler extends DiagnosticEmitter { if (initExpr) { initExpr = this.module.precomputeExpression(initExpr); if (getExpressionId(initExpr) == ExpressionId.Const) { - let local = new Local(program, name, -1, type); + let local = new Local(name, -1, type, flow.parentFunction); switch (getExpressionType(initExpr)) { case NativeType.I32: { - local = local.withConstantIntegerValue( + local.setConstantIntegerValue( i64_new( getConstValueI32(initExpr), 0 - ) + ), + type ); break; } case NativeType.I64: { - local = local.withConstantIntegerValue( + local.setConstantIntegerValue( i64_new( getConstValueI64Low(initExpr), getConstValueI64High(initExpr) - ) + ), + type ); break; } case NativeType.F32: { - local = local.withConstantFloatValue(getConstValueF32(initExpr)); + local.setConstantFloatValue(getConstValueF32(initExpr), type); break; } case NativeType.F64: { - local = local.withConstantFloatValue(getConstValueF64(initExpr)); + local.setConstantFloatValue(getConstValueF64(initExpr), type); break; } default: { @@ -2310,25 +2186,20 @@ export class Compiler extends DiagnosticEmitter { this.currentType ); + // Try to eliminate unnecesssary loops if the condition is constant + var condExprPrecomp = module.precomputeExpression(condExpr); if ( - !this.options.noTreeShaking || - outerFlow.actualFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) + getExpressionId(condExprPrecomp) == ExpressionId.Const && + getExpressionType(condExprPrecomp) == NativeType.I32 ) { - // Try to eliminate unnecesssary loops if the condition is constant - let condExprPrecomp = module.precomputeExpression(condExpr); - if ( - getExpressionId(condExprPrecomp) == ExpressionId.Const && - getExpressionType(condExprPrecomp) == NativeType.I32 - ) { - if (!getConstValueI32(condExprPrecomp)) return module.createNop(); + if (!getConstValueI32(condExprPrecomp)) return module.createNop(); - // Otherwise recompile to the original and let the optimizer decide - } else /* if (condExpr != condExprPrecomp) <- not guaranteed */ { - condExpr = this.makeIsTrueish( - this.compileExpressionRetainType(statement.condition, Type.bool, WrapMode.NONE), - this.currentType - ); - } + // Otherwise recompile to the original and let the optimizer decide + } else /* if (condExpr != condExprPrecomp) <- not guaranteed */ { + condExpr = this.makeIsTrueish( + this.compileExpressionRetainType(statement.condition, Type.bool, WrapMode.NONE), + this.currentType + ); } // Statements initiate a new branch with its own break context @@ -2465,7 +2336,6 @@ export class Compiler extends DiagnosticEmitter { wrapMode: WrapMode ): ExpressionRef { this.currentType = contextualType; - var expr: ExpressionRef; switch (expression.kind) { case NodeKind.ASSERTION: { @@ -2549,7 +2419,6 @@ export class Compiler extends DiagnosticEmitter { expr = this.module.createUnreachable(); } } - var currentType = this.currentType; if (conversionKind != ConversionKind.NONE && currentType != contextualType) { expr = this.convertExpression(expr, currentType, contextualType, conversionKind, wrapMode, expression); @@ -2775,6 +2644,7 @@ export class Compiler extends DiagnosticEmitter { case AssertionKind.AS: { let toType = this.resolver.resolveType( // reports assert(expression.toType), + this.currentFlow.actualFunction, this.currentFlow.contextualTypeArguments ); if (!toType) return this.module.createUnreachable(); @@ -3740,7 +3610,7 @@ export class Compiler extends DiagnosticEmitter { rightExpr = this.compileExpression(right, Type.f32, ConversionKind.IMPLICIT, WrapMode.NONE); rightType = this.currentType; if (!(instance = this.f32PowInstance)) { - let namespace = this.program.elementsLookup.get("Mathf"); + let namespace = this.program.lookupGlobal(LibrarySymbols.Mathf); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3749,7 +3619,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get("pow") : null; + let prototype = namespace.members ? namespace.members.get(LibrarySymbols.pow) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3782,7 +3652,7 @@ export class Compiler extends DiagnosticEmitter { ); rightType = this.currentType; if (!(instance = this.f64PowInstance)) { - let namespace = this.program.elementsLookup.get("Math"); + let namespace = this.program.lookupGlobal(LibrarySymbols.Math); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3791,7 +3661,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get("pow") : null; + let prototype = namespace.members ? namespace.members.get(LibrarySymbols.pow) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4032,7 +3902,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F32: { let instance = this.f32ModInstance; if (!instance) { - let namespace = this.program.elementsLookup.get("Mathf"); + let namespace = this.program.lookupGlobal(LibrarySymbols.Mathf); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4041,7 +3911,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get("mod") : null; + let prototype = namespace.members ? namespace.members.get(LibrarySymbols.mod) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4063,7 +3933,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F64: { let instance = this.f64ModInstance; if (!instance) { - let namespace = this.program.elementsLookup.get("Math"); + let namespace = this.program.lookupGlobal(LibrarySymbols.Math); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4072,7 +3942,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get("mod") : null; + let prototype = namespace.members ? namespace.members.get(LibrarySymbols.mod) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4768,20 +4638,33 @@ export class Compiler extends DiagnosticEmitter { targetType = (target).type; break; } - case ElementKind.PROPERTY: { - let setterPrototype = (target).setterPrototype; - if (setterPrototype) { - let instance = this.resolver.resolveFunction(setterPrototype, null); - if (!instance) return this.module.createUnreachable(); - assert(instance.signature.parameterTypes.length == 1); // parser must guarantee this - targetType = instance.signature.parameterTypes[0]; - break; + case ElementKind.PROPERTY_PROTOTYPE: { // static property + let setterPrototype = (target).setterPrototype; + if (!setterPrototype) { + this.error( + DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, + expression.range, (target).internalName + ); + return this.module.createUnreachable(); } - this.error( - DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, - expression.range, (target).internalName - ); - return this.module.createUnreachable(); + let setterInstance = this.resolver.resolveFunction(setterPrototype, null, makeMap(), ReportMode.REPORT); + if (!setterInstance) return this.module.createUnreachable(); + assert(setterInstance.signature.parameterTypes.length == 1); // parser must guarantee this + targetType = setterInstance.signature.parameterTypes[0]; + break; + } + case ElementKind.PROPERTY: { // instance property + let setterInstance = (target).setterInstance; + if (!setterInstance) { + this.error( + DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, + expression.range, (target).internalName + ); + return this.module.createUnreachable(); + } + assert(setterInstance.signature.parameterTypes.length == 1); // parser must guarantee this + targetType = setterInstance.signature.parameterTypes[0]; + break; } case ElementKind.CLASS: { if (resolver.currentElementExpression) { // indexed access @@ -4882,13 +4765,12 @@ export class Compiler extends DiagnosticEmitter { } } case ElementKind.FIELD: { - const declaration = (target).declaration; + let initializerNode = (target).initializerNode; if ( (target).is(CommonFlags.READONLY) && !( flow.actualFunction.is(CommonFlags.CONSTRUCTOR) || - declaration == null || - declaration.initializer != null + initializerNode ) ) { this.error( @@ -4941,66 +4823,68 @@ export class Compiler extends DiagnosticEmitter { ); } } - case ElementKind.PROPERTY: { - let setterPrototype = (target).setterPrototype; - if (setterPrototype) { - let setterInstance = this.resolver.resolveFunction(setterPrototype, null); - if (!setterInstance) return module.createUnreachable(); - - // call just the setter if the return value isn't of interest - if (!tee) { - if (setterInstance.is(CommonFlags.INSTANCE)) { - let thisExpression = assert(this.resolver.currentThisExpression); - let thisExpr = this.compileExpressionRetainType( - thisExpression, - this.options.usizeType, - WrapMode.NONE - ); - return this.makeCallDirect(setterInstance, [ thisExpr, valueWithCorrectType ]); - } else { - return this.makeCallDirect(setterInstance, [ valueWithCorrectType ]); - } - } - - // otherwise call the setter first, then the getter - let getterPrototype = (target).getterPrototype; - assert(getterPrototype != null); // must have one if there is a setter - let getterInstance = this.resolver.resolveFunction(getterPrototype, null); - if (!getterInstance) return module.createUnreachable(); - let returnType = getterInstance.signature.returnType; - let nativeReturnType = returnType.toNativeType(); - if (setterInstance.is(CommonFlags.INSTANCE)) { - let thisExpression = assert(this.resolver.currentThisExpression); - let thisExpr = this.compileExpressionRetainType( - thisExpression, - this.options.usizeType, - WrapMode.NONE - ); - let tempLocal = flow.getAndFreeTempLocal(returnType, false); - let tempLocalIndex = tempLocal.index; - return module.createBlock(null, [ - this.makeCallDirect(setterInstance, [ // set and remember the target - module.createTeeLocal(tempLocalIndex, thisExpr), - valueWithCorrectType - ]), - this.makeCallDirect(getterInstance, [ // get from remembered target - module.createGetLocal(tempLocalIndex, nativeReturnType) - ]) - ], nativeReturnType); - } else { - // note that this must be performed here because `resolved` is shared - return module.createBlock(null, [ - this.makeCallDirect(setterInstance, [ valueWithCorrectType ]), - this.makeCallDirect(getterInstance) - ], nativeReturnType); - } - } else { + case ElementKind.PROPERTY_PROTOTYPE: { // static property + let setterPrototype = (target).setterPrototype; + if (!setterPrototype) { this.error( DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, expression.range, target.internalName ); + return module.createUnreachable(); } - return module.createUnreachable(); + let setterInstance = this.resolver.resolveFunction(setterPrototype, null, makeMap(), ReportMode.REPORT); + if (!setterInstance) return module.createUnreachable(); + // call just the setter if the return value isn't of interest + if (!tee) return this.makeCallDirect(setterInstance, [ valueWithCorrectType ]); + // otherwise call the setter first, then the getter + let getterPrototype = assert((target).getterPrototype); // must be present + let getterInstance = this.resolver.resolveFunction(getterPrototype, null, makeMap(), ReportMode.REPORT); + if (!getterInstance) return module.createUnreachable(); + let returnType = getterInstance.signature.returnType; + let nativeReturnType = returnType.toNativeType(); + return module.createBlock(null, [ + this.makeCallDirect(setterInstance, [ valueWithCorrectType ]), + this.makeCallDirect(getterInstance) // sets currentType + ], nativeReturnType); + } + case ElementKind.PROPERTY: { // instance property + let setterInstance = (target).setterInstance; + if (!setterInstance) { + this.error( + DiagnosticCode.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, + expression.range, target.internalName + ); + return module.createUnreachable(); + } + // call just the setter if the return value isn't of interest + if (!tee) { + let thisExpr = this.compileExpressionRetainType( + assert(this.resolver.currentThisExpression), + this.options.usizeType, + WrapMode.NONE + ); + return this.makeCallDirect(setterInstance, [ thisExpr, valueWithCorrectType ]); + } + // otherwise call the setter first, then the getter + let getterInstance = assert((target).getterInstance); // must be present + let returnType = getterInstance.signature.returnType; + let nativeReturnType = returnType.toNativeType(); + let thisExpr = this.compileExpressionRetainType( + assert(this.resolver.currentThisExpression), + this.options.usizeType, + WrapMode.NONE + ); + let tempLocal = flow.getAndFreeTempLocal(returnType, false); + let tempLocalIndex = tempLocal.index; + return module.createBlock(null, [ + this.makeCallDirect(setterInstance, [ // set and remember the target + module.createTeeLocal(tempLocalIndex, thisExpr), + valueWithCorrectType + ]), + this.makeCallDirect(getterInstance, [ // get from remembered target + module.createGetLocal(tempLocalIndex, nativeReturnType) + ]) + ], nativeReturnType); } case ElementKind.CLASS: { let elementExpression = this.resolver.currentElementExpression; @@ -5088,7 +4972,7 @@ export class Compiler extends DiagnosticEmitter { let classInstance = assert(actualFunction.parent); assert(classInstance.kind == ElementKind.CLASS); let baseClassInstance = assert((classInstance).base); - let thisLocal = assert(flow.lookupLocal("this")); + let thisLocal = assert(flow.lookupLocal(CommonSymbols.this_)); let nativeSizeType = this.options.nativeSizeType; // { @@ -5160,6 +5044,7 @@ export class Compiler extends DiagnosticEmitter { instance = this.resolver.resolveFunctionInclTypeArguments( prototype, typeArguments, + flow.actualFunction.parent, // relative to caller makeMap(flow.contextualTypeArguments), expression ); @@ -5167,32 +5052,34 @@ export class Compiler extends DiagnosticEmitter { // infer generic call if type arguments have been omitted } else if (prototype.is(CommonFlags.GENERIC)) { let inferredTypes = new Map(); - let typeParameters = assert(prototype.declaration.typeParameters); - let numTypeParameters = typeParameters.length; + let typeParameterNodes = assert(prototype.typeParameterNodes); + let numTypeParameters = typeParameterNodes.length; for (let i = 0; i < numTypeParameters; ++i) { - inferredTypes.set(typeParameters[i].name.text, null); + inferredTypes.set(typeParameterNodes[i].name.text, null); } // let numInferred = 0; - let parameterTypes = prototype.declaration.signature.parameters; - let numParameterTypes = parameterTypes.length; - let argumentExpressions = expression.arguments; - let numArguments = argumentExpressions.length; + let parameterNodes = prototype.signatureNode.parameters; + let numParameters = parameterNodes.length; + let argumentNodes = expression.arguments; + let numArguments = argumentNodes.length; let argumentExprs = new Array(numArguments); - for (let i = 0; i < numParameterTypes; ++i) { - let typeNode = parameterTypes[i].type; - let name = typeNode.kind == NodeKind.TYPE ? (typeNode).name.text : null; + for (let i = 0; i < numParameters; ++i) { + let typeNode = parameterNodes[i].type; + let templateName = typeNode.kind == NodeKind.TYPE && !(typeNode).name.next + ? (typeNode).name.identifier.text + : null; let argumentExpression = i < numArguments - ? argumentExpressions[i] - : prototype.declaration.signature.parameters[i].initializer; + ? argumentNodes[i] + : parameterNodes[i].initializer; if (!argumentExpression) { // missing initializer -> too few arguments this.error( DiagnosticCode.Expected_0_arguments_but_got_1, - expression.range, numParameterTypes.toString(10), numArguments.toString(10) + expression.range, numParameters.toString(10), numArguments.toString(10) ); return module.createUnreachable(); } - if (name !== null && inferredTypes.has(name)) { - let inferredType = inferredTypes.get(name); + if (templateName !== null && inferredTypes.has(templateName)) { + let inferredType = inferredTypes.get(templateName); if (inferredType) { argumentExprs[i] = this.compileExpressionRetainType(argumentExpression, inferredType, WrapMode.NONE); let commonType: Type | null; @@ -5200,7 +5087,7 @@ export class Compiler extends DiagnosticEmitter { if (!(commonType = Type.commonCompatible(inferredType, this.currentType, false))) { this.error( DiagnosticCode.Type_0_is_not_assignable_to_type_1, - parameterTypes[i].type.range, this.currentType.toString(), inferredType.toString() + parameterNodes[i].type.range, this.currentType.toString(), inferredType.toString() ); return module.createUnreachable(); } @@ -5211,10 +5098,11 @@ export class Compiler extends DiagnosticEmitter { inferredType = this.currentType; // ++numInferred; } - inferredTypes.set(name, inferredType); + inferredTypes.set(templateName, inferredType); } else { let concreteType = this.resolver.resolveType( - parameterTypes[i].type, + parameterNodes[i].type, + flow.actualFunction, flow.contextualTypeArguments ); if (!concreteType) return module.createUnreachable(); @@ -5228,7 +5116,7 @@ export class Compiler extends DiagnosticEmitter { } let resolvedTypeArguments = new Array(numTypeParameters); for (let i = 0; i < numTypeParameters; ++i) { - let inferredType = assert(inferredTypes.get(typeParameters[i].name.text)); // TODO + let inferredType = assert(inferredTypes.get(typeParameterNodes[i].name.text)); // TODO resolvedTypeArguments[i] = inferredType; } instance = this.resolver.resolveFunction( @@ -5331,14 +5219,35 @@ export class Compiler extends DiagnosticEmitter { break; } - case ElementKind.PROPERTY: { - indexArg = this.compileGetter(target, expression.expression); - let type = this.currentType; - signature = type.signatureReference; + case ElementKind.PROPERTY_PROTOTYPE: { // static property + let getterPrototype = assert((target).getterPrototype); + let getterInstance = this.resolver.resolveFunction(getterPrototype, null); + if (!getterInstance) return module.createUnreachable(); + indexArg = this.compileCallDirect(getterInstance, [], expression.expression); + signature = this.currentType.signatureReference; if (!signature) { this.error( DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, - expression.range, type.toString() + expression.range, this.currentType.toString() + ); + return module.createUnreachable(); + } + break; + } + case ElementKind.PROPERTY: { // instance property + let getterInstance = assert((target).getterInstance); + indexArg = this.compileCallDirect(getterInstance, [], expression.expression, + this.compileExpressionRetainType( + assert(this.resolver.currentThisExpression), + this.options.usizeType, + WrapMode.NONE + ) + ); + signature = this.currentType.signatureReference; + if (!signature) { + this.error( + DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, + expression.range, this.currentType.toString() ); return module.createUnreachable(); } @@ -5371,6 +5280,7 @@ export class Compiler extends DiagnosticEmitter { // builtins handle omitted type arguments on their own. if present, however, resolve them here // and pass them to the builtin, even if it's still up to the builtin how to handle them. + var typeParameterNodes = prototype.typeParameterNodes; var typeArgumentNodes = expression.typeArguments; if (expression.typeArguments) { if (!prototype.is(CommonFlags.GENERIC)) { @@ -5380,8 +5290,9 @@ export class Compiler extends DiagnosticEmitter { ); } typeArguments = this.resolver.resolveTypeArguments( - assert(prototype.declaration.typeParameters), + assert(typeParameterNodes), typeArgumentNodes, + this.currentFlow.actualFunction.parent, makeMap(this.currentFlow.contextualTypeArguments), expression ); @@ -5538,12 +5449,12 @@ export class Compiler extends DiagnosticEmitter { if (thisArg) { let classInstance = assert(instance.parent); assert(classInstance.kind == ElementKind.CLASS); let thisType = assert(instance.signature.thisType); - let thisLocal = flow.addScopedLocal("this", thisType, false); + let thisLocal = flow.addScopedLocal(CommonSymbols.this_, thisType, false); body.push( module.createSetLocal(thisLocal.index, thisArg) ); let baseInstance = (classInstance).base; - if (baseInstance) flow.addScopedAlias("super", baseInstance.type, thisLocal.index); + if (baseInstance) flow.addScopedAlias(CommonSymbols.super_, baseInstance.type, thisLocal.index); } var numArguments = argumentExpressions.length; @@ -5568,11 +5479,10 @@ export class Compiler extends DiagnosticEmitter { // Compile optional parameter initializers in the scope of the inlined flow this.currentFlow = flow; - var declaration = instance.prototype.declaration; var numParameters = signature.parameterTypes.length; for (let i = numArguments; i < numParameters; ++i) { let initExpr = this.compileExpression( - assert(declaration.signature.parameters[i].initializer), + assert(instance.prototype.signatureNode.parameters[i].initializer), parameterTypes[i], ConversionKind.IMPLICIT, WrapMode.WRAP @@ -5618,7 +5528,7 @@ export class Compiler extends DiagnosticEmitter { var originalSignature = original.signature; var originalName = original.internalName; var originalParameterTypes = originalSignature.parameterTypes; - var originalParameterDeclarations = original.prototype.declaration.signature.parameters; + var originalParameterDeclarations = original.prototype.signatureNode.parameters; var commonReturnType = originalSignature.returnType; var commonThisType = originalSignature.thisType; var isInstance = original.is(CommonFlags.INSTANCE); @@ -5652,13 +5562,11 @@ export class Compiler extends DiagnosticEmitter { // create the trampoline element var trampolineSignature = new Signature(originalParameterTypes, commonReturnType, commonThisType); - var trampolineName = originalName + "|trampoline"; trampolineSignature.requiredParameters = maxArguments; trampoline = new Function( + original.name + "|trampoline", original.prototype, - trampolineName, trampolineSignature, - original.parent, original.contextualTypeArguments ); trampoline.set(original.flags | CommonFlags.TRAMPOLINE | CommonFlags.COMPILED); @@ -5684,10 +5592,10 @@ export class Compiler extends DiagnosticEmitter { minArguments ? module.createBinary( BinaryOp.SubI32, - module.createGetGlobal("~argc", NativeType.I32), + module.createGetGlobal(CompilerSymbols.argc, NativeType.I32), module.createI32(minArguments) ) - : module.createGetGlobal("~argc", NativeType.I32) + : module.createGetGlobal(CompilerSymbols.argc, NativeType.I32) ) ]), module.createUnreachable() @@ -5723,7 +5631,7 @@ export class Compiler extends DiagnosticEmitter { assert(operandIndex == maxOperands); var funcRef = module.addFunction( - trampolineName, + trampoline.internalName, this.ensureFunctionType( trampolineSignature.parameterTypes, trampolineSignature.returnType, @@ -5745,22 +5653,21 @@ export class Compiler extends DiagnosticEmitter { /** Makes sure that the argument count helper global is present and returns its name. */ private ensureArgcVar(): string { - var internalName = "~argc"; if (!this.argcVar) { let module = this.module; this.argcVar = module.addGlobal( - internalName, + CompilerSymbols.argc, NativeType.I32, true, module.createI32(0) ); } - return internalName; + return CompilerSymbols.argc; } /** Makes sure that the argument count helper setter is present and returns its name. */ private ensureArgcSet(): string { - var internalName = "~setargc"; + var internalName = CompilerSymbols.setargc; if (!this.argcSet) { let module = this.module; this.argcSet = module.addFunction(internalName, @@ -5805,7 +5712,7 @@ export class Compiler extends DiagnosticEmitter { operands.length = 0; } let parameterTypes = instance.signature.parameterTypes; - let parameterNodes = instance.prototype.declaration.signature.parameters; + let parameterNodes = instance.prototype.signatureNode.parameters; let allOptionalsAreConstant = true; for (let i = numArguments; i < maxArguments; ++i) { let initializer = parameterNodes[i].initializer; @@ -5834,7 +5741,6 @@ export class Compiler extends DiagnosticEmitter { instance = this.ensureTrampoline(instance); if (!this.compileFunction(instance)) return module.createUnreachable(); instance.flow.flags = original.flow.flags; - this.program.instancesLookup.set(instance.internalName, instance); // so canOverflow can find it let nativeReturnType = returnType.toNativeType(); this.currentType = returnType; return module.createBlock(null, [ @@ -5955,7 +5861,7 @@ export class Compiler extends DiagnosticEmitter { } compileElementAccessExpression(expression: ElementAccessExpression, contextualType: Type): ExpressionRef { - var target = this.resolver.resolveElementAccess( + var target = this.resolver.resolveElementAccessExpression( expression, this.currentFlow, contextualType @@ -5990,7 +5896,10 @@ export class Compiler extends DiagnosticEmitter { return this.module.createUnreachable(); } - compileFunctionExpression(expression: FunctionExpression, contextualType: Type): ExpressionRef { + compileFunctionExpression( + expression: FunctionExpression, + contextualType: Type + ): ExpressionRef { var declaration = expression.declaration; var name = declaration.name; var simpleName = (name.text.length @@ -5998,18 +5907,15 @@ export class Compiler extends DiagnosticEmitter { : "anonymous") + "|" + this.functionTable.length.toString(10); var flow = this.currentFlow; var prototype = new FunctionPrototype( - this.program, simpleName, - flow.actualFunction.internalName + INNER_DELIMITER + simpleName, - declaration, - null, + flow.actualFunction, + declaration.clone(), // same function can be compiled multiple times if generic DecoratorFlags.NONE ); var instance = this.compileFunctionUsingTypeArguments( prototype, [], makeMap(flow.contextualTypeArguments), - flow, declaration ); if (!instance) return this.module.createUnreachable(); @@ -6022,6 +5928,17 @@ export class Compiler extends DiagnosticEmitter { : this.module.createI32(index); } + /** Makes sure the enclosing source file of the specified expression has been compiled. */ + private maybeCompileEnclosingSource(expression: Expression): void { + var internalPath = expression.range.source.internalPath; + var filesByName = this.program.filesByName; + assert(filesByName.has(internalPath)); + var enclosingFile = filesByName.get(internalPath)!; + if (!enclosingFile.is(CommonFlags.COMPILED)) { + this.compileFileByPath(internalPath, expression); + } + } + /** * Compiles an identifier in the specified context. * @param retainConstantType Retains the type of inlined constants if `true`, otherwise @@ -6057,7 +5974,7 @@ export class Compiler extends DiagnosticEmitter { } case NodeKind.THIS: { if (actualFunction.is(CommonFlags.INSTANCE)) { - let thisLocal = assert(flow.lookupLocal("this")); + let thisLocal = assert(flow.lookupLocal(CommonSymbols.this_)); let classInstance = assert(actualFunction.parent); assert(classInstance.kind == ElementKind.CLASS); let nativeSizeType = this.options.nativeSizeType; if (actualFunction.is(CommonFlags.CONSTRUCTOR)) { @@ -6112,7 +6029,7 @@ export class Compiler extends DiagnosticEmitter { } } if (flow.is(FlowFlags.INLINE_CONTEXT)) { - let scopedThis = flow.lookupLocal("this"); + let scopedThis = flow.lookupLocal(CommonSymbols.this_); if (scopedThis) { let scopedThisClass = assert(scopedThis.type.classReference); let base = scopedThisClass.base; @@ -6140,6 +6057,8 @@ export class Compiler extends DiagnosticEmitter { } } + this.maybeCompileEnclosingSource(expression); + // otherwise resolve var target = this.resolver.resolveIdentifier( // reports expression, @@ -6183,7 +6102,8 @@ export class Compiler extends DiagnosticEmitter { } this.currentType = Type.i32; if ((target).is(CommonFlags.INLINED)) { - return this.module.createI32((target).constantValue); + assert((target).constantValueKind == ConstantValueKind.INTEGER); + return this.module.createI32(i64_low((target).constantIntegerValue)); } return this.module.createGetGlobal((target).internalName, NativeType.I32); } @@ -6216,7 +6136,10 @@ export class Compiler extends DiagnosticEmitter { // possible in AS anyway. var expr = this.compileExpressionRetainType(expression.expression, this.options.usizeType, WrapMode.NONE); var type = this.currentType; - var isType = this.resolver.resolveType(expression.isType); + var isType = this.resolver.resolveType( + expression.isType, + this.currentFlow.actualFunction + ); this.currentType = Type.bool; if (!isType) return module.createUnreachable(); return type.is(TypeFlags.NULLABLE) && !isType.is(TypeFlags.NULLABLE) @@ -6238,7 +6161,6 @@ export class Compiler extends DiagnosticEmitter { implicitNegate: bool = false ): ExpressionRef { var module = this.module; - switch (expression.literalKind) { case LiteralKind.ARRAY: { assert(!implicitNegate); @@ -6340,7 +6262,7 @@ export class Compiler extends DiagnosticEmitter { buf = new Uint8Array(totalSize); pos = 0; } - writeI32(length, buf, pos + stringInstance.offsetof("length")); + writeI32(length, buf, pos + stringInstance.offsetof(LibrarySymbols.length)); pos += headerSize; for (let i = 0; i < length; ++i) { writeI16(stringValue.charCodeAt(i), buf, pos + (i << 1)); @@ -6390,7 +6312,7 @@ export class Compiler extends DiagnosticEmitter { buf = new Uint8Array(bufferTotalSize); pos = 0; } - writeI32(byteLength, buf, pos + bufferInstance.offsetof("byteLength")); + writeI32(byteLength, buf, pos + bufferInstance.offsetof(LibrarySymbols.byteLength)); pos += bufferHeaderSize; var nativeType = elementType.toNativeType(); switch (nativeType) { @@ -6702,6 +6624,7 @@ export class Compiler extends DiagnosticEmitter { classInstance = this.resolver.resolveClassInclTypeArguments( classPrototype, typeArguments, + flow.actualFunction.parent, // relative to caller makeMap(flow.contextualTypeArguments), expression ); @@ -6712,11 +6635,11 @@ export class Compiler extends DiagnosticEmitter { /** Gets the compiled constructor of the specified class or generates one if none is present. */ ensureConstructor(classInstance: Class, reportNode: Node): Function { - var ctorInstance = classInstance.constructorInstance; - if (ctorInstance) { + var instance = classInstance.constructorInstance; + if (instance) { // do not attempt to compile it if inlined anyway - if (!ctorInstance.hasDecorator(DecoratorFlags.INLINE)) this.compileFunction(ctorInstance); - return ctorInstance; + if (!instance.hasDecorator(DecoratorFlags.INLINE)) this.compileFunction(instance); + return instance; } // use the signature of the parent constructor if a derived class @@ -6725,22 +6648,22 @@ export class Compiler extends DiagnosticEmitter { ? this.ensureConstructor(baseClass, reportNode).signature : new Signature(null, classInstance.type, classInstance.type); - var internalName = classInstance.internalName + INSTANCE_DELIMITER + "constructor"; - - var nativeDummy = assert(this.program.elementsLookup.get("NATIVE_CODE")); - assert(nativeDummy.kind == ElementKind.FUNCTION_PROTOTYPE); - - ctorInstance = new Function( - nativeDummy, - internalName, + instance = new Function( + CommonSymbols.constructor, + new FunctionPrototype(CommonSymbols.constructor, classInstance, + this.program.makeNativeFunctionDeclaration(CommonSymbols.constructor, + CommonFlags.INSTANCE | CommonFlags.CONSTRUCTOR + ) + ), signature, - classInstance, null ); - ctorInstance.set(CommonFlags.INSTANCE | CommonFlags.CONSTRUCTOR | CommonFlags.COMPILED); - classInstance.constructorInstance = ctorInstance; + instance.internalName = classInstance.internalName + INSTANCE_DELIMITER + "constructor"; + instance.set(CommonFlags.COMPILED); + instance.prototype.setResolvedInstance("", instance); + classInstance.constructorInstance = instance; var previousFlow = this.currentFlow; - this.currentFlow = ctorInstance.flow; + this.currentFlow = instance.flow; // generate body var module = this.module; @@ -6786,21 +6709,21 @@ export class Compiler extends DiagnosticEmitter { // make the function var typeRef = this.ensureFunctionType(signature.parameterTypes, signature.returnType, signature.thisType); - var locals = ctorInstance.localsByIndex; + var locals = instance.localsByIndex; var varTypes = new Array(); // of temp. vars added while compiling initializers var numOperands = 1 + signature.parameterTypes.length; var numLocals = locals.length; if (numLocals > numOperands) { for (let i = numOperands; i < numLocals; ++i) varTypes.push(locals[i].type.toNativeType()); } - var funcRef = module.addFunction(ctorInstance.internalName, typeRef, varTypes, + var funcRef = module.addFunction(instance.internalName, typeRef, varTypes, stmts.length == 1 ? stmts[0] : module.createBlock(null, stmts, nativeSizeType) ); - ctorInstance.finalize(module, funcRef); + instance.finalize(module, funcRef); this.currentFlow = previousFlow; - return ctorInstance; + return instance; } compileInstantiate(classInstance: Class, argumentExpressions: Expression[], reportNode: Node): ExpressionRef { @@ -6841,11 +6764,13 @@ export class Compiler extends DiagnosticEmitter { var module = this.module; var flow = this.currentFlow; - var target = this.resolver.resolvePropertyAccess(propertyAccess, flow, contextualType); // reports + this.maybeCompileEnclosingSource(propertyAccess); + + var target = this.resolver.resolvePropertyAccessExpression(propertyAccess, flow, contextualType); // reports if (!target) return module.createUnreachable(); switch (target.kind) { - case ElementKind.GLOBAL: { // static property + case ElementKind.GLOBAL: { // static field if (!this.compileGlobal(target)) { // reports; not yet compiled if a static field return module.createUnreachable(); } @@ -6865,15 +6790,15 @@ export class Compiler extends DiagnosticEmitter { } this.currentType = Type.i32; if ((target).is(CommonFlags.INLINED)) { - return module.createI32((target).constantValue); + assert((target).constantValueKind == ConstantValueKind.INTEGER); + return module.createI32(i64_low((target).constantIntegerValue)); } return module.createGetGlobal((target).internalName, NativeType.I32); } case ElementKind.FIELD: { // instance field - let thisExpression = assert(this.resolver.currentThisExpression); assert((target).memoryOffset >= 0); let thisExpr = this.compileExpressionRetainType( - thisExpression, + assert(this.resolver.currentThisExpression), this.options.usizeType, WrapMode.NONE ); @@ -6886,13 +6811,28 @@ export class Compiler extends DiagnosticEmitter { (target).memoryOffset ); } - case ElementKind.PROPERTY: {// instance property (here: getter) - return this.compileGetter(target, propertyAccess); + case ElementKind.PROPERTY_PROTOTYPE: {// static property + let getterPrototype = (target).getterPrototype; + if (getterPrototype) { + let getter = this.resolver.resolveFunction(getterPrototype, null); + if (getter) return this.compileCallDirect(getter, [], propertyAccess, 0); + } + return module.createUnreachable(); + } + case ElementKind.PROPERTY: { // instance property + let getterInstance = assert((target).getterInstance); + return this.compileCallDirect(getterInstance, [], propertyAccess, + this.compileExpressionRetainType( + assert(this.resolver.currentThisExpression), + this.options.usizeType, + WrapMode.NONE + ) + ); } case ElementKind.FUNCTION_PROTOTYPE: { this.error( DiagnosticCode.Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set, - propertyAccess.range, (target).simpleName + propertyAccess.range, (target).name ); return module.createUnreachable(); } @@ -6904,7 +6844,7 @@ export class Compiler extends DiagnosticEmitter { return module.createUnreachable(); } - private compileGetter(target: Property, reportNode: Node): ExpressionRef { + private compileGetter(target: PropertyPrototype, reportNode: Node): ExpressionRef { var prototype = target.getterPrototype; if (prototype) { let instance = this.resolver.resolveFunction(prototype, null); @@ -6935,7 +6875,7 @@ export class Compiler extends DiagnosticEmitter { } else { this.error( DiagnosticCode.Property_0_does_not_exist_on_type_1, - reportNode.range, (target).simpleName, (target).parent.toString() + reportNode.range, (target).name, (target).parent.toString() ); return this.module.createUnreachable(); } @@ -6951,27 +6891,22 @@ export class Compiler extends DiagnosticEmitter { this.currentType ); + // Try to eliminate unnecesssary branches if the condition is constant + var condExprPrecomp = this.module.precomputeExpression(condExpr); if ( - !this.options.noTreeShaking || - outerFlow.actualFunction.isAny(CommonFlags.GENERIC | CommonFlags.GENERIC_CONTEXT) + getExpressionId(condExprPrecomp) == ExpressionId.Const && + getExpressionType(condExprPrecomp) == NativeType.I32 ) { - // Try to eliminate unnecesssary branches if the condition is constant - let condExprPrecomp = this.module.precomputeExpression(condExpr); - if ( - getExpressionId(condExprPrecomp) == ExpressionId.Const && - getExpressionType(condExprPrecomp) == NativeType.I32 - ) { - return getConstValueI32(condExprPrecomp) - ? this.compileExpressionRetainType(ifThen, contextualType, WrapMode.NONE) - : this.compileExpressionRetainType(ifElse, contextualType, WrapMode.NONE); - - // Otherwise recompile to the original and let the optimizer decide - } else /* if (condExpr != condExprPrecomp) <- not guaranteed */ { - condExpr = this.makeIsTrueish( - this.compileExpressionRetainType(expression.condition, Type.bool, WrapMode.NONE), - this.currentType - ); - } + return getConstValueI32(condExprPrecomp) + ? this.compileExpressionRetainType(ifThen, contextualType, WrapMode.NONE) + : this.compileExpressionRetainType(ifElse, contextualType, WrapMode.NONE); + + // Otherwise recompile to the original and let the optimizer decide + } else /* if (condExpr != condExprPrecomp) <- not guaranteed */ { + condExpr = this.makeIsTrueish( + this.compileExpressionRetainType(expression.condition, Type.bool, WrapMode.NONE), + this.currentType + ); } var ifThenFlow = outerFlow.fork(); @@ -7798,7 +7733,7 @@ export class Compiler extends DiagnosticEmitter { var flow = this.currentFlow; var isInline = flow.is(FlowFlags.INLINE_CONTEXT); var thisLocalIndex = isInline - ? assert(flow.lookupLocal("this")).index + ? assert(flow.lookupLocal(CommonSymbols.this_)).index : 0; var nativeSizeType = this.options.nativeSizeType; @@ -7811,14 +7746,13 @@ export class Compiler extends DiagnosticEmitter { let field = member; assert(!field.isAny(CommonFlags.CONST)); let fieldType = field.type; let nativeFieldType = fieldType.toNativeType(); - let fieldDeclaration = field.prototype.declaration; - let initializer = fieldDeclaration.initializer; - if (initializer) { // use initializer + let initializerNode = field.prototype.initializerNode; + if (initializerNode) { // use initializer stmts.push( module.createStore(fieldType.byteSize, module.createGetLocal(thisLocalIndex, nativeSizeType), this.compileExpression( // reports - initializer, + initializerNode, fieldType, ConversionKind.IMPLICIT, WrapMode.NONE @@ -7828,14 +7762,14 @@ export class Compiler extends DiagnosticEmitter { ) ); } else { - let parameterIndex = fieldDeclaration.parameterIndex; + let parameterIndex = field.prototype.parameterIndex; stmts.push( module.createStore(fieldType.byteSize, module.createGetLocal(thisLocalIndex, nativeSizeType), parameterIndex >= 0 // initialized via parameter (here: a local) ? module.createGetLocal( isInline - ? assert(flow.lookupLocal(field.simpleName)).index + ? assert(flow.lookupLocal(field.name)).index : 1 + parameterIndex, // this is local 0 nativeFieldType ) @@ -7868,8 +7802,9 @@ function mangleImportName( // by default, use the file name as the module name mangleImportName_moduleName = declaration.range.source.simplePath; // and the internal name of the element within that file as the element name - mangleImportName_elementName = declaration.programLevelInternalName; - + mangleImportName_elementName = mangleInternalName( + element.name, element.parent, element.is(CommonFlags.INSTANCE), true + ); if (!element.hasDecorator(DecoratorFlags.EXTERNAL)) return; var program = element.program; @@ -7915,3 +7850,13 @@ function mangleImportName( var mangleImportName_moduleName: string; var mangleImportName_elementName: string; + +/** Special compiler symbols. */ +namespace CompilerSymbols { + /** Module started global. Used if an explicit start function is present. */ + export const started = "~lib/started"; + /** Argument count global. Used to call trampolines for varargs functions. */ + export const argc = "~lib/argc"; + /** Argument count setter. Exported for use by host calls. */ + export const setargc = "~lib/setargc"; +} diff --git a/src/definitions.ts b/src/definitions.ts index 8a899e0f19..1ef6e38128 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -22,7 +22,8 @@ import { Namespace, ConstantValueKind, Interface, - Property + Property, + PropertyPrototype } from "./program"; import { @@ -52,11 +53,15 @@ abstract class ExportsWalker { this.includePrivate; } - /** Walks all exports and calls the respective handlers. */ + /** Walks all elements and calls the respective handlers. */ walk(): void { - for (let moduleExport of this.program.moduleLevelExports.values()) { - // FIXME: doesn't honor the actual externally visible name - this.visitElement(moduleExport.element); + for (let file of this.program.filesByName.values()) { + let members = file.members; + if (!members) continue; + for (let member of members.values()) { + // FIXME: doesn't honor the actual externally visible name + this.visitElement(member); + } } var todo = this.todo; for (let i = 0; i < todo.length; ) this.visitElement(todo[i]); @@ -88,24 +93,30 @@ abstract class ExportsWalker { if ((element).is(CommonFlags.COMPILED)) this.visitField(element); break; } + case ElementKind.PROPERTY_PROTOTYPE: { + this.visitPropertyInstances(element); + break; + } case ElementKind.PROPERTY: { let prop = element; - let getter = prop.getterPrototype; - if (getter) this.visitFunctionInstances(getter); - let setter = prop.setterPrototype; - if (setter) this.visitFunctionInstances(setter); + let getter = prop.getterInstance; + if (getter) this.visitFunction(getter); + let setter = prop.setterInstance; + if (setter) this.visitFunction(setter); break; } case ElementKind.NAMESPACE: { if (hasCompiledMember(element)) this.visitNamespace(element); break; } + case ElementKind.TYPEDEFINITION: break; default: assert(false); } } private visitFunctionInstances(element: FunctionPrototype): void { - for (let instances of element.instances.values()) { + var instances = element.instances; + if (instances) { for (let instance of instances.values()) { if (instance.is(CommonFlags.COMPILED)) this.visitFunction(instance); } @@ -113,11 +124,24 @@ abstract class ExportsWalker { } private visitClassInstances(element: ClassPrototype): void { - for (let instance of element.instances.values()) { - if (instance.is(CommonFlags.COMPILED)) this.visitClass(instance); + var instances = element.instances; + if (instances) { + for (let instance of instances.values()) { + if (instance.is(CommonFlags.COMPILED)) this.visitClass(instance); + } } } + private visitPropertyInstances(element: PropertyPrototype): void { + // var instances = element.instances; + // if (instances) { + // for (let instance of instances.values()) { + // if (instance.is(CommonFlags.COMPILED)) this.visitProperty(instance); + // } + // } + assert(false); + } + abstract visitGlobal(element: Global): void; abstract visitEnum(element: Enum): void; abstract visitFunction(element: Function): void; @@ -150,7 +174,7 @@ export class IDLBuilder extends ExportsWalker { if (isConst) sb.push("const "); sb.push(this.typeToString(element.type)); sb.push(" "); - sb.push(element.simpleName); + sb.push(element.name); if (isConst) { switch (element.constantValueKind) { case ConstantValueKind.INTEGER: { @@ -173,7 +197,7 @@ export class IDLBuilder extends ExportsWalker { var sb = this.sb; indent(sb, this.indentLevel++); sb.push("interface "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(" {\n"); var members = element.members; if (members) { @@ -187,7 +211,8 @@ export class IDLBuilder extends ExportsWalker { sb.push(name); if (isConst) { sb.push(" = "); - sb.push((member).constantValue.toString(10)); + assert((member).constantValueKind == ConstantValueKind.INTEGER); + sb.push(i64_low((member).constantIntegerValue).toString(10)); } sb.push(";\n"); } @@ -206,7 +231,7 @@ export class IDLBuilder extends ExportsWalker { indent(sb, this.indentLevel); sb.push(this.typeToString(signature.returnType)); sb.push(" "); - sb.push(element.simpleName); + sb.push(element.name); sb.push("("); var parameters = signature.parameterTypes; var numParameters = parameters.length; @@ -223,7 +248,7 @@ export class IDLBuilder extends ExportsWalker { if (members && members.size) { indent(sb, this.indentLevel); sb.push("interface "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(" {\n"); for (let member of members.values()) this.visitElement(member); indent(sb, --this.indentLevel); @@ -235,7 +260,7 @@ export class IDLBuilder extends ExportsWalker { var sb = this.sb; indent(sb, this.indentLevel++); sb.push("interface "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(" {\n"); // TODO indent(sb, --this.indentLevel); @@ -254,7 +279,7 @@ export class IDLBuilder extends ExportsWalker { var sb = this.sb; indent(sb, this.indentLevel++); sb.push("interface "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(" {\n"); var members = element.members; if (members) { @@ -327,7 +352,7 @@ export class TSDBuilder extends ExportsWalker { if (isConst) sb.push("const "); else sb.push("var "); } - sb.push(element.simpleName); + sb.push(element.name); sb.push(": "); sb.push(this.typeToString(element.type)); sb.push(";\n"); @@ -338,7 +363,7 @@ export class TSDBuilder extends ExportsWalker { var sb = this.sb; indent(sb, this.indentLevel++); sb.push("enum "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(" {\n"); var members = element.members; if (members) { @@ -349,7 +374,8 @@ export class TSDBuilder extends ExportsWalker { sb.push(name); if (member.is(CommonFlags.INLINED)) { sb.push(" = "); - sb.push((member).constantValue.toString(10)); + assert((member).constantValueKind == ConstantValueKind.INTEGER); + sb.push(i64_low((member).constantIntegerValue).toString(10)); } sb.push(",\n"); --numMembers; @@ -369,14 +395,14 @@ export class TSDBuilder extends ExportsWalker { if (element.is(CommonFlags.PROTECTED)) sb.push("protected "); if (element.is(CommonFlags.STATIC)) sb.push("static "); if (element.is(CommonFlags.GET)) { - sb.push(element.prototype.declaration.name.text); // 'get:funcName' internally + sb.push(element.identifierNode.text); // 'get:funcName' internally sb.push(": "); sb.push(this.typeToString(signature.returnType)); sb.push(";\n"); return; } else { if (!element.isAny(CommonFlags.STATIC | CommonFlags.INSTANCE)) sb.push("function "); - sb.push(element.simpleName); + sb.push(element.name); } sb.push("("); var parameters = signature.parameterTypes; @@ -409,14 +435,14 @@ export class TSDBuilder extends ExportsWalker { if (element.is(CommonFlags.ABSTRACT)) sb.push("abstract "); sb.push("class "); } - sb.push(element.simpleName); + sb.push(element.name); var base = element.base; if (base && base.is(CommonFlags.COMPILED | CommonFlags.MODULE_EXPORT)) { sb.push(" extends "); - sb.push(base.simpleName); // TODO: fqn + sb.push(base.name); // TODO: fqn } sb.push(" {\n"); - var members = element.prototype.members; // static + var members = element.parent.members; // static if (members) { for (let member of members.values()) { this.visitElement(member); @@ -443,7 +469,7 @@ export class TSDBuilder extends ExportsWalker { if (element.is(CommonFlags.PROTECTED)) sb.push("protected "); if (element.is(CommonFlags.STATIC)) sb.push("static "); if (element.is(CommonFlags.READONLY)) sb.push("readonly "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(": "); sb.push(this.typeToString(element.type)); sb.push(";\n"); @@ -455,7 +481,7 @@ export class TSDBuilder extends ExportsWalker { let sb = this.sb; indent(sb, this.indentLevel++); sb.push("namespace "); - sb.push(element.simpleName); + sb.push(element.name); sb.push(" {\n"); for (let member of members.values()) this.visitElement(member); indent(sb, --this.indentLevel); @@ -519,7 +545,8 @@ function hasCompiledMember(element: Element): bool { for (let member of members.values()) { switch (member.kind) { case ElementKind.FUNCTION_PROTOTYPE: { - for (let instances of (member).instances.values()) { + let instances = (member).instances; + if (instances) { for (let instance of instances.values()) { if (instance.is(CommonFlags.COMPILED)) return true; } @@ -527,8 +554,11 @@ function hasCompiledMember(element: Element): bool { break; } case ElementKind.CLASS_PROTOTYPE: { - for (let instance of (member).instances.values()) { - if (instance.is(CommonFlags.COMPILED)) return true; + let instances = (member).instances; + if (instances) { + for (let instance of instances.values()) { + if (instance.is(CommonFlags.COMPILED)) return true; + } } break; } diff --git a/src/diagnosticMessages.generated.ts b/src/diagnosticMessages.generated.ts index 726de9f358..99e9c3d4ef 100644 --- a/src/diagnosticMessages.generated.ts +++ b/src/diagnosticMessages.generated.ts @@ -31,6 +31,7 @@ export enum DiagnosticCode { Cannot_access_method_0_without_calling_it_as_it_requires_this_to_be_set = 218, Optional_properties_are_not_supported = 219, Expression_must_be_a_compile_time_constant = 220, + Module_cannot_have_multiple_start_functions = 221, Unterminated_string_literal = 1002, Identifier_expected = 1003, _0_expected = 1005, @@ -112,6 +113,7 @@ export enum DiagnosticCode { Multiple_constructor_implementations_are_not_allowed = 2392, Duplicate_function_implementation = 2393, Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local = 2395, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged = 2434, Type_0_has_no_property_1 = 2460, The_0_operator_cannot_be_applied_to_type_1 = 2469, In_const_enum_declarations_member_initializer_must_be_constant_expression = 2474, @@ -127,6 +129,7 @@ export enum DiagnosticCode { Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration = 2674, Namespace_0_has_no_exported_member_1 = 2694, Required_type_parameters_may_not_follow_optional_type_parameters = 2706, + Duplicate_property_0 = 2718, File_0_not_found = 6054, Numeric_separators_are_not_allowed_here = 6188, Multiple_consecutive_numeric_separators_are_not_permitted = 6189, @@ -161,6 +164,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string { case 218: return "Cannot access method '{0}' without calling it as it requires 'this' to be set."; case 219: return "Optional properties are not supported."; case 220: return "Expression must be a compile-time constant."; + case 221: return "Module cannot have multiple start functions."; case 1002: return "Unterminated string literal."; case 1003: return "Identifier expected."; case 1005: return "'{0}' expected."; @@ -242,6 +246,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string { case 2392: return "Multiple constructor implementations are not allowed."; case 2393: return "Duplicate function implementation."; case 2395: return "Individual declarations in merged declaration '{0}' must be all exported or all local."; + case 2434: return "A namespace declaration cannot be located prior to a class or function with which it is merged."; case 2460: return "Type '{0}' has no property '{1}'."; case 2469: return "The '{0}' operator cannot be applied to type '{1}'."; case 2474: return "In 'const' enum declarations member initializer must be constant expression."; @@ -257,6 +262,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string { case 2674: return "Constructor of class '{0}' is protected and only accessible within the class declaration."; case 2694: return "Namespace '{0}' has no exported member '{1}'."; case 2706: return "Required type parameters may not follow optional type parameters."; + case 2718: return "Duplicate property '{0}'."; case 6054: return "File '{0}' not found."; case 6188: return "Numeric separators are not allowed here."; case 6189: return "Multiple consecutive numeric separators are not permitted."; diff --git a/src/diagnosticMessages.json b/src/diagnosticMessages.json index 50d880e623..041c578b55 100644 --- a/src/diagnosticMessages.json +++ b/src/diagnosticMessages.json @@ -23,6 +23,7 @@ "Cannot access method '{0}' without calling it as it requires 'this' to be set.": 218, "Optional properties are not supported.": 219, "Expression must be a compile-time constant.": 220, + "Module cannot have multiple start functions.": 221, "Unterminated string literal.": 1002, "Identifier expected.": 1003, @@ -106,6 +107,7 @@ "Multiple constructor implementations are not allowed.": 2392, "Duplicate function implementation.": 2393, "Individual declarations in merged declaration '{0}' must be all exported or all local.": 2395, + "A namespace declaration cannot be located prior to a class or function with which it is merged.": 2434, "Type '{0}' has no property '{1}'.": 2460, "The '{0}' operator cannot be applied to type '{1}'.": 2469, "In 'const' enum declarations member initializer must be constant expression.": 2474, @@ -121,6 +123,7 @@ "Constructor of class '{0}' is protected and only accessible within the class declaration.": 2674, "Namespace '{0}' has no exported member '{1}'.": 2694, "Required type parameters may not follow optional type parameters.": 2706, + "Duplicate property '{0}'.": 2718, "File '{0}' not found.": 6054, "Numeric separators are not allowed here.": 6188, diff --git a/src/diagnostics.ts b/src/diagnostics.ts index c1b31bf7b6..b7f3f4061f 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -78,6 +78,8 @@ export class DiagnosticMessage { message: string; /** Respective source range, if any. */ range: Range | null = null; + /** Related range, if any. */ + relatedRange: Range | null = null; /** Constructs a new diagnostic message. */ private constructor(code: i32, category: DiagnosticCategory, message: string) { @@ -134,6 +136,12 @@ export class DiagnosticMessage { return this; } + /** Adds a related source range to this message. */ + withRelatedRange(range: Range): this { + this.relatedRange = range; + return this; + } + /** Converts this message to a string. */ toString(): string { if (this.range) { @@ -185,9 +193,8 @@ export function formatDiagnosticMessage( let range = message.range; if (showContext) { sb.push("\n"); - sb.push(formatDiagnosticContext(message.range, useColors)); + sb.push(formatDiagnosticContext(range, useColors)); } - sb.push("\n"); sb.push(" in "); sb.push(range.source.normalizedPath); @@ -196,6 +203,22 @@ export function formatDiagnosticMessage( sb.push(","); sb.push(range.column.toString(10)); sb.push(")"); + + let relatedRange = message.relatedRange; + if (relatedRange) { + if (showContext) { + sb.push("\n"); + sb.push(formatDiagnosticContext(relatedRange, useColors)); + } + sb.push("\n"); + sb.push(" in "); + sb.push(range.source.normalizedPath); + sb.push("("); + sb.push(range.line.toString(10)); + sb.push(","); + sb.push(range.column.toString(10)); + sb.push(")"); + } } return sb.join(""); } @@ -243,11 +266,13 @@ export abstract class DiagnosticEmitter { code: DiagnosticCode, category: DiagnosticCategory, range: Range, + relatedRange: Range | null, arg0: string | null = null, arg1: string | null = null, arg2: string | null = null ): void { var message = DiagnosticMessage.create(code, category, arg0, arg1, arg2).withRange(range); + if (relatedRange) message.relatedRange = relatedRange; this.diagnostics.push(message); // console.log(formatDiagnosticMessage(message, true, true) + "\n"); // temporary // console.log(new Error("stack").stack); @@ -261,7 +286,19 @@ export abstract class DiagnosticEmitter { arg1: string | null = null, arg2: string | null = null ): void { - this.emitDiagnostic(code, DiagnosticCategory.INFO, range, arg0, arg1, arg2); + this.emitDiagnostic(code, DiagnosticCategory.INFO, range, null, arg0, arg1, arg2); + } + + /** Emits an informatory diagnostic message with a related range. */ + infoRelated( + code: DiagnosticCode, + range: Range, + relatedRange: Range, + arg0: string | null = null, + arg1: string | null = null, + arg2: string | null = null + ): void { + this.emitDiagnostic(code, DiagnosticCategory.INFO, range, relatedRange, arg0, arg1, arg2); } /** Emits a warning diagnostic message. */ @@ -272,7 +309,19 @@ export abstract class DiagnosticEmitter { arg1: string | null = null, arg2: string | null = null ): void { - this.emitDiagnostic(code, DiagnosticCategory.WARNING, range, arg0, arg1, arg2); + this.emitDiagnostic(code, DiagnosticCategory.WARNING, range, null, arg0, arg1, arg2); + } + + /** Emits a warning diagnostic message with a related range. */ + warningRelated( + code: DiagnosticCode, + range: Range, + relatedRange: Range, + arg0: string | null = null, + arg1: string | null = null, + arg2: string | null = null + ): void { + this.emitDiagnostic(code, DiagnosticCategory.WARNING, range, relatedRange, arg0, arg1, arg2); } /** Emits an error diagnostic message. */ @@ -283,6 +332,18 @@ export abstract class DiagnosticEmitter { arg1: string | null = null, arg2: string | null = null ): void { - this.emitDiagnostic(code, DiagnosticCategory.ERROR, range, arg0, arg1, arg2); + this.emitDiagnostic(code, DiagnosticCategory.ERROR, range, null, arg0, arg1, arg2); + } + + /** Emits an error diagnostic message with a related range. */ + errorRelated( + code: DiagnosticCode, + range: Range, + relatedRange: Range, + arg0: string | null = null, + arg1: string | null = null, + arg2: string | null = null + ): void { + this.emitDiagnostic(code, DiagnosticCategory.ERROR, range, relatedRange, arg0, arg1, arg2); } } diff --git a/src/extra/ast.ts b/src/extra/ast.ts index 2daa8338f0..08ceac95b6 100644 --- a/src/extra/ast.ts +++ b/src/extra/ast.ts @@ -13,6 +13,7 @@ import { CommonTypeNode, TypeNode, + TypeName, TypeParameterNode, SignatureNode, @@ -79,7 +80,8 @@ import { ParameterNode, ParameterKind, ExportMember, - SwitchCase + SwitchCase, + DeclarationStatement } from "../ast"; import { @@ -358,8 +360,7 @@ export class ASTBuilder { return; } var typeNode = node; - assert(typeNode.name.text.length); - this.visitIdentifierExpression(typeNode.name); + this.visitTypeName((node).name); var typeArguments = typeNode.typeArguments; if (typeArguments) { let numTypeArguments = typeArguments.length; @@ -377,6 +378,17 @@ export class ASTBuilder { } } + visitTypeName(node: TypeName): void { + this.visitIdentifierExpression(node.identifier); + var sb = this.sb; + var current = node.next; + while (current) { + sb.push("."); + this.visitIdentifierExpression(current.identifier); + current = current.next; + } + } + visitTypeParameter(node: TypeParameterNode): void { this.visitIdentifierExpression(node.name); var extendsType = node.extendsType; @@ -423,7 +435,7 @@ export class ASTBuilder { // expressions visitIdentifierExpression(node: IdentifierExpression): void { - if (node.is(CommonFlags.QUOTED)) this.visitStringLiteral(node.text); + if (node.isQuoted) this.visitStringLiteral(node.text); else this.sb.push(node.text); } @@ -565,7 +577,7 @@ export class ASTBuilder { visitFunctionExpression(node: FunctionExpression): void { var declaration = node.declaration; - if (!node.is(CommonFlags.ARROW)) { + if (!declaration.is(CommonFlags.ARROW)) { if (declaration.name.text.length) { this.sb.push("function "); } else { @@ -853,13 +865,12 @@ export class ASTBuilder { sb.push("class"); } var typeParameters = node.typeParameters; - var numTypeParameters = typeParameters.length; - if (numTypeParameters) { + if (typeParameters && typeParameters.length) { sb.push("<"); this.visitTypeParameter(typeParameters[0]); - for (let i = 1; i < numTypeParameters; ++i) { + for (let i = 1, k = typeParameters.length; i < k; ++i) { sb.push(", "); - this.visitTypeParameter(node.typeParameters[i]); + this.visitTypeParameter(typeParameters[i]); } sb.push(">"); } @@ -960,16 +971,16 @@ export class ASTBuilder { } visitExportMember(node: ExportMember): void { - this.visitIdentifierExpression(node.name); - if (node.externalName.text != node.name.text) { + this.visitIdentifierExpression(node.localName); + if (node.exportedName.text != node.localName.text) { this.sb.push(" as "); - this.visitIdentifierExpression(node.externalName); + this.visitIdentifierExpression(node.exportedName); } } visitExportStatement(node: ExportStatement): void { var sb = this.sb; - if (node.is(CommonFlags.DECLARE)) { + if (node.isDeclare) { sb.push("declare "); } var members = node.members; @@ -1158,7 +1169,7 @@ export class ASTBuilder { } visitImportDeclaration(node: ImportDeclaration): void { - var externalName = node.externalName; + var externalName = node.foreignName; var name = node.name; this.visitIdentifierExpression(externalName); if (externalName.text != name.text) { @@ -1217,11 +1228,10 @@ export class ASTBuilder { sb.push("interface "); this.visitIdentifierExpression(node.name); var typeParameters = node.typeParameters; - var numTypeParameters = typeParameters.length; - if (numTypeParameters) { + if (typeParameters && typeParameters.length) { sb.push("<"); this.visitTypeParameter(typeParameters[0]); - for (let i = 0; i < numTypeParameters; ++i) { + for (let i = 1, k = typeParameters.length; i < k; ++i) { sb.push(", "); this.visitTypeParameter(typeParameters[i]); } @@ -1429,11 +1439,12 @@ export class ASTBuilder { this.serializeDecorator(decorators[i]); } } - this.serializeExternalModifiers(node); var sb = this.sb; - sb.push(node.is(CommonFlags.CONST) ? "const " : node.is(CommonFlags.LET) ? "let " : "var "); var declarations = node.declarations; var numDeclarations = assert(declarations.length); + var firstDeclaration = declarations[0]; + this.serializeExternalModifiers(firstDeclaration); + sb.push(firstDeclaration.is(CommonFlags.CONST) ? "const " : firstDeclaration.is(CommonFlags.LET) ? "let " : "var "); this.visitVariableDeclaration(node.declarations[0]); for (let i = 1; i < numDeclarations; ++i) { sb.push(", "); @@ -1504,7 +1515,7 @@ export class ASTBuilder { } } - serializeExternalModifiers(node: Node): void { + serializeExternalModifiers(node: DeclarationStatement): void { var sb = this.sb; if (node.is(CommonFlags.EXPORT)) { sb.push("export "); @@ -1515,7 +1526,7 @@ export class ASTBuilder { } } - serializeAccessModifiers(node: Node): void { + serializeAccessModifiers(node: DeclarationStatement): void { var sb = this.sb; if (node.is(CommonFlags.PUBLIC)) { sb.push("public "); @@ -1542,5 +1553,9 @@ export class ASTBuilder { } function isTypeOmitted(type: CommonTypeNode): bool { - return type.kind == NodeKind.TYPE && !changetype(type).name.text.length; + if (type.kind == NodeKind.TYPE) { + let name = (type).name; + return !(name.next || name.identifier.text.length); + } + return false; } diff --git a/src/flow.ts b/src/flow.ts new file mode 100644 index 0000000000..597a1e25ce --- /dev/null +++ b/src/flow.ts @@ -0,0 +1,753 @@ +/** + * A control flow analyzer. + * @module flow + *//***/ + +import { + Type, + TypeFlags, + TypeKind +} from "./types"; + +import { + Local, + Function, + Element, + ElementKind, + Global +} from "./program"; + +import { + NativeType, + ExpressionId, + ExpressionRef, + + getExpressionId, + getGetLocalIndex, + isTeeLocal, + getSetLocalValue, + getGetGlobalName, + getBinaryOp, + BinaryOp, + getBinaryLeft, + getConstValueI32, + getBinaryRight, + getUnaryOp, + UnaryOp, + getExpressionType, + getConstValueI64Low, + getConstValueF32, + getConstValueF64, + getLoadBytes, + isLoadSigned, + getBlockName, + getBlockChildCount, + getBlockChild, + getIfTrue, + getIfFalse, + getSelectThen, + getSelectElse, + getCallTarget +} from "./module"; + +import { + CommonFlags +} from "./common"; + +import { + DiagnosticCode +} from "./diagnostics"; + +import { + Node +} from "./ast"; + +import { + bitsetIs, + bitsetSet +} from "./util"; + +/** Control flow flags indicating specific conditions. */ +export const enum FlowFlags { + /** No specific conditions. */ + NONE = 0, + + // categorical + + /** This flow returns. */ + RETURNS = 1 << 0, + /** This flow returns a wrapped value. */ + RETURNS_WRAPPED = 1 << 1, + /** This flow throws. */ + THROWS = 1 << 2, + /** This flow breaks. */ + BREAKS = 1 << 3, + /** This flow continues. */ + CONTINUES = 1 << 4, + /** This flow allocates. Constructors only. */ + ALLOCATES = 1 << 5, + /** This flow calls super. Constructors only. */ + CALLS_SUPER = 1 << 6, + + // conditional + + /** This flow conditionally returns in a child flow. */ + CONDITIONALLY_RETURNS = 1 << 7, + /** This flow conditionally throws in a child flow. */ + CONDITIONALLY_THROWS = 1 << 8, + /** This flow conditionally breaks in a child flow. */ + CONDITIONALLY_BREAKS = 1 << 9, + /** This flow conditionally continues in a child flow. */ + CONDITIONALLY_CONTINUES = 1 << 10, + /** This flow conditionally allocates in a child flow. Constructors only. */ + CONDITIONALLY_ALLOCATES = 1 << 11, + + // special + + /** This is an inlining flow. */ + INLINE_CONTEXT = 1 << 12, + /** This is a flow with explicitly disabled bounds checking. */ + UNCHECKED_CONTEXT = 1 << 13, + + // masks + + /** Any terminating flag. */ + ANY_TERMINATING = FlowFlags.RETURNS + | FlowFlags.THROWS + | FlowFlags.BREAKS + | FlowFlags.CONTINUES, + + /** Any categorical flag. */ + ANY_CATEGORICAL = FlowFlags.RETURNS + | FlowFlags.RETURNS_WRAPPED + | FlowFlags.THROWS + | FlowFlags.BREAKS + | FlowFlags.CONTINUES + | FlowFlags.ALLOCATES + | FlowFlags.CALLS_SUPER, + + /** Any conditional flag. */ + ANY_CONDITIONAL = FlowFlags.CONDITIONALLY_RETURNS + | FlowFlags.CONDITIONALLY_THROWS + | FlowFlags.CONDITIONALLY_BREAKS + | FlowFlags.CONDITIONALLY_CONTINUES + | FlowFlags.CONDITIONALLY_ALLOCATES +} + +/** A control flow evaluator. */ +export class Flow { + + /** Parent flow. */ + parent: Flow | null; + /** Flow flags indicating specific conditions. */ + flags: FlowFlags; + /** Function this flow belongs to. */ + parentFunction: Function; + /** The label we break to when encountering a continue statement. */ + continueLabel: string | null; + /** The label we break to when encountering a break statement. */ + breakLabel: string | null; + /** The current return type. */ + returnType: Type; + /** The current contextual type arguments. */ + contextualTypeArguments: Map | null; + /** Scoped local variables. */ + scopedLocals: Map | null = null; + /** Local variable wrap states for the first 64 locals. */ + wrappedLocals: I64; + /** Local variable wrap states for locals with index >= 64. */ + wrappedLocalsExt: I64[] | null; + /** Function being inlined, when inlining. */ + inlineFunction: Function | null; + /** The label we break to when encountering a return statement, when inlining. */ + inlineReturnLabel: string | null; + + /** Creates the parent flow of the specified function. */ + static create(parentFunction: Function): Flow { + var flow = new Flow(); + flow.parent = null; + flow.flags = FlowFlags.NONE; + flow.parentFunction = parentFunction; + flow.continueLabel = null; + flow.breakLabel = null; + flow.returnType = parentFunction.signature.returnType; + flow.contextualTypeArguments = parentFunction.contextualTypeArguments; + flow.wrappedLocals = i64_new(0); + flow.wrappedLocalsExt = null; + flow.inlineFunction = null; + flow.inlineReturnLabel = null; + return flow; + } + + /** Creates an inline flow within `currentFunction`. */ + static createInline(parentFunction: Function, inlineFunction: Function): Flow { + var flow = Flow.create(parentFunction); + flow.set(FlowFlags.INLINE_CONTEXT); + flow.inlineFunction = inlineFunction; + flow.inlineReturnLabel = inlineFunction.internalName + "|inlined." + (inlineFunction.nextInlineId++).toString(10); + flow.returnType = inlineFunction.signature.returnType; + flow.contextualTypeArguments = inlineFunction.contextualTypeArguments; + return flow; + } + + private constructor() { } + + /** Gets the actual function being compiled, The inlined function when inlining, otherwise the parent function. */ + get actualFunction(): Function { + return this.inlineFunction || this.parentFunction; + } + + /** Tests if this flow has the specified flag or flags. */ + is(flag: FlowFlags): bool { return (this.flags & flag) == flag; } + /** Tests if this flow has one of the specified flags. */ + isAny(flag: FlowFlags): bool { return (this.flags & flag) != 0; } + /** Sets the specified flag or flags. */ + set(flag: FlowFlags): void { this.flags |= flag; } + /** Unsets the specified flag or flags. */ + unset(flag: FlowFlags): void { this.flags &= ~flag; } + + /** Forks this flow to a child flow. */ + fork(): Flow { + var branch = new Flow(); + branch.parent = this; + branch.flags = this.flags; + branch.parentFunction = this.parentFunction; + branch.continueLabel = this.continueLabel; + branch.breakLabel = this.breakLabel; + branch.returnType = this.returnType; + branch.contextualTypeArguments = this.contextualTypeArguments; + branch.wrappedLocals = this.wrappedLocals; + branch.wrappedLocalsExt = this.wrappedLocalsExt ? this.wrappedLocalsExt.slice() : null; + branch.inlineFunction = this.inlineFunction; + branch.inlineReturnLabel = this.inlineReturnLabel; + return branch; + } + + /** Gets a free temporary local of the specified type. */ + getTempLocal(type: Type, wrapped: bool = false): Local { + var parentFunction = this.parentFunction; + var temps: Local[] | null; + switch (type.toNativeType()) { + case NativeType.I32: { temps = parentFunction.tempI32s; break; } + case NativeType.I64: { temps = parentFunction.tempI64s; break; } + case NativeType.F32: { temps = parentFunction.tempF32s; break; } + case NativeType.F64: { temps = parentFunction.tempF64s; break; } + default: throw new Error("concrete type expected"); + } + var local: Local; + if (temps && temps.length) { + local = temps.pop(); + local.type = type; + local.flags = CommonFlags.NONE; + } else { + local = parentFunction.addLocal(type); + } + if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) this.setLocalWrapped(local.index, wrapped); + return local; + } + + /** Frees the temporary local for reuse. */ + freeTempLocal(local: Local): void { + if (local.is(CommonFlags.INLINED)) return; + assert(local.index >= 0); + var parentFunction = this.parentFunction; + var temps: Local[]; + assert(local.type != null); // internal error + switch ((local.type).toNativeType()) { + case NativeType.I32: { + temps = parentFunction.tempI32s || (parentFunction.tempI32s = []); + break; + } + case NativeType.I64: { + temps = parentFunction.tempI64s || (parentFunction.tempI64s = []); + break; + } + case NativeType.F32: { + temps = parentFunction.tempF32s || (parentFunction.tempF32s = []); + break; + } + case NativeType.F64: { + temps = parentFunction.tempF64s || (parentFunction.tempF64s = []); + break; + } + default: throw new Error("concrete type expected"); + } + assert(local.index >= 0); + temps.push(local); + } + + /** Gets and immediately frees a temporary local of the specified type. */ + getAndFreeTempLocal(type: Type, wrapped: bool): Local { + var parentFunction = this.parentFunction; + var temps: Local[]; + switch (type.toNativeType()) { + case NativeType.I32: { + temps = parentFunction.tempI32s || (parentFunction.tempI32s = []); + break; + } + case NativeType.I64: { + temps = parentFunction.tempI64s || (parentFunction.tempI64s = []); + break; + } + case NativeType.F32: { + temps = parentFunction.tempF32s || (parentFunction.tempF32s = []); + break; + } + case NativeType.F64: { + temps = parentFunction.tempF64s || (parentFunction.tempF64s = []); + break; + } + default: throw new Error("concrete type expected"); + } + var local: Local; + if (temps.length) { + local = temps[temps.length - 1]; + local.type = type; + } else { + local = parentFunction.addLocal(type); + temps.push(local); + } + if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) this.setLocalWrapped(local.index, wrapped); + return local; + } + + /** Adds a new scoped local of the specified name. */ + addScopedLocal(name: string, type: Type, wrapped: bool, reportNode: Node | null = null): Local { + var scopedLocal = this.getTempLocal(type, false); + if (!this.scopedLocals) this.scopedLocals = new Map(); + else { + let existingLocal = this.scopedLocals.get(name); + if (existingLocal) { + if (reportNode) { + this.parentFunction.program.error( + DiagnosticCode.Duplicate_identifier_0, + reportNode.range + ); + } + return existingLocal; + } + } + scopedLocal.set(CommonFlags.SCOPED); + this.scopedLocals.set(name, scopedLocal); + if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) { + this.setLocalWrapped(scopedLocal.index, wrapped); + } + return scopedLocal; + } + + /** Adds a new scoped alias for the specified local. For example `super` aliased to the `this` local. */ + addScopedAlias(name: string, type: Type, index: i32, reportNode: Node | null = null): Local { + if (!this.scopedLocals) this.scopedLocals = new Map(); + else { + let existingLocal = this.scopedLocals.get(name); + if (existingLocal) { + if (reportNode) { + this.parentFunction.program.error( + DiagnosticCode.Duplicate_identifier_0, + reportNode.range + ); + } + return existingLocal; + } + } + assert(index < this.parentFunction.localsByIndex.length); + var scopedAlias = new Local( + name, + index, + type, + this.parentFunction + ); + // not flagged as SCOPED as it must not be free'd when the flow is finalized + this.scopedLocals.set(name, scopedAlias); + return scopedAlias; + } + + /** Frees this flow's scoped variables and returns its parent flow. */ + freeScopedLocals(): void { + if (this.scopedLocals) { + for (let scopedLocal of this.scopedLocals.values()) { + if (scopedLocal.is(CommonFlags.SCOPED)) { // otherwise an alias + this.freeTempLocal(scopedLocal); + } + } + this.scopedLocals = null; + } + } + + /** Looks up the local of the specified name in the current scope. */ + lookupLocal(name: string): Local | null { + var current: Flow | null = this; + var scope: Map | null; + do if ((scope = current.scopedLocals) && (scope.has(name))) return scope.get(name); + while (current = current.parent); + return this.parentFunction.localsByName.get(name); + } + + /** Looks up the element with the specified name relative to the scope of this flow. */ + lookup(name: string): Element | null { + var element = this.lookupLocal(name); + if (element) return element; + return this.actualFunction.lookup(name); + } + + /** Tests if the value of the local at the specified index is considered wrapped. */ + isLocalWrapped(index: i32): bool { + if (index < 0) return true; // inlined constant + if (index < 64) return bitsetIs(this.wrappedLocals, index); + var ext = this.wrappedLocalsExt; + var i = ((index - 64) / 64) | 0; + if (!(ext && i < ext.length)) return false; + return bitsetIs(ext[i], index - (i + 1) * 64); + } + + /** Sets if the value of the local at the specified index is considered wrapped. */ + setLocalWrapped(index: i32, wrapped: bool): void { + if (index < 0) return; // inlined constant + if (index < 64) { + this.wrappedLocals = bitsetSet(this.wrappedLocals, index, wrapped); + return; + } + var ext = this.wrappedLocalsExt; + var i = ((index - 64) / 64) | 0; + if (!ext) { + this.wrappedLocalsExt = ext = new Array(i + 1); + for (let j = 0; j <= i; ++j) ext[j] = i64_new(0); + } else { + while (ext.length <= i) ext.push(i64_new(0)); + } + ext[i] = bitsetSet(ext[i], index - (i + 1) * 64, wrapped); + } + + /** Pushes a new break label to the stack, for example when entering a loop that one can `break` from. */ + pushBreakLabel(): string { + var parentFunction = this.parentFunction; + var id = parentFunction.nextBreakId++; + var stack = parentFunction.breakStack; + if (!stack) parentFunction.breakStack = [ id ]; + else stack.push(id); + return parentFunction.breakLabel = id.toString(10); + } + + /** Pops the most recent break label from the stack. */ + popBreakLabel(): void { + var parentFunction = this.parentFunction; + var stack = assert(parentFunction.breakStack); + var length = assert(stack.length); + stack.pop(); + if (length > 1) { + parentFunction.breakLabel = stack[length - 2].toString(10); + } else { + parentFunction.breakLabel = null; + parentFunction.breakStack = null; + } + } + + /** Inherits flags and local wrap states from the specified flow (e.g. blocks). */ + inherit(other: Flow): void { + this.flags |= other.flags & (FlowFlags.ANY_CATEGORICAL | FlowFlags.ANY_CONDITIONAL); + this.wrappedLocals = other.wrappedLocals; + this.wrappedLocalsExt = other.wrappedLocalsExt; // no need to slice because other flow is finished + } + + /** Inherits categorical flags as conditional flags from the specified flow (e.g. then without else). */ + inheritConditional(other: Flow): void { + if (other.is(FlowFlags.RETURNS)) { + this.set(FlowFlags.CONDITIONALLY_RETURNS); + } + if (other.is(FlowFlags.THROWS)) { + this.set(FlowFlags.CONDITIONALLY_THROWS); + } + if (other.is(FlowFlags.BREAKS) && other.breakLabel == this.breakLabel) { + this.set(FlowFlags.CONDITIONALLY_BREAKS); + } + if (other.is(FlowFlags.CONTINUES) && other.continueLabel == this.continueLabel) { + this.set(FlowFlags.CONDITIONALLY_CONTINUES); + } + if (other.is(FlowFlags.ALLOCATES)) { + this.set(FlowFlags.CONDITIONALLY_ALLOCATES); + } + } + + /** Inherits mutual flags and local wrap states from the specified flows (e.g. then with else). */ + inheritMutual(left: Flow, right: Flow): void { + // categorical flags set in both arms + this.flags |= left.flags & right.flags & FlowFlags.ANY_CATEGORICAL; + + // conditional flags set in at least one arm + this.flags |= left.flags & FlowFlags.ANY_CONDITIONAL; + this.flags |= right.flags & FlowFlags.ANY_CONDITIONAL; + + // locals wrapped in both arms + this.wrappedLocals = i64_and(left.wrappedLocals, right.wrappedLocals); + var leftExt = left.wrappedLocalsExt; + var rightExt = right.wrappedLocalsExt; + if (leftExt != null && rightExt != null) { + let thisExt = this.wrappedLocalsExt; + let minLength = min(leftExt.length, rightExt.length); + if (minLength) { + if (!thisExt) thisExt = new Array(minLength); + else while (thisExt.length < minLength) thisExt.push(i64_new(0)); + for (let i = 0; i < minLength; ++i) { + thisExt[i] = i64_and( + leftExt[i], + rightExt[i] + ); + } + } + } + } + + /** + * Tests if an expression can possibly overflow in the context of this flow. Assumes that the + * expression might already have overflown and returns `false` only if the operation neglects + * any possible combination of garbage bits being present. + */ + canOverflow(expr: ExpressionRef, type: Type): bool { + // TODO: the following catches most common and a few uncommon cases, but there are additional + // opportunities here, obviously. + assert(type != Type.void); + + // types other than i8, u8, i16, u16 and bool do not overflow + if (!type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) return false; + + var operand: ExpressionRef; + switch (getExpressionId(expr)) { + + // overflows if the local isn't wrapped or the conversion does + case ExpressionId.GetLocal: { + let local = this.parentFunction.localsByIndex[getGetLocalIndex(expr)]; + return !this.isLocalWrapped(local.index) + || canConversionOverflow(local.type, type); + } + + // overflows if the value does + case ExpressionId.SetLocal: { // tee + assert(isTeeLocal(expr)); + return this.canOverflow(getSetLocalValue(expr), type); + } + + // overflows if the conversion does (globals are wrapped on set) + case ExpressionId.GetGlobal: { + // TODO: this is inefficient because it has to read a string + let global = assert(this.parentFunction.program.elementsByName.get(assert(getGetGlobalName(expr)))); + assert(global.kind == ElementKind.GLOBAL); + return canConversionOverflow(assert((global).type), type); + } + + case ExpressionId.Binary: { + switch (getBinaryOp(expr)) { + + // comparisons do not overflow (result is 0 or 1) + case BinaryOp.EqI32: + case BinaryOp.EqI64: + case BinaryOp.EqF32: + case BinaryOp.EqF64: + case BinaryOp.NeI32: + case BinaryOp.NeI64: + case BinaryOp.NeF32: + case BinaryOp.NeF64: + case BinaryOp.LtI32: + case BinaryOp.LtU32: + case BinaryOp.LtI64: + case BinaryOp.LtU64: + case BinaryOp.LtF32: + case BinaryOp.LtF64: + case BinaryOp.LeI32: + case BinaryOp.LeU32: + case BinaryOp.LeI64: + case BinaryOp.LeU64: + case BinaryOp.LeF32: + case BinaryOp.LeF64: + case BinaryOp.GtI32: + case BinaryOp.GtU32: + case BinaryOp.GtI64: + case BinaryOp.GtU64: + case BinaryOp.GtF32: + case BinaryOp.GtF64: + case BinaryOp.GeI32: + case BinaryOp.GeU32: + case BinaryOp.GeI64: + case BinaryOp.GeU64: + case BinaryOp.GeF32: + case BinaryOp.GeF64: return false; + + // result won't overflow if one side is 0 or if one side is 1 and the other wrapped + case BinaryOp.MulI32: { + return !( + ( + getExpressionId(operand = getBinaryLeft(expr)) == ExpressionId.Const && + ( + getConstValueI32(operand) == 0 || + ( + getConstValueI32(operand) == 1 && + !this.canOverflow(getBinaryRight(expr), type) + ) + ) + ) || ( + getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && + ( + getConstValueI32(operand) == 0 || + ( + getConstValueI32(operand) == 1 && + !this.canOverflow(getBinaryLeft(expr), type) + ) + ) + ) + ); + } + + // result won't overflow if one side is a constant less than this type's mask or one side + // is wrapped + case BinaryOp.AndI32: { + // note that computeSmallIntegerMask returns the mask minus the MSB for signed types + // because signed value garbage bits must be guaranteed to be equal to the MSB. + return !( + ( + ( + getExpressionId(operand = getBinaryLeft(expr)) == ExpressionId.Const && + getConstValueI32(operand) <= type.computeSmallIntegerMask(Type.i32) + ) || !this.canOverflow(operand, type) + ) || ( + ( + getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && + getConstValueI32(operand) <= type.computeSmallIntegerMask(Type.i32) + ) || !this.canOverflow(operand, type) + ) + ); + } + + // overflows if the shift doesn't clear potential garbage bits + case BinaryOp.ShlI32: { + let shift = 32 - type.size; + return getExpressionId(operand = getBinaryRight(expr)) != ExpressionId.Const + || getConstValueI32(operand) < shift; + } + + // overflows if the value does and the shift doesn't clear potential garbage bits + case BinaryOp.ShrI32: { + let shift = 32 - type.size; + return this.canOverflow(getBinaryLeft(expr), type) && ( + getExpressionId(operand = getBinaryRight(expr)) != ExpressionId.Const || + getConstValueI32(operand) < shift + ); + } + + // overflows if the shift does not clear potential garbage bits. if an unsigned value is + // wrapped, it can't overflow. + case BinaryOp.ShrU32: { + let shift = 32 - type.size; + return type.is(TypeFlags.SIGNED) + ? !( + getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && + getConstValueI32(operand) > shift // must clear MSB + ) + : this.canOverflow(getBinaryLeft(expr), type) && !( + getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && + getConstValueI32(operand) >= shift // can leave MSB + ); + } + + // overflows if any side does + case BinaryOp.DivU32: + case BinaryOp.RemI32: + case BinaryOp.RemU32: { + return this.canOverflow(getBinaryLeft(expr), type) + || this.canOverflow(getBinaryRight(expr), type); + } + } + break; + } + + case ExpressionId.Unary: { + switch (getUnaryOp(expr)) { + + // comparisons do not overflow (result is 0 or 1) + case UnaryOp.EqzI32: + case UnaryOp.EqzI64: return false; + + // overflow if the maximum result (32) cannot be represented in the target type + case UnaryOp.ClzI32: + case UnaryOp.CtzI32: + case UnaryOp.PopcntI32: return type.size < 7; + } + break; + } + + // overflows if the value cannot be represented in the target type + case ExpressionId.Const: { + let value: i32 = 0; + switch (getExpressionType(expr)) { + case NativeType.I32: { value = getConstValueI32(expr); break; } + case NativeType.I64: { value = getConstValueI64Low(expr); break; } // discards upper bits + case NativeType.F32: { value = i32(getConstValueF32(expr)); break; } + case NativeType.F64: { value = i32(getConstValueF64(expr)); break; } + default: assert(false); + } + switch (type.kind) { + case TypeKind.I8: return value < i8.MIN_VALUE || value > i8.MAX_VALUE; + case TypeKind.I16: return value < i16.MIN_VALUE || value > i16.MAX_VALUE; + case TypeKind.U8: return value < 0 || value > u8.MAX_VALUE; + case TypeKind.U16: return value < 0 || value > u16.MAX_VALUE; + case TypeKind.BOOL: return (value & ~1) != 0; + } + break; + } + + // overflows if the conversion does + case ExpressionId.Load: { + let fromType: Type; + switch (getLoadBytes(expr)) { + case 1: { fromType = isLoadSigned(expr) ? Type.i8 : Type.u8; break; } + case 2: { fromType = isLoadSigned(expr) ? Type.i16 : Type.u16; break; } + default: { fromType = isLoadSigned(expr) ? Type.i32 : Type.u32; break; } + } + return canConversionOverflow(fromType, type); + } + + // overflows if the result does, which is either + // - the last expression of the block, by contract, if the block doesn't have a label + // - the last expression or the value of an inner br if the block has a label (TODO) + case ExpressionId.Block: { + if (!getBlockName(expr)) { + let size = assert(getBlockChildCount(expr)); + let last = getBlockChild(expr, size - 1); + return this.canOverflow(last, type); + } + break; + } + + // overflows if either side does + case ExpressionId.If: { + return this.canOverflow(getIfTrue(expr), type) + || this.canOverflow(assert(getIfFalse(expr)), type); + } + + // overflows if either side does + case ExpressionId.Select: { + return this.canOverflow(getSelectThen(expr), type) + || this.canOverflow(getSelectElse(expr), type); + } + + // overflows if the call does not return a wrapped value or the conversion does + case ExpressionId.Call: { + let program = this.parentFunction.program; + let instance = assert(program.instancesByName.get(assert(getCallTarget(expr)))); + assert(instance.kind == ElementKind.FUNCTION); + let returnType = (instance).signature.returnType; + return !(instance).flow.is(FlowFlags.RETURNS_WRAPPED) + || canConversionOverflow(returnType, type); + } + + // doesn't technically overflow + case ExpressionId.Unreachable: return false; + } + return true; + } +} + +/** Tests if a conversion from one type to another can technically overflow. */ +function canConversionOverflow(fromType: Type, toType: Type): bool { + return !fromType.is(TypeFlags.INTEGER) // non-i32 locals or returns + || fromType.size > toType.size + || fromType.is(TypeFlags.SIGNED) != toType.is(TypeFlags.SIGNED); +} diff --git a/src/index.ts b/src/index.ts index f7dcd38ca3..c1d5e0a0d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -87,11 +87,6 @@ export function setTarget(options: Options, target: Target): void { options.target = target; } -/** Sets the `noTreeShaking` option. */ -export function setNoTreeShaking(options: Options, noTreeShaking: bool): void { - options.noTreeShaking = noTreeShaking; -} - /** Sets the `noAssert` option. */ export function setNoAssert(options: Options, noAssert: bool): void { options.noAssert = noAssert; @@ -185,6 +180,7 @@ export * from "./decompiler"; export * from "./definitions"; export * from "./diagnosticMessages.generated"; export * from "./diagnostics"; +export * from "./flow"; export * from "./module"; export * from "./parser"; export * from "./program"; diff --git a/src/parser.ts b/src/parser.ts index 75b24ded2d..c36b31445d 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -140,11 +140,8 @@ export class Parser extends DiagnosticEmitter { source.tokenizer = tn; var statements = source.statements; while (!tn.skip(Token.ENDOFFILE)) { - let statement = this.parseTopLevelStatement(tn); - if (statement) { - statement.parent = source; - statements.push(statement); - } + let statement = this.parseTopLevelStatement(tn, null); + if (statement) statements.push(statement); } tn.finish(); } @@ -152,7 +149,7 @@ export class Parser extends DiagnosticEmitter { /** Parses a top-level statement. */ parseTopLevelStatement( tn: Tokenizer, - namespace: Node | null = null + namespace: NamespaceDeclaration | null = null ): Statement | null { var flags = CommonFlags.NONE; var startPos: i32 = -1; @@ -300,7 +297,7 @@ export class Parser extends DiagnosticEmitter { // handle plain exports if (flags & CommonFlags.EXPORT) { - statement = this.parseExport(tn, flags, startPos); + statement = this.parseExport(tn, startPos, (flags & CommonFlags.DECLARE) != 0); // handle non-declaration statements } else { @@ -431,42 +428,41 @@ export class Parser extends DiagnosticEmitter { // 'void' } else if (token == Token.VOID) { type = Node.createType( - Node.createIdentifierExpression("void", tn.range()), [], false, tn.range(startPos, tn.pos) + Node.createSimpleTypeName("void", tn.range()), [], false, tn.range(startPos, tn.pos) ); // 'this' } else if (token == Token.THIS) { type = Node.createType( - Node.createThisExpression(tn.range()), [], false, tn.range(startPos, tn.pos) + Node.createSimpleTypeName("this", tn.range()), [], false, tn.range(startPos, tn.pos) ); // 'true' } else if (token == Token.TRUE || token == Token.FALSE) { type = Node.createType( - Node.createIdentifierExpression("bool", tn.range()), [], false, tn.range(startPos, tn.pos) + Node.createSimpleTypeName("bool", tn.range()), [], false, tn.range(startPos, tn.pos) ); // StringLiteral } else if (token == Token.STRINGLITERAL) { tn.readString(); type = Node.createType( - Node.createIdentifierExpression("string", tn.range()), [], false, tn.range(startPos, tn.pos) + Node.createSimpleTypeName("string", tn.range()), [], false, tn.range(startPos, tn.pos) ); // Identifier } else if (token == Token.IDENTIFIER) { - let identifier = Node.createIdentifierExpression(tn.readIdentifier(), tn.range()); + let first = Node.createSimpleTypeName(tn.readIdentifier(), tn.range()); + let current = first; let parameters = new Array(); let nullable = false; // Identifier ('.' Identifier)+ while (tn.skip(Token.DOT)) { if (tn.skip(Token.IDENTIFIER)) { - // TODO: this works for now, but the representation isn't great - identifier = Node.createIdentifierExpression( - identifier.text + "." + tn.readIdentifier(), - tn.range(identifier.range.start, tn.pos) - ); + let next = Node.createSimpleTypeName(tn.readIdentifier(), tn.range()); + current.next = next; + current = next; } else { this.error( DiagnosticCode.Identifier_expected, @@ -507,7 +503,7 @@ export class Parser extends DiagnosticEmitter { return null; } } - type = Node.createType(identifier, parameters, nullable, tn.range(startPos, tn.pos)); + type = Node.createType(first, parameters, nullable, tn.range(startPos, tn.pos)); } else { if (!suppressErrors) { @@ -548,7 +544,7 @@ export class Parser extends DiagnosticEmitter { } } type = Node.createType( - Node.createIdentifierExpression("Array", bracketRange), + Node.createSimpleTypeName("Array", bracketRange), [ type ], nullable, tn.range(startPos, tn.pos) @@ -765,7 +761,7 @@ export class Parser extends DiagnosticEmitter { members.push(member); } while (tn.skip(Token.COMMA)); - var ret = Node.createVariableStatement(members, decorators, flags, tn.range(startPos, tn.pos)); + var ret = Node.createVariableStatement(members, decorators, tn.range(startPos, tn.pos)); tn.skip(Token.SEMICOLON); return ret; } @@ -1500,13 +1496,11 @@ export class Parser extends DiagnosticEmitter { tn.range() ); - var typeParameters: TypeParameterNode[] | null; + var typeParameters: TypeParameterNode[] | null = null; if (tn.skip(Token.LESSTHAN)) { typeParameters = this.parseTypeParameters(tn); if (!typeParameters) return null; flags |= CommonFlags.GENERIC; - } else { - typeParameters = []; } var extendsType: TypeNode | null = null; @@ -1577,9 +1571,7 @@ export class Parser extends DiagnosticEmitter { if (!tn.skip(Token.CLOSEBRACE)) { do { let member = this.parseClassMember(tn, declaration); - if (!member) return null; - member.parent = declaration; - members.push(member); + if (member) members.push(member); } while (!tn.skip(Token.CLOSEBRACE)); } return declaration; @@ -1620,9 +1612,7 @@ export class Parser extends DiagnosticEmitter { if (!tn.skip(Token.CLOSEBRACE)) { do { let member = this.parseClassMember(tn, declaration); - if (!member) return null; - member.parent = declaration; - members.push(member); + if (member) members.push(member); } while (!tn.skip(Token.CLOSEBRACE)); } return Node.createClassExpression(declaration); @@ -1898,7 +1888,6 @@ export class Parser extends DiagnosticEmitter { parameter.range ); implicitFieldDeclaration.parameterIndex = i; - implicitFieldDeclaration.parent = parent; parameter.implicitFieldDeclaration = implicitFieldDeclaration; parent.members.push(implicitFieldDeclaration); } @@ -2157,9 +2146,7 @@ export class Parser extends DiagnosticEmitter { ); while (!tn.skip(Token.CLOSEBRACE)) { let member = this.parseTopLevelStatement(tn, ns); - if (!member) return null; - member.parent = ns; - members.push(member); + if (member) members.push(member); } tn.skip(Token.SEMICOLON); return ns; @@ -2180,8 +2167,8 @@ export class Parser extends DiagnosticEmitter { parseExport( tn: Tokenizer, - flags: CommonFlags, - startPos: i32 + startPos: i32, + isDeclare: bool ): ExportStatement | null { // at 'export': '{' ExportMember (',' ExportMember)* }' ('from' StringLiteral)? ';'? @@ -2216,7 +2203,7 @@ export class Parser extends DiagnosticEmitter { return null; } } - let ret = Node.createExportStatement(members, path, flags, tn.range(startPos, tn.pos)); + let ret = Node.createExportStatement(members, path, isDeclare, tn.range(startPos, tn.pos)); let internalPath = ret.internalPath; if (internalPath !== null && !this.seenlog.has(internalPath)) { this.backlog.push(internalPath); @@ -2228,7 +2215,7 @@ export class Parser extends DiagnosticEmitter { if (tn.skip(Token.FROM)) { if (tn.skip(Token.STRINGLITERAL)) { path = Node.createStringLiteralExpression(tn.readString(), tn.range()); - let ret = Node.createExportStatement(null, path, flags, tn.range(startPos, tn.pos)); + let ret = Node.createExportStatement(null, path, isDeclare, tn.range(startPos, tn.pos)); let internalPath = assert(ret.internalPath); let source = tn.source; if (!source.exportPaths) source.exportPaths = new Set(); @@ -3275,7 +3262,7 @@ export class Parser extends DiagnosticEmitter { return null; } name = Node.createIdentifierExpression(tn.readString(), tn.range()); - name.set(CommonFlags.QUOTED); + name.isQuoted = true; } else { name = Node.createIdentifierExpression(tn.readIdentifier(), tn.range()); } @@ -3284,7 +3271,7 @@ export class Parser extends DiagnosticEmitter { let value = this.parseExpression(tn, Precedence.COMMA + 1); if (!value) return null; values.push(value); - } else if (!name.is(CommonFlags.QUOTED)) { + } else if (!name.isQuoted) { values.push(name); } else { this.error( diff --git a/src/program.ts b/src/program.ts index 3b4047cc53..41fbd843d6 100644 --- a/src/program.ts +++ b/src/program.ts @@ -8,10 +8,13 @@ import { PATH_DELIMITER, STATIC_DELIMITER, INSTANCE_DELIMITER, - LIBRARY_PREFIX, GETTER_PREFIX, SETTER_PREFIX, - FILESPACE_PREFIX + INNER_DELIMITER, + LIBRARY_SUBST, + INDEX_SUFFIX, + CommonSymbols, + LibrarySymbols } from "./common"; import { @@ -36,11 +39,14 @@ import { Node, NodeKind, Source, + SourceKind, Range, - CommonTypeNode, - TypeParameterNode, DecoratorNode, DecoratorKind, + SignatureNode, + TypeParameterNode, + CommonTypeNode, + TypeNode, Expression, IdentifierExpression, @@ -48,6 +54,7 @@ import { LiteralKind, StringLiteralExpression, + Statement, ClassDeclaration, DeclarationStatement, EnumDeclaration, @@ -72,74 +79,62 @@ import { import { Module, - NativeType, - FunctionRef, - ExpressionRef, - ExpressionId, - BinaryOp, - UnaryOp, - - getExpressionId, - getGetLocalIndex, - isTeeLocal, - getSetLocalValue, - getBinaryOp, - getConstValueI32, - getBinaryLeft, - getBinaryRight, - getUnaryOp, - getExpressionType, - getLoadBytes, - isLoadSigned, - getIfTrue, - getIfFalse, - getSelectThen, - getSelectElse, - getCallTarget, - getBlockChildCount, - getBlockChild, - getBlockName, - getConstValueF32, - getConstValueF64, - getConstValueI64Low, - getGetGlobalName + FunctionRef } from "./module"; import { - CharCode, - bitsetIs, - bitsetSet + CharCode } from "./util"; import { Resolver } from "./resolver"; -/** Represents a yet unresolved import. */ +import { + Flow +} from "./flow"; + +/** Represents a yet unresolved `import`. */ class QueuedImport { - localName: string; - externalName: string; - externalNameAlt: string; - declaration: ImportDeclaration | null; // not set if a filespace + constructor( + /** File being imported into. */ + public localFile: File, + /** Identifier within the local file. */ + public localIdentifier: IdentifierExpression, + /** Identifier within the other file. Is an `import *` if not set. */ + public foreignIdentifier: IdentifierExpression | null, + /** Path to the other file. */ + public foreignPath: string, + /** Alternative path to the other file. */ + public foreignPathAlt: string + ) {} } -/** Represents a yet unresolved export. */ +/** Represents a yet unresolved `export`. */ class QueuedExport { - externalName: string; - isReExport: bool; - member: ExportMember; -} - -/** Represents a type alias. */ -class TypeAlias { - typeParameters: TypeParameterNode[] | null; - type: CommonTypeNode; + constructor( + /** Identifier within the local file. */ + public localIdentifier: IdentifierExpression, + /** Identifier within the other file. */ + public foreignIdentifier: IdentifierExpression, + /** Path to the other file if a re-export. */ + public foreignPath: string | null, + /** Alternative path to the other file if a re-export. */ + public foreignPathAlt: string | null + ) {} } -/** Represents a module-level export. */ -class ModuleExport { - element: Element; - identifier: IdentifierExpression; +/** Represents a yet unresolved `export *`. */ +class QueuedExportStar { + // stored in a map with localFile as the key + constructor( + /** Path to the other file. */ + public foreignPath: string, + /** Alternative path to the other file. */ + public foreignPathAlt: string, + /** Reference to the path literal for reporting. */ + public pathLiteral: StringLiteralExpression + ) {} } /** Represents the kind of an operator overload. */ @@ -304,34 +299,38 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O return OperatorKind.INVALID; } -const noTypesYet = new Map(); - /** Represents an AssemblyScript program. */ export class Program extends DiagnosticEmitter { - /** Array of source files. */ - sources: Source[]; /** Resolver instance. */ resolver: Resolver; + /** Array of sources. */ + sources: Source[] = []; /** Diagnostic offset used where successively obtaining the next diagnostic. */ diagnosticsOffset: i32 = 0; /** Compiler options. */ options: Options; - - /** Elements by internal name. */ - elementsLookup: Map = new Map(); - /** Class and function instances by internal name. */ - instancesLookup: Map = new Map(); - /** Types by internal name. */ - typesLookup: Map = noTypesYet; - /** Declared type aliases. */ - typeAliases: Map = new Map(); - /** File-level exports by exported name. */ - fileLevelExports: Map = new Map(); - /** Module-level exports by exported name. */ - moduleLevelExports: Map = new Map(); + /** Special native code source. */ + nativeSource: Source; + /** Special native code file. */ + nativeFile: File; + /** Explicitly annotated start function. */ + explicitStartFunction: FunctionPrototype | null = null; + + // lookup maps + + /** Files by unique internal name. */ + filesByName: Map = new Map(); + /** Elements by unique internal name in element space. */ + elementsByName: Map = new Map(); + /** Elements by declaration. */ + elementsByDeclaration: Map = new Map(); + /** Element instances by unique internal name. */ + instancesByName: Map = new Map(); /** Classes backing basic types like `i32`. */ - basicClasses: Map = new Map(); + typeClasses: Map = new Map(); + + // runtime references /** ArrayBuffer instance reference. */ arrayBufferInstance: Class | null = null; @@ -339,15 +338,13 @@ export class Program extends DiagnosticEmitter { arrayPrototype: ClassPrototype | null = null; /** String instance reference. */ stringInstance: Class | null = null; - /** Start function reference. */ - startFunction: FunctionPrototype; - /** Main function reference, if present. */ - mainFunction: FunctionPrototype | null = null; /** Abort function reference, if present. */ abortInstance: Function | null = null; /** Memory allocation function. */ memoryAllocateInstance: Function | null = null; + // gc integration + /** Whether a garbage collector is present or not. */ hasGC: bool = false; /** Garbage collector allocation function. */ @@ -361,245 +358,373 @@ export class Program extends DiagnosticEmitter { /** Offset of the GC hook. */ gcHookOffset: u32 = 0; - /** Currently processing filespace. */ - currentFilespace: Filespace; - /** Constructs a new program, optionally inheriting parser diagnostics. */ - constructor(diagnostics: DiagnosticMessage[] | null = null) { + constructor( + /** Shared array of diagnostic messages (emitted so far). */ + diagnostics: DiagnosticMessage[] | null = null + ) { super(diagnostics); + var nativeSource = new Source(LIBRARY_SUBST, "[native code]", SourceKind.LIBRARY); + this.nativeSource = nativeSource; + var nativeFile = new File(this, nativeSource); + this.nativeFile = nativeFile; + this.filesByName.set(nativeFile.internalName, nativeFile); this.resolver = new Resolver(this); - this.sources = []; } - /** Gets a source by its exact path. */ - getSource(normalizedPath: string): Source | null { - var sources = this.sources; - for (let i = 0, k = sources.length; i < k; ++i) { - let source = sources[i]; - if (source.normalizedPath == normalizedPath) return source; - } - return null; + /** Creates a native variable declaration. */ + makeNativeVariableDeclaration( + /** The simple name of the variable */ + name: string, + /** Flags indicating specific traits, e.g. `CONST`. */ + flags: CommonFlags = CommonFlags.NONE + ): VariableDeclaration { + var range = this.nativeSource.range; + return Node.createVariableDeclaration( + Node.createIdentifierExpression(name, range), + null, null, null, flags, range + ); + } + + /** Creates a native type declaration. */ + makeNativeTypeDeclaration( + /** The simple name of the type. */ + name: string, + /** Flags indicating specific traits, e.g. `GENERIC`. */ + flags: CommonFlags = CommonFlags.NONE + ): TypeDeclaration { + var range = this.nativeSource.range; + var identifier = Node.createIdentifierExpression(name, range); + return Node.createTypeDeclaration( + identifier, + null, + Node.createOmittedType(range), + null, flags, range + ); + } + + // a dummy signature for programmatically generated native functions + private nativeDummySignature: SignatureNode | null = null; + + /** Creates a native function declaration. */ + makeNativeFunctionDeclaration( + /** The simple name of the function. */ + name: string, + /** Flags indicating specific traits, e.g. `DECLARE`. */ + flags: CommonFlags = CommonFlags.NONE + ): FunctionDeclaration { + var range = this.nativeSource.range; + return Node.createFunctionDeclaration( + Node.createIdentifierExpression(name, range), + null, + this.nativeDummySignature || (this.nativeDummySignature = Node.createSignature([], + Node.createType( // ^ AST signature doesn't really matter, is overridden anyway + Node.createSimpleTypeName(CommonSymbols.void_, range), + null, false, range + ), + null, false, range) + ), + null, null, flags, range + ); + } + + /** Creates a native namespace declaration. */ + makeNativeNamespaceDeclaration( + /** The simple name of the namespace. */ + name: string, + /** Flags indicating specific traits, e.g. `EXPORT`. */ + flags: CommonFlags = CommonFlags.NONE + ): NamespaceDeclaration { + var range = this.nativeSource.range; + return Node.createNamespaceDeclaration( + Node.createIdentifierExpression(name, range), + [], null, flags, range + ); } - /** Looks up the source for the specified possibly ambiguous path. */ - lookupSourceByPath(normalizedPathWithoutExtension: string): Source | null { - var tmp: string; - return ( - this.getSource(normalizedPathWithoutExtension + ".ts") || - this.getSource(normalizedPathWithoutExtension + "/index.ts") || - this.getSource((tmp = LIBRARY_PREFIX + normalizedPathWithoutExtension) + ".ts") || - this.getSource( tmp + "/index.ts") + /** Creates a native function. */ + makeNativeFunction( + /** The simple name of the function. */ + name: string, + /** Concrete function signature. */ + signature: Signature, + /** Parent element, usually a file, class or namespace. */ + parent: Element = this.nativeFile, + /** Flags indicating specific traits, e.g. `GENERIC`. */ + flags: CommonFlags = CommonFlags.NONE, + /** Decorator flags representing built-in decorators. */ + decoratorFlags: DecoratorFlags = DecoratorFlags.NONE + ): Function { + return new Function( + name, + new FunctionPrototype( + name, + parent, + this.makeNativeFunctionDeclaration(name, flags), + decoratorFlags + ), + signature ); } + /** Gets the (possibly merged) program element linked to the specified declaration. */ + getElementByDeclaration(declaration: DeclarationStatement): DeclaredElement { + var elementsByDeclaration = this.elementsByDeclaration; + assert(elementsByDeclaration.has(declaration)); + return elementsByDeclaration.get(declaration)!; + } + /** Initializes the program and its elements prior to compilation. */ initialize(options: Options): void { this.options = options; - // add built-in types - this.typesLookup = new Map([ - ["i8", Type.i8], - ["i16", Type.i16], - ["i32", Type.i32], - ["i64", Type.i64], - ["isize", options.isizeType], - ["u8", Type.u8], - ["u16", Type.u16], - ["u32", Type.u32], - ["u64", Type.u64], - ["usize", options.usizeType], - ["bool", Type.bool], - ["f32", Type.f32], - ["f64", Type.f64], - ["void", Type.void], - ["number", Type.f64], - ["boolean", Type.bool] - ]); - if (options.hasFeature(Feature.SIMD)) this.typesLookup.set("v128", Type.v128); - - // add compiler hints - this.setConstantInteger("ASC_TARGET", Type.i32, + // register native types + this.registerNativeType(CommonSymbols.i8, Type.i8); + this.registerNativeType(CommonSymbols.i16, Type.i16); + this.registerNativeType(CommonSymbols.i32, Type.i32); + this.registerNativeType(CommonSymbols.i64, Type.i64); + this.registerNativeType(CommonSymbols.isize, options.isizeType); + this.registerNativeType(CommonSymbols.u8, Type.u8); + this.registerNativeType(CommonSymbols.u16, Type.u16); + this.registerNativeType(CommonSymbols.u32, Type.u32); + this.registerNativeType(CommonSymbols.u64, Type.u64); + this.registerNativeType(CommonSymbols.usize, options.usizeType); + this.registerNativeType(CommonSymbols.bool, Type.bool); + this.registerNativeType(CommonSymbols.f32, Type.f32); + this.registerNativeType(CommonSymbols.f64, Type.f64); + this.registerNativeType(CommonSymbols.void_, Type.void); + this.registerNativeType(CommonSymbols.number, Type.f64); // alias + this.registerNativeType(CommonSymbols.boolean, Type.bool); // alias + this.nativeFile.add(CommonSymbols.native, new TypeDefinition( + CommonSymbols.native, + this.nativeFile, + this.makeNativeTypeDeclaration(CommonSymbols.native, CommonFlags.EXPORT | CommonFlags.GENERIC), + DecoratorFlags.BUILTIN + )); + if (options.hasFeature(Feature.SIMD)) this.registerNativeType(CommonSymbols.v128, Type.v128); + + // register compiler hints + this.registerConstantInteger(LibrarySymbols.ASC_TARGET, Type.i32, i64_new(options.isWasm64 ? 2 : 1)); - this.setConstantInteger("ASC_NO_TREESHAKING", Type.bool, - i64_new(options.noTreeShaking ? 1 : 0, 0)); - this.setConstantInteger("ASC_NO_ASSERT", Type.bool, + this.registerConstantInteger(LibrarySymbols.ASC_NO_ASSERT, Type.bool, i64_new(options.noAssert ? 1 : 0, 0)); - this.setConstantInteger("ASC_MEMORY_BASE", Type.i32, + this.registerConstantInteger(LibrarySymbols.ASC_MEMORY_BASE, Type.i32, i64_new(options.memoryBase, 0)); - this.setConstantInteger("ASC_OPTIMIZE_LEVEL", Type.i32, + this.registerConstantInteger(LibrarySymbols.ASC_OPTIMIZE_LEVEL, Type.i32, i64_new(options.optimizeLevelHint, 0)); - this.setConstantInteger("ASC_SHRINK_LEVEL", Type.i32, + this.registerConstantInteger(LibrarySymbols.ASC_SHRINK_LEVEL, Type.i32, i64_new(options.shrinkLevelHint, 0)); - this.setConstantInteger("ASC_FEATURE_MUTABLE_GLOBAL", Type.bool, + this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_MUTABLE_GLOBAL, Type.bool, i64_new(options.hasFeature(Feature.MUTABLE_GLOBAL) ? 1 : 0, 0)); - this.setConstantInteger("ASC_FEATURE_SIGN_EXTENSION", Type.bool, + this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_SIGN_EXTENSION, Type.bool, i64_new(options.hasFeature(Feature.SIGN_EXTENSION) ? 1 : 0, 0)); - this.setConstantInteger("ASC_FEATURE_BULK_MEMORY", Type.bool, + this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_BULK_MEMORY, Type.bool, i64_new(options.hasFeature(Feature.BULK_MEMORY) ? 1 : 0, 0)); - this.setConstantInteger("ASC_FEATURE_SIMD", Type.bool, + this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_SIMD, Type.bool, i64_new(options.hasFeature(Feature.SIMD) ? 1 : 0, 0)); // remember deferred elements var queuedImports = new Array(); - var queuedExports = new Map(); + var queuedExports = new Map>(); + var queuedExportsStar = new Map(); var queuedExtends = new Array(); var queuedImplements = new Array(); - // build initial lookup maps of internal names to declarations + // initialize relevant declaration-like statements of the entire program for (let i = 0, k = this.sources.length; i < k; ++i) { let source = this.sources[i]; - - // create one filespace per source - let filespace = new Filespace(this, source); - this.elementsLookup.set(filespace.internalName, filespace); - this.currentFilespace = filespace; - - // process this source's statements + let file = new File(this, source); + this.filesByName.set(file.internalName, file); let statements = source.statements; for (let j = 0, l = statements.length; j < l; ++j) { let statement = statements[j]; switch (statement.kind) { - case NodeKind.CLASSDECLARATION: { - this.initializeClass(statement, queuedExtends, queuedImplements); + case NodeKind.EXPORT: { + this.initializeExports(statement, file, queuedExports, queuedExportsStar); break; } - case NodeKind.ENUMDECLARATION: { - this.initializeEnum(statement); + case NodeKind.IMPORT: { + this.initializeImports(statement, file, queuedImports, queuedExports); break; } - case NodeKind.EXPORT: { - this.initializeExports(statement, queuedExports); + case NodeKind.VARIABLE: { + this.initializeVariables(statement, file); break; } - case NodeKind.FUNCTIONDECLARATION: { - this.initializeFunction(statement); + case NodeKind.CLASSDECLARATION: { + this.initializeClass(statement, file, queuedExtends, queuedImplements); break; } - case NodeKind.IMPORT: { - this.initializeImports(statement, queuedExports, queuedImports); + case NodeKind.ENUMDECLARATION: { + this.initializeEnum(statement, file); + break; + } + case NodeKind.FUNCTIONDECLARATION: { + this.initializeFunction(statement, file); break; } case NodeKind.INTERFACEDECLARATION: { - this.initializeInterface(statement); + this.initializeInterface(statement, file); break; } case NodeKind.NAMESPACEDECLARATION: { - this.initializeNamespace(statement, queuedExtends, queuedImplements); + this.initializeNamespace(statement, file, queuedExtends, queuedImplements); break; } case NodeKind.TYPEDECLARATION: { - this.initializeTypeAlias(statement); - break; - } - case NodeKind.VARIABLE: { - this.initializeVariables(statement); + this.initializeTypeDefinition(statement, file); break; } } } } + // queued exports * should be linkable now that all files have been processed + for (let [file, exportsStar] of queuedExportsStar) { + for (let i = 0, k = exportsStar.length; i < k; ++i) { + let exportStar = exportsStar[i]; + let foreignFile = this.lookupForeignFile(exportStar.foreignPath, exportStar.foreignPathAlt); + if (!foreignFile) { + this.error( + DiagnosticCode.File_0_not_found, + exportStar.pathLiteral.range, exportStar.pathLiteral.value + ); + continue; + } + file.ensureExportStar(foreignFile); + } + } + // queued imports should be resolvable now through traversing exports and queued exports - for (let i = 0; i < queuedImports.length;) { + for (let i = 0, k = queuedImports.length; i < k; ++i) { let queuedImport = queuedImports[i]; - let declaration = queuedImport.declaration; - if (declaration) { // named - let element = this.tryLocateImport(queuedImport.externalName, queuedExports); + let foreignIdentifier = queuedImport.foreignIdentifier; + if (foreignIdentifier) { // i.e. import { foo [as bar] } from "./baz" + let element = this.lookupForeign( + foreignIdentifier.text, + queuedImport.foreignPath, + queuedImport.foreignPathAlt, + queuedExports + ); if (element) { - this.elementsLookup.set(queuedImport.localName, element); - queuedImports.splice(i, 1); + queuedImport.localFile.add( + queuedImport.localIdentifier.text, + element, + true // isImport + ); } else { - if (element = this.tryLocateImport(queuedImport.externalNameAlt, queuedExports)) { - this.elementsLookup.set(queuedImport.localName, element); - queuedImports.splice(i, 1); - } else { - this.error( - DiagnosticCode.Module_0_has_no_exported_member_1, - declaration.range, - (declaration.parent).path.value, - declaration.externalName.text - ); - ++i; - } + this.error( + DiagnosticCode.Module_0_has_no_exported_member_1, + foreignIdentifier.range, + queuedImport.foreignPath, + foreignIdentifier.text + ); } - } else { // filespace - let element = this.elementsLookup.get(queuedImport.externalName); - if (element) { - this.elementsLookup.set(queuedImport.localName, element); - queuedImports.splice(i, 1); + } else { // i.e. import * as bar from "./bar" + let foreignFile = this.lookupForeignFile(queuedImport.foreignPath, queuedImport.foreignPathAlt); + if (foreignFile) { + let localFile = queuedImport.localFile; + let localName = queuedImport.localIdentifier.text; + localFile.add( + localName, + foreignFile.asImportedNamespace( + localName, + localFile + ), + true // isImport + ); } else { - if (element = this.elementsLookup.get(queuedImport.externalNameAlt)) { - this.elementsLookup.set(queuedImport.localName, element); - queuedImports.splice(i, 1); - } else { - assert(false); // already reported by the parser not finding the file - ++i; - } + assert(false); // already reported by the parser not finding the file } } } // queued exports should be resolvable now that imports are finalized - for (let [exportName, queuedExport] of queuedExports) { - let currentExport: QueuedExport | null = queuedExport; // nullable below - let element: Element | null; - do { - if (currentExport.isReExport) { - if (element = this.fileLevelExports.get(currentExport.externalName)) { - this.setExportAndCheckLibrary( - exportName, - element, - queuedExport.member.externalName - ); - break; - } - currentExport = queuedExports.get(currentExport.externalName); - if (!currentExport) { + for (let [file, exports] of queuedExports) { + for (let [exportName, queuedExport] of exports) { + let localName = queuedExport.localIdentifier.text; + let foreignPath = queuedExport.foreignPath; + if (foreignPath) { // i.e. export { foo [as bar] } from "./baz" + let element = this.lookupForeign( + localName, + foreignPath, + assert(queuedExport.foreignPathAlt), // must be set if foreignPath is + queuedExports + ); + if (element) { + file.ensureExport(exportName, element); + } else { this.error( DiagnosticCode.Module_0_has_no_exported_member_1, - queuedExport.member.externalName.range, - ((queuedExport.member.parent).path).value, - queuedExport.member.externalName.text + queuedExport.localIdentifier.range, + foreignPath, localName ); } - } else { - if ( - // normal export - (element = this.elementsLookup.get(currentExport.externalName)) || - // library re-export - (element = this.elementsLookup.get(currentExport.member.name.text)) - ) { - this.setExportAndCheckLibrary( - exportName, - element, - queuedExport.member.externalName - ); + } else { // i.e. export { foo [as bar] } + let element = file.lookupInSelf(localName); + if (element) { + file.ensureExport(exportName, element); } else { - this.error( - DiagnosticCode.Cannot_find_name_0, - queuedExport.member.range, queuedExport.member.name.text - ); + let globalElement = this.lookupGlobal(localName); + if (globalElement && globalElement instanceof DeclaredElement) { // export { memory } + file.ensureExport(exportName, globalElement); + } else { + this.error( + DiagnosticCode.Module_0_has_no_exported_member_1, + queuedExport.foreignIdentifier.range, + file.internalName, queuedExport.foreignIdentifier.text + ); + } } - break; } - } while (currentExport); + } } + // register classes backing basic types + this.registerNativeTypeClass(TypeKind.I8, LibrarySymbols.I8); + this.registerNativeTypeClass(TypeKind.I16, LibrarySymbols.I16); + this.registerNativeTypeClass(TypeKind.I32, LibrarySymbols.I32); + this.registerNativeTypeClass(TypeKind.I64, LibrarySymbols.I64); + this.registerNativeTypeClass(TypeKind.ISIZE, LibrarySymbols.Isize); + this.registerNativeTypeClass(TypeKind.U8, LibrarySymbols.U8); + this.registerNativeTypeClass(TypeKind.U16, LibrarySymbols.U16); + this.registerNativeTypeClass(TypeKind.U32, LibrarySymbols.U32); + this.registerNativeTypeClass(TypeKind.U64, LibrarySymbols.U64); + this.registerNativeTypeClass(TypeKind.USIZE, LibrarySymbols.Usize); + this.registerNativeTypeClass(TypeKind.BOOL, LibrarySymbols.Bool); + this.registerNativeTypeClass(TypeKind.F32, LibrarySymbols.F32); + this.registerNativeTypeClass(TypeKind.F64, LibrarySymbols.F64); + if (options.hasFeature(Feature.SIMD)) this.registerNativeTypeClass(TypeKind.V128, LibrarySymbols.V128); + // resolve base prototypes of derived classes var resolver = this.resolver; for (let i = 0, k = queuedExtends.length; i < k; ++i) { - let derivedPrototype = queuedExtends[i]; - let derivedDeclaration = derivedPrototype.declaration; - let derivedType = assert(derivedDeclaration.extendsType); - let baseElement = resolver.resolveIdentifier(derivedType.name, null, null); // reports + let thisPrototype = queuedExtends[i]; + let extendsNode = assert(thisPrototype.extendsNode); // must be present if in queuedExtends + let baseElement = resolver.resolveTypeName(extendsNode.name, thisPrototype.parent); // reports if (!baseElement) continue; if (baseElement.kind == ElementKind.CLASS_PROTOTYPE) { let basePrototype = baseElement; - derivedPrototype.basePrototype = basePrototype; + if (basePrototype.hasDecorator(DecoratorFlags.SEALED)) { + this.error( + DiagnosticCode.Class_0_is_sealed_and_cannot_be_extended, + extendsNode.range, (baseElement).identifierNode.text + ); + } + if ( + basePrototype.hasDecorator(DecoratorFlags.UNMANAGED) != + thisPrototype.hasDecorator(DecoratorFlags.UNMANAGED) + ) { + this.error( + DiagnosticCode.Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa, + Range.join(thisPrototype.identifierNode.range, extendsNode.range) + ); + } + thisPrototype.basePrototype = basePrototype; } else { this.error( DiagnosticCode.A_class_may_only_extend_another_class, - derivedType.range + extendsNode.range ); } } @@ -610,111 +735,55 @@ export class Program extends DiagnosticEmitter { if (globalAliases) { for (let [alias, name] of globalAliases) { if (!name.length) continue; // explicitly disabled - let element = this.elementsLookup.get(name); - if (element) this.elementsLookup.set(alias, element); - else throw new Error("element not found: " + name); - } - } - } - - // register 'ArrayBuffer' - if (this.elementsLookup.has("ArrayBuffer")) { - let element = assert(this.elementsLookup.get("ArrayBuffer")); - assert(element.kind == ElementKind.CLASS_PROTOTYPE); - this.arrayBufferInstance = resolver.resolveClass(element, null); - } - - // register 'Array' - if (this.elementsLookup.has("Array")) { - let element = assert(this.elementsLookup.get("Array")); - assert(element.kind == ElementKind.CLASS_PROTOTYPE); - this.arrayPrototype = element; - } - - // register 'String' - if (this.elementsLookup.has("String")) { - let element = assert(this.elementsLookup.get("String")); - assert(element.kind == ElementKind.CLASS_PROTOTYPE); - let instance = resolver.resolveClass(element, null); - if (instance) { - if (this.typesLookup.has("string")) { - let declaration = (element).declaration; - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, declaration.programLevelInternalName - ); - } else { - this.stringInstance = instance; - this.typesLookup.set("string", instance.type); + let elementsByName = this.elementsByName; + let element = elementsByName.get(name); + if (element) { + if (elementsByName.has(alias)) throw new Error("duplicate global element: " + name); + elementsByName.set(alias, element); + } + else throw new Error("no such global element: " + name); } } } - // register classes backing basic types - this.registerBasicClass(TypeKind.I8, "I8"); - this.registerBasicClass(TypeKind.I16, "I16"); - this.registerBasicClass(TypeKind.I32, "I32"); - this.registerBasicClass(TypeKind.I64, "I64"); - this.registerBasicClass(TypeKind.ISIZE, "Isize"); - this.registerBasicClass(TypeKind.U8, "U8"); - this.registerBasicClass(TypeKind.U16, "U16"); - this.registerBasicClass(TypeKind.U32, "U32"); - this.registerBasicClass(TypeKind.U64, "U64"); - this.registerBasicClass(TypeKind.USIZE, "Usize"); - this.registerBasicClass(TypeKind.BOOL, "Bool"); - this.registerBasicClass(TypeKind.F32, "F32"); - this.registerBasicClass(TypeKind.F64, "F64"); - if (options.hasFeature(Feature.SIMD)) this.registerBasicClass(TypeKind.V128, "V128"); - - // register 'start' + // register global library elements { - let element = assert(this.elementsLookup.get("start")); - assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - this.startFunction = element; - } - - // register 'main' if present - if (this.moduleLevelExports.has("main")) { - let element = (this.moduleLevelExports.get("main")).element; - if ( - element.kind == ElementKind.FUNCTION_PROTOTYPE && - !(element).isAny(CommonFlags.GENERIC | CommonFlags.AMBIENT) - ) { - (element).set(CommonFlags.MAIN); - this.mainFunction = element; + let element: Element | null; + if (element = this.lookupGlobal(LibrarySymbols.String)) { + assert(element.kind == ElementKind.CLASS_PROTOTYPE); + this.stringInstance = resolver.resolveClass(element, null); } - } - - // register 'abort' if present - if (this.elementsLookup.has("abort")) { - let element = this.elementsLookup.get("abort"); - assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - let instance = this.resolver.resolveFunction(element, null); - if (instance) this.abortInstance = instance; - } - - // register 'memory.allocate' if present - if (this.elementsLookup.has("memory")) { - let element = this.elementsLookup.get("memory"); - let members = element.members; - if (members) { - if (members.has("allocate")) { - element = assert(members.get("allocate")); + if (element = this.lookupGlobal(LibrarySymbols.ArrayBuffer)) { + assert(element.kind == ElementKind.CLASS_PROTOTYPE); + this.arrayBufferInstance = resolver.resolveClass(element, null); + } + if (element = this.lookupGlobal(LibrarySymbols.Array)) { + assert(element.kind == ElementKind.CLASS_PROTOTYPE); + this.arrayPrototype = element; + } + if (element = this.lookupGlobal(LibrarySymbols.abort)) { + assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); + this.abortInstance = this.resolver.resolveFunction(element, null); + } + if (element = this.lookupGlobal(LibrarySymbols.memory)) { + if (element = element.lookupInSelf(LibrarySymbols.allocate)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - let instance = this.resolver.resolveFunction(element, null); - if (instance) this.memoryAllocateInstance = instance; + this.memoryAllocateInstance = this.resolver.resolveFunction(element, null); } } } // register GC hooks if present + // FIXME: think about a better way than globals to model this, maybe a GC namespace that can be + // dynamically extended by a concrete implementation but then has `@unsafe` methods that normal + // code cannot call without explicitly enabling it with a flag. if ( - this.elementsLookup.has("__gc_allocate") && - this.elementsLookup.has("__gc_link") && - this.elementsLookup.has("__gc_mark") + this.elementsByName.has("__gc_allocate") && + this.elementsByName.has("__gc_link") && + this.elementsByName.has("__gc_mark") ) { // __gc_allocate(usize, (ref: usize) => void): usize - let element = this.elementsLookup.get("__gc_allocate"); + let element = this.elementsByName.get("__gc_allocate"); assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); let gcAllocateInstance = assert(this.resolver.resolveFunction(element, null)); let signature = gcAllocateInstance.signature; @@ -724,7 +793,7 @@ export class Program extends DiagnosticEmitter { assert(signature.returnType == this.options.usizeType); // __gc_link(usize, usize): void - element = this.elementsLookup.get("__gc_link"); + element = this.elementsByName.get("__gc_link"); assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); let gcLinkInstance = assert(this.resolver.resolveFunction(element, null)); signature = gcLinkInstance.signature; @@ -734,7 +803,7 @@ export class Program extends DiagnosticEmitter { assert(signature.returnType == Type.void); // __gc_mark(usize): void - element = this.elementsLookup.get("__gc_mark"); + element = this.elementsByName.get("__gc_mark"); assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); let gcMarkInstance = assert(this.resolver.resolveFunction(element, null)); signature = gcMarkInstance.signature; @@ -750,167 +819,249 @@ export class Program extends DiagnosticEmitter { this.gcHeaderSize = (gcHookOffset + 4 + 7) & ~7; // + .hook index + alignment this.hasGC = true; } + + // mark module exports, i.e. to apply proper wrapping behavior on the boundaries + for (let file of this.filesByName.values()) { + let exports = file.exports; + if (!(file.source.isEntry && exports)) continue; + for (let element of exports.values()) this.markModuleExport(element); + } + } + + /** Marks an element and its children as a module export. */ + private markModuleExport(element: Element): void { + element.set(CommonFlags.MODULE_EXPORT); + switch (element.kind) { + case ElementKind.CLASS_PROTOTYPE: { + let instanceMembers = (element).instanceMembers; + if (instanceMembers) for (let member of instanceMembers.values()) this.markModuleExport(member); + break; + } + case ElementKind.PROPERTY_PROTOTYPE: { + let getterPrototype = (element).getterPrototype; + if (getterPrototype) this.markModuleExport(getterPrototype); + let setterPrototype = (element).setterPrototype; + if (setterPrototype) this.markModuleExport(setterPrototype); + break; + } + case ElementKind.PROPERTY: + case ElementKind.FUNCTION: + case ElementKind.FIELD: + case ElementKind.CLASS: assert(false); // assumes that there are no instances yet + } + { + let members = element.members; + if (members) for (let member of members.values()) this.markModuleExport(member); + } + } + + /** Registers a native type with the program. */ + private registerNativeType(name: string, type: Type): void { + var element = new TypeDefinition( + name, + this.nativeFile, + this.makeNativeTypeDeclaration(name, CommonFlags.EXPORT), + DecoratorFlags.BUILTIN + ); + element.setType(type); + this.nativeFile.add(name, element); } - private registerBasicClass(typeKind: TypeKind, className: string): void { - if (this.elementsLookup.has(className)) { - let element = assert(this.elementsLookup.get(className)); + /** Registers the backing class of a native type. */ + private registerNativeTypeClass(typeKind: TypeKind, className: string): void { + assert(!this.typeClasses.has(typeKind)); + var element = this.lookupGlobal(className); + if (element) { assert(element.kind == ElementKind.CLASS_PROTOTYPE); let classElement = this.resolver.resolveClass(element, null); - if (classElement) this.basicClasses.set(typeKind, classElement); + if (classElement) this.typeClasses.set(typeKind, classElement); } } - /** Sets a constant integer value. */ - setConstantInteger(globalName: string, type: Type, value: I64): void { - assert(type.is(TypeFlags.INTEGER)); - var global = new Global(this, globalName, globalName, type, null, DecoratorFlags.NONE) - .withConstantIntegerValue(value); - global.set(CommonFlags.RESOLVED); - this.elementsLookup.set(globalName, global); + /** Registers a constant integer value within the global scope. */ + private registerConstantInteger(name: string, type: Type, value: I64): void { + assert(type.is(TypeFlags.INTEGER)); // must be an integer type + var global = new Global( + name, + this.nativeFile, + DecoratorFlags.NONE, + this.makeNativeVariableDeclaration(name, CommonFlags.CONST | CommonFlags.EXPORT) + ); + global.setConstantIntegerValue(value, type); + this.nativeFile.add(name, global); } - /** Sets a constant float value. */ - setConstantFloat(globalName: string, type: Type, value: f64): void { - assert(type.is(TypeFlags.FLOAT)); - var global = new Global(this, globalName, globalName, type, null, DecoratorFlags.NONE) - .withConstantFloatValue(value); - global.set(CommonFlags.RESOLVED); - this.elementsLookup.set(globalName, global); - } - - /** Tries to locate an import by traversing exports and queued exports. */ - private tryLocateImport( - externalName: string, - queuedNamedExports: Map - ): Element | null { - var element: Element | null; - var fileLevelExports = this.fileLevelExports; + /** Registers a constant float value within the global scope. */ + private registerConstantFloat(name: string, type: Type, value: f64): void { + assert(type.is(TypeFlags.FLOAT)); // must be a float type + var global = new Global( + name, + this.nativeFile, + DecoratorFlags.NONE, + this.makeNativeVariableDeclaration(name, CommonFlags.CONST | CommonFlags.EXPORT) + ); + global.setConstantFloatValue(value, type); + this.nativeFile.add(name, global); + } + + /** Ensures that the given global element exists. Attempts to merge duplicates. */ + ensureGlobal(name: string, element: DeclaredElement): void { + var elementsByName = this.elementsByName; + if (elementsByName.has(name)) { + let actual = elementsByName.get(name); + // NOTE: this is effectively only performed when merging native types with + // their respective namespaces in std/builtins, but can also trigger when a + // user has multiple global elements of the same name in different files, + // which might result in unexpected shared symbols accross files. considering + // this a wonky feature for now that we might want to revisit later. + if (actual !== element) { + let merged = tryMerge(elementsByName.get(name)!, element); + if (!merged) { + this.error( + DiagnosticCode.Duplicate_identifier_0, + element.identifierNode.range, name + ); + return; + } + element = merged; + } + } + elementsByName.set(name, element); + } + + /** Looks up the element of the specified name in the global scope. */ + lookupGlobal(name: string): Element | null { + var elements = this.elementsByName; + if (elements.has(name)) return elements.get(name); + return null; + } + + /** Tries to locate a foreign file given its normalized path. */ + private lookupForeignFile( + /** Normalized path to the other file. */ + foreignPath: string, + /** Alternative normalized path to the other file. */ + foreignPathAlt: string + ): File | null { + var filesByName = this.filesByName; + return filesByName.has(foreignPath) + ? filesByName.get(foreignPath)! + : filesByName.has(foreignPathAlt) + ? filesByName.get(foreignPathAlt)! + : null; + } + + /** Tries to locate a foreign element by traversing exports and queued exports. */ + private lookupForeign( + /** Identifier within the other file. */ + foreignName: string, + /** Normalized path to the other file. */ + foreignPath: string, + /** Alternative normalized path to the other file. */ + foreignPathAlt: string, + /** So far queued exports. */ + queuedExports: Map> + ): DeclaredElement | null { do { - if (element = fileLevelExports.get(externalName)) return element; - let queuedExport = queuedNamedExports.get(externalName); - if (!queuedExport) break; - if (queuedExport.isReExport) { - externalName = queuedExport.externalName; - continue; + let foreignFile = this.lookupForeignFile(foreignPath, foreignPathAlt); + if (!foreignFile) return null; // no such file + + // search already resolved exports + let element = foreignFile.lookupExport(foreignName); + if (element) return element; + + // otherwise traverse queued exports + if (queuedExports.has(foreignFile)) { + let fileQueuedExports = queuedExports.get(foreignFile)!; + if (fileQueuedExports.has(foreignName)) { + let queuedExport = fileQueuedExports.get(foreignName)!; + if (queuedExport.foreignPath) { // imported from another file + foreignName = queuedExport.localIdentifier.text; + foreignPath = queuedExport.foreignPath; + foreignPathAlt = assert(queuedExport.foreignPathAlt); + continue; + } else { // local element of this file + element = foreignFile.lookupInSelf(queuedExport.localIdentifier.text); + if (element) return element; + } + } } - return this.elementsLookup.get(queuedExport.externalName); + break; } while (true); return null; } - /** Checks that only supported decorators are present. */ + /** Validates that only supported decorators are present. */ private checkDecorators( - decorators: DecoratorNode[], + /** Decorators present on an element. */ + decorators: DecoratorNode[] | null, + /** Accepted decorator flags. Emits diagnostics if any other decorators are present. */ acceptedFlags: DecoratorFlags ): DecoratorFlags { - var presentFlags = DecoratorFlags.NONE; - for (let i = 0, k = decorators.length; i < k; ++i) { - let decorator = decorators[i]; - let kind = decoratorNameToKind(decorator.name); - let flag = decoratorKindToFlag(kind); - if (flag) { - if (flag == DecoratorFlags.BUILTIN) { - if (decorator.range.source.isLibrary) { - presentFlags |= flag; - } else { + var flags = DecoratorFlags.NONE; + if (decorators) { + for (let i = 0, k = decorators.length; i < k; ++i) { + let decorator = decorators[i]; + let kind = decoratorNameToKind(decorator.name); + let flag = decoratorKindToFlag(kind); + if (flag) { + if (flag == DecoratorFlags.BUILTIN) { + if (decorator.range.source.isLibrary) { + flags |= flag; + } else { + this.error( + DiagnosticCode.Decorator_0_is_not_valid_here, + decorator.range, decorator.name.range.toString() + ); + } + } else if (!(acceptedFlags & flag)) { this.error( DiagnosticCode.Decorator_0_is_not_valid_here, decorator.range, decorator.name.range.toString() ); + } else if (flags & flag) { + this.error( + DiagnosticCode.Duplicate_decorator, + decorator.range, decorator.name.range.toString() + ); + } else { + flags |= flag; } - } else if (!(acceptedFlags & flag)) { - this.error( - DiagnosticCode.Decorator_0_is_not_valid_here, - decorator.range, decorator.name.range.toString() - ); - } else if (presentFlags & flag) { - this.error( - DiagnosticCode.Duplicate_decorator, - decorator.range, decorator.name.range.toString() - ); - } else { - presentFlags |= flag; } } } - return presentFlags; - } - - /** Checks and sets up global options of an element. */ - private checkGlobal( - element: Element, - declaration: DeclarationStatement - ): void { - var parentNode = declaration.parent; - // alias globally if explicitly annotated @global or exported from a top-level library file - if ( - (element.hasDecorator(DecoratorFlags.GLOBAL)) || - ( - declaration.range.source.isLibrary && - element.is(CommonFlags.EXPORT) && - ( - assert(parentNode).kind == NodeKind.SOURCE || - ( - parentNode).kind == NodeKind.VARIABLE && - assert((parentNode).parent).kind == NodeKind.SOURCE - ) - ) - ) { - let globalName = declaration.programLevelInternalName; - if (this.elementsLookup.has(globalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, element.internalName - ); - } else { - this.elementsLookup.set(globalName, element); - } - } - // builtins use the global name directly - if (element.hasDecorator(DecoratorFlags.BUILTIN)) { - element.internalName = declaration.programLevelInternalName; - } + return flags; } /** Initializes a class declaration. */ private initializeClass( + /** The declaration to initialize. */ declaration: ClassDeclaration, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** So far queued `extends` clauses. */ queuedExtends: ClassPrototype[], - queuedImplements: ClassPrototype[], - namespace: Element | null = null + /** So far queued `implements` clauses. */ + queuedImplements: ClassPrototype[] ): void { - var internalName = declaration.fileLevelInternalName; - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - - var decorators = declaration.decorators; - var simpleName = declaration.name.text; - var prototype = new ClassPrototype( - this, - simpleName, - internalName, + var name = declaration.name.text; + var element = new ClassPrototype( + name, + parent, declaration, - decorators - ? this.checkDecorators(decorators, - DecoratorFlags.GLOBAL | - DecoratorFlags.SEALED | - DecoratorFlags.UNMANAGED - ) - : DecoratorFlags.NONE + this.checkDecorators(declaration.decorators, + DecoratorFlags.GLOBAL | + DecoratorFlags.SEALED | + DecoratorFlags.UNMANAGED + ) ); - prototype.parent = namespace; - this.elementsLookup.set(internalName, prototype); + if (!parent.add(name, element)) return; var implementsTypes = declaration.implementsTypes; if (implementsTypes) { let numImplementsTypes = implementsTypes.length; - if (prototype.hasDecorator(DecoratorFlags.UNMANAGED)) { + // cannot implement interfaces when unmanaged + if (element.hasDecorator(DecoratorFlags.UNMANAGED)) { if (numImplementsTypes) { this.error( DiagnosticCode.Unmanaged_classes_cannot_implement_interfaces, @@ -920,67 +1071,19 @@ export class Program extends DiagnosticEmitter { ) ); } - - // remember classes that implement interfaces } else if (numImplementsTypes) { + // remember classes that implement interfaces for (let i = 0; i < numImplementsTypes; ++i) { - this.warning( // TODO + this.warning( // TODO: not yet supported DiagnosticCode.Operation_not_supported, implementsTypes[i].range ); } - queuedImplements.push(prototype); - } - } - - // remember classes that extend another one - if (declaration.extendsType) queuedExtends.push(prototype); - - // add as namespace member if applicable - if (namespace) { - if (namespace.members) { - if (namespace.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - namespace.members = new Map(); - } - namespace.members.set(simpleName, prototype); - if (namespace.is(CommonFlags.MODULE_EXPORT) && prototype.is(CommonFlags.EXPORT)) { - prototype.set(CommonFlags.MODULE_EXPORT); - } - - // otherwise add to file-level exports if exported - } else if (prototype.is(CommonFlags.EXPORT)) { - if (this.fileLevelExports.has(internalName)) { - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - declaration.name.range, internalName - ); - return; - } - this.fileLevelExports.set(internalName, prototype); - this.currentFilespace.members.set(simpleName, prototype); - if (prototype.is(CommonFlags.EXPORT) && declaration.range.source.isEntry) { - if (this.moduleLevelExports.has(simpleName)) { - let existingExport = this.moduleLevelExports.get(simpleName); - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - declaration.name.range, existingExport.element.internalName - ); - return; - } - prototype.set(CommonFlags.MODULE_EXPORT); - this.moduleLevelExports.set(simpleName, { - element: prototype, - identifier: declaration.name - }); + queuedImplements.push(element); } } + // remember classes that extend another class + if (declaration.extendsType) queuedExtends.push(element); // initialize members var memberDeclarations = declaration.members; @@ -988,218 +1091,96 @@ export class Program extends DiagnosticEmitter { let memberDeclaration = memberDeclarations[i]; switch (memberDeclaration.kind) { case NodeKind.FIELDDECLARATION: { - this.initializeField(memberDeclaration, prototype); + this.initializeField(memberDeclaration, element); break; } case NodeKind.METHODDECLARATION: { if (memberDeclaration.isAny(CommonFlags.GET | CommonFlags.SET)) { - this.initializeAccessor(memberDeclaration, prototype); + this.initializeProperty(memberDeclaration, element); } else { - this.initializeMethod(memberDeclaration, prototype); + this.initializeMethod(memberDeclaration, element); } break; } case NodeKind.INDEXSIGNATUREDECLARATION: break; // ignored for now - default: { - assert(false); // should have been reported while parsing - return; - } + default: assert(false); // class member expected } } - - this.checkGlobal(prototype, declaration); } /** Initializes a field of a class or interface. */ private initializeField( + /** The declaration to initialize. */ declaration: FieldDeclaration, - classPrototype: ClassPrototype + /** Parent class. */ + parent: ClassPrototype ): void { var name = declaration.name.text; - var internalName = declaration.fileLevelInternalName; var decorators = declaration.decorators; - var isInterface = classPrototype.kind == ElementKind.INTERFACE_PROTOTYPE; - - // static fields become global variables - if (declaration.is(CommonFlags.STATIC)) { - if (isInterface) { - // should have been reported while parsing - assert(false); - } - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - if (classPrototype.members) { - if (classPrototype.members.has(name)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - classPrototype.members = new Map(); - } - let staticField = new Global( - this, + var element: DeclaredElement; + if (declaration.is(CommonFlags.STATIC)) { // global variable + assert(parent.kind != ElementKind.INTERFACE_PROTOTYPE); + element = new Global( name, - internalName, - Type.void, // resolved later on + parent, + this.checkDecorators(decorators, + (declaration.is(CommonFlags.READONLY) + ? DecoratorFlags.INLINE + : DecoratorFlags.NONE + ) | DecoratorFlags.LAZY + ), + declaration + ); + if (!parent.add(name, element)) return; + } else { // actual instance field + assert(!declaration.isAny(CommonFlags.ABSTRACT | CommonFlags.GET | CommonFlags.SET)); + element = new FieldPrototype( + name, + parent, declaration, - decorators - ? this.checkDecorators(decorators, DecoratorFlags.INLINE) - : DecoratorFlags.NONE + this.checkDecorators(decorators, DecoratorFlags.NONE) ); - staticField.parent = classPrototype; - classPrototype.members.set(name, staticField); - this.elementsLookup.set(internalName, staticField); - if (classPrototype.is(CommonFlags.MODULE_EXPORT)) { - staticField.set(CommonFlags.MODULE_EXPORT); - } - - if (staticField.hasDecorator(DecoratorFlags.INLINE) && !staticField.is(CommonFlags.READONLY)) { - this.error( - DiagnosticCode.Decorator_0_is_not_valid_here, - assert(findDecorator(DecoratorKind.INLINE, decorators)).range, "inline" - ); - } - - // instance fields are remembered until resolved - } else { - if (isInterface) { - // should have been reported while parsing - assert(!declaration.isAny(CommonFlags.ABSTRACT | CommonFlags.GET | CommonFlags.SET)); - } - if (classPrototype.instanceMembers) { - if (classPrototype.instanceMembers.has(name)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - classPrototype.instanceMembers = new Map(); - } - let instanceField = new FieldPrototype( - classPrototype, - name, - internalName, - declaration - ); - if (decorators) this.checkDecorators(decorators, DecoratorFlags.NONE); - classPrototype.instanceMembers.set(name, instanceField); - } - } + if (!parent.addInstance(name, element)) return; + } + } /** Initializes a method of a class or interface. */ private initializeMethod( + /** The declaration to initialize. */ declaration: MethodDeclaration, - classPrototype: ClassPrototype + /** Parent class. */ + parent: ClassPrototype ): void { - var simpleName = declaration.name.text; - var internalName = declaration.fileLevelInternalName; - var prototype: FunctionPrototype | null = null; - - var decorators = declaration.decorators; - var decoratorFlags = DecoratorFlags.NONE; - if (decorators) { - decoratorFlags = this.checkDecorators(decorators, - DecoratorFlags.OPERATOR_BINARY | - DecoratorFlags.OPERATOR_PREFIX | - DecoratorFlags.OPERATOR_POSTFIX | - DecoratorFlags.INLINE - ); - } - - // static methods become global functions - if (declaration.is(CommonFlags.STATIC)) { + var name = declaration.name.text; + var isStatic = declaration.is(CommonFlags.STATIC); + var acceptedFlags = DecoratorFlags.INLINE; + if (!declaration.is(CommonFlags.GENERIC)) { + acceptedFlags |= DecoratorFlags.OPERATOR_BINARY + | DecoratorFlags.OPERATOR_PREFIX + | DecoratorFlags.OPERATOR_POSTFIX; + } + var element = new FunctionPrototype( + name, + parent, + declaration, + this.checkDecorators(declaration.decorators, acceptedFlags) + ); + if (isStatic) { // global function assert(declaration.name.kind != NodeKind.CONSTRUCTOR); - - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, declaration.name.range, - internalName - ); - return; - } - if (classPrototype.members) { - if (classPrototype.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - classPrototype.members = new Map(); - } - prototype = new FunctionPrototype( - this, - simpleName, - internalName, - declaration, - classPrototype, - decoratorFlags - ); - classPrototype.members.set(simpleName, prototype); - this.elementsLookup.set(internalName, prototype); - if (classPrototype.is(CommonFlags.MODULE_EXPORT)) { - prototype.set(CommonFlags.MODULE_EXPORT); - } - - // instance methods are remembered until resolved - } else { - if (classPrototype.instanceMembers) { - if (classPrototype.instanceMembers.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - classPrototype.instanceMembers = new Map(); - } - prototype = new FunctionPrototype( - this, - simpleName, - internalName, - declaration, - classPrototype, - decoratorFlags - ); - // if (classPrototype.isUnmanaged && instancePrototype.isAbstract) { - // this.error( Unmanaged classes cannot declare abstract methods. ); - // } - if (declaration.name.kind == NodeKind.CONSTRUCTOR) { - if (classPrototype.constructorPrototype) { - this.error( - DiagnosticCode.Multiple_constructor_implementations_are_not_allowed, - declaration.name.range - ); - } else { - prototype.set(CommonFlags.CONSTRUCTOR); - classPrototype.constructorPrototype = prototype; - } - } else { - classPrototype.instanceMembers.set(simpleName, prototype); - } - if (classPrototype.is(CommonFlags.MODULE_EXPORT)) { - prototype.set(CommonFlags.MODULE_EXPORT); - } + if (!parent.add(name, element)) return; + } else { // actual instance method + if (!parent.addInstance(name, element)) return; } - - this.checkOperatorOverloads(declaration.decorators, prototype, classPrototype); + this.checkOperatorOverloads(declaration.decorators, element, parent); } + /** Checks that operator overloads are generally valid, if present. */ private checkOperatorOverloads( + /** Decorators to check. */ decorators: DecoratorNode[] | null, + /** Decorated method. */ prototype: FunctionPrototype, + /** Parent class. */ classPrototype: ClassPrototype ): void { if (decorators) { @@ -1256,856 +1237,457 @@ export class Program extends DiagnosticEmitter { } } - private initializeAccessor( + /** Ensures that the property introduced by the specified getter or setter exists.*/ + private ensureProperty( + /** The declaration of the getter or setter introducing the property. */ declaration: MethodDeclaration, - classPrototype: ClassPrototype + /** Parent class. */ + parent: ClassPrototype + ): PropertyPrototype | null { + var name = declaration.name.text; + if (declaration.is(CommonFlags.STATIC)) { + let parentMembers = parent.members; + if (parentMembers && parentMembers.has(name)) { + let element = parentMembers.get(name)!; + if (element.kind == ElementKind.PROPERTY_PROTOTYPE) return element; + } else { + let element = new PropertyPrototype(name, parent, declaration); + if (!parent.add(name, element)) return null; + return element; + } + } else { + let parentMembers = parent.instanceMembers; + if (parentMembers && parentMembers.has(name)) { + let element = parentMembers.get(name); + if (element.kind == ElementKind.PROPERTY_PROTOTYPE) return element; + } else { + let element = new PropertyPrototype(name, parent, declaration); + if (!parent.addInstance(name, element)) return null; + return element; + } + } + this.error( + DiagnosticCode.Duplicate_property_0, + declaration.name.range, name + ); + return null; + } + + /** Initializes a property of a class. */ + private initializeProperty( + /** The declaration of the getter or setter. */ + declaration: MethodDeclaration, + /** Parent class. */ + parent: ClassPrototype ): void { - var simpleName = declaration.name.text; - var internalPropertyName = declaration.fileLevelInternalName; - var propertyElement = this.elementsLookup.get(internalPropertyName); + var property = this.ensureProperty(declaration, parent); + if (!property) return; + var name = declaration.name.text; var isGetter = declaration.is(CommonFlags.GET); - var isNew = false; - if (propertyElement) { - if ( - propertyElement.kind != ElementKind.PROPERTY || - (isGetter - ? (propertyElement).getterPrototype - : (propertyElement).setterPrototype - ) != null - ) { + if (isGetter) { + if (property.getterPrototype) { this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalPropertyName + DiagnosticCode.Duplicate_property_0, + declaration.name.range, name ); return; } } else { - propertyElement = new Property( - this, - simpleName, - internalPropertyName, - classPrototype - ); - isNew = true; - } - - var decorators = declaration.decorators; - var decoratorFlags = DecoratorFlags.NONE; - if (decorators) { - decoratorFlags = this.checkDecorators(decorators, - DecoratorFlags.INLINE - ); - } - - var baseName = (isGetter ? GETTER_PREFIX : SETTER_PREFIX) + simpleName; - - // static accessors become global functions - if (declaration.is(CommonFlags.STATIC)) { - let staticName = classPrototype.internalName + STATIC_DELIMITER + baseName; - if (this.elementsLookup.has(staticName)) { + if (property.setterPrototype) { this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, staticName + DiagnosticCode.Duplicate_property_0, + declaration.name.range, name ); return; } - let staticPrototype = new FunctionPrototype( - this, - baseName, - staticName, - declaration, - null, - decoratorFlags - ); - if (isGetter) { - (propertyElement).getterPrototype = staticPrototype; - } else { - (propertyElement).setterPrototype = staticPrototype; - } - if (isNew) { - if (classPrototype.members) { - if (classPrototype.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, staticName - ); - return; - } - } else { - classPrototype.members = new Map(); - } - classPrototype.members.set(simpleName, propertyElement); // check above - } else { - assert(classPrototype.members && classPrototype.members.has(simpleName)); - } - this.elementsLookup.set(internalPropertyName, propertyElement); - if (classPrototype.is(CommonFlags.MODULE_EXPORT)) { - propertyElement.set(CommonFlags.MODULE_EXPORT); - } - - // instance accessors are remembered until resolved + } + var element = new FunctionPrototype( + (isGetter ? GETTER_PREFIX : SETTER_PREFIX) + name, + property, + declaration, + this.checkDecorators(declaration.decorators, + DecoratorFlags.INLINE + ) + ); + if (isGetter) { + property.getterPrototype = element; } else { - let instanceName = classPrototype.internalName + INSTANCE_DELIMITER + baseName; - if (classPrototype.instanceMembers) { - if (classPrototype.instanceMembers.has(baseName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalPropertyName - ); - return; - } - } else { - classPrototype.instanceMembers = new Map(); - } - let instancePrototype = new FunctionPrototype( - this, - baseName, - instanceName, - declaration, - classPrototype, - decoratorFlags - ); - if (isGetter) { - (propertyElement).getterPrototype = instancePrototype; - } else { - (propertyElement).setterPrototype = instancePrototype; - } - classPrototype.instanceMembers.set(baseName, propertyElement); - this.elementsLookup.set(internalPropertyName, propertyElement); - if (classPrototype.is(CommonFlags.MODULE_EXPORT)) { - propertyElement.set(CommonFlags.MODULE_EXPORT); - instancePrototype.set(CommonFlags.MODULE_EXPORT); - } + property.setterPrototype = element; } } + /** Initializes an enum. */ private initializeEnum( + /** The declaration to initialize. */ declaration: EnumDeclaration, - namespace: Element | null = null + /** Parent element, usually a file or namespace. */ + parent: Element ): void { - var internalName = declaration.fileLevelInternalName; - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - var simpleName = declaration.name.text; - var element = new Enum(this, simpleName, internalName, declaration); - element.parent = namespace; - this.elementsLookup.set(internalName, element); - - if (namespace) { - if (namespace.members) { - if (namespace.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - namespace.members = new Map(); - } - namespace.members.set(simpleName, element); - if (namespace.is(CommonFlags.MODULE_EXPORT) && element.is(CommonFlags.EXPORT)) { - element.set(CommonFlags.MODULE_EXPORT); - } - } else if (element.is(CommonFlags.EXPORT)) { // no namespace - if (this.fileLevelExports.has(internalName)) { - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - declaration.name.range, internalName - ); - return; - } - this.fileLevelExports.set(internalName, element); - this.currentFilespace.members.set(simpleName, element); - if (declaration.range.source.isEntry) { - if (this.moduleLevelExports.has(simpleName)) { - let existingExport = this.moduleLevelExports.get(simpleName); - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - declaration.name.range, existingExport.element.internalName - ); - return; - } - element.set(CommonFlags.MODULE_EXPORT); - this.moduleLevelExports.set(simpleName, { - element, - identifier: declaration.name - }); - } - } - + var name = declaration.name.text; + var element = new Enum( + name, + parent, + declaration, + this.checkDecorators(declaration.decorators, + DecoratorFlags.GLOBAL | + DecoratorFlags.INLINE | + DecoratorFlags.LAZY + ) + ); + if (!parent.add(name, element)) return; var values = declaration.values; for (let i = 0, k = values.length; i < k; ++i) { this.initializeEnumValue(values[i], element); } - - this.checkGlobal(element, declaration); } + /** Initializes an enum value. */ private initializeEnumValue( + /** The declaration to initialize. */ declaration: EnumValueDeclaration, - enm: Enum + /** Parent enum. */ + parent: Enum ): void { var name = declaration.name.text; - var internalName = declaration.fileLevelInternalName; - if (enm.members) { - if (enm.members.has(name)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - enm.members = new Map(); - } - var value = new EnumValue(enm, this, name, internalName, declaration); - enm.members.set(name, value); - if (enm.is(CommonFlags.MODULE_EXPORT)) { - value.set(CommonFlags.MODULE_EXPORT); - } + var element = new EnumValue( + name, + parent, + declaration, + this.checkDecorators(declaration.decorators, + DecoratorFlags.NONE + ) + ); + if (!parent.add(name, element)) return; } + /** Initializes an `export` statement. */ private initializeExports( + /** The statement to initialize. */ statement: ExportStatement, - queuedExports: Map + /** Parent file. */ + parent: File, + /** So far queued `export`s. */ + queuedExports: Map>, + /** So far queued `export *`s. */ + queuedExportsStar: Map ): void { var members = statement.members; - if (members) { // named + if (members) { // export { foo, bar } [from "./baz"] for (let i = 0, k = members.length; i < k; ++i) { - this.initializeExport(members[i], statement.internalPath, queuedExports); + this.initializeExport(members[i], parent, statement.internalPath, queuedExports); } - } else { // TODO: filespace - this.error( - DiagnosticCode.Operation_not_supported, - statement.range - ); - } - } - - private setExportAndCheckLibrary( - internalName: string, - element: Element, - externalIdentifier: IdentifierExpression - ): void { - // add to file-level exports - this.fileLevelExports.set(internalName, element); - - // add to filespace - var internalPath = externalIdentifier.range.source.internalPath; - var prefix = FILESPACE_PREFIX + internalPath; - var filespace = this.elementsLookup.get(prefix); - if (!filespace) filespace = assert(this.elementsLookup.get(prefix + PATH_DELIMITER + "index")); - assert(filespace.kind == ElementKind.FILESPACE); - var simpleName = externalIdentifier.text; - (filespace).members.set(simpleName, element); - - // add global alias if a top-level export of a library file - var source = externalIdentifier.range.source; - if (source.isLibrary) { - if (this.elementsLookup.has(simpleName)) { - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - externalIdentifier.range, simpleName - ); - } else { - element.internalName = simpleName; - this.elementsLookup.set(simpleName, element); - } - - // add module level export if a top-level export of an entry file - } else if (source.isEntry) { - this.moduleLevelExports.set(externalIdentifier.text, { - element, - identifier: externalIdentifier - }); + } else { // export * from "./baz" + let queued: QueuedExportStar[]; + if (queuedExportsStar.has(parent)) queued = queuedExportsStar.get(parent)!; + else queuedExportsStar.set(parent, queued = []); + let foreignPath = assert(statement.internalPath); // must be set for export * + queued.push(new QueuedExportStar( + foreignPath, + foreignPath.endsWith(INDEX_SUFFIX) // strip or add index depending on what's already present + ? foreignPath.substring(0, foreignPath.length - INDEX_SUFFIX.length) + : foreignPath + INDEX_SUFFIX, + assert(statement.path) + )); } } + /** Initializes a single `export` member. Does not handle `export *`. */ private initializeExport( + /** The member to initialize. */ member: ExportMember, - internalPath: string | null, - queuedExports: Map + /** Local file. */ + localFile: File, + /** Path to the other file, if present. */ + foreignPath: string | null, + /** So far queued `export`s. */ + queuedExports: Map> ): void { - var externalName = member.range.source.internalPath + PATH_DELIMITER + member.externalName.text; - if (this.fileLevelExports.has(externalName)) { + var localName = member.localName.text; + var foreignName = member.exportedName.text; + + // check for duplicates + var element = localFile.lookupExport(foreignName); + if (element) { this.error( DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - member.externalName.range, externalName + member.exportedName.range, foreignName ); return; } - var referencedName: string; - var referencedElement: Element | null; - var queuedExport: QueuedExport | null; + // local element, i.e. export { foo [as bar] } + if (foreignPath === null) { - // export local element - if (internalPath == null) { - referencedName = member.range.source.internalPath + PATH_DELIMITER + member.name.text; - - // resolve right away if the element exists - if (this.elementsLookup.has(referencedName)) { - this.setExportAndCheckLibrary( - externalName, - this.elementsLookup.get(referencedName), - member.externalName - ); - return; - } + // resolve right away if the local element already exists + if (element = localFile.lookupInSelf(localName)) { + localFile.ensureExport(foreignName, element); // otherwise queue it - if (queuedExports.has(externalName)) { - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - member.externalName.range, externalName - ); - return; + } else { + let queued: Map; + if (queuedExports.has(localFile)) queued = queuedExports.get(localFile)!; + else queuedExports.set(localFile, queued = new Map()); + queued.set(foreignName, new QueuedExport( + member.localName, + member.exportedName, + null, null + )); } - queuedExport = new QueuedExport(); - queuedExport.isReExport = false; - queuedExport.externalName = referencedName; // -> here: local name - queuedExport.member = member; - queuedExports.set(externalName, queuedExport); - // export external element + // foreign element, i.e. export { foo } from "./bar" } else { - referencedName = internalPath + PATH_DELIMITER + member.name.text; - - // resolve right away if the export exists - referencedElement = this.elementsLookup.get(referencedName); - if (referencedElement) { - this.setExportAndCheckLibrary( - externalName, - referencedElement, - member.externalName - ); - return; - } - - // walk already known queued exports - let seen = new Set(); - while (queuedExport = queuedExports.get(referencedName)) { - if (queuedExport.isReExport) { - referencedElement = this.fileLevelExports.get(queuedExport.externalName); - if (referencedElement) { - this.setExportAndCheckLibrary( - externalName, - referencedElement, - member.externalName - ); - return; - } - referencedName = queuedExport.externalName; - if (seen.has(queuedExport)) break; - seen.add(queuedExport); - } else { - referencedElement = this.elementsLookup.get(queuedExport.externalName); - if (referencedElement) { - this.setExportAndCheckLibrary( - externalName, - referencedElement, - member.externalName - ); - return; - } - break; - } - } - - // otherwise queue it - if (queuedExports.has(externalName)) { - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - member.externalName.range, externalName - ); - return; - } - queuedExport = new QueuedExport(); - queuedExport.isReExport = true; - queuedExport.externalName = referencedName; // -> here: external name - queuedExport.member = member; - queuedExports.set(externalName, queuedExport); + let queued: Map; + if (queuedExports.has(localFile)) queued = queuedExports.get(localFile)!; + else queuedExports.set(localFile, queued = new Map()); + queued.set(foreignName, new QueuedExport( + member.localName, + member.exportedName, + foreignPath, + foreignPath.endsWith(INDEX_SUFFIX) // strip or add index depending on what's already present + ? foreignPath.substring(0, foreignPath.length - INDEX_SUFFIX.length) + : foreignPath + INDEX_SUFFIX + )); } } - private initializeFunction( - declaration: FunctionDeclaration, - namespace: Element | null = null - ): void { - var internalName = declaration.fileLevelInternalName; - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - var simpleName = declaration.name.text; - var decorators = declaration.decorators; - var prototype = new FunctionPrototype( - this, - simpleName, - internalName, - declaration, - null, - decorators - ? this.checkDecorators(decorators, - DecoratorFlags.GLOBAL | - DecoratorFlags.INLINE | - DecoratorFlags.EXTERNAL - ) - : DecoratorFlags.NONE - ); - prototype.parent = namespace; - this.elementsLookup.set(internalName, prototype); - - if (namespace) { - if (namespace.members) { - if (namespace.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - namespace.members = new Map(); - } - namespace.members.set(simpleName, prototype); - if (namespace.is(CommonFlags.MODULE_EXPORT) && prototype.is(CommonFlags.EXPORT)) { - prototype.parent = namespace; - prototype.set(CommonFlags.MODULE_EXPORT); - } - } else if (prototype.is(CommonFlags.EXPORT)) { // no namespace - if (this.fileLevelExports.has(internalName)) { - this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - declaration.name.range, internalName - ); - return; - } - this.fileLevelExports.set(internalName, prototype); - this.currentFilespace.members.set(simpleName, prototype); - if (declaration.range.source.isEntry) { - if (this.moduleLevelExports.has(simpleName)) { - let existingExport = this.moduleLevelExports.get(simpleName); - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, existingExport.element.internalName - ); - return; - } - prototype.set(CommonFlags.MODULE_EXPORT); - this.moduleLevelExports.set(simpleName, { - element: prototype, - identifier: declaration.name - }); - } - } - - this.checkGlobal(prototype, declaration); - } - + /** Initializes an `import` statement. */ private initializeImports( + /** The statement to initialize. */ statement: ImportStatement, - queuedExports: Map, - queuedImports: QueuedImport[] + /** Parent file. */ + parent: File, + /** So far queued `import`s. */ + queuedImports: QueuedImport[], + /** SO far queued `export`s. */ + queuedExports: Map> ): void { var declarations = statement.declarations; - if (declarations) { + if (declarations) { // import { foo [as bar] } from "./baz" for (let i = 0, k = declarations.length; i < k; ++i) { this.initializeImport( declarations[i], + parent, statement.internalPath, - queuedExports, queuedImports - ); - } - } else if (statement.namespaceName) { // import * as simpleName from "file" - let simpleName = statement.namespaceName.text; - let internalName = ( - statement.range.source.internalPath + - PATH_DELIMITER + - simpleName - ); - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - statement.namespaceName.range, - internalName + queuedImports, + queuedExports ); - return; - } - - // resolve right away if the exact filespace exists - let filespace = this.elementsLookup.get(statement.internalPath); - if (filespace) { - this.elementsLookup.set(internalName, filespace); - return; } - - // otherwise queue it - let queuedImport = new QueuedImport(); - queuedImport.localName = internalName; - let externalName = FILESPACE_PREFIX + statement.internalPath; - queuedImport.externalName = externalName; - queuedImport.externalNameAlt = externalName + PATH_DELIMITER + "index"; - queuedImport.declaration = null; // filespace - queuedImports.push(queuedImport); + } else if (statement.namespaceName) { // import * as foo from "./bar" + queuedImports.push(new QueuedImport( + parent, + statement.namespaceName, + null, // indicates import * + statement.internalPath, + statement.internalPath + INDEX_SUFFIX + )); + } else { + // import "./foo" } } - private initializeImport( + /** Initializes a single `import` declaration. Does not handle `import *`. */ + private initializeImport( // { foo [as bar] } + /** The declaration to initialize. */ declaration: ImportDeclaration, - internalPath: string, - queuedNamedExports: Map, - queuedImports: QueuedImport[] + /** Parent file. */ + parent: File, + /** Path to the other file. */ + foreignPath: string, + /** So far queued `import`s. */ + queuedImports: QueuedImport[], + /** So far queued `export`s. */ + queuedExports: Map> ): void { - var localName = declaration.fileLevelInternalName; - if (this.elementsLookup.has(localName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, localName - ); - return; - } - - var externalName = internalPath + PATH_DELIMITER + declaration.externalName.text; - - // resolve right away if the exact export exists - var element: Element | null; - if (element = this.fileLevelExports.get(externalName)) { - this.elementsLookup.set(localName, element); + var foreignPathAlt = foreignPath.endsWith(INDEX_SUFFIX) // strip or add index depending on what's already present + ? foreignPath.substring(0, foreignPath.length - INDEX_SUFFIX.length) + : foreignPath + INDEX_SUFFIX; + + // resolve right away if the element exists + var element = this.lookupForeign(declaration.foreignName.text, foreignPath, foreignPathAlt, queuedExports); + if (element) { + parent.add(declaration.name.text, element, true); return; } // otherwise queue it - const indexPart = PATH_DELIMITER + "index"; - var queuedImport = new QueuedImport(); - queuedImport.localName = localName; - if (internalPath.endsWith(indexPart)) { - queuedImport.externalName = externalName; // try exact first - queuedImport.externalNameAlt = ( - internalPath.substring(0, internalPath.length - indexPart.length + 1) + - declaration.externalName.text - ); - } else { - queuedImport.externalName = externalName; // try exact first - queuedImport.externalNameAlt = ( - internalPath + - indexPart + - PATH_DELIMITER + - declaration.externalName.text - ); - } - queuedImport.declaration = declaration; // named - queuedImports.push(queuedImport); + queuedImports.push(new QueuedImport( + parent, + declaration.name, + declaration.foreignName, + foreignPath, + foreignPathAlt + )); } - private initializeInterface(declaration: InterfaceDeclaration, namespace: Element | null = null): void { - var internalName = declaration.fileLevelInternalName; - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; + /** Initializes a function. Does not handle methods. */ + private initializeFunction( + /** The declaration to initialize. */ + declaration: FunctionDeclaration, + /** Parent element, usually a file or namespace. */ + parent: Element + ): void { + var name = declaration.name.text; + var validDecorators = DecoratorFlags.NONE; + if (!declaration.is(CommonFlags.AMBIENT)) { + validDecorators |= DecoratorFlags.INLINE; } - - var decorators = declaration.decorators; - var simpleName = declaration.name.text; - var prototype = new InterfacePrototype( - this, - simpleName, - internalName, + if (parent.kind != ElementKind.CLASS_PROTOTYPE && !declaration.is(CommonFlags.INSTANCE)) { + validDecorators |= DecoratorFlags.GLOBAL; + } + if (!declaration.is(CommonFlags.GENERIC)) { + if (declaration.is(CommonFlags.AMBIENT)) { + validDecorators |= DecoratorFlags.EXTERNAL; + } else if (parent.kind == ElementKind.FILE && (parent).source.isEntry) { + validDecorators |= DecoratorFlags.START; + } + } + var element = new FunctionPrototype( + name, + parent, declaration, - decorators - ? this.checkDecorators(decorators, DecoratorFlags.GLOBAL) - : DecoratorFlags.NONE + this.checkDecorators(declaration.decorators, validDecorators) ); - prototype.parent = namespace; - this.elementsLookup.set(internalName, prototype); - - if (namespace) { - if (namespace.members) { - if (namespace.members.has(prototype.internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - namespace.members = new Map(); - } - namespace.members.set(prototype.internalName, prototype); - if (namespace.is(CommonFlags.MODULE_EXPORT) && prototype.is(CommonFlags.EXPORT)) { - prototype.set(CommonFlags.MODULE_EXPORT); - } - } else if (prototype.is(CommonFlags.EXPORT)) { // no namespace - if (this.fileLevelExports.has(internalName)) { + if (!parent.add(name, element)) return; + if (element.hasDecorator(DecoratorFlags.START)) { + if (this.explicitStartFunction) { this.error( - DiagnosticCode.Export_declaration_conflicts_with_exported_declaration_of_0, - declaration.name.range, internalName + DiagnosticCode.Module_cannot_have_multiple_start_functions, + assert(findDecorator(DecoratorKind.START, declaration.decorators)).range ); - return; - } - this.fileLevelExports.set(internalName, prototype); - this.currentFilespace.members.set(simpleName, prototype); - if (declaration.range.source.isEntry) { - if (this.moduleLevelExports.has(simpleName)) { - let existingExport = this.moduleLevelExports.get(simpleName); - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, existingExport.element.internalName - ); - return; - } - prototype.set(CommonFlags.MODULE_EXPORT); - this.moduleLevelExports.set(simpleName, { - element: prototype, - identifier: declaration.name - }); - } + } else this.explicitStartFunction = element; } + } + /** Initializes an interface. */ + private initializeInterface( + /** The declaration to initialize. */ + declaration: InterfaceDeclaration, + /** Parent element, usually a file or namespace. */ + parent: Element + ): void { + var name = declaration.name.text; + var element = new InterfacePrototype( + name, + parent, + declaration, + this.checkDecorators(declaration.decorators, + DecoratorFlags.GLOBAL + ) + ); + if (!parent.add(name, element)) return; var memberDeclarations = declaration.members; for (let i = 0, k = memberDeclarations.length; i < k; ++i) { let memberDeclaration = memberDeclarations[i]; switch (memberDeclaration.kind) { - case NodeKind.FIELDDECLARATION: { - this.initializeField(memberDeclaration, prototype); + this.initializeField(memberDeclaration, element); break; } case NodeKind.METHODDECLARATION: { if (memberDeclaration.isAny(CommonFlags.GET | CommonFlags.SET)) { - this.initializeAccessor(memberDeclaration, prototype); + this.initializeProperty(memberDeclaration, element); } else { - this.initializeMethod(memberDeclaration, prototype); + this.initializeMethod(memberDeclaration, element); } break; } - default: { - throw new Error("interface member expected"); - } + default: assert(false); // interface member expected } } - - this.checkGlobal(prototype, declaration); } + /** Initializes a namespace. */ private initializeNamespace( + /** The declaration to initialize. */ declaration: NamespaceDeclaration, + /** Parent element, usually a file or another namespace. */ + parent: Element, + /** So far queued `extends` clauses. */ queuedExtends: ClassPrototype[], - queuedImplements: ClassPrototype[], - parentNamespace: Element | null = null + /** So far queued `implements` clauses. */ + queuedImplements: ClassPrototype[] ): void { - var internalName = declaration.fileLevelInternalName; - var simpleName = declaration.name.text; - var namespace = this.elementsLookup.get(internalName); - if (!namespace) { - namespace = new Namespace(this, simpleName, internalName, declaration); - namespace.parent = parentNamespace; - this.elementsLookup.set(internalName, namespace); - this.checkGlobal(namespace, declaration); - } - - if (parentNamespace) { - if (parentNamespace.members) { - if (parentNamespace.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - return; - } - } else { - parentNamespace.members = new Map(); - } - parentNamespace.members.set(simpleName, namespace); - if (parentNamespace.is(CommonFlags.MODULE_EXPORT) && namespace.is(CommonFlags.EXPORT)) { - namespace.set(CommonFlags.MODULE_EXPORT); - } - } else if (namespace.is(CommonFlags.EXPORT)) { // no parent namespace - let existingExport = this.fileLevelExports.get(internalName); - if (existingExport) { - if (!existingExport.is(CommonFlags.EXPORT)) { - this.error( - DiagnosticCode.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, - declaration.name.range, namespace.internalName - ); // recoverable - } - namespace = existingExport; // join - } else { - this.fileLevelExports.set(internalName, namespace); - } - this.currentFilespace.members.set(simpleName, namespace); - if (declaration.range.source.isEntry) { - if (this.moduleLevelExports.has(simpleName)) { - let existingExport = this.moduleLevelExports.get(simpleName); - if (existingExport.element !== namespace) { // not merged - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, existingExport.element.internalName - ); - return; - } - } else { - this.moduleLevelExports.set(simpleName, { - element: namespace, - identifier: declaration.name - }); - } - namespace.set(CommonFlags.MODULE_EXPORT); - } - } - + var name = declaration.name.text; + var element = new Namespace(name, parent, declaration); + if (!parent.add(name, element)) return; + element = assert(parent.lookupInSelf(name)); // possibly merged var members = declaration.members; for (let i = 0, k = members.length; i < k; ++i) { switch (members[i].kind) { case NodeKind.CLASSDECLARATION: { - this.initializeClass(members[i], queuedExtends, queuedImplements, namespace); + this.initializeClass(members[i], element, queuedExtends, queuedImplements); break; } case NodeKind.ENUMDECLARATION: { - this.initializeEnum(members[i], namespace); + this.initializeEnum(members[i], element); break; } case NodeKind.FUNCTIONDECLARATION: { - this.initializeFunction(members[i], namespace); + this.initializeFunction(members[i], element); break; } case NodeKind.INTERFACEDECLARATION: { - this.initializeInterface(members[i], namespace); + this.initializeInterface(members[i], element); break; } case NodeKind.NAMESPACEDECLARATION: { - this.initializeNamespace(members[i], queuedExtends, queuedImplements, namespace); + this.initializeNamespace(members[i], element, queuedExtends, queuedImplements); break; } case NodeKind.TYPEDECLARATION: { - // this.initializeTypeAlias(members[i], namespace); - // TODO: what about namespaced types? - this.error( - DiagnosticCode.Operation_not_supported, - members[i].range - ); + this.initializeTypeDefinition(members[i], element); break; } case NodeKind.VARIABLE: { - this.initializeVariables(members[i], namespace); + this.initializeVariables(members[i], element); break; } - default: { - throw new Error("namespace member expected"); - } + default: assert(false); // namespace member expected } } } - private initializeTypeAlias(declaration: TypeDeclaration, namespace: Element | null = null): void { - // type aliases are program globals - // TODO: what about namespaced types? + /** Initializes a `type` definition. */ + private initializeTypeDefinition( + /** The declaration to initialize. */ + declaration: TypeDeclaration, + /** Parent element, usually a file or namespace. */ + parent: Element + ): void { var name = declaration.name.text; - if (this.typesLookup.has(name) || this.typeAliases.has(name)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, name - ); - return; - } - var alias = new TypeAlias(); - alias.typeParameters = declaration.typeParameters; - alias.type = declaration.type; - this.typeAliases.set(name, alias); + var element = new TypeDefinition( + name, + parent, + declaration, + this.checkDecorators(declaration.decorators, DecoratorFlags.NONE) + ); + parent.add(name, element); // reports } - private initializeVariables(statement: VariableStatement, namespace: Element | null = null): void { + /** Initializes a variable statement. */ + private initializeVariables( + /** The statement to initialize. */ + statement: VariableStatement, + /** Parent element, usually a file or namespace. */ + parent: Element + ): void { var declarations = statement.declarations; for (let i = 0, k = declarations.length; i < k; ++i) { let declaration = declarations[i]; - let decorators = declaration.decorators; - let internalName = declaration.fileLevelInternalName; - if (this.elementsLookup.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - continue; - } - let simpleName = declaration.name.text; - let global = new Global( - this, - simpleName, - internalName, - Type.void, // resolved later on - declaration, - decorators - ? this.checkDecorators(decorators, - DecoratorFlags.GLOBAL | - DecoratorFlags.INLINE | - DecoratorFlags.EXTERNAL - ) - : DecoratorFlags.NONE - ); - global.parent = namespace; - this.elementsLookup.set(internalName, global); - - if (global.hasDecorator(DecoratorFlags.INLINE) && !global.is(CommonFlags.CONST)) { - this.error( - DiagnosticCode.Decorator_0_is_not_valid_here, - assert(findDecorator(DecoratorKind.INLINE, decorators)).range, "inline" - ); + let name = declaration.name.text; + let acceptedFlags = DecoratorFlags.GLOBAL | DecoratorFlags.LAZY; + if (declaration.is(CommonFlags.DECLARE)) { + acceptedFlags |= DecoratorFlags.EXTERNAL; } - - if (namespace) { - if (namespace.members) { - if (namespace.members.has(simpleName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - continue; - } - } else { - namespace.members = new Map(); - } - namespace.members.set(simpleName, global); - if (namespace.is(CommonFlags.MODULE_EXPORT) && global.is(CommonFlags.EXPORT)) { - global.set(CommonFlags.MODULE_EXPORT); - } - } else if (global.is(CommonFlags.EXPORT)) { // no namespace - if (this.fileLevelExports.has(internalName)) { - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, internalName - ); - } else { - this.fileLevelExports.set(internalName, global); - } - this.currentFilespace.members.set(simpleName, global); - if (declaration.range.source.isEntry) { - if (this.moduleLevelExports.has(simpleName)) { - let existingExport = this.moduleLevelExports.get(simpleName); - this.error( - DiagnosticCode.Duplicate_identifier_0, - declaration.name.range, existingExport.element.internalName - ); - continue; - } - global.set(CommonFlags.MODULE_EXPORT); - this.moduleLevelExports.set(simpleName, { - element: global, - identifier: declaration.name - }); - } + if (declaration.is(CommonFlags.CONST)) { + acceptedFlags |= DecoratorFlags.INLINE; } - this.checkGlobal(global, declaration); + let element = new Global( + name, + parent, + this.checkDecorators(declaration.decorators, acceptedFlags), + declaration + ); + if (!parent.add(name, element)) continue; // reports } } } @@ -2138,14 +1720,19 @@ export enum ElementKind { FIELD_PROTOTYPE, /** A {@link Field}. */ FIELD, + /** A {@link PropertyPrototype}. */ + PROPERTY_PROTOTYPE, /** A {@link Property}. */ PROPERTY, /** A {@link Namespace}. */ NAMESPACE, - /** A {@link Filespace}. */ - FILESPACE, + /** A {@link File}. */ + FILE, + /** A {@link TypeDefinition}. */ + TYPEDEFINITION, } +/** Indicates built-in decorators that are present. */ export enum DecoratorFlags { /** No flags set. */ NONE = 0, @@ -2166,9 +1753,14 @@ export enum DecoratorFlags { /** Is using a different external name. */ EXTERNAL = 1 << 7, /** Is a builtin. */ - BUILTIN = 1 << 8 + BUILTIN = 1 << 8, + /** Is compiled lazily. */ + LAZY = 1 << 9, + /** Is the explicit start function. */ + START = 1 << 10 } +/** Translates a decorator kind to the respective decorator flag. */ export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags { switch (kind) { case DecoratorKind.GLOBAL: return DecoratorFlags.GLOBAL; @@ -2181,6 +1773,8 @@ export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags { case DecoratorKind.INLINE: return DecoratorFlags.INLINE; case DecoratorKind.EXTERNAL: return DecoratorFlags.EXTERNAL; case DecoratorKind.BUILTIN: return DecoratorFlags.BUILTIN; + case DecoratorKind.LAZY: return DecoratorFlags.LAZY; + case DecoratorKind.START: return DecoratorFlags.START; default: return DecoratorFlags.NONE; } } @@ -2188,28 +1782,46 @@ export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags { /** Base class of all program elements. */ export abstract class Element { - /** Specific element kind. */ - kind: ElementKind; - /** Containing {@link Program}. */ - program: Program; - /** Simple name. */ - simpleName: string; - /** Internal name referring to this element. */ - internalName: string; + /** Parent element. */ + parent: Element; /** Common flags indicating specific traits. */ flags: CommonFlags = CommonFlags.NONE; /** Decorator flags indicating annotated traits. */ decoratorFlags: DecoratorFlags = DecoratorFlags.NONE; - /** Namespaced member elements. */ - members: Map | null = null; - /** Parent element, if applicable. */ - parent: Element | null = null; + /** Member elements. */ + members: Map | null = null; + /** Shadowing type in type space, if any. */ + shadowType: TypeDefinition | null = null; - /** Constructs a new element, linking it to its containing {@link Program}. */ - protected constructor(program: Program, simpleName: string, internalName: string) { + /** Constructs a new program element. */ + protected constructor( + /** Specific element kind. */ + public kind: ElementKind, + /** Simple name. */ + public name: string, + /** Internal name referring to this element. */ + public internalName: string, + /** Containing {@link Program}. */ + public program: Program, + /** Parent element. */ + parent: Element | null + ) { this.program = program; - this.simpleName = simpleName; + this.name = name; this.internalName = internalName; + if (parent) { + this.parent = parent; + } else { + assert(this.kind == ElementKind.FILE); + this.parent = this; // special case to keep this.parent non-nullable + } + } + + /** Gets the enclosing file. */ + get file(): File { + var current: Element = this; + do if ((current = current.parent).kind == ElementKind.FILE) return current; + while (true); } /** Tests if this element has a specific flag or flags. */ @@ -2220,106 +1832,347 @@ export abstract class Element { set(flag: CommonFlags): void { this.flags |= flag; } /** Tests if this element has a specific decorator flag or flags. */ hasDecorator(flag: DecoratorFlags): bool { return (this.decoratorFlags & flag) == flag; } -} -/** A filespace representing the implicit top-level namespace of a source. */ -export class Filespace extends Element { + /** Looks up the element with the specified name within this element. */ + lookupInSelf(name: string): DeclaredElement | null { + var members = this.members; + if (members && members.has(name)) return members.get(name)!; + return null; + } - kind = ElementKind.FILESPACE; + /** Looks up the element with the specified name relative to this element, like in JS. */ + abstract lookup(name: string): Element | null; - /** File members (externally visible only). */ - members: Map; // more specific + /** Adds an element as a member of this one. Reports and returns `false` if a duplicate. */ + add(name: string, element: DeclaredElement): bool { + var originalDeclaration = element.declaration; + var members = this.members; + if (!members) this.members = members = new Map(); + else if (members.has(name)) { + let actual = members.get(name)!; + if (actual.parent !== this) { + // override non-own element + } else { + let merged = tryMerge(actual, element); + if (merged) { + element = merged; // use merged element + } else { + this.program.error( + DiagnosticCode.Duplicate_identifier_0, + element.identifierNode.range, element.identifierNode.text + ); + return false; + } + } + } + members.set(name, element); + var program = this.program; + if (element.kind != ElementKind.FUNCTION_PROTOTYPE || !(element).isBound) { + // prefer unbound prototypes in global lookup maps + program.elementsByName.set(element.internalName, element); + program.elementsByDeclaration.set(originalDeclaration, element); + } + return true; + } - /** Constructs a new filespace. */ - constructor( + /** Returns a string representation of this element. */ + toString(): string { + return ElementKind[this.kind] + ":" + this.internalName; + } +} + +/** Base class of elements with an associated declaration statement. */ +export abstract class DeclaredElement extends Element { + + /** Constructs a new declared program element. */ + protected constructor( + /** Specific element kind. */ + kind: ElementKind, + /** Simple name. */ + name: string, + /** Internal name referring to this element. */ + internalName: string, + /** Containing {@link Program}. */ program: Program, - source: Source + /** Parent element. */ + parent: Element | null, + /** Declaration reference. */ + public declaration: DeclarationStatement ) { - super(program, source.internalPath, FILESPACE_PREFIX + source.internalPath); - this.members = new Map(); + super(kind, name, internalName, program, parent); + // It is necessary to have access to identifiers of all members and exports + // for reporting purposes and this is the lowest common denominator. Comes + // at the expense of not having more specific type information in derived + // classes, though. Instead, derived classes implement getters for other + // important AST nodes directly through manual casting, allowing the resolver + // etc. to not worry about actual declarations. + this.declaration = declaration; + this.flags = declaration.flags; // inherit + } + + /** Tests if this element is a library element. */ + get isDeclaredInLibrary(): bool { + return this.declaration.range.source.isLibrary; + } + + /** Gets the associated identifier node. */ + get identifierNode(): IdentifierExpression { + return this.declaration.name; + } + + /** Gets the assiciated decorator nodes. */ + get decoratorNodes(): DecoratorNode[] | null { + return this.declaration.decorators; } } -/** A namespace that differs from a filespace in being user-declared with a name. */ -export class Namespace extends Element { +/** Base class of elements that can be resolved to a concrete type. */ +export abstract class TypedElement extends DeclaredElement { - // All elements have namespace semantics. This is an explicitly declared one. - kind = ElementKind.NAMESPACE; + /** Resolved type. Set once `is(RESOLVED)`, otherwise void. */ + type: Type = Type.void; - /** Declaration reference. */ - declaration: NamespaceDeclaration; // more specific + /** Sets the resolved type of this element. */ + setType(type: Type): void { + assert(!this.is(CommonFlags.RESOLVED)); + this.type = type; + this.set(CommonFlags.RESOLVED); + } +} - /** Constructs a new namespace. */ +/** A file representing the implicit top-level namespace of a source. */ +export class File extends Element { + + /** File exports. */ + exports: Map | null = null; + /** File re-exports. */ + exportsStar: File[] | null = null; + /** Top-level start function of this file. */ + startFunction: Function; + + /** Constructs a new file. */ constructor( + /** Program this file belongs to. */ program: Program, - simpleName: string, - internalName: string, - declaration: NamespaceDeclaration + /** Source of this file. */ + public source: Source ) { - super(program, simpleName, internalName); - this.declaration = declaration; - this.flags = declaration.flags; + super( + ElementKind.FILE, + source.normalizedPath, + source.internalPath, + program, + null // special case for files + ); + this.source = source; + assert(!program.filesByName.has(this.internalName)); + program.filesByName.set(this.internalName, this); + var startFunction = this.program.makeNativeFunction( + "start:" + this.internalName, + new Signature(null, Type.void), + this + ); + startFunction.internalName = startFunction.name; + this.startFunction = startFunction; + } + + /* @override */ + add(name: string, element: DeclaredElement, isImport: bool = false): bool { + if (!super.add(name, element)) return false; + element = assert(this.lookupInSelf(name)); // possibly merged + if (element.is(CommonFlags.EXPORT) && !isImport) { + this.ensureExport( + element.name, + element + ); + } + if (element.hasDecorator(DecoratorFlags.GLOBAL)) this.program.ensureGlobal(name, element); + return true; } -} -/** An enum. */ -export class Enum extends Element { + /* @override */ + lookupInSelf(name: string): DeclaredElement | null { + var element = super.lookupInSelf(name); + if (element) return element; + var exportsStar = this.exportsStar; + if (exportsStar) { + for (let i = 0, k = exportsStar.length; i < k; ++i) { + if (element = exportsStar[i].lookupInSelf(name)) return element; + } + } + return null; + } - kind = ElementKind.ENUM; + /* @override */ + lookup(name: string): Element | null { + var element = this.lookupInSelf(name); + if (element) return element; + return this.program.lookupGlobal(name); + } - /** Declaration reference. */ - declaration: EnumDeclaration; + /** Ensures that an element is an export of this file. */ + ensureExport(name: string, element: DeclaredElement): void { + var exports = this.exports; + if (!exports) this.exports = exports = new Map(); + exports.set(name, element); + if (this.source.isLibrary) this.program.ensureGlobal(name, element); + } - /** Constructs a new enum. */ + /** Ensures that another file is a re-export of this file. */ + ensureExportStar(file: File): void { + var exportsStar = this.exportsStar; + if (!exportsStar) this.exportsStar = exportsStar = []; + else if (exportsStar.includes(file)) return; + exportsStar.push(file); + } + + /** Looks up the export of the specified name. */ + lookupExport(name: string): DeclaredElement | null { + var exports = this.exports; + if (exports && exports.has(name)) return exports.get(name)!; + var exportsStar = this.exportsStar; + if (exportsStar) { + for (let i = 0, k = exportsStar.length; i < k; ++i) { + let element = exportsStar[i].lookupExport(name); + if (element) return element; + } + } + return null; + } + + /** Creates an imported namespace from this file. */ + asImportedNamespace(name: string, parent: Element): Namespace { + var ns = new Namespace( + name, + parent, + this.program.makeNativeNamespaceDeclaration(name) + ); + var exports = this.exports; + if (exports) { + for (let [memberName, member] of exports) { + ns.add(memberName, member); + } + } + return ns; + } +} + +/** A type definition. */ +export class TypeDefinition extends TypedElement { + + /** Constructs a new type definition. */ constructor( - program: Program, - simpleName: string, - internalName: string, - declaration: EnumDeclaration + /** Simple name. */ + name: string, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: TypeDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags = DecoratorFlags.NONE ) { - super(program, simpleName, internalName); - this.declaration = declaration; - this.flags = declaration.flags; + super( + ElementKind.TYPEDEFINITION, + name, + mangleInternalName(name, parent, false), + parent.program, + parent, + declaration + ); + this.decoratorFlags = decoratorFlags; + } + + /** Gets the associated type parameter nodes. */ + get typeParameterNodes(): TypeParameterNode[] | null { + return (this.declaration).typeParameters; + } + + /** Gets the associated type node. */ + get typeNode(): CommonTypeNode { + return (this.declaration).type; + } + + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); } } -/** An enum value. */ -export class EnumValue extends Element { +/** A namespace that differs from a file in being user-declared with a name. */ +export class Namespace extends DeclaredElement { + + /** Constructs a new namespace. */ + constructor( + /** Simple name. */ + name: string, + /** Parent element, usually a file or another namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: NamespaceDeclaration + ) { + super( + ElementKind.NAMESPACE, + name, + mangleInternalName(name, parent, false), + parent.program, + parent, + declaration + ); + } - kind = ElementKind.ENUMVALUE; + /* @override */ + lookup(name: string): Element | null { + return this.lookupInSelf(name) + || this.parent.lookup(name); + } +} - /** Declaration reference. */ - declaration: EnumValueDeclaration; - /** Constant value, if applicable. */ - constantValue: i32 = 0; +/** An enum. */ +export class Enum extends TypedElement { + /** Constructs a new enum. */ constructor( - enm: Enum, - program: Program, - simpleName: string, - internalName: string, - declaration: EnumValueDeclaration + /** Simple name. */ + name: string, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** Declaration reference. */ + declaration: EnumDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags = DecoratorFlags.NONE ) { - super(program, simpleName, internalName); - this.parent = enm; - this.declaration = declaration; + super( + ElementKind.ENUM, + name, + mangleInternalName(name, parent, false), + parent.program, + parent, + declaration + ); + this.decoratorFlags = decoratorFlags; + this.setType(Type.i32); + } + + /* @override */ + lookup(name: string): Element | null { + return this.lookupInSelf(name) + || this.parent.lookup(name); } } +/** Indicates the kind of an inlined constant value. */ export const enum ConstantValueKind { + /** No constant value. */ NONE, + /** Constant integer value. */ INTEGER, + /** Constant float value. */ FLOAT } -export class VariableLikeElement extends Element { - - // kind varies +/** Base class of all variable-like program elements. */ +export abstract class VariableLikeElement extends TypedElement { - /** Declaration reference. */ - declaration: VariableLikeDeclarationStatement | null; - /** Variable type. Is {@link Type.void} for type-inferred {@link Global}s before compilation. */ - type: Type; /** Constant value kind. */ constantValueKind: ConstantValueKind = ConstantValueKind.NONE; /** Constant integer value, if applicable. */ @@ -2327,151 +2180,263 @@ export class VariableLikeElement extends Element { /** Constant float value, if applicable. */ constantFloatValue: f64; + /** Constructs a new variable-like element. */ protected constructor( - program: Program, - simpleName: string, - internalName: string, - type: Type, - declaration: VariableLikeDeclarationStatement | null + /** Specific element kind. */ + kind: ElementKind, + /** Simple name. */ + name: string, + /** Parent element, usually a file, namespace or class. */ + parent: Element, + /** Declaration reference. Creates a native declaration if omitted. */ + declaration: VariableLikeDeclarationStatement = parent.program.makeNativeVariableDeclaration(name) ) { - super(program, simpleName, internalName); - this.type = type; - this.declaration = declaration; + super( + kind, + name, + mangleInternalName(name, parent, false), + parent.program, + parent, + declaration + ); + this.flags = declaration.flags; + } + + /** Gets the associated type node.s */ + get typeNode(): CommonTypeNode | null { + return (this.declaration).type; } - withConstantIntegerValue(value: I64): this { + /** Gets the associated initializer node. */ + get initializerNode(): Expression | null { + return (this.declaration).initializer; + } + + /** Applies a constant integer value to this element. */ + setConstantIntegerValue(value: I64, type: Type): void { + assert(type.is(TypeFlags.INTEGER)); + this.type = type; this.constantValueKind = ConstantValueKind.INTEGER; this.constantIntegerValue = value; - this.set(CommonFlags.CONST | CommonFlags.INLINED); - return this; + this.set(CommonFlags.CONST | CommonFlags.INLINED | CommonFlags.RESOLVED); } - withConstantFloatValue(value: f64): this { + /** Applies a constant float value to this element. */ + setConstantFloatValue(value: f64, type: Type): void { + assert(type.is(TypeFlags.FLOAT)); + this.type = type; this.constantValueKind = ConstantValueKind.FLOAT; this.constantFloatValue = value; - this.set(CommonFlags.CONST | CommonFlags.INLINED); - return this; + this.set(CommonFlags.CONST | CommonFlags.INLINED | CommonFlags.RESOLVED); + } + + /** @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); + } +} + +/** An enum value. */ +export class EnumValue extends VariableLikeElement { + + /** Constructs a new enum value. */ + constructor( + /** Simple name. */ + name: string, + /** Parent enum. */ + parent: Enum, + /** Declaration reference. */ + declaration: EnumValueDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags = DecoratorFlags.NONE + ) { + super( + ElementKind.ENUMVALUE, + name, + parent, + declaration + ); + this.decoratorFlags = decoratorFlags; + this.setType(Type.i32); + } + + /** Gets the associated value node. */ + get valueNode(): Expression | null { + return (this.declaration).value; + } + + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); } } /** A global variable. */ export class Global extends VariableLikeElement { - kind = ElementKind.GLOBAL; - + /** Constructs a new global variable. */ constructor( - program: Program, - simpleName: string, - internalName: string, - type: Type, - declaration: VariableLikeDeclarationStatement | null, - decoratorFlags: DecoratorFlags + /** Simple name. */ + name: string, + /** Parent element, usually a file, namespace or static class. */ + parent: Element, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags, + /** Declaration reference. Creates a native declaration if omitted. */ + declaration: VariableLikeDeclarationStatement = parent.program.makeNativeVariableDeclaration(name) ) { - super(program, simpleName, internalName, type, declaration); - this.flags = declaration ? declaration.flags : CommonFlags.NONE; + super( + ElementKind.GLOBAL, + name, + parent, + declaration + ); this.decoratorFlags = decoratorFlags; - this.type = type; // resolved later if `void` } } /** A function parameter. */ export class Parameter { - - // not an Element on its own - - /** Parameter name. */ - name: string; - /** Parameter type. */ - type: Type; - /** Parameter initializer. */ - initializer: Expression | null; - /** Constructs a new function parameter. */ - constructor(name: string, type: Type, initializer: Expression | null = null) { - this.name = name; - this.type = type; - this.initializer = initializer; - } + constructor( + /** Parameter name. */ + public name: string, + /** Parameter type. */ + public type: Type, + /** Parameter initializer, if present. */ + public initializer: Expression | null = null + ) {} } -/** A function local. */ +/** A local variable. */ export class Local extends VariableLikeElement { - kind = ElementKind.LOCAL; - - /** Local index. */ - index: i32; - /** Respective scoped global, if any. */ - scopedGlobal: Global | null = null; - + /** Constructs a new local variable. */ constructor( - program: Program, - simpleName: string, - index: i32, + /** Simple name. */ + name: string, + /** Zero-based index within the enclosing function. `-1` indicates a virtual local. */ + public index: i32, + /** Resolved type. */ type: Type, - declaration: VariableLikeDeclarationStatement | null = null + /** Parent function. */ + parent: Function, + /** Declaration reference. */ + declaration: VariableLikeDeclarationStatement = parent.program.makeNativeVariableDeclaration(name) ) { - super(program, simpleName, simpleName, type, declaration); + super( + ElementKind.LOCAL, + name, + parent, + declaration + ); this.index = index; + assert(type != Type.void); + this.setType(type); } } /** A yet unresolved function prototype. */ -export class FunctionPrototype extends Element { - - kind = ElementKind.FUNCTION_PROTOTYPE; - - /** Declaration reference. */ - declaration: FunctionDeclaration; - /** If an instance method, the class prototype reference. */ - classPrototype: ClassPrototype | null; - /** Resolved instances by class type arguments and function type arguments. */ - instances: Map> = new Map(); - /** Class type arguments, if a partially resolved method of a generic class. Not set otherwise. */ - classTypeArguments: Type[] | null = null; +export class FunctionPrototype extends DeclaredElement { + /** Operator kind, if an overload. */ operatorKind: OperatorKind = OperatorKind.INVALID; + /** Already resolved instances. */ + instances: Map | null = null; + + /** Clones of this prototype that are bounds to specific classes. */ + private boundPrototypes: Map | null = null; /** Constructs a new function prototype. */ constructor( - program: Program, - simpleName: string, - internalName: string, + /** Simple na,e */ + name: string, + /** Parent element, usually a file, namespace or class (if a method). */ + parent: Element, + /** Declaration reference. */ declaration: FunctionDeclaration, - classPrototype: ClassPrototype | null = null, + /** Pre-checked flags indicating built-in decorators. */ decoratorFlags: DecoratorFlags = DecoratorFlags.NONE ) { - super(program, simpleName, internalName); - this.declaration = declaration; - this.flags = declaration.flags; - this.classPrototype = classPrototype; + super( + ElementKind.FUNCTION_PROTOTYPE, + name, + mangleInternalName(name, parent, declaration.is(CommonFlags.INSTANCE)), + parent.program, + parent, + declaration + ); this.decoratorFlags = decoratorFlags; } - /** Applies class type arguments to the context of a partially resolved instance method. */ - applyClassTypeArguments(contextualTypeArguments: Map): void { - var classTypeArguments = assert(this.classTypeArguments); // set only if partial - var classDeclaration = assert(this.classPrototype).declaration; - var classTypeParameters = classDeclaration.typeParameters; - var numClassTypeParameters = classTypeParameters.length; - assert(numClassTypeParameters == classTypeArguments.length); - for (let i = 0; i < numClassTypeParameters; ++i) { - contextualTypeArguments.set( - classTypeParameters[i].name.text, - classTypeArguments[i] - ); - } + /** Gets the associated type parameter nodes. */ + get typeParameterNodes(): TypeParameterNode[] | null { + return (this.declaration).typeParameters; + } + + /** Gets the associated signature node. */ + get signatureNode(): SignatureNode { + return (this.declaration).signature; + } + + /** Gets the associated body node. */ + get bodyNode(): Statement | null { + return (this.declaration).body; + } + + /** Tests if this prototype is bound to a class. */ + get isBound(): bool { + var parent = this.parent; + return parent.kind == ElementKind.CLASS + || parent.kind == ElementKind.PROPERTY_PROTOTYPE && parent.parent.kind == ElementKind.CLASS; + } + + /** Creates a clone of this prototype that is bound to a concrete class instead. */ + toBound(classInstance: Class): FunctionPrototype { + assert(this.is(CommonFlags.INSTANCE)); + assert(!this.isBound); + var boundPrototypes = this.boundPrototypes; + if (!boundPrototypes) this.boundPrototypes = boundPrototypes = new Map(); + else if (boundPrototypes.has(classInstance)) return boundPrototypes.get(classInstance)!; + var declaration = this.declaration; assert(declaration.kind == NodeKind.METHODDECLARATION); + var bound = new FunctionPrototype( + this.name, + classInstance, // ! + declaration, + this.decoratorFlags + ); + bound.flags = this.flags; + bound.operatorKind = this.operatorKind; + // NOTE: this.instances holds instances per bound class / unbound + boundPrototypes.set(classInstance, bound); + return bound; + } + + /** Gets the resolved instance for the specified instance key, if already resolved. */ + getResolvedInstance(instanceKey: string): Function | null { + var instances = this.instances; + if (instances && instances.has(instanceKey)) return instances.get(instanceKey); + return null; + } + + /** Sets the resolved instance for the specified instance key. */ + setResolvedInstance(instanceKey: string, instance: Function): void { + var instances = this.instances; + if (!instances) this.instances = instances = new Map(); + else assert(!instances.has(instanceKey)); + instances.set(instanceKey, instance); } - toString(): string { return this.simpleName; } + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); + } } /** A resolved function. */ -export class Function extends Element { +export class Function extends TypedElement { - kind = ElementKind.FUNCTION; - - /** Prototype reference. */ + /** Function prototype. */ prototype: FunctionPrototype; /** Function signature. */ signature: Signature; @@ -2483,7 +2448,7 @@ export class Function extends Element { additionalLocals: Type[] = []; /** Contextual type arguments. */ contextualTypeArguments: Map | null; - /** Current control flow. */ + /** Default control flow. */ flow: Flow; /** Remembered debug locations. */ debugLocations: Range[] = []; @@ -2493,65 +2458,63 @@ export class Function extends Element { functionTableIndex: i32 = -1; /** Trampoline function for calling with omitted arguments. */ trampoline: Function | null = null; - /** The outer scope, if a function expression. */ - outerScope: Flow | null = null; + /** Counting id of inline operations involving this function. */ nextInlineId: i32 = 0; /** Constructs a new concrete function. */ constructor( + /** Name incl. type parameters, i.e. `foo`. */ + nameInclTypeParameters: string, + /** Respective function prototype. */ prototype: FunctionPrototype, - internalName: string, - signature: Signature, - parent: Element | null = null, + /** Concrete signature. */ + signature: Signature, // pre-resolved + /** Contextual type arguments inherited from its parent class, if any. */ contextualTypeArguments: Map | null = null ) { - super(prototype.program, prototype.simpleName, internalName); + super( + ElementKind.FUNCTION, + nameInclTypeParameters, + mangleInternalName(nameInclTypeParameters, prototype.parent, prototype.is(CommonFlags.INSTANCE)), + prototype.program, + prototype.parent, + prototype.declaration + ); this.prototype = prototype; this.signature = signature; - this.parent = parent; - this.flags = prototype.flags; + this.flags = prototype.flags | CommonFlags.RESOLVED; this.decoratorFlags = prototype.decoratorFlags; this.contextualTypeArguments = contextualTypeArguments; + this.type = Type.u32.asFunction(signature); if (!prototype.is(CommonFlags.AMBIENT)) { let localIndex = 0; - if (parent && parent.kind == ElementKind.CLASS) { + if (this.is(CommonFlags.INSTANCE)) { let local = new Local( - prototype.program, - "this", + CommonSymbols.this_, localIndex++, - assert(signature.thisType) + assert(signature.thisType), + this ); - this.localsByName.set("this", local); + this.localsByName.set(CommonSymbols.this_, local); this.localsByIndex[local.index] = local; - let inheritedTypeArguments = (parent).contextualTypeArguments; - if (inheritedTypeArguments) { - if (!this.contextualTypeArguments) this.contextualTypeArguments = new Map(); - for (let [inheritedName, inheritedType] of inheritedTypeArguments) { - if (!this.contextualTypeArguments.has(inheritedName)) { - this.contextualTypeArguments.set(inheritedName, inheritedType); - } - } - } - } else { - assert(!this.is(CommonFlags.INSTANCE)); // internal error } let parameterTypes = signature.parameterTypes; for (let i = 0, k = parameterTypes.length; i < k; ++i) { let parameterType = parameterTypes[i]; let parameterName = signature.getParameterName(i); let local = new Local( - prototype.program, parameterName, localIndex++, - parameterType - // FIXME: declaration? + parameterType, + this ); this.localsByName.set(parameterName, local); this.localsByIndex[local.index] = local; } } this.flow = Flow.create(this); + registerConcreteElement(this.program, this); } /** Adds a local of the specified type, with an optional name. */ @@ -2559,14 +2522,15 @@ export class Function extends Element { // if it has a name, check previously as this method will throw otherwise var localIndex = this.signature.parameterTypes.length + this.additionalLocals.length; if (this.is(CommonFlags.INSTANCE)) ++localIndex; + var localName = name !== null + ? name + : "var$" + localIndex.toString(); var local = new Local( - this.prototype.program, - name - ? name - : "var$" + localIndex.toString(10), + localName, localIndex, type, - declaration + this, + declaration || this.program.makeNativeVariableDeclaration(localName) ); if (name) { if (this.localsByName.has(name)) throw new Error("duplicate local name"); @@ -2577,6 +2541,13 @@ export class Function extends Element { return local; } + /* @override */ + lookup(name: string): Element | null { + var locals = this.localsByName; + if (locals.has(name)) return locals.get(name); + return this.parent.lookup(name); + } + // used by flows to keep track of temporary locals tempI32s: Local[] | null = null; tempI64s: Local[] | null = null; @@ -2609,61 +2580,91 @@ export class Function extends Element { } } } - - /** Returns the TypeScript representation of this function. */ - toString(): string { return this.prototype.simpleName; } } /** A resolved function target, that is a function called indirectly by an index and signature. */ export class FunctionTarget extends Element { - kind = ElementKind.FUNCTION_TARGET; - /** Underlying signature. */ signature: Signature; /** Function type. */ type: Type; /** Constructs a new function target. */ - constructor(program: Program, signature: Signature) { - super(program, "", ""); - var simpleName = signature.toSignatureString(); - this.simpleName = simpleName; - this.internalName = simpleName; + constructor( + /** Concrete signature. */ + signature: Signature, + /** Program reference. */ + program: Program, + __s: string = "" // FIXME: current TS limitation workaround, but a fix seems underway + ) { + super( + ElementKind.FUNCTION_TARGET, + __s = "sig:" + signature.toSignatureString(), + __s, + program, + program.nativeFile + ); this.signature = signature; + this.flags = CommonFlags.RESOLVED; this.type = Type.u32.asFunction(signature); } + + /* @override */ + lookup(name: string): Element | null { + return null; + } } /** A yet unresolved instance field prototype. */ -export class FieldPrototype extends Element { - - kind = ElementKind.FIELD_PROTOTYPE; - - /** Declaration reference. */ - declaration: FieldDeclaration; - /** Parent class prototype. */ - classPrototype: ClassPrototype; +export class FieldPrototype extends DeclaredElement { /** Constructs a new field prototype. */ constructor( - classPrototype: ClassPrototype, - simpleName: string, - internalName: string, - declaration: FieldDeclaration + /** Simple name. */ + name: string, + /** Parent class. */ + parent: ClassPrototype, + /** Declaration reference. */ + declaration: FieldDeclaration, + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags = DecoratorFlags.NONE ) { - super(classPrototype.program, simpleName, internalName); - this.classPrototype = classPrototype; - this.declaration = declaration; - this.flags = declaration.flags; + super( + ElementKind.FIELD_PROTOTYPE, + name, + mangleInternalName(name, parent, assert(declaration.is(CommonFlags.INSTANCE))), + parent.program, + parent, + declaration + ); + this.decoratorFlags = decoratorFlags; + } + + /** Gets the associated type node. */ + get typeNode(): CommonTypeNode | null { + return (this.declaration).type; + } + + /** Gets the associated initializer node. */ + get initializerNode(): Expression | null { + return (this.declaration).initializer; + } + + /** Gets the associated parameter index. Set if declared as a constructor parameter, otherwise `-1`. */ + get parameterIndex(): i32 { + return (this.declaration).parameterIndex; + } + + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); } } /** A resolved instance field. */ export class Field extends VariableLikeElement { - kind = ElementKind.FIELD; - /** Field prototype reference. */ prototype: FieldPrototype; /** Field memory offset, if an instance field. */ @@ -2671,27 +2672,30 @@ export class Field extends VariableLikeElement { /** Constructs a new field. */ constructor( + /** Respective field prototype. */ prototype: FieldPrototype, - internalName: string, - type: Type, - declaration: FieldDeclaration, - parent: Class + /** Parent class. */ + parent: Class, + /** Concrete type. */ + type: Type ) { - super(prototype.program, prototype.simpleName, internalName, type, declaration); + super( + ElementKind.FIELD, + prototype.name, + parent, + prototype.declaration + ); this.prototype = prototype; this.flags = prototype.flags; - this.type = type; - this.parent = parent; + assert(type != Type.void); + this.setType(type); + registerConcreteElement(this.program, this); } } /** A property comprised of a getter and a setter function. */ -export class Property extends Element { - - kind = ElementKind.PROPERTY; +export class PropertyPrototype extends DeclaredElement { - /** Parent class prototype. */ - parent: ClassPrototype; /** Getter prototype. */ getterPrototype: FunctionPrototype | null = null; /** Setter prototype. */ @@ -2699,25 +2703,71 @@ export class Property extends Element { /** Constructs a new property prototype. */ constructor( - program: Program, - simpleName: string, - internalName: string, - parent: ClassPrototype + /** Simple name. */ + name: string, + /** Parent class. */ + parent: ClassPrototype, + /** Declaration of the getter or setter introducing the property. */ + firstDeclaration: FunctionDeclaration ) { - super(program, simpleName, internalName); - this.parent = parent; + super( + ElementKind.PROPERTY_PROTOTYPE, + name, + mangleInternalName(name, parent, firstDeclaration.is(CommonFlags.INSTANCE)), + parent.program, + parent, + firstDeclaration + ); + this.flags &= ~(CommonFlags.GET | CommonFlags.SET); + } + + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); } } -/** A yet unresolved class prototype. */ -export class ClassPrototype extends Element { +/** A resolved property. */ +export class Property extends VariableLikeElement { + + /** Prototype reference. */ + prototype: PropertyPrototype; + /** Getter instance. */ + getterInstance: Function | null = null; + /** Setter instance. */ + setterInstance: Function | null = null; - kind = ElementKind.CLASS_PROTOTYPE; + /** Constructs a new property prototype. */ + constructor( + /** Respective property prototype. */ + prototype: PropertyPrototype, + /** Parent element, usually a static class prototype or class instance. */ + parent: Element + ) { + super( + ElementKind.PROPERTY, + prototype.name, + parent, + prototype.program.makeNativeVariableDeclaration( + prototype.name, + prototype.is(CommonFlags.INSTANCE) + ? CommonFlags.INSTANCE + : CommonFlags.NONE + ) + ); + this.prototype = prototype; + registerConcreteElement(this.program, this); + } + + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); + } +} + +/** A yet unresolved class prototype. */ +export class ClassPrototype extends DeclaredElement { - /** Declaration reference. */ - declaration: ClassDeclaration; - /** Resolved instances. */ - instances: Map = new Map(); /** Instance member prototypes. */ instanceMembers: Map | null = null; /** Base class prototype, if applicable. */ @@ -2726,20 +2776,45 @@ export class ClassPrototype extends Element { constructorPrototype: FunctionPrototype | null = null; /** Operator overload prototypes. */ overloadPrototypes: Map = new Map(); + /** Already resolved instances. */ + instances: Map | null = null; constructor( - program: Program, - simpleName: string, - internalName: string, + /** Simple name. */ + name: string, + /** Parent element, usually a file or namespace. */ + parent: Element, + /** Declaration reference. */ declaration: ClassDeclaration, - decoratorFlags: DecoratorFlags + /** Pre-checked flags indicating built-in decorators. */ + decoratorFlags: DecoratorFlags = DecoratorFlags.NONE, + _isInterface: bool = false // FIXME ) { - super(program, simpleName, internalName); - this.declaration = declaration; - this.flags = declaration.flags; + super( + _isInterface ? ElementKind.INTERFACE_PROTOTYPE : ElementKind.CLASS_PROTOTYPE, + name, + mangleInternalName(name, parent, declaration.is(CommonFlags.INSTANCE)), + parent.program, + parent, + declaration + ); this.decoratorFlags = decoratorFlags; } + /** Gets the associated type parameter nodes. */ + get typeParameterNodes(): TypeParameterNode[] | null { + return (this.declaration).typeParameters; + } + /** Gets the associated extends node. */ + get extendsNode(): TypeNode | null { + return (this.declaration).extendsType; + } + /** Gets the associated implements nodes. */ + get implementsNodes(): TypeNode[] | null { + return (this.declaration).implementsTypes; + } + + /** Tests if this prototype extends the specified. */ extends(basePtototype: ClassPrototype | null): bool { var current: ClassPrototype | null = this; do { @@ -2748,22 +2823,58 @@ export class ClassPrototype extends Element { return false; } - toString(): string { - return this.simpleName; + /** Adds an element as an instance member of this one. Returns the previous element if a duplicate. */ + addInstance(name: string, element: DeclaredElement): bool { + var originalDeclaration = element.declaration; + var instanceMembers = this.instanceMembers; + if (!instanceMembers) this.instanceMembers = instanceMembers = new Map(); + else if (instanceMembers.has(name)) { + let merged = tryMerge(instanceMembers.get(name)!, element); + if (!merged) { + this.program.error( + DiagnosticCode.Duplicate_identifier_0, + element.identifierNode.range, element.identifierNode.text + ); + return false; + } + element = merged; + } + instanceMembers.set(name, element); + if (element.is(CommonFlags.EXPORT) && this.is(CommonFlags.MODULE_EXPORT)) { + element.set(CommonFlags.MODULE_EXPORT); // propagate + } + this.program.elementsByDeclaration.set(originalDeclaration, element); + return true; + } + + /** Gets the resolved instance for the specified instance key, if already resolved. */ + getResolvedInstance(instanceKey: string): Class | null { + var instances = this.instances; + if (instances && instances.has(instanceKey)) return instances.get(instanceKey); + return null; + } + + /** Sets the resolved instance for the specified instance key. */ + setResolvedInstance(instanceKey: string, instance: Class): void { + var instances = this.instances; + if (!instances) this.instances = instances = new Map(); + else assert(!instances.has(instanceKey)); + instances.set(instanceKey, instance); + } + + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); } } /** A resolved class. */ -export class Class extends Element { - - kind = ElementKind.CLASS; +export class Class extends TypedElement { - /** Prototype reference. */ + /** Class prototype. */ prototype: ClassPrototype; /** Resolved type arguments. */ typeArguments: Type[] | null; - /** Resolved class type. */ - type: Type; /** Base class, if applicable. */ base: Class | null; /** Contextual type arguments for fields and methods. */ @@ -2779,50 +2890,60 @@ export class Class extends Element { /** Constructs a new class. */ constructor( + /** Name incl. type parameters, i.e. `Foo`. */ + nameInclTypeParameters: string, + /** The respective class prototype. */ prototype: ClassPrototype, - simpleName: string, - internalName: string, + /** Concrete type arguments, if any. */ typeArguments: Type[] | null = null, - base: Class | null = null + /** Base class, if derived. */ + base: Class | null = null, + _isInterface: bool = false // FIXME ) { - super(prototype.program, simpleName, internalName); + super( + _isInterface ? ElementKind.INTERFACE : ElementKind.CLASS, + nameInclTypeParameters, + mangleInternalName(nameInclTypeParameters, prototype.parent, prototype.is(CommonFlags.INSTANCE)), + prototype.program, + prototype.parent, + prototype.declaration + ); this.prototype = prototype; this.flags = prototype.flags; this.decoratorFlags = prototype.decoratorFlags; this.typeArguments = typeArguments; - this.type = prototype.program.options.usizeType.asClass(this); + this.setType(this.program.options.usizeType.asClass(this)); this.base = base; // inherit static members and contextual type arguments from base class if (base) { let inheritedTypeArguments = base.contextualTypeArguments; if (inheritedTypeArguments) { - if (!this.contextualTypeArguments) this.contextualTypeArguments = new Map(); + let contextualTypeArguments = this.contextualTypeArguments; for (let [baseName, baseType] of inheritedTypeArguments) { - this.contextualTypeArguments.set(baseName, baseType); + if (!contextualTypeArguments) this.contextualTypeArguments = contextualTypeArguments = new Map(); + contextualTypeArguments.set(baseName, baseType); } } } - // apply instance-specific contextual type arguments - var declaration = this.prototype.declaration; - var i: i32, k: i32; - if (declaration) { // irrelevant for built-ins - let typeParameters = declaration.typeParameters; - if (typeArguments) { - if ((k = typeArguments.length) != typeParameters.length) { - throw new Error("type argument count mismatch"); - } - if (k) { - if (!this.contextualTypeArguments) this.contextualTypeArguments = new Map(); - for (i = 0; i < k; ++i) { - this.contextualTypeArguments.set(typeParameters[i].name.text, typeArguments[i]); - } - } - } else if (typeParameters.length) { + // apply pre-checked instance-specific contextual type arguments + var typeParameters = prototype.typeParameterNodes; + if (typeArguments) { + let numTypeArguments = typeArguments.length; + if (!typeParameters || numTypeArguments != typeParameters.length) { throw new Error("type argument count mismatch"); } + if (numTypeArguments) { + if (!this.contextualTypeArguments) this.contextualTypeArguments = new Map(); + for (let i = 0; i < numTypeArguments; ++i) { + this.contextualTypeArguments.set(typeParameters[i].name.text, typeArguments[i]); + } + } + } else if (typeParameters && typeParameters.length) { + throw new Error("type argument count mismatch"); } + registerConcreteElement(this.program, this); } /** Tests if a value of this class type is assignable to a target of the specified class type. */ @@ -2861,16 +2982,12 @@ export class Class extends Element { return null; } - lookupField(name: string, shouldReadonly: boolean = false): Element | null { - if (this.members == null) return null; - var member = this.members.get(name); - if ( - member == null || member.kind != ElementKind.FIELD || - (shouldReadonly && !member.is(CommonFlags.READONLY)) - ) return null; - return member; + /* @override */ + lookup(name: string): Element | null { + return this.parent.lookup(name); } + /** Calculates the memory offset of the specified field. */ offsetof(fieldName: string): u32 { var members = assert(this.members); assert(members.has(fieldName)); @@ -2878,729 +2995,178 @@ export class Class extends Element { assert(field.kind == ElementKind.FIELD); return (field).memoryOffset; } - - toString(): string { - return this.simpleName; - } } /** A yet unresolved interface. */ -export class InterfacePrototype extends ClassPrototype { - - kind = ElementKind.INTERFACE_PROTOTYPE; - - /** Declaration reference. */ - declaration: InterfaceDeclaration; // more specific +export class InterfacePrototype extends ClassPrototype { // FIXME /** Constructs a new interface prototype. */ constructor( - program: Program, - simpleName: string, - internalName: string, + name: string, + parent: Element, declaration: InterfaceDeclaration, decoratorFlags: DecoratorFlags ) { - super(program, simpleName, internalName, declaration, decoratorFlags); + super( + name, + parent, + declaration, + decoratorFlags, + true + ); } } /** A resolved interface. */ -export class Interface extends Class { - - kind = ElementKind.INTERFACE; - - /** Prototype reference. */ - prototype: InterfacePrototype; // more specific - /** Base interface, if applcable. */ - base: Interface | null; // more specific +export class Interface extends Class { // FIXME /** Constructs a new interface. */ constructor( + nameInclTypeParameters: string, prototype: InterfacePrototype, - simpleName: string, - internalName: string, typeArguments: Type[] = [], base: Interface | null = null ) { - super(prototype, simpleName, internalName, typeArguments, base); + super( + nameInclTypeParameters, + prototype, + typeArguments, + base, + true + ); } } -/** Control flow flags indicating specific conditions. */ -export const enum FlowFlags { - /** No specific conditions. */ - NONE = 0, - - // categorical - - /** This flow returns. */ - RETURNS = 1 << 0, - /** This flow returns a wrapped value. */ - RETURNS_WRAPPED = 1 << 1, - /** This flow throws. */ - THROWS = 1 << 2, - /** This flow breaks. */ - BREAKS = 1 << 3, - /** This flow continues. */ - CONTINUES = 1 << 4, - /** This flow allocates. Constructors only. */ - ALLOCATES = 1 << 5, - /** This flow calls super. Constructors only. */ - CALLS_SUPER = 1 << 6, - - // conditional - - /** This flow conditionally returns in a child flow. */ - CONDITIONALLY_RETURNS = 1 << 7, - /** This flow conditionally throws in a child flow. */ - CONDITIONALLY_THROWS = 1 << 8, - /** This flow conditionally breaks in a child flow. */ - CONDITIONALLY_BREAKS = 1 << 9, - /** This flow conditionally continues in a child flow. */ - CONDITIONALLY_CONTINUES = 1 << 10, - /** This flow conditionally allocates in a child flow. Constructors only. */ - CONDITIONALLY_ALLOCATES = 1 << 11, - - // special - - /** This is an inlining flow. */ - INLINE_CONTEXT = 1 << 12, - /** This is a flow with explicitly disabled bounds checking. */ - UNCHECKED_CONTEXT = 1 << 13, - - // masks - - /** Any terminating flag. */ - ANY_TERMINATING = FlowFlags.RETURNS - | FlowFlags.THROWS - | FlowFlags.BREAKS - | FlowFlags.CONTINUES, - - /** Any categorical flag. */ - ANY_CATEGORICAL = FlowFlags.RETURNS - | FlowFlags.RETURNS_WRAPPED - | FlowFlags.THROWS - | FlowFlags.BREAKS - | FlowFlags.CONTINUES - | FlowFlags.ALLOCATES - | FlowFlags.CALLS_SUPER, - - /** Any conditional flag. */ - ANY_CONDITIONAL = FlowFlags.CONDITIONALLY_RETURNS - | FlowFlags.CONDITIONALLY_THROWS - | FlowFlags.CONDITIONALLY_BREAKS - | FlowFlags.CONDITIONALLY_CONTINUES - | FlowFlags.CONDITIONALLY_ALLOCATES +/** Registers a concrete element with a program. */ +function registerConcreteElement(program: Program, element: Element): void { + assert(!program.instancesByName.has(element.internalName)); + program.instancesByName.set(element.internalName, element); } -/** A control flow evaluator. */ -export class Flow { - - /** Parent flow. */ - parent: Flow | null; - /** Flow flags indicating specific conditions. */ - flags: FlowFlags; - /** Function this flow belongs to. */ - parentFunction: Function; - /** The label we break to when encountering a continue statement. */ - continueLabel: string | null; - /** The label we break to when encountering a break statement. */ - breakLabel: string | null; - /** The current return type. */ - returnType: Type; - /** The current contextual type arguments. */ - contextualTypeArguments: Map | null; - /** Scoped local variables. */ - scopedLocals: Map | null = null; - /** Local variable wrap states for the first 64 locals. */ - wrappedLocals: I64; - /** Local variable wrap states for locals with index >= 64. */ - wrappedLocalsExt: I64[] | null; - /** Function being inlined, when inlining. */ - inlineFunction: Function | null; - /** The label we break to when encountering a return statement, when inlining. */ - inlineReturnLabel: string | null; - - /** Creates the parent flow of the specified function. */ - static create(parentFunction: Function): Flow { - var flow = new Flow(); - flow.parent = null; - flow.flags = FlowFlags.NONE; - flow.parentFunction = parentFunction; - flow.continueLabel = null; - flow.breakLabel = null; - flow.returnType = parentFunction.signature.returnType; - flow.contextualTypeArguments = parentFunction.contextualTypeArguments; - flow.wrappedLocals = i64_new(0); - flow.wrappedLocalsExt = null; - flow.inlineFunction = null; - flow.inlineReturnLabel = null; - return flow; - } - - /** Creates an inline flow within `currentFunction`. */ - static createInline(parentFunction: Function, inlineFunction: Function): Flow { - var flow = Flow.create(parentFunction); - flow.set(FlowFlags.INLINE_CONTEXT); - flow.inlineFunction = inlineFunction; - flow.inlineReturnLabel = inlineFunction.internalName + "|inlined." + (inlineFunction.nextInlineId++).toString(10); - flow.returnType = inlineFunction.signature.returnType; - flow.contextualTypeArguments = inlineFunction.contextualTypeArguments; - return flow; - } - - private constructor() { } - - /** Gets the actual function being compiled, The inlined function when inlining, otherwise the parent function. */ - get actualFunction(): Function { - return this.inlineFunction || this.parentFunction; - } - - /** Tests if this flow has the specified flag or flags. */ - is(flag: FlowFlags): bool { return (this.flags & flag) == flag; } - /** Tests if this flow has one of the specified flags. */ - isAny(flag: FlowFlags): bool { return (this.flags & flag) != 0; } - /** Sets the specified flag or flags. */ - set(flag: FlowFlags): void { this.flags |= flag; } - /** Unsets the specified flag or flags. */ - unset(flag: FlowFlags): void { this.flags &= ~flag; } - - /** Forks this flow to a child flow. */ - fork(): Flow { - var branch = new Flow(); - branch.parent = this; - branch.flags = this.flags; - branch.parentFunction = this.parentFunction; - branch.continueLabel = this.continueLabel; - branch.breakLabel = this.breakLabel; - branch.returnType = this.returnType; - branch.contextualTypeArguments = this.contextualTypeArguments; - branch.wrappedLocals = this.wrappedLocals; - branch.wrappedLocalsExt = this.wrappedLocalsExt ? this.wrappedLocalsExt.slice() : null; - branch.inlineFunction = this.inlineFunction; - branch.inlineReturnLabel = this.inlineReturnLabel; - return branch; - } - - /** Gets a free temporary local of the specified type. */ - getTempLocal(type: Type, wrapped: bool = false): Local { - var parentFunction = this.parentFunction; - var temps: Local[] | null; - switch (type.toNativeType()) { - case NativeType.I32: { temps = parentFunction.tempI32s; break; } - case NativeType.I64: { temps = parentFunction.tempI64s; break; } - case NativeType.F32: { temps = parentFunction.tempF32s; break; } - case NativeType.F64: { temps = parentFunction.tempF64s; break; } - default: throw new Error("concrete type expected"); - } - var local: Local; - if (temps && temps.length) { - local = temps.pop(); - local.type = type; - local.flags = CommonFlags.NONE; - } else { - local = parentFunction.addLocal(type); - } - if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) this.setLocalWrapped(local.index, wrapped); - return local; - } - - /** Frees the temporary local for reuse. */ - freeTempLocal(local: Local): void { - if (local.is(CommonFlags.INLINED)) return; - assert(local.index >= 0); - var parentFunction = this.parentFunction; - var temps: Local[]; - assert(local.type != null); // internal error - switch ((local.type).toNativeType()) { - case NativeType.I32: { - temps = parentFunction.tempI32s || (parentFunction.tempI32s = []); - break; - } - case NativeType.I64: { - temps = parentFunction.tempI64s || (parentFunction.tempI64s = []); - break; - } - case NativeType.F32: { - temps = parentFunction.tempF32s || (parentFunction.tempF32s = []); - break; - } - case NativeType.F64: { - temps = parentFunction.tempF64s || (parentFunction.tempF64s = []); - break; +/** Attempts to merge two elements. Returns the merged element on success. */ +function tryMerge(older: Element, newer: Element): DeclaredElement | null { + // NOTE: some of the following cases are not supported by TS, not sure why exactly. + // suggesting to just merge what seems to be possible for now and revisit later. + assert(older.program === newer.program); + assert(!newer.members); + var merged: DeclaredElement | null = null; + switch (older.kind) { + case ElementKind.FUNCTION_PROTOTYPE: { + switch (newer.kind) { + case ElementKind.NAMESPACE: { + copyMembers(newer, older); + merged = older; + break; + } + case ElementKind.TYPEDEFINITION: { + if (!older.shadowType) { + older.shadowType = newer; + copyMembers(newer, older); + merged = older; + } + break; + } } - default: throw new Error("concrete type expected"); + break; } - assert(local.index >= 0); - temps.push(local); - } - - /** Gets and immediately frees a temporary local of the specified type. */ - getAndFreeTempLocal(type: Type, wrapped: bool): Local { - var parentFunction = this.parentFunction; - var temps: Local[]; - switch (type.toNativeType()) { - case NativeType.I32: { - temps = parentFunction.tempI32s || (parentFunction.tempI32s = []); + case ElementKind.CLASS_PROTOTYPE: + case ElementKind.ENUM: { + if (newer.kind == ElementKind.NAMESPACE) { + copyMembers(newer, older); + merged = older; break; } - case NativeType.I64: { - temps = parentFunction.tempI64s || (parentFunction.tempI64s = []); - break; - } - case NativeType.F32: { - temps = parentFunction.tempF32s || (parentFunction.tempF32s = []); - break; - } - case NativeType.F64: { - temps = parentFunction.tempF64s || (parentFunction.tempF64s = []); - break; - } - default: throw new Error("concrete type expected"); - } - var local: Local; - if (temps.length) { - local = temps[temps.length - 1]; - local.type = type; - } else { - local = parentFunction.addLocal(type); - temps.push(local); + break; } - if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) this.setLocalWrapped(local.index, wrapped); - return local; - } - - /** Adds a new scoped local of the specified name. */ - addScopedLocal(name: string, type: Type, wrapped: bool, reportNode: Node | null = null): Local { - var scopedLocal = this.getTempLocal(type, false); - if (!this.scopedLocals) this.scopedLocals = new Map(); - else { - let existingLocal = this.scopedLocals.get(name); - if (existingLocal) { - if (reportNode) { - this.parentFunction.program.error( - DiagnosticCode.Duplicate_identifier_0, - reportNode.range - ); + case ElementKind.NAMESPACE: { + switch (newer.kind) { + case ElementKind.ENUM: + case ElementKind.CLASS_PROTOTYPE: // TS2434 + case ElementKind.FUNCTION_PROTOTYPE: { // TS2434 + copyMembers(older, newer); + merged = newer; + break; + } + case ElementKind.NAMESPACE: { + copyMembers(newer, older); + merged = older; + break; + } + case ElementKind.TYPEDEFINITION: { + if (!older.shadowType) { + older.shadowType = newer; + copyMembers(newer, older); + merged = older; + } + break; } - return existingLocal; } + break; } - scopedLocal.set(CommonFlags.SCOPED); - this.scopedLocals.set(name, scopedLocal); - if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) { - this.setLocalWrapped(scopedLocal.index, wrapped); - } - return scopedLocal; - } - - /** Adds a new scoped alias for the specified local. For example `super` aliased to the `this` local. */ - addScopedAlias(name: string, type: Type, index: i32, reportNode: Node | null = null): Local { - if (!this.scopedLocals) this.scopedLocals = new Map(); - else { - let existingLocal = this.scopedLocals.get(name); - if (existingLocal) { - if (reportNode) { - this.parentFunction.program.error( - DiagnosticCode.Duplicate_identifier_0, - reportNode.range - ); + case ElementKind.GLOBAL: { + if (newer.kind == ElementKind.TYPEDEFINITION) { + if (!older.shadowType) { + older.shadowType = newer; + copyMembers(newer, older); + merged = older; } - return existingLocal; } + break; } - assert(index < this.parentFunction.localsByIndex.length); - var scopedAlias = new Local( - this.parentFunction.program, - name, - index, - type, - null - ); - // not flagged as SCOPED as it must not be free'd when the flow is finalized - this.scopedLocals.set(name, scopedAlias); - return scopedAlias; - } - - /** Frees this flow's scoped variables and returns its parent flow. */ - freeScopedLocals(): void { - if (this.scopedLocals) { - for (let scopedLocal of this.scopedLocals.values()) { - if (scopedLocal.is(CommonFlags.SCOPED)) { // otherwise an alias - this.freeTempLocal(scopedLocal); + case ElementKind.TYPEDEFINITION: { + switch (newer.kind) { + case ElementKind.GLOBAL: + case ElementKind.FUNCTION_PROTOTYPE: + case ElementKind.NAMESPACE: { + if (!newer.shadowType) { + newer.shadowType = older; + copyMembers(older, newer); + merged = newer; + } + break; } } - this.scopedLocals = null; + break; } } - - /** Looks up the local of the specified name in the current scope. */ - lookupLocal(name: string): Local | null { - var local: Local | null; - var current: Flow | null = this; - do if (current.scopedLocals && (local = current.scopedLocals.get(name))) return local; - while (current = current.parent); - return this.parentFunction.localsByName.get(name); - } - - /** Tests if the value of the local at the specified index is considered wrapped. */ - isLocalWrapped(index: i32): bool { - if (index < 0) return true; // inlined constant - if (index < 64) return bitsetIs(this.wrappedLocals, index); - var ext = this.wrappedLocalsExt; - var i = ((index - 64) / 64) | 0; - if (!(ext && i < ext.length)) return false; - return bitsetIs(ext[i], index - (i + 1) * 64); - } - - /** Sets if the value of the local at the specified index is considered wrapped. */ - setLocalWrapped(index: i32, wrapped: bool): void { - if (index < 0) return; // inlined constant - if (index < 64) { - this.wrappedLocals = bitsetSet(this.wrappedLocals, index, wrapped); - return; - } - var ext = this.wrappedLocalsExt; - var i = ((index - 64) / 64) | 0; - if (!ext) { - this.wrappedLocalsExt = ext = new Array(i + 1); - for (let j = 0; j <= i; ++j) ext[j] = i64_new(0); - } else { - while (ext.length <= i) ext.push(i64_new(0)); + if (merged) { + if (older.is(CommonFlags.EXPORT) != newer.is(CommonFlags.EXPORT)) { + older.program.error( + DiagnosticCode.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, + merged.identifierNode.range, merged.identifierNode.text + ); } - ext[i] = bitsetSet(ext[i], index - (i + 1) * 64, wrapped); - } - - /** Pushes a new break label to the stack, for example when entering a loop that one can `break` from. */ - pushBreakLabel(): string { - var parentFunction = this.parentFunction; - var id = parentFunction.nextBreakId++; - var stack = parentFunction.breakStack; - if (!stack) parentFunction.breakStack = [ id ]; - else stack.push(id); - return parentFunction.breakLabel = id.toString(10); } + return merged; +} - /** Pops the most recent break label from the stack. */ - popBreakLabel(): void { - var parentFunction = this.parentFunction; - var stack = assert(parentFunction.breakStack); - var length = assert(stack.length); - stack.pop(); - if (length > 1) { - parentFunction.breakLabel = stack[length - 2].toString(10); - } else { - parentFunction.breakLabel = null; - parentFunction.breakStack = null; +/** Copies the members of `src` to `dest`. */ +function copyMembers(src: Element, dest: Element): void { + var srcMembers = src.members; + if (srcMembers) { + let destMembers = dest.members; + if (!destMembers) dest.members = destMembers = new Map(); + for (let [memberName, member] of srcMembers) { + destMembers.set(memberName, member); } } +} - /** Inherits flags and local wrap states from the specified flow (e.g. blocks). */ - inherit(other: Flow): void { - this.flags |= other.flags & (FlowFlags.ANY_CATEGORICAL | FlowFlags.ANY_CONDITIONAL); - this.wrappedLocals = other.wrappedLocals; - this.wrappedLocalsExt = other.wrappedLocalsExt; // no need to slice because other flow is finished - } - - /** Inherits categorical flags as conditional flags from the specified flow (e.g. then without else). */ - inheritConditional(other: Flow): void { - if (other.is(FlowFlags.RETURNS)) { - this.set(FlowFlags.CONDITIONALLY_RETURNS); - } - if (other.is(FlowFlags.THROWS)) { - this.set(FlowFlags.CONDITIONALLY_THROWS); +/** Mangles the internal name of an element with the specified name that is a child of the given parent. */ +export function mangleInternalName(name: string, parent: Element, isInstance: bool, asGlobal: bool = false): string { + switch (parent.kind) { + case ElementKind.FILE: { + if (asGlobal) return name; + return parent.internalName + PATH_DELIMITER + name; } - if (other.is(FlowFlags.BREAKS) && other.breakLabel == this.breakLabel) { - this.set(FlowFlags.CONDITIONALLY_BREAKS); - } - if (other.is(FlowFlags.CONTINUES) && other.continueLabel == this.continueLabel) { - this.set(FlowFlags.CONDITIONALLY_CONTINUES); - } - if (other.is(FlowFlags.ALLOCATES)) { - this.set(FlowFlags.CONDITIONALLY_ALLOCATES); - } - } - - /** Inherits mutual flags and local wrap states from the specified flows (e.g. then with else). */ - inheritMutual(left: Flow, right: Flow): void { - // categorical flags set in both arms - this.flags |= left.flags & right.flags & FlowFlags.ANY_CATEGORICAL; - - // conditional flags set in at least one arm - this.flags |= left.flags & FlowFlags.ANY_CONDITIONAL; - this.flags |= right.flags & FlowFlags.ANY_CONDITIONAL; - - // locals wrapped in both arms - this.wrappedLocals = i64_and(left.wrappedLocals, right.wrappedLocals); - var leftExt = left.wrappedLocalsExt; - var rightExt = right.wrappedLocalsExt; - if (leftExt != null && rightExt != null) { - let thisExt = this.wrappedLocalsExt; - let minLength = min(leftExt.length, rightExt.length); - if (minLength) { - if (!thisExt) thisExt = new Array(minLength); - else while (thisExt.length < minLength) thisExt.push(i64_new(0)); - for (let i = 0; i < minLength; ++i) { - thisExt[i] = i64_and( - leftExt[i], - rightExt[i] - ); - } - } + case ElementKind.FUNCTION: { + if (asGlobal) return name; + assert(!isInstance); + return parent.internalName + INNER_DELIMITER + name; } - } - - /** - * Tests if an expression can possibly overflow in the context of this flow. Assumes that the - * expression might already have overflown and returns `false` only if the operation neglects - * any possible combination of garbage bits being present. - */ - canOverflow(expr: ExpressionRef, type: Type): bool { - // TODO: the following catches most common and a few uncommon cases, but there are additional - // opportunities here, obviously. - assert(type != Type.void); - - // types other than i8, u8, i16, u16 and bool do not overflow - if (!type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) return false; - - var operand: ExpressionRef; - switch (getExpressionId(expr)) { - - // overflows if the local isn't wrapped or the conversion does - case ExpressionId.GetLocal: { - let local = this.parentFunction.localsByIndex[getGetLocalIndex(expr)]; - return !this.isLocalWrapped(local.index) - || canConversionOverflow(local.type, type); - } - - // overflows if the value does - case ExpressionId.SetLocal: { // tee - assert(isTeeLocal(expr)); - return this.canOverflow(getSetLocalValue(expr), type); - } - - // overflows if the conversion does (globals are wrapped on set) - case ExpressionId.GetGlobal: { - // TODO: this is inefficient because it has to read a string - let global = assert(this.parentFunction.program.elementsLookup.get(assert(getGetGlobalName(expr)))); - assert(global.kind == ElementKind.GLOBAL); - return canConversionOverflow(assert((global).type), type); - } - - case ExpressionId.Binary: { - switch (getBinaryOp(expr)) { - - // comparisons do not overflow (result is 0 or 1) - case BinaryOp.EqI32: - case BinaryOp.EqI64: - case BinaryOp.EqF32: - case BinaryOp.EqF64: - case BinaryOp.NeI32: - case BinaryOp.NeI64: - case BinaryOp.NeF32: - case BinaryOp.NeF64: - case BinaryOp.LtI32: - case BinaryOp.LtU32: - case BinaryOp.LtI64: - case BinaryOp.LtU64: - case BinaryOp.LtF32: - case BinaryOp.LtF64: - case BinaryOp.LeI32: - case BinaryOp.LeU32: - case BinaryOp.LeI64: - case BinaryOp.LeU64: - case BinaryOp.LeF32: - case BinaryOp.LeF64: - case BinaryOp.GtI32: - case BinaryOp.GtU32: - case BinaryOp.GtI64: - case BinaryOp.GtU64: - case BinaryOp.GtF32: - case BinaryOp.GtF64: - case BinaryOp.GeI32: - case BinaryOp.GeU32: - case BinaryOp.GeI64: - case BinaryOp.GeU64: - case BinaryOp.GeF32: - case BinaryOp.GeF64: return false; - - // result won't overflow if one side is 0 or if one side is 1 and the other wrapped - case BinaryOp.MulI32: { - return !( - ( - getExpressionId(operand = getBinaryLeft(expr)) == ExpressionId.Const && - ( - getConstValueI32(operand) == 0 || - ( - getConstValueI32(operand) == 1 && - !this.canOverflow(getBinaryRight(expr), type) - ) - ) - ) || ( - getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && - ( - getConstValueI32(operand) == 0 || - ( - getConstValueI32(operand) == 1 && - !this.canOverflow(getBinaryLeft(expr), type) - ) - ) - ) - ); - } - - // result won't overflow if one side is a constant less than this type's mask or one side - // is wrapped - case BinaryOp.AndI32: { - // note that computeSmallIntegerMask returns the mask minus the MSB for signed types - // because signed value garbage bits must be guaranteed to be equal to the MSB. - return !( - ( - ( - getExpressionId(operand = getBinaryLeft(expr)) == ExpressionId.Const && - getConstValueI32(operand) <= type.computeSmallIntegerMask(Type.i32) - ) || !this.canOverflow(operand, type) - ) || ( - ( - getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && - getConstValueI32(operand) <= type.computeSmallIntegerMask(Type.i32) - ) || !this.canOverflow(operand, type) - ) - ); - } - - // overflows if the shift doesn't clear potential garbage bits - case BinaryOp.ShlI32: { - let shift = 32 - type.size; - return getExpressionId(operand = getBinaryRight(expr)) != ExpressionId.Const - || getConstValueI32(operand) < shift; - } - - // overflows if the value does and the shift doesn't clear potential garbage bits - case BinaryOp.ShrI32: { - let shift = 32 - type.size; - return this.canOverflow(getBinaryLeft(expr), type) && ( - getExpressionId(operand = getBinaryRight(expr)) != ExpressionId.Const || - getConstValueI32(operand) < shift - ); - } - - // overflows if the shift does not clear potential garbage bits. if an unsigned value is - // wrapped, it can't overflow. - case BinaryOp.ShrU32: { - let shift = 32 - type.size; - return type.is(TypeFlags.SIGNED) - ? !( - getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && - getConstValueI32(operand) > shift // must clear MSB - ) - : this.canOverflow(getBinaryLeft(expr), type) && !( - getExpressionId(operand = getBinaryRight(expr)) == ExpressionId.Const && - getConstValueI32(operand) >= shift // can leave MSB - ); - } - - // overflows if any side does - case BinaryOp.DivU32: - case BinaryOp.RemI32: - case BinaryOp.RemU32: { - return this.canOverflow(getBinaryLeft(expr), type) - || this.canOverflow(getBinaryRight(expr), type); - } - } - break; - } - - case ExpressionId.Unary: { - switch (getUnaryOp(expr)) { - - // comparisons do not overflow (result is 0 or 1) - case UnaryOp.EqzI32: - case UnaryOp.EqzI64: return false; - - // overflow if the maximum result (32) cannot be represented in the target type - case UnaryOp.ClzI32: - case UnaryOp.CtzI32: - case UnaryOp.PopcntI32: return type.size < 7; - } - break; - } - - // overflows if the value cannot be represented in the target type - case ExpressionId.Const: { - let value: i32 = 0; - switch (getExpressionType(expr)) { - case NativeType.I32: { value = getConstValueI32(expr); break; } - case NativeType.I64: { value = getConstValueI64Low(expr); break; } // discards upper bits - case NativeType.F32: { value = i32(getConstValueF32(expr)); break; } - case NativeType.F64: { value = i32(getConstValueF64(expr)); break; } - default: assert(false); - } - switch (type.kind) { - case TypeKind.I8: return value < i8.MIN_VALUE || value > i8.MAX_VALUE; - case TypeKind.I16: return value < i16.MIN_VALUE || value > i16.MAX_VALUE; - case TypeKind.U8: return value < 0 || value > u8.MAX_VALUE; - case TypeKind.U16: return value < 0 || value > u16.MAX_VALUE; - case TypeKind.BOOL: return (value & ~1) != 0; - } - break; - } - - // overflows if the conversion does - case ExpressionId.Load: { - let fromType: Type; - switch (getLoadBytes(expr)) { - case 1: { fromType = isLoadSigned(expr) ? Type.i8 : Type.u8; break; } - case 2: { fromType = isLoadSigned(expr) ? Type.i16 : Type.u16; break; } - default: { fromType = isLoadSigned(expr) ? Type.i32 : Type.u32; break; } - } - return canConversionOverflow(fromType, type); - } - - // overflows if the result does, which is either - // - the last expression of the block, by contract, if the block doesn't have a label - // - the last expression or the value of an inner br if the block has a label (TODO) - case ExpressionId.Block: { - if (!getBlockName(expr)) { - let size = assert(getBlockChildCount(expr)); - let last = getBlockChild(expr, size - 1); - return this.canOverflow(last, type); - } - break; - } - - // overflows if either side does - case ExpressionId.If: { - return this.canOverflow(getIfTrue(expr), type) - || this.canOverflow(assert(getIfFalse(expr)), type); - } - - // overflows if either side does - case ExpressionId.Select: { - return this.canOverflow(getSelectThen(expr), type) - || this.canOverflow(getSelectElse(expr), type); - } - - // overflows if the call does not return a wrapped value or the conversion does - case ExpressionId.Call: { - let program = this.parentFunction.program; - let instance = assert(program.instancesLookup.get(assert(getCallTarget(expr)))); - assert(instance.kind == ElementKind.FUNCTION); - let returnType = (instance).signature.returnType; - return !(instance).flow.is(FlowFlags.RETURNS_WRAPPED) - || canConversionOverflow(returnType, type); - } - - // doesn't technically overflow - case ExpressionId.Unreachable: return false; + default: { + return mangleInternalName(parent.name, parent.parent, parent.is(CommonFlags.INSTANCE), asGlobal) + + (isInstance ? INSTANCE_DELIMITER : STATIC_DELIMITER) + name; } - return true; } } - -/** Tests if a conversion from one type to another can technically overflow. */ -function canConversionOverflow(fromType: Type, toType: Type): bool { - return !fromType.is(TypeFlags.INTEGER) // non-i32 locals or returns - || fromType.size > toType.size - || fromType.is(TypeFlags.SIGNED) != toType.is(TypeFlags.SIGNED); -} diff --git a/src/resolver.ts b/src/resolver.ts index 7d440e4957..5ceb2a808e 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -12,29 +12,32 @@ import { Program, ElementKind, OperatorKind, - FlowFlags, - Element, Class, ClassPrototype, Function, - FunctionTarget, FunctionPrototype, VariableLikeElement, Property, - DecoratorFlags, - FieldPrototype, + PropertyPrototype, Field, + FieldPrototype, Global, - Flow + TypeDefinition } from "./program"; +import { + FlowFlags, + Flow +} from "./flow"; + import { SignatureNode, ParameterKind, CommonTypeNode, NodeKind, TypeNode, + TypeName, TypeParameterNode, Node, Range, @@ -50,7 +53,10 @@ import { IntegerLiteralExpression, UnaryPrefixExpression, UnaryPostfixExpression, - AssertionKind + AssertionKind, + BinaryExpression, + ThisExpression, + SuperExpression } from "./ast"; import { @@ -62,9 +68,8 @@ import { } from "./types"; import { - PATH_DELIMITER, - INSTANCE_DELIMITER, - CommonFlags + CommonFlags, + CommonSymbols } from "./common"; import { @@ -95,221 +100,319 @@ export class Resolver extends DiagnosticEmitter { currentElementExpression : Expression | null = null; /** Constructs the resolver for the specified program. */ - constructor(program: Program) { + constructor( + /** The program to construct a resolver for. */ + program: Program + ) { super(program.diagnostics); this.program = program; } /** Resolves a {@link CommonTypeNode} to a concrete {@link Type}. */ resolveType( + /** The type to resolve. */ node: CommonTypeNode, + /** Relative context. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ contextualTypeArguments: Map | null = null, - reportMode = ReportMode.REPORT + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT ): Type | null { - // handle signatures specifically + // handle signature if (node.kind == NodeKind.SIGNATURE) { - let signature = this.resolveSignature(node, contextualTypeArguments, reportMode); - if (!signature) return null; + let explicitThisType = (node).explicitThisType; + let thisType: Type | null = null; + if (explicitThisType) { + thisType = this.resolveType( + explicitThisType, + context, + contextualTypeArguments, + reportMode + ); + if (!thisType) return null; + } + let parameterNodes = (node).parameters; + let numParameters = parameterNodes.length; + let parameterTypes = new Array(numParameters); + let parameterNames = new Array(numParameters); + let requiredParameters = 0; + let hasRest = false; + for (let i = 0; i < numParameters; ++i) { + let parameterTypeNode = parameterNodes[i]; + switch (parameterTypeNode.parameterKind) { + case ParameterKind.DEFAULT: { + requiredParameters = i + 1; + break; + } + case ParameterKind.REST: { + assert(i == numParameters); + hasRest = true; + break; + } + } + let parameterType = this.resolveType( + assert(parameterTypeNode.type), + context, + contextualTypeArguments, + reportMode + ); + if (!parameterType) return null; + parameterTypes[i] = parameterType; + parameterNames[i] = parameterTypeNode.name.text; + } + let returnTypeNode = (node).returnType; + let returnType: Type | null; + if (returnTypeNode) { + returnType = this.resolveType( + returnTypeNode, + context, + contextualTypeArguments, + reportMode + ); + if (!returnType) return null; + } else { + returnType = Type.void; + } + let signature = new Signature(parameterTypes, returnType, thisType); + signature.parameterNames = parameterNames; + signature.requiredParameters = requiredParameters; + signature.hasRest = hasRest; return node.isNullable ? signature.type.asNullable() : signature.type; } // now dealing with TypeNode assert(node.kind == NodeKind.TYPE); var typeNode = node; - var simpleName = typeNode.name.text; - var globalName = simpleName; - var localName = typeNode.range.source.internalPath + PATH_DELIMITER + simpleName; // TODO cache + var typeName = typeNode.name; + var typeArgumentNodes = typeNode.typeArguments; + var possiblyPlaceholder = !typeName.next; - // check file-global / program-global enum or class - { - let elementsLookup = this.program.elementsLookup; - let element: Element | null; - if ( - (element = elementsLookup.get(localName)) || // file-global - (element = elementsLookup.get(globalName)) // program-global - ) { - switch (element.kind) { - case ElementKind.ENUM: { - if (typeNode.typeArguments !== null && typeNode.typeArguments.length) { - if (reportMode == ReportMode.REPORT) { - this.error( - DiagnosticCode.Type_0_is_not_generic, - node.range, element.internalName - ); - } - return null; - } - return Type.i32; + // look up in contextual type arguments if possibly a placeholder + if (possiblyPlaceholder) { + if (contextualTypeArguments && contextualTypeArguments.has(typeName.identifier.text)) { + let type = contextualTypeArguments.get(typeName.identifier.text)!; + if (typeArgumentNodes !== null && typeArgumentNodes.length) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Type_0_is_not_generic, + node.range, type.toString() + ); } - case ElementKind.CLASS_PROTOTYPE: { - let instance = this.resolveClassInclTypeArguments( - element, - typeNode.typeArguments, - makeMap(contextualTypeArguments), - node - ); // reports - if (!instance) return null; - return node.isNullable ? instance.type.asNullable() : instance.type; + } + if (node.isNullable) { + if (!type.is(TypeFlags.REFERENCE)) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Basic_type_0_cannot_be_nullable, + node.range, type.toString() + ); + } } + return type.asNullable(); } + return type; } } - // check (global) type alias - { - let alias = this.program.typeAliases.get(simpleName); - if (alias) return this.resolveType(alias.type, contextualTypeArguments, reportMode); - } + // look up in context + var element = this.resolveTypeName(typeName, context, reportMode); + if (!element) return null; - // resolve parameters - var typeArgumentNodes = typeNode.typeArguments; - var typeArguments: Type[] | null = null; - if (typeArgumentNodes) { - let numTypeArguments = typeArgumentNodes.length; - typeArguments = new Array(numTypeArguments); - for (let i = 0; i < numTypeArguments; ++i) { - let paramType = this.resolveType( // reports - typeArgumentNodes[i], - contextualTypeArguments, - reportMode - ); - if (!paramType) return null; - typeArguments[i] = paramType; - } - if (numTypeArguments) { // can't be a placeholder if it has parameters - let instanceKey = typesToString(typeArguments); - if (instanceKey.length) { - localName += "<" + instanceKey + ">"; - globalName += "<" + instanceKey + ">"; + // use shadow type if present (i.e. namespace sharing a type) + if (element.shadowType) { + element = element.shadowType; + + } else { + // handle enums (become i32) + if (element.kind == ElementKind.ENUM) { + if (typeArgumentNodes !== null && typeArgumentNodes.length) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Type_0_is_not_generic, + node.range, element.internalName + ); + } } - } else if (contextualTypeArguments) { - let placeholderType = contextualTypeArguments.get(globalName); - if (placeholderType) return placeholderType; + if (node.isNullable) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Basic_type_0_cannot_be_nullable, + node.range, element.name + ); + } + } + return Type.i32; + } + + // handle classes + if (element.kind == ElementKind.CLASS_PROTOTYPE) { + let instance = this.resolveClassInclTypeArguments( + element, + typeArgumentNodes, + context, + makeMap(contextualTypeArguments), // don't inherit + node + ); // reports + if (!instance) return null; + return node.isNullable ? instance.type.asNullable() : instance.type; } } - // check file-global / program-global type - { - let typesLookup = this.program.typesLookup; - let type: Type | null; - if ( - (type = typesLookup.get(localName)) || - (type = typesLookup.get(globalName)) - ) { - if (!type.is(TypeFlags.REFERENCE) && node.isNullable) { + // handle type definitions + if (element.kind == ElementKind.TYPEDEFINITION) { + + // shortcut already resolved (mostly builtins) + if (element.is(CommonFlags.RESOLVED)) { + if (typeArgumentNodes !== null && typeArgumentNodes.length) { if (reportMode == ReportMode.REPORT) { this.error( - DiagnosticCode.Basic_type_0_cannot_be_nullable, - node.range, type.toString() + DiagnosticCode.Type_0_is_not_generic, + node.range, element.internalName ); } } + let type = (element).type; + if (node.isNullable) { + if (!type.is(TypeFlags.REFERENCE)) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Basic_type_0_cannot_be_nullable, + typeNode.name.range, typeName.identifier.text + ); + } + } else { + return type.asNullable(); + } + } return type; } - } - // check built-in macro types - if (simpleName == "NATIVE") { - if (!(typeArguments && typeArguments.length == 1)) { - if (reportMode == ReportMode.REPORT) { - this.error( - DiagnosticCode.Expected_0_type_arguments_but_got_1, - typeNode.range, "1", (typeArgumentNodes ? typeArgumentNodes.length : 1).toString(10) - ); + // handle special native type + if (possiblyPlaceholder && typeName.identifier.text == CommonSymbols.native) { + if (!(typeArgumentNodes && typeArgumentNodes.length == 1)) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Expected_0_type_arguments_but_got_1, + typeNode.range, "1", (typeArgumentNodes ? typeArgumentNodes.length : 1).toString(10) + ); + } + return null; + } + let typeArgument = this.resolveType( + typeArgumentNodes[0], + context, + contextualTypeArguments, + reportMode + ); + if (!typeArgument) return null; + switch (typeArgument.kind) { + case TypeKind.I8: + case TypeKind.I16: + case TypeKind.I32: return Type.i32; + case TypeKind.ISIZE: if (!this.program.options.isWasm64) return Type.i32; + case TypeKind.I64: return Type.i64; + case TypeKind.U8: + case TypeKind.U16: + case TypeKind.U32: + case TypeKind.BOOL: return Type.u32; + case TypeKind.USIZE: if (!this.program.options.isWasm64) return Type.u32; + case TypeKind.U64: return Type.u64; + case TypeKind.F32: return Type.f32; + case TypeKind.F64: return Type.f64; + case TypeKind.V128: return Type.v128; + case TypeKind.VOID: return Type.void; + default: assert(false); } - return null; } - switch (typeArguments[0].kind) { - case TypeKind.I8: - case TypeKind.I16: - case TypeKind.I32: return Type.i32; - case TypeKind.ISIZE: if (!this.program.options.isWasm64) return Type.i32; - case TypeKind.I64: return Type.i64; - case TypeKind.U8: - case TypeKind.U16: - case TypeKind.U32: - case TypeKind.BOOL: return Type.u32; - case TypeKind.USIZE: if (!this.program.options.isWasm64) return Type.u32; - case TypeKind.U64: return Type.u64; - case TypeKind.F32: return Type.f32; - case TypeKind.F64: return Type.f64; - case TypeKind.V128: return Type.v128; - case TypeKind.VOID: return Type.void; - default: assert(false); + + // resolve normally + let typeParameterNodes = (element).typeParameterNodes; + let typeArguments: Type[] | null = null; + if (typeParameterNodes) { + typeArguments = this.resolveTypeArguments( + typeParameterNodes, + typeArgumentNodes, + context, + contextualTypeArguments = makeMap(contextualTypeArguments), // inherit + node, + reportMode + ); + if (!typeArguments) return null; + } else if (typeArgumentNodes && typeArgumentNodes.length) { + this.error( + DiagnosticCode.Type_0_is_not_generic, + typeNode.range, typeName.identifier.text + ); + // recoverable } + return this.resolveType( + (element).typeNode, + element, + contextualTypeArguments, + reportMode + ); } - if (reportMode == ReportMode.REPORT) { this.error( DiagnosticCode.Cannot_find_name_0, - typeNode.name.range, globalName + typeNode.name.range, typeName.identifier.text ); } return null; } - /** Resolves a {@link SignatureNode} to a concrete {@link Signature}. */ - resolveSignature( - node: SignatureNode, - contextualTypeArguments: Map | null = null, - reportMode: ReportMode = ReportMode.REPORT - ): Signature | null { - var explicitThisType = node.explicitThisType; - var thisType: Type | null = null; - if (explicitThisType) { - thisType = this.resolveType(explicitThisType, contextualTypeArguments, reportMode); - if (!thisType) return null; + /** Resolves a type name to the program element it refers to. */ + resolveTypeName( + /** The type name to resolve. */ + typeName: TypeName, + /** Relative context. */ + context: Element, + /** How to proceed with eventualy diagnostics. */ + reportMode = ReportMode.REPORT + ): Element | null { + var element = context.lookup(typeName.identifier.text); + if (!element) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Cannot_find_name_0, + typeName.range, typeName.identifier.text + ); + } + return null; } - var parameterTypeNodes = node.parameters; - var numParameters = parameterTypeNodes.length; - var parameterTypes = new Array(numParameters); - var parameterNames = new Array(numParameters); - var requiredParameters = 0; - var hasRest = false; - for (let i = 0; i < numParameters; ++i) { - let parameterTypeNode = parameterTypeNodes[i]; - switch (parameterTypeNode.parameterKind) { - case ParameterKind.DEFAULT: { - requiredParameters = i + 1; - break; - } - case ParameterKind.REST: { - assert(i == numParameters); - hasRest = true; - break; + var prev = typeName; + var next = typeName.next; + while (next) { + if (!(element = element.lookupInSelf(next.identifier.text))) { + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Property_0_does_not_exist_on_type_1, + next.range, next.identifier.text, prev.identifier.text + ); } + return null; } - let parameterType = this.resolveType( - assert(parameterTypeNode.type), - contextualTypeArguments, - reportMode - ); - if (!parameterType) return null; - parameterTypes[i] = parameterType; - parameterNames[i] = parameterTypeNode.name.text; - } - var returnTypeNode = node.returnType; - var returnType: Type | null; - if (returnTypeNode) { - returnType = this.resolveType(returnTypeNode, contextualTypeArguments, reportMode); - if (!returnType) return null; - } else { - returnType = Type.void; + prev = next; + next = next.next; } - var signature = new Signature(parameterTypes, returnType, thisType); - signature.parameterNames = parameterNames; - signature.requiredParameters = requiredParameters; - signature.hasRest = hasRest; - return signature; + return element; } /** Resolves an array of type arguments to concrete types. */ resolveTypeArguments( + /** Actual type parameter nodes. */ typeParameters: TypeParameterNode[], + /** Type arguments provided. */ typeArgumentNodes: CommonTypeNode[] | null, - contextualTypeArguments: Map, + /** Relative context. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ + contextualTypeArguments: Map = makeMap(), + /** Alternative report node in case of empty type arguments. */ alternativeReportNode: Node | null = null, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Type[] | null { var minParameterCount = 0; @@ -327,7 +430,7 @@ export class Resolver extends DiagnosticEmitter { (typeArgumentNodes)[0].range, (typeArgumentNodes)[argumentCount - 1].range ) - : assert(alternativeReportNode).range.atEnd, + : assert(alternativeReportNode).range, (argumentCount < minParameterCount ? minParameterCount : maxParameterCount).toString(10), argumentCount.toString(10) ); @@ -338,11 +441,13 @@ export class Resolver extends DiagnosticEmitter { let type = i < argumentCount ? this.resolveType( // reports (typeArgumentNodes)[i], + context, contextualTypeArguments, reportMode ) : this.resolveType( // reports assert(typeParameters[i].defaultType), + context, contextualTypeArguments, reportMode ); @@ -354,67 +459,38 @@ export class Resolver extends DiagnosticEmitter { return typeArguments; } - /** Resolves an identifier to the element it refers to. */ + /** Resolves an identifier to the program element it refers to. */ resolveIdentifier( + /** The expression to resolve. */ identifier: IdentifierExpression, + /** Optional flow to search for scoped locals. */ flow: Flow | null, + /** Optional context to search. */ context: Element | null, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Element | null { var name = identifier.text; var element: Element | null; - if (flow) { - let local = flow.lookupLocal(name); - if (local) { + if (element = flow.lookup(name)) { this.currentThisExpression = null; this.currentElementExpression = null; - return local; + return element; } } - if (context) { - - switch (context.kind) { - case ElementKind.FUNCTION: { // use prototype - context = (context).prototype.parent; - break; - } - case ElementKind.CLASS: { // use prototype - context = (context).prototype.parent; - break; - } - } - - // search context - while (context) { - let members = context.members; - if (members) { - if (element = members.get(name)) { - this.currentThisExpression = null; - this.currentElementExpression = null; - return element; - } - } - context = context.parent; + if (element = context.lookup(name)) { + this.currentThisExpression = null; + this.currentElementExpression = null; + return element; } } - - // search current file - var elementsLookup = this.program.elementsLookup; - if (element = elementsLookup.get(identifier.range.source.internalPath + PATH_DELIMITER + name)) { + if (element = this.program.lookupGlobal(name)) { this.currentThisExpression = null; this.currentElementExpression = null; - return element; // GLOBAL, FUNCTION_PROTOTYPE, CLASS_PROTOTYPE + return element; } - - // search global scope - if (element = elementsLookup.get(name)) { - this.currentThisExpression = null; - this.currentElementExpression = null; - return element; // GLOBAL, FUNCTION_PROTOTYPE, CLASS_PROTOTYPE - } - if (reportMode == ReportMode.REPORT) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -427,42 +503,46 @@ export class Resolver extends DiagnosticEmitter { /** Resolves a lazily compiled global, i.e. a static class field. */ ensureResolvedLazyGlobal(global: Global, reportMode: ReportMode = ReportMode.REPORT): bool { if (global.is(CommonFlags.RESOLVED)) return true; - var resolveType = assert(global.declaration).type; - if (!resolveType) return false; - var resolvedType = this.resolveType(resolveType, null, reportMode); - if (!resolvedType) return false; - global.type = resolvedType; - global.set(CommonFlags.RESOLVED); + var typeNode = global.typeNode; + if (!typeNode) return false; + var type = this.resolveType( // reports + typeNode, + global.parent, + null, + reportMode + ); + if (!type) return false; + global.setType(type); return true; } - /** Resolves a property access to the element it refers to. */ - resolvePropertyAccess( + /** Resolves a property access expression to the program element it refers to. */ + resolvePropertyAccessExpression( + /** The expression to resolve. */ propertyAccess: PropertyAccessExpression, + /** Current flow. */ flow: Flow, + /** Current contextual type. */ contextualType: Type, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Element | null { - // start by resolving the lhs target (expression before the last dot) var targetExpression = propertyAccess.expression; var target = this.resolveExpression(targetExpression, flow, contextualType, reportMode); // reports if (!target) return null; - - // at this point we know exactly what the target is, so look up the element within var propertyName = propertyAccess.property.text; - // Resolve variable-likes to the class type they reference first + // Resolve variable-likes to their class type first switch (target.kind) { case ElementKind.GLOBAL: if (!this.ensureResolvedLazyGlobal(target, reportMode)) return null; case ElementKind.LOCAL: case ElementKind.FIELD: { - let type = (target).type; - assert(type != Type.void); + let type = (target).type; assert(type != Type.void); let classReference = type.classReference; if (!classReference) { - let basicClasses = this.program.basicClasses; - if (!type.is(TypeFlags.REFERENCE) && basicClasses.has(type.kind)) { - classReference = assert(basicClasses.get(type.kind)); + let typeClasses = this.program.typeClasses; + if (!type.is(TypeFlags.REFERENCE) && typeClasses.has(type.kind)) { + classReference = typeClasses.get(type.kind)!; } else { this.error( DiagnosticCode.Property_0_does_not_exist_on_type_1, @@ -474,26 +554,39 @@ export class Resolver extends DiagnosticEmitter { target = classReference; break; } - case ElementKind.PROPERTY: { - let getter = this.resolveFunction( - assert((target).getterPrototype), + case ElementKind.PROPERTY_PROTOTYPE: { // static + let getterInstance = this.resolveFunction( // reports + assert((target).getterPrototype), // must have a getter null, makeMap(), reportMode ); - if (!getter) return null; - let classReference = getter.signature.returnType.classReference; + if (!getterInstance) return null; + let classReference = getterInstance.signature.returnType.classReference; if (!classReference) { this.error( DiagnosticCode.Property_0_does_not_exist_on_type_1, - propertyAccess.property.range, propertyName, getter.signature.returnType.toString() + propertyAccess.property.range, propertyName, getterInstance.signature.returnType.toString() ); return null; } target = classReference; break; } - case ElementKind.CLASS: { + case ElementKind.PROPERTY: { // instance + let getterInstance = assert((target).getterInstance); // must have a getter + let classReference = getterInstance.signature.returnType.classReference; + if (!classReference) { + this.error( + DiagnosticCode.Property_0_does_not_exist_on_type_1, + propertyAccess.property.range, propertyName, getterInstance.signature.returnType.toString() + ); + return null; + } + target = classReference; + break; + } + case ElementKind.CLASS: { // property access on element access? let elementExpression = this.currentElementExpression; if (elementExpression) { let indexedGet = (target).lookupOverload(OperatorKind.INDEXED_GET); @@ -523,11 +616,10 @@ export class Resolver extends DiagnosticEmitter { case ElementKind.CLASS: { do { let members = target.members; - let member: Element | null; - if (members && (member = members.get(propertyName))) { + if (members && members.has(propertyName)) { this.currentThisExpression = targetExpression; this.currentElementExpression = null; - return member; // instance FIELD, static GLOBAL, FUNCTION_PROTOTYPE... + return members.get(propertyName)!; // instance FIELD, static GLOBAL, FUNCTION_PROTOTYPE... } // traverse inherited static members on the base prototype if target is a class prototype if (target.kind == ElementKind.CLASS_PROTOTYPE) { @@ -551,13 +643,10 @@ export class Resolver extends DiagnosticEmitter { } default: { // enums or other namespace-like elements let members = target.members; - if (members) { - let member = members.get(propertyName); - if (member) { - this.currentThisExpression = targetExpression; - this.currentElementExpression = null; - return member; // static ENUMVALUE, static GLOBAL, static FUNCTION_PROTOTYPE... - } + if (members && members.has(propertyName)) { + this.currentThisExpression = targetExpression; + this.currentElementExpression = null; + return members.get(propertyName)!; // static ENUMVALUE, static GLOBAL, static FUNCTION_PROTOTYPE... } break; } @@ -569,14 +658,19 @@ export class Resolver extends DiagnosticEmitter { return null; } - resolveElementAccess( + /** Resolves an element access expression to the program element it refers to. */ + resolveElementAccessExpression( + /** The expression to resolve. */ elementAccess: ElementAccessExpression, + /** Current flow. */ flow: Flow, + /** Current contextual type. */ contextualType: Type, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Element | null { var targetExpression = elementAccess.expression; - var target = this.resolveExpression(targetExpression, flow, contextualType, reportMode); + var target = this.resolveExpression(targetExpression, flow, contextualType, reportMode); // reports if (!target) return null; switch (target.kind) { case ElementKind.GLOBAL: if (!this.ensureResolvedLazyGlobal(target, reportMode)) return null; @@ -624,11 +718,13 @@ export class Resolver extends DiagnosticEmitter { return null; } + /** Determines the final type of an integer literal given the specified contextual type. */ determineIntegerLiteralType( + /** Integer literal value. */ intValue: I64, + /** Current contextual type. */ contextualType: Type ): Type { - if (!contextualType.is(TypeFlags.REFERENCE)) { // compile to contextualType if matching switch (contextualType.kind) { @@ -682,252 +778,198 @@ export class Resolver extends DiagnosticEmitter { default: assert(false); } } - // otherwise compile to best fitting native type if (i64_is_i32(intValue)) return Type.i32; if (i64_is_u32(intValue)) return Type.u32; return Type.i64; } + /** Resolves any expression to the program element it refers to. */ resolveExpression( + /** The expression to resolve. */ expression: Expression, + /** Current flow. */ flow: Flow, + /** Current contextual type. */ contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Element | null { - while (expression.kind == NodeKind.PARENTHESIZED) { + while (expression.kind == NodeKind.PARENTHESIZED) { // simply skip expression = (expression).expression; } switch (expression.kind) { case NodeKind.ASSERTION: { - if ((expression).assertionKind == AssertionKind.NONNULL) { - return this.resolveExpression( - (expression).expression, - flow, - contextualType, - reportMode - ); - } - let type = this.resolveType( - assert((expression).toType), - flow.contextualTypeArguments, - reportMode + return this.resolveAssertionExpression( + expression, + flow, contextualType, reportMode ); - if (!type) return null; - let element: Element | null = type.classReference; - if (!element) { - let signature = type.signatureReference; - if (!signature) return null; - element = signature.asFunctionTarget(this.program); - } - this.currentThisExpression = null; - this.currentElementExpression = null; - return element; } case NodeKind.UNARYPREFIX: { - // TODO: overloads - switch ((expression).operator) { - case Token.MINUS: { - let operand = (expression).operand; - // implicitly negate if an integer literal to distinguish between i32/u32/i64 - if (operand.kind == NodeKind.LITERAL && (operand).literalKind == LiteralKind.INTEGER) { - let type = this.determineIntegerLiteralType( - i64_sub(i64_zero, (operand).value), - contextualType - ); - return assert(this.program.basicClasses.get(type.kind)); - } - return this.resolveExpression( - operand, - flow, - contextualType, - reportMode - ); - } - case Token.PLUS: - case Token.PLUS_PLUS: - case Token.MINUS_MINUS: { - return this.resolveExpression( - (expression).operand, - flow, - contextualType, - reportMode - ); - } - case Token.EXCLAMATION: { - return assert(this.program.basicClasses.get(TypeKind.BOOL)); - } - case Token.TILDE: { - let resolvedOperand = this.resolveExpression( - (expression).operand, - flow, - contextualType, - reportMode - ); - if (!resolvedOperand) return null; - throw new Error("not implemented"); // TODO: should all elements have a corresponding type right away? - } - default: assert(false); - } - return null; + return this.resolveUnaryPrefixExpression( + expression, + flow, contextualType, reportMode + ); } case NodeKind.UNARYPOSTFIX: { - // TODO: overloads - switch ((expression).operator) { - case Token.PLUS_PLUS: - case Token.MINUS_MINUS: { - return this.resolveExpression( - (expression).operand, - flow, - contextualType, - reportMode - ); - } - default: assert(false); - } - return null; + return this.resolveUnaryPostfixExpression( + expression, + flow, contextualType, reportMode + ); } case NodeKind.BINARY: { - // TODO: all sorts of unary and binary expressions, which means looking up overloads and - // evaluating their return types, knowing the semantics of different operators etc. - // should probably share that code with the compiler somehow, as it also does exactly this. - throw new Error("not implemented"); + return this.resolveBinaryExpression( + expression, + flow, contextualType, reportMode + ); } - case NodeKind.THIS: { // -> Class / ClassPrototype - if (flow.is(FlowFlags.INLINE_CONTEXT)) { - let explicitLocal = flow.lookupLocal("this"); - if (explicitLocal) { - this.currentThisExpression = null; - this.currentElementExpression = null; - return explicitLocal; - } - } - let parent = flow.parentFunction.parent; - if (parent) { - this.currentThisExpression = null; - this.currentElementExpression = null; - return parent; - } - if (reportMode == ReportMode.REPORT) { - this.error( - DiagnosticCode._this_cannot_be_referenced_in_current_location, - expression.range - ); - } - return null; + case NodeKind.THIS: { + return this.resolveThisExpression( + expression, + flow, contextualType, reportMode + ); } - case NodeKind.SUPER: { // -> Class - if (flow.is(FlowFlags.INLINE_CONTEXT)) { - let explicitLocal = flow.lookupLocal("super"); - if (explicitLocal) { - this.currentThisExpression = null; - this.currentElementExpression = null; - return explicitLocal; - } - } - let parent = flow.actualFunction.parent; - if (parent && parent.kind == ElementKind.CLASS && (parent = (parent).base)) { - this.currentThisExpression = null; - this.currentElementExpression = null; - return parent; - } - if (reportMode == ReportMode.REPORT) { - this.error( - DiagnosticCode._super_can_only_be_referenced_in_a_derived_class, - expression.range - ); - } - return null; + case NodeKind.SUPER: { + return this.resolveSuperExpression( + expression, + flow, contextualType, reportMode + ); } case NodeKind.IDENTIFIER: { - return this.resolveIdentifier(expression, flow, flow.actualFunction, reportMode); + return this.resolveIdentifier( + expression, + flow, flow.actualFunction, reportMode + ); } case NodeKind.LITERAL: { - switch ((expression).literalKind) { - case LiteralKind.INTEGER: { - return assert( - this.program.basicClasses.get( - this.determineIntegerLiteralType( - (expression).value, - contextualType - ).kind - ) - ); - } - case LiteralKind.FLOAT: { - this.currentThisExpression = expression; - this.currentElementExpression = null; - return assert( - this.program.basicClasses.get( - contextualType == Type.f32 - ? TypeKind.F32 - : TypeKind.F64 - ) - ); - } - case LiteralKind.STRING: { - this.currentThisExpression = expression; - this.currentElementExpression = null; - return this.program.stringInstance; - } - // case LiteralKind.ARRAY: // TODO - } - break; + return this.resolveLiteralExpression( + expression, + flow, contextualType, reportMode + ); } case NodeKind.PROPERTYACCESS: { - return this.resolvePropertyAccess( + return this.resolvePropertyAccessExpression( expression, + flow, contextualType, reportMode + ); + } + case NodeKind.ELEMENTACCESS: { + return this.resolveElementAccessExpression( + expression, + flow, contextualType, reportMode + ); + } + case NodeKind.CALL: { + return this.resolveCallExpression( + expression, + flow, contextualType, reportMode + ); + } + // TODO: everything else + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Operation_not_supported, + expression.range + ); + } + return null; + } + + /** Resolves an assertion expression to the program element it refers to. */ + resolveAssertionExpression( + /** The expression to resolve. */ + expression: AssertionExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + if (expression.assertionKind == AssertionKind.NONNULL) { + return this.resolveExpression( + expression.expression, + flow, + contextualType, + reportMode + ); + } + var type = this.resolveType( + assert(expression.toType), // must be set if not NONNULL + flow.actualFunction, + flow.contextualTypeArguments, + reportMode + ); + if (!type) return null; + var element: Element | null = type.classReference; + if (!element) { + let signature = type.signatureReference; + if (!signature) return null; + element = signature.asFunctionTarget(this.program); + } + this.currentThisExpression = null; + this.currentElementExpression = null; + return element; + } + + /** Resolves an unary prefix expression to the program element it refers to. */ + resolveUnaryPrefixExpression( + /** The expression to resolve. */ + expression: UnaryPrefixExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + var operand = expression.operand; + // TODO: operator overloads + switch (expression.operator) { + case Token.MINUS: { + // implicitly negate if an integer literal to distinguish between i32/u32/i64 + if (operand.kind == NodeKind.LITERAL && (operand).literalKind == LiteralKind.INTEGER) { + let type = this.determineIntegerLiteralType( + i64_sub(i64_zero, (operand).value), + contextualType + ); + let typeClasses = this.program.typeClasses; + return typeClasses.has(type.kind) ? typeClasses.get(type.kind)! : null; + } + return this.resolveExpression( + operand, flow, contextualType, reportMode ); } - case NodeKind.ELEMENTACCESS: { - return this.resolveElementAccess( - expression, + case Token.PLUS: + case Token.PLUS_PLUS: + case Token.MINUS_MINUS: { + return this.resolveExpression( + expression.operand, flow, contextualType, reportMode ); } - case NodeKind.CALL: { - let targetExpression = (expression).expression; - let target = this.resolveExpression(targetExpression, flow, contextualType, reportMode); - if (!target) return null; - if (target.kind == ElementKind.FUNCTION_PROTOTYPE) { - let instance = this.resolveFunctionInclTypeArguments( - target, - (expression).typeArguments, - makeMap(flow.contextualTypeArguments), - expression, - reportMode - ); - if (!instance) return null; - let returnType = instance.signature.returnType; - let classType = returnType.classReference; - if (classType) { - // reuse resolvedThisExpression (might be property access) - // reuse resolvedElementExpression (might be element access) - return classType; - } else { - let signature = returnType.signatureReference; - if (signature) { - let functionTarget = signature.asFunctionTarget(this.program); - // reuse resolvedThisExpression (might be property access) - // reuse resolvedElementExpression (might be element access) - return functionTarget; - } - } - if (reportMode == ReportMode.REPORT) { - this.error( - DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, - targetExpression.range, target.internalName - ); - } - return null; - } + case Token.EXCLAMATION: { + let typeClasses = this.program.typeClasses; + return typeClasses.has(TypeKind.BOOL) ? typeClasses.get(TypeKind.BOOL)! : null; + } + case Token.TILDE: { + let resolvedOperand = this.resolveExpression( + expression.operand, + flow, + contextualType, + reportMode + ); + if (!resolvedOperand) return null; + // TODO break; } + default: assert(false); } if (reportMode == ReportMode.REPORT) { this.error( @@ -938,91 +980,340 @@ export class Resolver extends DiagnosticEmitter { return null; } - /** Resolves a function prototype to an instance using the specified concrete type arguments. */ + /** Resolves an unary postfix expression to the program element it refers to. */ + resolveUnaryPostfixExpression( + /** The expression to resolve. */ + expression: UnaryPostfixExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + // TODO: operator overloads + switch (expression.operator) { + case Token.PLUS_PLUS: + case Token.MINUS_MINUS: { + return this.resolveExpression( + expression.operand, + flow, + contextualType, + reportMode + ); + } + default: assert(false); + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Operation_not_supported, + expression.range + ); + } + return null; + } + + /** Resolves a binary expression to the program element it refers to. */ + resolveBinaryExpression( + /** The expression to resolve. */ + expression: BinaryExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + // TODO + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Operation_not_supported, + expression.range + ); + } + return null; + } + + /** Resolves a this expression to the program element it refers to. */ + resolveThisExpression( + /** The expression to resolve. */ + expression: ThisExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + if (flow.is(FlowFlags.INLINE_CONTEXT)) { + let thisLocal = flow.lookupLocal(CommonSymbols.this_); + if (thisLocal) { + this.currentThisExpression = null; + this.currentElementExpression = null; + return thisLocal; + } + } + var parent = flow.actualFunction.parent; + if (parent) { + this.currentThisExpression = null; + this.currentElementExpression = null; + return parent; + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode._this_cannot_be_referenced_in_current_location, + expression.range + ); + } + return null; + } + + /** Resolves a super expression to the program element it refers to. */ + resolveSuperExpression( + /** The expression to resolve. */ + expression: SuperExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + if (flow.is(FlowFlags.INLINE_CONTEXT)) { + let superLocal = flow.lookupLocal(CommonSymbols.super_); + if (superLocal) { + this.currentThisExpression = null; + this.currentElementExpression = null; + return superLocal; + } + } + var parent: Element | null = flow.actualFunction.parent; + if (parent && parent.kind == ElementKind.CLASS && (parent = (parent).base)) { + this.currentThisExpression = null; + this.currentElementExpression = null; + return parent; + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode._super_can_only_be_referenced_in_a_derived_class, + expression.range + ); + } + return null; + } + + /** Resolves a literal expression to the program element it refers to. */ + resolveLiteralExpression( + /** The expression to resolve. */ + expression: LiteralExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + switch (expression.literalKind) { + case LiteralKind.INTEGER: { + this.currentThisExpression = expression; + this.currentElementExpression = null; + let literalType = this.determineIntegerLiteralType( + (expression).value, + contextualType + ); + let typeClasses = this.program.typeClasses; + return typeClasses.has(literalType.kind) ? typeClasses.get(literalType.kind)! : null; + } + case LiteralKind.FLOAT: { + this.currentThisExpression = expression; + this.currentElementExpression = null; + let literalType = contextualType == Type.f32 ? Type.f32 : Type.f64; + let typeClasses = this.program.typeClasses; + return typeClasses.has(literalType.kind) ? typeClasses.get(literalType.kind)! : null; + } + case LiteralKind.STRING: { + this.currentThisExpression = expression; + this.currentElementExpression = null; + return this.program.stringInstance; + } + // TODO + // case LiteralKind.ARRAY: + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Operation_not_supported, + expression.range + ); + } + return null; + } + + /** Resolves a call expression to the program element it refers to. */ + resolveCallExpression( + /** The expression to resolve. */ + expression: CallExpression, + /** Current flow. */ + flow: Flow, + /** Current contextual type. */ + contextualType: Type = Type.void, + /** How to proceed with eventualy diagnostics. */ + reportMode: ReportMode = ReportMode.REPORT + ): Element | null { + var targetExpression = expression.expression; + var target = this.resolveExpression( // reports + targetExpression, + flow, + contextualType, + reportMode + ); + if (!target) return null; + if (target.kind == ElementKind.FUNCTION_PROTOTYPE) { + let instance = this.resolveFunctionInclTypeArguments( + target, + expression.typeArguments, + flow.actualFunction, + makeMap(flow.contextualTypeArguments), // don't inherit + expression, + reportMode + ); + if (!instance) return null; + let returnType = instance.signature.returnType; + let classType = returnType.classReference; + if (classType) { + // reuse resolvedThisExpression (might be property access) + // reuse resolvedElementExpression (might be element access) + return classType; + } else { + let signature = returnType.signatureReference; + if (signature) { + let functionTarget = signature.asFunctionTarget(this.program); + // reuse resolvedThisExpression (might be property access) + // reuse resolvedElementExpression (might be element access) + return functionTarget; + } + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, + targetExpression.range, target.internalName + ); + } + return null; + } + if (reportMode == ReportMode.REPORT) { + this.error( + DiagnosticCode.Operation_not_supported, + expression.range + ); + } + return null; + } + + /** Resolves a function prototype using the specified concrete type arguments. */ resolveFunction( + /** The prototype of the function. */ prototype: FunctionPrototype, + /** Concrete type arguments. */ typeArguments: Type[] | null, + /** Type arguments inherited through context, i.e. `T`. */ contextualTypeArguments: Map = makeMap(), + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Function | null { - var classTypeArguments = prototype.classTypeArguments; // set only if partially resolved - var classInstanceKey = classTypeArguments ? typesToString(classTypeArguments) : ""; + var actualParent = prototype.parent.kind == ElementKind.PROPERTY_PROTOTYPE + ? prototype.parent.parent + : prototype.parent; + var classInstance: Class | null = null; // if an instance method var instanceKey = typeArguments ? typesToString(typeArguments) : ""; - var classInstances = prototype.instances.get(classInstanceKey); - if (classInstances) { - let instance = classInstances.get(instanceKey); - if (instance) return instance; - } - - var declaration = prototype.declaration; - var isInstance = prototype.is(CommonFlags.INSTANCE); - var classPrototype = prototype.classPrototype; - // apply class type arguments if a partially resolved instance method - if (classTypeArguments) prototype.applyClassTypeArguments(contextualTypeArguments); + // Instance method prototypes are pre-bound to their concrete class as their parent + if (prototype.is(CommonFlags.INSTANCE)) { + assert(actualParent.kind == ElementKind.CLASS); + classInstance = actualParent; + + // check if this exact concrete class and function combination is known already + let resolvedInstance = prototype.getResolvedInstance(instanceKey); + if (resolvedInstance) return resolvedInstance; + + // inherit class specific type arguments + let classTypeArguments = classInstance.typeArguments; + if (classTypeArguments) { + let classTypeParameters = assert(classInstance.prototype.typeParameterNodes); + let numClassTypeArguments = classTypeParameters.length; + assert(numClassTypeArguments == classTypeParameters.length); + for (let i = 0; i < numClassTypeArguments; ++i) { + let classTypeParameterName = classTypeParameters[i].name.text; + if (!contextualTypeArguments.has(classTypeParameterName)) { + contextualTypeArguments.set( + classTypeParameterName, + classTypeArguments[i] + ); + } + } + } + } else { + assert(actualParent.kind != ElementKind.CLASS); // must not be pre-bound + let resolvedInstance = prototype.getResolvedInstance(instanceKey); + if (resolvedInstance) return resolvedInstance; + } - // override with function specific type arguments - var signatureNode = declaration.signature; - var functionTypeParameters = declaration.typeParameters; + // override whatever is contextual with actual function type arguments + var signatureNode = prototype.signatureNode; + var typeParameterNodes = prototype.typeParameterNodes; var numFunctionTypeArguments: i32; if (typeArguments && (numFunctionTypeArguments = typeArguments.length)) { - assert(functionTypeParameters && numFunctionTypeArguments == functionTypeParameters.length); + assert(typeParameterNodes && numFunctionTypeArguments == typeParameterNodes.length); for (let i = 0; i < numFunctionTypeArguments; ++i) { contextualTypeArguments.set( - (functionTypeParameters)[i].name.text, + (typeParameterNodes)[i].name.text, typeArguments[i] ); } } else { - assert(!functionTypeParameters || functionTypeParameters.length == 0); + assert(!typeParameterNodes || typeParameterNodes.length == 0); } - // resolve class if an instance method - var classInstance: Class | null = null; + // resolve `this` type if applicable var thisType: Type | null = null; - if (isInstance) { - classInstance = this.resolveClass( - assert(classPrototype), - classTypeArguments, + var explicitThisType = signatureNode.explicitThisType; + if (explicitThisType) { + thisType = this.resolveType( + explicitThisType, + prototype.parent, // relative to function contextualTypeArguments, reportMode ); - if (!classInstance) return null; - let explicitThisType = signatureNode.explicitThisType; - if (explicitThisType) { - thisType = this.resolveType(explicitThisType, contextualTypeArguments, reportMode); - if (!thisType) return null; - } else { - thisType = classInstance.type; - } - contextualTypeArguments.set("this", thisType); - } else { - if (signatureNode.explicitThisType) { - this.error( - DiagnosticCode._this_cannot_be_referenced_in_current_location, - signatureNode.explicitThisType.range - ); // recoverable - } + if (!thisType) return null; + contextualTypeArguments.set(CommonSymbols.this_, thisType); + } else if (classInstance) { + thisType = classInstance.type; + contextualTypeArguments.set(CommonSymbols.this_, thisType); } - // resolve signature node + // resolve parameter types var signatureParameters = signatureNode.parameters; - var signatureParameterCount = signatureParameters.length; - var parameterTypes = new Array(signatureParameterCount); - var parameterNames = new Array(signatureParameterCount); + var numSignatureParameters = signatureParameters.length; + var parameterTypes = new Array(numSignatureParameters); + var parameterNames = new Array(numSignatureParameters); var requiredParameters = 0; - for (let i = 0; i < signatureParameterCount; ++i) { + for (let i = 0; i < numSignatureParameters; ++i) { let parameterDeclaration = signatureParameters[i]; if (parameterDeclaration.parameterKind == ParameterKind.DEFAULT) { requiredParameters = i + 1; } let typeNode = assert(parameterDeclaration.type); - let parameterType = this.resolveType(typeNode, contextualTypeArguments, reportMode); + let parameterType = this.resolveType( + typeNode, + prototype.parent, // relative to function + contextualTypeArguments, + reportMode + ); if (!parameterType) return null; parameterTypes[i] = parameterType; parameterNames[i] = parameterDeclaration.name.text; } + // resolve return type var returnType: Type; if (prototype.is(CommonFlags.SET)) { returnType = Type.void; // not annotated @@ -1030,7 +1321,12 @@ export class Resolver extends DiagnosticEmitter { returnType = assert(classInstance).type; // not annotated } else { let typeNode = assert(signatureNode.returnType); - let type = this.resolveType(typeNode, contextualTypeArguments, reportMode); + let type = this.resolveType( + typeNode, + prototype.parent, // relative to function + contextualTypeArguments, + reportMode + ); if (!type) return null; returnType = type; } @@ -1039,73 +1335,62 @@ export class Resolver extends DiagnosticEmitter { signature.parameterNames = parameterNames; signature.requiredParameters = requiredParameters; - var internalName = prototype.internalName; - if (instanceKey.length) internalName += "<" + instanceKey + ">"; + var nameInclTypeParameters = prototype.name; + if (instanceKey.length) nameInclTypeParameters += "<" + instanceKey + ">"; var instance = new Function( + nameInclTypeParameters, prototype, - internalName, signature, - classInstance - ? classInstance - : classPrototype, contextualTypeArguments ); - if (!classInstances) prototype.instances.set(classInstanceKey, classInstances = new Map()); - classInstances.set(instanceKey, instance); - this.program.instancesLookup.set(internalName, instance); + prototype.setResolvedInstance(instanceKey, instance); return instance; } - /** Resolves a function prototype partially by applying the specified type arguments. */ - resolveFunctionPartially( - prototype: FunctionPrototype, - typeArguments: Type[] | null, - reportMode: ReportMode = ReportMode.REPORT - ): FunctionPrototype | null { - assert(prototype.is(CommonFlags.INSTANCE)); - var classPrototype = assert(prototype.classPrototype); - - if (!(typeArguments && typeArguments.length)) return prototype; // no need to clone - - var simpleName = prototype.simpleName; - var partialKey = typesToString(typeArguments); - var partialPrototype = new FunctionPrototype( - this.program, - simpleName, - classPrototype.internalName + "<" + partialKey + ">" + INSTANCE_DELIMITER + simpleName, - prototype.declaration, - classPrototype, - prototype.decoratorFlags - ); - partialPrototype.flags = prototype.flags; - partialPrototype.operatorKind = prototype.operatorKind; - partialPrototype.classTypeArguments = typeArguments; - partialPrototype.instances = prototype.instances; - return partialPrototype; - } - - /** Resolves a function prototype to an instance by first resolving the specified type arguments. */ + /** Resolves a function prototypeby first resolving the specified type arguments. */ resolveFunctionInclTypeArguments( + /** The prototype of the function. */ prototype: FunctionPrototype, + /** Type arguments provided. */ typeArgumentNodes: CommonTypeNode[] | null, + /** Relative context. Type arguments are resolved from here. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ contextualTypeArguments: Map, + /** The node to use when reporting intermediate errors. */ reportNode: Node, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Function | null { + var actualParent = prototype.parent.kind == ElementKind.PROPERTY_PROTOTYPE + ? prototype.parent.parent + : prototype.parent; var resolvedTypeArguments: Type[] | null = null; // Resolve type arguments if generic if (prototype.is(CommonFlags.GENERIC)) { - // apply class type arguments if a partially resolved instance method - // FIXME: this is done once more in resolveFunction. required here for resolveTypeArguments, - // required there for just resolving a function no matter if a partial or not. - let classTypeArguments = prototype.classTypeArguments; - if (classTypeArguments) prototype.applyClassTypeArguments(contextualTypeArguments); + // If this is an instance method, first apply the class's type arguments + if (prototype.is(CommonFlags.INSTANCE)) { + assert(actualParent.kind == ElementKind.CLASS); + let classTypeArguments = (actualParent).typeArguments; + if (classTypeArguments) { + let typeParameterNodes = assert((actualParent).prototype.typeParameterNodes); + let numClassTypeArguments = classTypeArguments.length; + assert(numClassTypeArguments == typeParameterNodes.length); + for (let i = 0; i < numClassTypeArguments; ++i) { + contextualTypeArguments.set( + typeParameterNodes[i].name.text, + classTypeArguments[i] + ); + } + } + } resolvedTypeArguments = this.resolveTypeArguments( // reports - assert(prototype.declaration.typeParameters), + assert(prototype.typeParameterNodes), typeArgumentNodes, + context, contextualTypeArguments, reportNode, reportMode @@ -1136,161 +1421,123 @@ export class Resolver extends DiagnosticEmitter { /** Resolves a class prototype using the specified concrete type arguments. */ resolveClass( + /** The prototype of the class. */ prototype: ClassPrototype, + /** Concrete type arguments. */ typeArguments: Type[] | null, + /** Type arguments inherited through context, i.e. `T`. */ contextualTypeArguments: Map = makeMap(), + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Class | null { var instanceKey = typeArguments ? typesToString(typeArguments) : ""; // Check if this exact instance has already been resolved - var instance = prototype.instances.get(instanceKey); + var instance = prototype.getResolvedInstance(instanceKey); if (instance) return instance; // Insert contextual type arguments for this operation. Internally, this method is always // called with matching type parameter / argument counts. - var declaration = prototype.declaration; if (typeArguments) { - let typeParameters = declaration.typeParameters; - let expectedTypeArguments = typeParameters.length; - let actualTypeArguments = typeArguments.length; - assert(actualTypeArguments == expectedTypeArguments); - for (let i = 0; i < actualTypeArguments; ++i) { - contextualTypeArguments.set(typeParameters[i].name.text, typeArguments[i]); + let typeParameterNodes = assert(prototype.typeParameterNodes); + let numTypeParameters = typeParameterNodes.length; + let numTypeArguments = typeArguments.length; + assert(numTypeArguments == numTypeParameters); + for (let i = 0; i < numTypeArguments; ++i) { + contextualTypeArguments.set(typeParameterNodes[i].name.text, typeArguments[i]); } } else { - assert(declaration.typeParameters.length == 0); + let typeParameterNodes = prototype.typeParameterNodes; + assert(!(typeParameterNodes && typeParameterNodes.length)); } // Resolve base class if applicable + var basePrototype = prototype.basePrototype; var baseClass: Class | null = null; - if (declaration.extendsType) { - let baseClassType = this.resolveType( - declaration.extendsType, - contextualTypeArguments, + if (basePrototype) { + let extendsNode = assert(prototype.extendsNode); // must be present if it has a base prototype + baseClass = this.resolveClassInclTypeArguments( + basePrototype, + extendsNode.typeArguments, + prototype.parent, // relative to derived class + makeMap(contextualTypeArguments), // don't inherit + extendsNode, reportMode ); - if (!baseClassType) return null; - if (!(baseClass = baseClassType.classReference)) { - if (reportMode == ReportMode.REPORT) { - this.program.error( - DiagnosticCode.A_class_may_only_extend_another_class, - declaration.extendsType.range - ); - } - return null; - } - if (baseClass.hasDecorator(DecoratorFlags.SEALED)) { - if (reportMode == ReportMode.REPORT) { - this.program.error( - DiagnosticCode.Class_0_is_sealed_and_cannot_be_extended, - declaration.extendsType.range, baseClass.internalName - ); - } - return null; - } - if (baseClass.hasDecorator(DecoratorFlags.UNMANAGED) != prototype.hasDecorator(DecoratorFlags.UNMANAGED)) { - if (reportMode == ReportMode.REPORT) { - this.program.error( - DiagnosticCode.Unmanaged_classes_cannot_extend_managed_classes_and_vice_versa, - Range.join(declaration.name.range, declaration.extendsType.range) - ); - } - return null; - } + if (!baseClass) return null; } // Construct the instance and remember that it has been resolved already - var simpleName = prototype.simpleName; - var internalName = prototype.internalName; - if (instanceKey.length) { - simpleName += "<" + instanceKey + ">"; - internalName += "<" + instanceKey + ">"; - } - instance = new Class(prototype, simpleName, internalName, typeArguments, baseClass); + var nameInclTypeParamters = prototype.name; + if (instanceKey.length) nameInclTypeParamters += "<" + instanceKey + ">"; + instance = new Class(nameInclTypeParamters, prototype, typeArguments, baseClass); instance.contextualTypeArguments = contextualTypeArguments; - prototype.instances.set(instanceKey, instance); - this.program.instancesLookup.set(internalName, instance); + prototype.setResolvedInstance(instanceKey, instance); // Inherit base class members and set up the initial memory offset for own fields var memoryOffset: u32 = 0; if (baseClass) { - if (baseClass.members) { - if (!instance.members) instance.members = new Map(); - for (let inheritedMember of baseClass.members.values()) { - instance.members.set(inheritedMember.simpleName, inheritedMember); + let baseMembers = baseClass.members; + if (baseMembers) { + let instanceMembers = instance.members; + if (!instanceMembers) instance.members = instanceMembers = new Map(); + for (let [baseMemberName, baseMember] of baseMembers) { + instanceMembers.set(baseMemberName, baseMember); } } memoryOffset = baseClass.currentMemoryOffset; } - // Resolve constructor by first applying the class type arguments - var constructorPrototype = prototype.constructorPrototype; - if (constructorPrototype) { - let constructorPartial = this.resolveFunctionPartially( - constructorPrototype, - typeArguments, - reportMode - ); - if (!constructorPartial) return null; - instance.constructorInstance = this.resolveFunction( - constructorPartial, - null, - makeMap(), - reportMode - ); - } - // Resolve instance members - if (prototype.instanceMembers) { - for (let member of prototype.instanceMembers.values()) { + var instanceMemberPrototypes = prototype.instanceMembers; + if (instanceMemberPrototypes) { + for (let member of instanceMemberPrototypes.values()) { switch (member.kind) { // Lay out fields in advance case ElementKind.FIELD_PROTOTYPE: { - let fieldDeclaration = (member).declaration; - if (!instance.members) instance.members = new Map(); - else if (instance.members.has(member.simpleName)) { + let instanceMembers = instance.members; + if (!instanceMembers) instance.members = instanceMembers = new Map(); + else if (instanceMembers.has(member.name)) { this.error( DiagnosticCode.Duplicate_identifier_0, - fieldDeclaration.name.range, - member.simpleName + (member).identifierNode.range, + member.name ); break; } + let fieldTypeNode = (member).typeNode; let fieldType: Type | null = null; - // TODO: handle duplicate non-private fields - if (!fieldDeclaration.type) { - if (baseClass !== null && baseClass.members !== null) { - let baseField = baseClass.members.get((member).simpleName); - if (baseField && !baseField.is(CommonFlags.PRIVATE)) { - assert(baseField.kind == ElementKind.FIELD); - fieldType = (baseField).type; + // TODO: handle duplicate non-private fields specifically? + if (!fieldTypeNode) { + if (baseClass) { + let baseMembers = baseClass.members; + if (baseMembers && baseMembers.has((member).name)) { + let baseField = baseMembers.get((member).name)!; + if (!baseField.is(CommonFlags.PRIVATE)) { + assert(baseField.kind == ElementKind.FIELD); + fieldType = (baseField).type; + } } } if (!fieldType) { if (reportMode == ReportMode.REPORT) { this.error( DiagnosticCode.Type_expected, - fieldDeclaration.name.range.atEnd + (member).identifierNode.range.atEnd ); } } } else { fieldType = this.resolveType( - fieldDeclaration.type, + fieldTypeNode, + prototype.parent, // relative to class instance.contextualTypeArguments, reportMode ); } - if (!fieldType) break; - let fieldInstance = new Field( - member, - internalName + INSTANCE_DELIMITER + (member).simpleName, - fieldType, - fieldDeclaration, - instance - ); + if (!fieldType) break; // did report above + let fieldInstance = new Field(member, instance, fieldType); switch (fieldType.byteSize) { // align case 1: break; case 2: { if (memoryOffset & 1) ++memoryOffset; break; } @@ -1300,56 +1547,46 @@ export class Resolver extends DiagnosticEmitter { } fieldInstance.memoryOffset = memoryOffset; memoryOffset += fieldType.byteSize; - instance.members.set(member.simpleName, fieldInstance); + instance.add(member.name, fieldInstance); // reports break; } - - // Partially resolve methods as these might have type arguments on their own case ElementKind.FUNCTION_PROTOTYPE: { - if (!instance.members) instance.members = new Map(); - let partialPrototype = this.resolveFunctionPartially( - member, - typeArguments, - reportMode - ); - if (!partialPrototype) return null; - partialPrototype.internalName = internalName + INSTANCE_DELIMITER + partialPrototype.simpleName; - instance.members.set(member.simpleName, partialPrototype); + let boundPrototype = (member).toBound(instance); + instance.add(boundPrototype.name, boundPrototype); // reports break; } - - // Clone properties and partially resolve the wrapped accessors for consistence with other methods - case ElementKind.PROPERTY: { - if (!instance.members) instance.members = new Map(); - let getterPrototype = assert((member).getterPrototype); // must be present - let setterPrototype = (member).setterPrototype; // might be present - let instanceProperty = new Property( - this.program, - member.simpleName, - internalName + INSTANCE_DELIMITER + member.simpleName, - prototype - ); - let partialGetterPrototype = this.resolveFunctionPartially( - getterPrototype, - typeArguments, - reportMode - ); - if (!partialGetterPrototype) return null; - partialGetterPrototype - .internalName = internalName + INSTANCE_DELIMITER + partialGetterPrototype.simpleName; - instanceProperty.getterPrototype = partialGetterPrototype; + case ElementKind.PROPERTY_PROTOTYPE: { + let propertyInstance = new Property(member, instance); + let getterPrototype = (member).getterPrototype; + if (getterPrototype) { + let getterInstance = this.resolveFunction( + getterPrototype.toBound(instance), + null, + makeMap(instance.contextualTypeArguments), + reportMode + ); + if (getterInstance) { + propertyInstance.getterInstance = getterInstance; + propertyInstance.setType(getterInstance.signature.returnType); + } + } + let setterPrototype = (member).setterPrototype; if (setterPrototype) { - let partialSetterPrototype = this.resolveFunctionPartially( - setterPrototype, - typeArguments, + let setterInstance = this.resolveFunction( + setterPrototype.toBound(instance), + null, + makeMap(instance.contextualTypeArguments), reportMode ); - if (!partialSetterPrototype) return null; - partialSetterPrototype - .internalName = internalName + INSTANCE_DELIMITER + partialSetterPrototype.simpleName; - instanceProperty.setterPrototype = partialSetterPrototype; + if (setterInstance) { + propertyInstance.setterInstance = setterInstance; + if (!propertyInstance.is(CommonFlags.RESOLVED)) { + assert(setterInstance.signature.parameterTypes.length == 1); + propertyInstance.setType(setterInstance.signature.parameterTypes[0]); + } + } } - instance.members.set(member.simpleName, instanceProperty); + instance.add(propertyInstance.name, propertyInstance); // reports break; } default: assert(false); @@ -1360,19 +1597,29 @@ export class Resolver extends DiagnosticEmitter { // Finalize memory offset instance.currentMemoryOffset = memoryOffset; + // Link _own_ constructor if present + { + let ctorPrototype = instance.lookupInSelf(CommonSymbols.constructor); + if (ctorPrototype && ctorPrototype.parent === instance) { + assert(ctorPrototype.kind == ElementKind.FUNCTION_PROTOTYPE); + let ctorInstance = this.resolveFunction( + ctorPrototype, + null, + instance.contextualTypeArguments, + reportMode + ); + if (ctorInstance) instance.constructorInstance = ctorInstance; + } + } + // Fully resolve operator overloads (don't have type parameters on their own) for (let [kind, overloadPrototype] of prototype.overloadPrototypes) { assert(kind != OperatorKind.INVALID); let operatorInstance: Function | null; if (overloadPrototype.is(CommonFlags.INSTANCE)) { - let operatorPartial = this.resolveFunctionPartially( - overloadPrototype, - typeArguments, - reportMode - ); - if (!operatorPartial) continue; + let boundPrototype = overloadPrototype.toBound(instance); operatorInstance = this.resolveFunction( - operatorPartial, + boundPrototype, null, makeMap(), reportMode @@ -1395,19 +1642,27 @@ export class Resolver extends DiagnosticEmitter { /** Resolves a class prototype by first resolving the specified type arguments. */ resolveClassInclTypeArguments( + /** The prototype of the class. */ prototype: ClassPrototype, + /** Type argument nodes provided. */ typeArgumentNodes: CommonTypeNode[] | null, + /** Relative context. Type arguments are resolved from here. */ + context: Element, + /** Type arguments inherited through context, i.e. `T`. */ contextualTypeArguments: Map, + /** The node to use when reporting intermediate errors. */ reportNode: Node, + /** How to proceed with eventualy diagnostics. */ reportMode: ReportMode = ReportMode.REPORT ): Class | null { var resolvedTypeArguments: Type[] | null = null; // Resolve type arguments if generic if (prototype.is(CommonFlags.GENERIC)) { - resolvedTypeArguments = this.resolveTypeArguments( - assert(prototype.declaration.typeParameters), + resolvedTypeArguments = this.resolveTypeArguments( // reports + assert(prototype.typeParameterNodes), // must be present if generic typeArgumentNodes, + context, contextualTypeArguments, reportNode, reportMode diff --git a/src/types.ts b/src/types.ts index 2f2fd0f9e7..76908b7661 100644 --- a/src/types.ts +++ b/src/types.ts @@ -258,8 +258,8 @@ export class Type { let classReference = this.classReference; if (classReference) { return this.is(TypeFlags.NULLABLE) - ? classReference.toString() + " | null" - : classReference.toString(); + ? classReference.name + " | null" + : classReference.name; } let signatureReference = this.signatureReference; if (signatureReference) { @@ -551,7 +551,7 @@ export class Signature { asFunctionTarget(program: Program): FunctionTarget { var target = this.cachedFunctionTarget; - if (!target) this.cachedFunctionTarget = target = new FunctionTarget(program, this); + if (!target) this.cachedFunctionTarget = target = new FunctionTarget(this, program); else assert(target.program == program); return target; } diff --git a/src/util/collections.ts b/src/util/collections.ts index 921d497af9..f854d6af7f 100644 --- a/src/util/collections.ts +++ b/src/util/collections.ts @@ -16,11 +16,13 @@ export function makeSet(original: Set | null = null): Set { return new Set(); } -export function makeMap(original: Map | null = null): Map { +export function makeMap(original: Map | null = null, overrides: Map | null = null): Map { + var cloned = new Map(); if (original) { - let cloned = new Map(); for (let [k, v] of original) cloned.set(k, v); - return cloned; + if (overrides) for (let [k, v] of overrides) cloned.set(k, v); + } else if (overrides) { + for (let [k, v] of overrides) cloned.set(k, v); } - return new Map(); + return cloned; } diff --git a/std/assembly/builtins.ts b/std/assembly/builtins.ts index c8dd2ec33c..370047ad3c 100644 --- a/std/assembly/builtins.ts +++ b/std/assembly/builtins.ts @@ -59,20 +59,20 @@ export namespace atomic { @builtin export declare function i8(value: void): i8; export namespace i8 { - export const MIN_VALUE: i8 = -128; - export const MAX_VALUE: i8 = 127; + @lazy export const MIN_VALUE: i8 = -128; + @lazy export const MAX_VALUE: i8 = 127; } @builtin export declare function i16(value: void): i16; export namespace i16 { - export const MIN_VALUE: i16 = -32768; - export const MAX_VALUE: i16 = 32767; + @lazy export const MIN_VALUE: i16 = -32768; + @lazy export const MAX_VALUE: i16 = 32767; } @builtin export declare function i32(value: void): i32; export namespace i32 { - export const MIN_VALUE: i32 = -2147483648; - export const MAX_VALUE: i32 = 2147483647; + @lazy export const MIN_VALUE: i32 = -2147483648; + @lazy export const MAX_VALUE: i32 = 2147483647; @builtin export declare function clz(value: i32): i32; @builtin export declare function ctz(value: i32): i32; @builtin export declare function popcnt(value: i32): i32; @@ -134,8 +134,8 @@ export namespace i32 { @builtin export declare function i64(value: void): i64; export namespace i64 { - export const MIN_VALUE: i64 = -9223372036854775808; - export const MAX_VALUE: i64 = 9223372036854775807; + @lazy export const MIN_VALUE: i64 = -9223372036854775808; + @lazy export const MAX_VALUE: i64 = 9223372036854775807; @builtin export declare function clz(value: i64): i64; @builtin export declare function ctz(value: i64): i64; @builtin export declare function load8_s(offset: usize, constantOffset?: usize): i64; @@ -210,60 +210,60 @@ export namespace i64 { @builtin export declare function isize(value: void): isize; export namespace isize { - export const MIN_VALUE: isize = sizeof() == sizeof() + @lazy export const MIN_VALUE: isize = sizeof() == sizeof() ? -2147483648 : -9223372036854775808; - export const MAX_VALUE: isize = sizeof() == sizeof() + @lazy export const MAX_VALUE: isize = sizeof() == sizeof() ? 2147483647 : 9223372036854775807; } @builtin export declare function u8(value: void): u8; export namespace u8 { - export const MIN_VALUE: u8 = 0; - export const MAX_VALUE: u8 = 255; + @lazy export const MIN_VALUE: u8 = 0; + @lazy export const MAX_VALUE: u8 = 255; } @builtin export declare function u16(value: void): u16; export namespace u16 { - export const MIN_VALUE: u16 = 0; - export const MAX_VALUE: u16 = 65535; + @lazy export const MIN_VALUE: u16 = 0; + @lazy export const MAX_VALUE: u16 = 65535; } @builtin export declare function u32(value: void): u32; export namespace u32 { - export const MIN_VALUE: u32 = 0; - export const MAX_VALUE: u32 = 4294967295; + @lazy export const MIN_VALUE: u32 = 0; + @lazy export const MAX_VALUE: u32 = 4294967295; } @builtin export declare function u64(value: void): u64; export namespace u64 { - export const MIN_VALUE: u64 = 0; - export const MAX_VALUE: u64 = 18446744073709551615; + @lazy export const MIN_VALUE: u64 = 0; + @lazy export const MAX_VALUE: u64 = 18446744073709551615; } @builtin export declare function usize(value: void): usize; export namespace usize { - export const MIN_VALUE: usize = 0; - export const MAX_VALUE: usize = sizeof() == sizeof() + @lazy export const MIN_VALUE: usize = 0; + @lazy export const MAX_VALUE: usize = sizeof() == sizeof() ? 4294967295 : 18446744073709551615; } @builtin export declare function bool(value: void): bool; export namespace bool { - export const MIN_VALUE: bool = false; - export const MAX_VALUE: bool = true; + @lazy export const MIN_VALUE: bool = false; + @lazy export const MAX_VALUE: bool = true; } @builtin export declare function f32(value: void): f32; export namespace f32 { - export const EPSILON = reinterpret(0x34000000); // 0x1p-23f - export const MIN_VALUE = reinterpret(0x00000001); // 0x0.000001p+0f - export const MAX_VALUE = reinterpret(0x7F7FFFFF); // 0x1.fffffep+127f - export const MIN_NORMAL_VALUE = reinterpret(0x00800000); // 0x1p-126f - export const MIN_SAFE_INTEGER: f32 = -16777215; - export const MAX_SAFE_INTEGER: f32 = 16777215; + @lazy export const EPSILON = reinterpret(0x34000000); // 0x1p-23f + @lazy export const MIN_VALUE = reinterpret(0x00000001); // 0x0.000001p+0f + @lazy export const MAX_VALUE = reinterpret(0x7F7FFFFF); // 0x1.fffffep+127f + @lazy export const MIN_NORMAL_VALUE = reinterpret(0x00800000); // 0x1p-126f + @lazy export const MIN_SAFE_INTEGER: f32 = -16777215; + @lazy export const MAX_SAFE_INTEGER: f32 = 16777215; @builtin export declare function abs(value: f32): f32; @builtin export declare function ceil(value: f32): f32; @builtin export declare function copysign(x: f32, y: f32): f32; @@ -280,12 +280,12 @@ export namespace f32 { @builtin export declare function f64(value: void): f64; export namespace f64 { - export const EPSILON = reinterpret(0x3CB0000000000000); // 0x1p-52 - export const MIN_VALUE = reinterpret(0x0000000000000001); // 0x0.0000000000001p+0 - export const MAX_VALUE = reinterpret(0x7FEFFFFFFFFFFFFF); // 0x1.fffffffffffffp+1023 - export const MIN_NORMAL_VALUE = reinterpret(0x0010000000000000); // 0x1p-1022 - export const MIN_SAFE_INTEGER: f64 = -9007199254740991; - export const MAX_SAFE_INTEGER: f64 = 9007199254740991; + @lazy export const EPSILON = reinterpret(0x3CB0000000000000); // 0x1p-52 + @lazy export const MIN_VALUE = reinterpret(0x0000000000000001); // 0x0.0000000000001p+0 + @lazy export const MAX_VALUE = reinterpret(0x7FEFFFFFFFFFFFFF); // 0x1.fffffffffffffp+1023 + @lazy export const MIN_NORMAL_VALUE = reinterpret(0x0010000000000000); // 0x1p-1022 + @lazy export const MIN_SAFE_INTEGER: f64 = -9007199254740991; + @lazy export const MAX_SAFE_INTEGER: f64 = 9007199254740991; @builtin export declare function abs(value: f64): f64; @builtin export declare function ceil(value: f64): f64; @builtin export declare function copysign(x: f64, y: f64): f64; @@ -301,5 +301,3 @@ export namespace f64 { } @builtin export declare function start(): void; - -@builtin export function NATIVE_CODE(): void { unreachable(); } diff --git a/std/assembly/collector/itcm.ts b/std/assembly/collector/itcm.ts index 14d5e039f7..0dbeb5487c 100644 --- a/std/assembly/collector/itcm.ts +++ b/std/assembly/collector/itcm.ts @@ -6,10 +6,10 @@ // Largely based on Bach Le's μgc, see: https://github.com/bullno1/ugc -const TRACE = false; +@inline const TRACE = false; /** Size of a managed object header. */ -export const HEADER_SIZE: usize = (offsetof() + AL_MASK) & ~AL_MASK; +@inline export const HEADER_SIZE: usize = (offsetof() + AL_MASK) & ~AL_MASK; import { AL_MASK, MAX_SIZE_32 } from "../internal/allocator"; import { iterateRoots } from "../gc"; diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index 635a5b47f5..d91cc791af 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -38,8 +38,6 @@ declare type f64 = number; /** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */ declare const ASC_TARGET: i32; -/** Provided noTreeshaking option. */ -declare const ASC_NO_TREESHAKING: bool; /** Provided noAssert option. */ declare const ASC_NO_ASSERT: bool; /** Provided memoryBase option. */ @@ -354,7 +352,7 @@ declare namespace f64 { export function store(offset: usize, value: f64, constantOffset?: usize): void; } /** Macro type evaluating to the underlying native WebAssembly type. */ -declare type NATIVE = T; +declare type native = T; /** Pseudo-class representing the backing class of integer types. */ declare class _Integer { @@ -966,7 +964,7 @@ declare function unmanaged(constructor: Function): void; /** Annotates a class as being sealed / non-derivable. */ declare function sealed(constructor: Function): void; -/** Annotates a method or function as always inlined. */ +/** Annotates a method, function or constant global as always inlined. */ declare function inline( target: any, propertyKey: string, @@ -979,3 +977,17 @@ declare function external(namespace: string, name: string): ( propertyKey: string, descriptor: TypedPropertyDescriptor ) => TypedPropertyDescriptor | void; + +/** Annotates a global for lazy compilation. */ +declare function lazy( + target: any, + propertyKey: string, + descriptor: TypedPropertyDescriptor +): TypedPropertyDescriptor | void; + +/** Annotates a function as the explicit start function. */ +declare function start( + target: any, + propertyKey: string, + descriptor: TypedPropertyDescriptor +): TypedPropertyDescriptor | void; diff --git a/std/assembly/internal/allocator.ts b/std/assembly/internal/allocator.ts index 04248ad903..508710c6cf 100644 --- a/std/assembly/internal/allocator.ts +++ b/std/assembly/internal/allocator.ts @@ -1,8 +1,8 @@ /** Number of alignment bits. */ -export const AL_BITS: u32 = 3; +@inline export const AL_BITS: u32 = 3; /** Number of possible alignment values. */ -export const AL_SIZE: usize = 1 << AL_BITS; +@inline export const AL_SIZE: usize = 1 << AL_BITS; /** Mask to obtain just the alignment bits. */ -export const AL_MASK: usize = AL_SIZE - 1; +@inline export const AL_MASK: usize = AL_SIZE - 1; /** Maximum 32-bit allocation size. */ -export const MAX_SIZE_32: usize = 1 << 30; // 1GB +@inline export const MAX_SIZE_32: usize = 1 << 30; // 1GB diff --git a/std/assembly/internal/arraybuffer.ts b/std/assembly/internal/arraybuffer.ts index faf8facd41..4545d8e0d3 100644 --- a/std/assembly/internal/arraybuffer.ts +++ b/std/assembly/internal/arraybuffer.ts @@ -4,9 +4,9 @@ import { } from "./allocator"; /** Size of an ArrayBuffer header. */ -export const HEADER_SIZE: usize = (offsetof() + AL_MASK) & ~AL_MASK; +@inline export const HEADER_SIZE: usize = (offsetof() + AL_MASK) & ~AL_MASK; /** Maximum byte length of an ArrayBuffer. */ -export const MAX_BLENGTH: i32 = MAX_SIZE_32 - HEADER_SIZE; +@inline export const MAX_BLENGTH: i32 = MAX_SIZE_32 - HEADER_SIZE; function computeSize(byteLength: i32): usize { // round up to power of 2, with HEADER_SIZE=8: diff --git a/std/assembly/internal/hash.ts b/std/assembly/internal/hash.ts index 7927e91d76..dd7c740325 100644 --- a/std/assembly/internal/hash.ts +++ b/std/assembly/internal/hash.ts @@ -25,8 +25,8 @@ export function HASH(key: T): u32 { // FNV-1a 32-bit as a starting point, see: http://isthe.com/chongo/tech/comp/fnv/ -const FNV_OFFSET: u32 = 2166136261; -const FNV_PRIME: u32 = 16777619; +@inline const FNV_OFFSET: u32 = 2166136261; +@inline const FNV_PRIME: u32 = 16777619; function hash8(key: u32): u32 { return (FNV_OFFSET ^ key) * FNV_PRIME; diff --git a/std/assembly/internal/number.ts b/std/assembly/internal/number.ts index ab3b6f6365..e308798df4 100644 --- a/std/assembly/internal/number.ts +++ b/std/assembly/internal/number.ts @@ -1,4 +1,3 @@ - import { CharCode, allocateUnsafe as allocateUnsafeString, @@ -10,7 +9,7 @@ import { LOAD } from "./arraybuffer"; -export const MAX_DOUBLE_LENGTH = 28; +@lazy export const MAX_DOUBLE_LENGTH = 28; @inline export function POWERS10(): u32[] { @@ -359,16 +358,13 @@ export function itoa(value: T): String { } } -var _K: i32 = 0; - -var _frc: u64 = 0; -var _exp: i32 = 0; - -var _frc_minus: u64 = 0; -var _frc_plus: u64 = 0; - -var _frc_pow: u64 = 0; -var _exp_pow: i32 = 0; +@lazy var _K: i32 = 0; +// @lazy var _frc: u64 = 0; +@lazy var _exp: i32 = 0; +@lazy var _frc_minus: u64 = 0; +@lazy var _frc_plus: u64 = 0; +@lazy var _frc_pow: u64 = 0; +@lazy var _exp_pow: i32 = 0; @inline function umul64f(u: u64, v: u64): u64 { diff --git a/std/assembly/internal/string.ts b/std/assembly/internal/string.ts index a8dae3f21b..74eda907ff 100644 --- a/std/assembly/internal/string.ts +++ b/std/assembly/internal/string.ts @@ -2,9 +2,9 @@ import { MAX_SIZE_32 } from "./allocator"; import { String } from "../string"; /** Size of a String header. */ -export const HEADER_SIZE = (offsetof() + 1) & ~1; // 2 byte aligned +@inline export const HEADER_SIZE = (offsetof() + 1) & ~1; // 2 byte aligned /** Maximum length of a String. */ -export const MAX_LENGTH = (MAX_SIZE_32 - HEADER_SIZE) >>> 1; +@inline export const MAX_LENGTH = (MAX_SIZE_32 - HEADER_SIZE) >>> 1; // Low-level utility diff --git a/std/assembly/internal/typedarray.ts b/std/assembly/internal/typedarray.ts index 089fa3a32c..a3f3f18533 100644 --- a/std/assembly/internal/typedarray.ts +++ b/std/assembly/internal/typedarray.ts @@ -46,14 +46,14 @@ export abstract class TypedArray { } @operator("[]=") - protected __set(index: i32, value: NATIVE): void { + protected __set(index: i32, value: native): void { if (index >= (this.byteLength >>> alignof())) throw new Error("Index out of bounds"); - STORE>(this.buffer, index, value, this.byteOffset); + STORE>(this.buffer, index, value, this.byteOffset); } @inline @operator("{}=") - protected __unchecked_set(index: i32, value: NATIVE): void { - STORE>(this.buffer, index, value, this.byteOffset); + protected __unchecked_set(index: i32, value: native): void { + STORE>(this.buffer, index, value, this.byteOffset); } // copyWithin(target: i32, start: i32, end: i32 = this.length): this @@ -62,7 +62,7 @@ export abstract class TypedArray { @inline export function FILL, T extends number>( array: TArray, - value: NATIVE, + value: native, start: i32, end: i32 ): TArray { @@ -81,7 +81,7 @@ export function FILL, T extends number>( } } else { for (; start < end; ++start) { - STORE>(buffer, start, value, byteOffset); + STORE>(buffer, start, value, byteOffset); } } return array; @@ -177,7 +177,7 @@ export function MAP, T>( var result = instantiate(length); var resultBuffer = result.buffer; for (let i = 0; i < length; i++) { - STORE>(resultBuffer, i, >callbackfn(LOAD(buffer, i, byteOffset), i, array)); + STORE>(resultBuffer, i, >callbackfn(LOAD(buffer, i, byteOffset), i, array)); } return result; diff --git a/std/assembly/map.ts b/std/assembly/map.ts index 018b483baa..076962bf0c 100644 --- a/std/assembly/map.ts +++ b/std/assembly/map.ts @@ -8,9 +8,9 @@ import { // A deterministic hash map based on CloseTable from https://github.com/jorendorff/dht -const INITIAL_CAPACITY = 4; -const FILL_FACTOR: f64 = 8 / 3; -const FREE_FACTOR: f64 = 3 / 4; +@inline const INITIAL_CAPACITY = 4; +@inline const FILL_FACTOR: f64 = 8 / 3; +@inline const FREE_FACTOR: f64 = 3 / 4; /** Structure of a map entry. */ @unmanaged class MapEntry { @@ -20,10 +20,10 @@ const FREE_FACTOR: f64 = 3 / 4; } /** Empty bit. */ -const EMPTY: usize = 1 << 0; +@inline const EMPTY: usize = 1 << 0; /** Size of a bucket. */ -const BUCKET_SIZE = sizeof(); +@inline const BUCKET_SIZE = sizeof(); /** Computes the alignment of an entry. */ @inline function ENTRY_ALIGN(): usize { diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 6eb9479564..13a9563766 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -24,7 +24,6 @@ import { // TODO: sin, cos, tan -/** @internal */ function R(z: f64): f64 { // Rational approximation of (asin(x)-x)/x^3 const // see: musl/src/math/asin.c and SUN COPYRIGHT NOTICE above pS0 = reinterpret(0x3FC5555555555555), // 1.66666666666666657415e-01 @@ -42,8 +41,7 @@ function R(z: f64): f64 { // Rational approximation of (asin(x)-x)/x^3 return p / q; } -@inline /** @internal */ -function expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX) +@inline function expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX) const // see: musl/src/math/__expo2.c k = 2043, kln2 = reinterpret(0x40962066151ADD8B); // 0x1.62066151add8bp+10 @@ -51,13 +49,12 @@ function expo2(x: f64): f64 { // exp(x)/2 for x >= log(DBL_MAX) return NativeMath.exp(x - kln2) * scale * scale; } -var random_seeded = false; -var random_state0_64: u64; -var random_state1_64: u64; -var random_state0_32: u32; -var random_state1_32: u32; +@lazy var random_seeded = false; +@lazy var random_state0_64: u64; +@lazy var random_state1_64: u64; +@lazy var random_state0_32: u32; +@lazy var random_state1_32: u32; -/** @internal */ function murmurHash3(h: u64): u64 { // Force all bits of a hash block to avalanche h ^= h >> 33; // see: https://github.com/aappleby/smhasher h *= 0xFF51AFD7ED558CCD; @@ -67,7 +64,6 @@ function murmurHash3(h: u64): u64 { // Force all bits of a hash block to avalanc return h; } -/** @internal */ function splitMix32(h: u32): u32 { h += 0x6D2B79F5; h = (h ^ (h >> 15)) * (h | 1); @@ -77,14 +73,14 @@ function splitMix32(h: u32): u32 { export namespace NativeMath { - export const E = reinterpret(0x4005BF0A8B145769); // 2.7182818284590452354 - export const LN2 = reinterpret(0x3FE62E42FEFA39EF); // 0.69314718055994530942 - export const LN10 = reinterpret(0x40026BB1BBB55516); // 2.30258509299404568402 - export const LOG2E = reinterpret(0x3FF71547652B82FE); // 1.4426950408889634074 - export const LOG10E = reinterpret(0x3FDBCB7B1526E50E); // 0.43429448190325182765 - export const PI = reinterpret(0x400921FB54442D18); // 3.14159265358979323846 - export const SQRT1_2 = reinterpret(0x3FE6A09E667F3BCD); // 0.70710678118654752440 - export const SQRT2 = reinterpret(0x3FF6A09E667F3BCD); // 1.41421356237309504880 + @lazy export const E = reinterpret(0x4005BF0A8B145769); // 2.7182818284590452354 + @lazy export const LN2 = reinterpret(0x3FE62E42FEFA39EF); // 0.69314718055994530942 + @lazy export const LN10 = reinterpret(0x40026BB1BBB55516); // 2.30258509299404568402 + @lazy export const LOG2E = reinterpret(0x3FF71547652B82FE); // 1.4426950408889634074 + @lazy export const LOG10E = reinterpret(0x3FDBCB7B1526E50E); // 0.43429448190325182765 + @lazy export const PI = reinterpret(0x400921FB54442D18); // 3.14159265358979323846 + @lazy export const SQRT1_2 = reinterpret(0x3FE6A09E667F3BCD); // 0.70710678118654752440 + @lazy export const SQRT2 = reinterpret(0x3FF6A09E667F3BCD); // 1.41421356237309504880 @inline export function abs(x: f64): f64 { @@ -1073,7 +1069,6 @@ export namespace NativeMath { return builtin_trunc(x); } - /** @internal */ export function scalbn(x: f64, n: i32): f64 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbn.c const Ox1p53 = reinterpret(0x4340000000000000), @@ -1227,7 +1222,6 @@ export namespace NativeMath { } } -/** @internal */ function Rf(z: f32): f32 { // Rational approximation of (asin(x)-x)/x^3 const // see: musl/src/math/asinf.c and SUN COPYRIGHT NOTICE above pS0 = reinterpret(0x3E2AAA75), // 1.6666586697e-01f @@ -1239,8 +1233,7 @@ function Rf(z: f32): f32 { // Rational approximation of (asin(x)-x)/x^3 return p / q; } -@inline /** @internal */ -function expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX) +@inline function expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX) const // see: musl/src/math/__expo2f.c k = 235, kln2 = reinterpret(0x4322E3BC); // 0x1.45c778p+7f @@ -1250,14 +1243,14 @@ function expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX) export namespace NativeMathf { - export const E = NativeMath.E; - export const LN2 = NativeMath.LN2; - export const LN10 = NativeMath.LN10; - export const LOG2E = NativeMath.LOG2E; - export const LOG10E = NativeMath.LOG10E; - export const PI = NativeMath.PI; - export const SQRT1_2 = NativeMath.SQRT1_2; - export const SQRT2 = NativeMath.SQRT2; + @lazy export const E = NativeMath.E; + @lazy export const LN2 = NativeMath.LN2; + @lazy export const LN10 = NativeMath.LN10; + @lazy export const LOG2E = NativeMath.LOG2E; + @lazy export const LOG10E = NativeMath.LOG10E; + @lazy export const PI = NativeMath.PI; + @lazy export const SQRT1_2 = NativeMath.SQRT1_2; + @lazy export const SQRT2 = NativeMath.SQRT2; @inline export function abs(x: f32): f32 { @@ -2138,7 +2131,6 @@ export namespace NativeMathf { return builtin_trunc(x); } - /** @internal */ export function scalbn(x: f32, n: i32): f32 { // see: https://git.musl-libc.org/cgit/musl/tree/src/math/scalbnf.c const Ox1p24f = reinterpret(0x4B800000), diff --git a/std/assembly/number.ts b/std/assembly/number.ts index cfe8474673..20288e1913 100644 --- a/std/assembly/number.ts +++ b/std/assembly/number.ts @@ -11,8 +11,8 @@ import { @sealed export abstract class I8 { - static readonly MIN_VALUE: i8 = i8.MIN_VALUE; - static readonly MAX_VALUE: i8 = i8.MAX_VALUE; + @lazy static readonly MIN_VALUE: i8 = i8.MIN_VALUE; + @lazy static readonly MAX_VALUE: i8 = i8.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): i8 { return parseI32(value, radix); @@ -27,8 +27,8 @@ export abstract class I8 { @sealed export abstract class I16 { - static readonly MIN_VALUE: i16 = i16.MIN_VALUE; - static readonly MAX_VALUE: i16 = i16.MAX_VALUE; + @lazy static readonly MIN_VALUE: i16 = i16.MIN_VALUE; + @lazy static readonly MAX_VALUE: i16 = i16.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): i16 { return parseI32(value, radix); @@ -43,8 +43,8 @@ export abstract class I16 { @sealed export abstract class I32 { - static readonly MIN_VALUE: i32 = i32.MIN_VALUE; - static readonly MAX_VALUE: i32 = i32.MAX_VALUE; + @lazy static readonly MIN_VALUE: i32 = i32.MIN_VALUE; + @lazy static readonly MAX_VALUE: i32 = i32.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): i32 { return parseI32(value, radix); @@ -59,8 +59,8 @@ export abstract class I32 { @sealed export abstract class I64 { - static readonly MIN_VALUE: i64 = i64.MIN_VALUE; - static readonly MAX_VALUE: i64 = i64.MAX_VALUE; + @lazy static readonly MIN_VALUE: i64 = i64.MIN_VALUE; + @lazy static readonly MAX_VALUE: i64 = i64.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): i64 { return parseI64(value, radix); @@ -75,8 +75,8 @@ export abstract class I64 { @sealed export abstract class Isize { - static readonly MIN_VALUE: isize = isize.MIN_VALUE; - static readonly MAX_VALUE: isize = isize.MAX_VALUE; + @lazy static readonly MIN_VALUE: isize = isize.MIN_VALUE; + @lazy static readonly MAX_VALUE: isize = isize.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): isize { return parseI64(value, radix); @@ -91,8 +91,8 @@ export abstract class Isize { @sealed export abstract class U8 { - static readonly MIN_VALUE: u8 = u8.MIN_VALUE; - static readonly MAX_VALUE: u8 = u8.MAX_VALUE; + @lazy static readonly MIN_VALUE: u8 = u8.MIN_VALUE; + @lazy static readonly MAX_VALUE: u8 = u8.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): u8 { return parseI32(value, radix); @@ -107,8 +107,8 @@ export abstract class U8 { @sealed export abstract class U16 { - static readonly MIN_VALUE: u16 = u16.MIN_VALUE; - static readonly MAX_VALUE: u16 = u16.MAX_VALUE; + @lazy static readonly MIN_VALUE: u16 = u16.MIN_VALUE; + @lazy static readonly MAX_VALUE: u16 = u16.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): u16 { return parseI32(value, radix); @@ -123,8 +123,8 @@ export abstract class U16 { @sealed export abstract class U32 { - static readonly MIN_VALUE: u32 = u32.MIN_VALUE; - static readonly MAX_VALUE: u32 = u32.MAX_VALUE; + @lazy static readonly MIN_VALUE: u32 = u32.MIN_VALUE; + @lazy static readonly MAX_VALUE: u32 = u32.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): u32 { return parseI32(value, radix); @@ -139,8 +139,8 @@ export abstract class U32 { @sealed export abstract class U64 { - static readonly MIN_VALUE: u64 = u64.MIN_VALUE; - static readonly MAX_VALUE: u64 = u64.MAX_VALUE; + @lazy static readonly MIN_VALUE: u64 = u64.MIN_VALUE; + @lazy static readonly MAX_VALUE: u64 = u64.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): u64 { return parseI64(value, radix); @@ -155,8 +155,8 @@ export abstract class U64 { @sealed export abstract class Usize { - static readonly MIN_VALUE: usize = usize.MIN_VALUE; - static readonly MAX_VALUE: usize = usize.MAX_VALUE; + @lazy static readonly MIN_VALUE: usize = usize.MIN_VALUE; + @lazy static readonly MAX_VALUE: usize = usize.MAX_VALUE; static parseInt(value: string, radix: i32 = 0): usize { return parseI64(value, radix); @@ -171,8 +171,8 @@ export abstract class Usize { @sealed export abstract class Bool { - static readonly MIN_VALUE: bool = bool.MIN_VALUE; - static readonly MAX_VALUE: bool = bool.MAX_VALUE; + @lazy static readonly MIN_VALUE: bool = bool.MIN_VALUE; + @lazy static readonly MAX_VALUE: bool = bool.MAX_VALUE; toString(this: bool): String { // TODO: radix? @@ -180,20 +180,19 @@ export abstract class Bool { } } -@sealed -export abstract class Boolean extends Bool {} +export { Bool as Boolean }; @sealed export abstract class F32 { - static readonly EPSILON: f32 = f32.EPSILON; - static readonly MIN_VALUE: f32 = f32.MIN_VALUE; - static readonly MAX_VALUE: f32 = f32.MAX_VALUE; - static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER; - static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER; - static readonly POSITIVE_INFINITY: f32 = Infinity; - static readonly NEGATIVE_INFINITY: f32 = -Infinity; - static readonly NaN: f32 = NaN; + @lazy static readonly EPSILON: f32 = f32.EPSILON; + @lazy static readonly MIN_VALUE: f32 = f32.MIN_VALUE; + @lazy static readonly MAX_VALUE: f32 = f32.MAX_VALUE; + @lazy static readonly MIN_SAFE_INTEGER: f32 = f32.MIN_SAFE_INTEGER; + @lazy static readonly MAX_SAFE_INTEGER: f32 = f32.MAX_SAFE_INTEGER; + @lazy static readonly POSITIVE_INFINITY: f32 = Infinity; + @lazy static readonly NEGATIVE_INFINITY: f32 = -Infinity; + @lazy static readonly NaN: f32 = NaN; static isNaN(value: f32): bool { return isNaN(value); @@ -228,14 +227,14 @@ export abstract class F32 { @sealed export abstract class F64 { - static readonly EPSILON: f64 = f64.EPSILON; - static readonly MIN_VALUE: f64 = f64.MIN_VALUE; - static readonly MAX_VALUE: f64 = f64.MAX_VALUE; - static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER; - static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER; - static readonly POSITIVE_INFINITY: f64 = Infinity; - static readonly NEGATIVE_INFINITY: f64 = -Infinity; - static readonly NaN: f64 = NaN; + @lazy static readonly EPSILON: f64 = f64.EPSILON; + @lazy static readonly MIN_VALUE: f64 = f64.MIN_VALUE; + @lazy static readonly MAX_VALUE: f64 = f64.MAX_VALUE; + @lazy static readonly MIN_SAFE_INTEGER: f64 = f64.MIN_SAFE_INTEGER; + @lazy static readonly MAX_SAFE_INTEGER: f64 = f64.MAX_SAFE_INTEGER; + @lazy static readonly POSITIVE_INFINITY: f64 = Infinity; + @lazy static readonly NEGATIVE_INFINITY: f64 = -Infinity; + @lazy static readonly NaN: f64 = NaN; static isNaN(value: f64): bool { return builtin_isNaN(value); @@ -267,5 +266,4 @@ export abstract class F64 { } } -@sealed -export abstract class Number extends F64 {} +export { F64 as Number }; diff --git a/std/assembly/set.ts b/std/assembly/set.ts index 6b636a762b..e7f527ef4f 100644 --- a/std/assembly/set.ts +++ b/std/assembly/set.ts @@ -8,9 +8,9 @@ import { // A deterministic hash set based on CloseTable from https://github.com/jorendorff/dht -const INITIAL_CAPACITY = 4; -const FILL_FACTOR: f64 = 8 / 3; -const FREE_FACTOR: f64 = 3 / 4; +@inline const INITIAL_CAPACITY = 4; +@inline const FILL_FACTOR: f64 = 8 / 3; +@inline const FREE_FACTOR: f64 = 3 / 4; /** Structure of a set entry. */ @unmanaged class SetEntry { @@ -19,10 +19,10 @@ const FREE_FACTOR: f64 = 3 / 4; } /** Empty bit. */ -const EMPTY: usize = 1 << 0; +@inline const EMPTY: usize = 1 << 0; /** Size of a bucket. */ -const BUCKET_SIZE = sizeof(); +@inline const BUCKET_SIZE = sizeof(); /** Computes the alignment of an entry. */ @inline function ENTRY_ALIGN(): usize { diff --git a/std/assembly/string.ts b/std/assembly/string.ts index e3462a9e5c..0ede3ccfb7 100644 --- a/std/assembly/string.ts +++ b/std/assembly/string.ts @@ -596,6 +596,8 @@ export class String { } } +export type string = String; + export function parseInt(str: String, radix: i32 = 0): f64 { return parse(str, radix); } diff --git a/std/assembly/symbol.ts b/std/assembly/symbol.ts index e0059a6a03..625b2c0b90 100644 --- a/std/assembly/symbol.ts +++ b/std/assembly/symbol.ts @@ -1,8 +1,8 @@ import { Map } from "./map"; -var stringToId: Map; -var idToString: Map; -var nextId: usize = 12; // Symbol.unscopables + 1 +@lazy var stringToId: Map; +@lazy var idToString: Map; +@lazy var nextId: usize = 12; // Symbol.unscopables + 1 @unmanaged export class symbol { toString(): string { @@ -29,8 +29,6 @@ var nextId: usize = 12; // Symbol.unscopables + 1 } } -type Symbol = symbol; - export function Symbol(description: string | null = null): symbol { var id = nextId++; if (!id) unreachable(); // out of ids @@ -40,18 +38,18 @@ export function Symbol(description: string | null = null): symbol { export namespace Symbol { // well-known symbols - export const hasInstance = changetype(1); - export const isConcatSpreadable = changetype(2); - export const isRegExp = changetype(3); - export const iterator = changetype(3); - export const match = changetype(4); - export const replace = changetype(5); - export const search = changetype(6); - export const species = changetype(7); - export const split = changetype(8); - export const toPrimitive = changetype(9); - export const toStringTag = changetype(10); - export const unscopables = changetype(11); + @lazy export const hasInstance = changetype(1); + @lazy export const isConcatSpreadable = changetype(2); + @lazy export const isRegExp = changetype(3); + @lazy export const iterator = changetype(3); + @lazy export const match = changetype(4); + @lazy export const replace = changetype(5); + @lazy export const search = changetype(6); + @lazy export const species = changetype(7); + @lazy export const split = changetype(8); + @lazy export const toPrimitive = changetype(9); + @lazy export const toStringTag = changetype(10); + @lazy export const unscopables = changetype(11); /* tslint:disable */// not valid TS export function for(key: string): symbol { diff --git a/std/assembly/typedarray.ts b/std/assembly/typedarray.ts index 7e637a9d8c..68ba480ac4 100644 --- a/std/assembly/typedarray.ts +++ b/std/assembly/typedarray.ts @@ -16,7 +16,7 @@ import { } from "./internal/sort"; export class Int8Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int8Array { return FILL(this, value, start, end); @@ -62,7 +62,7 @@ export class Int8Array extends TypedArray { } export class Uint8Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint8Array { return FILL(this, value, start, end); @@ -108,7 +108,7 @@ export class Uint8Array extends TypedArray { } export class Uint8ClampedArray extends Uint8Array { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); @inline @operator("[]=") protected __set(index: i32, value: i32): void { @@ -150,7 +150,7 @@ export class Uint8ClampedArray extends Uint8Array { } export class Int16Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int16Array { return FILL(this, value, start, end); @@ -196,7 +196,7 @@ export class Int16Array extends TypedArray { } export class Uint16Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint16Array { return FILL(this, value, start, end); @@ -242,7 +242,7 @@ export class Uint16Array extends TypedArray { } export class Int32Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: i32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int32Array { return FILL(this, value, start, end); @@ -288,7 +288,7 @@ export class Int32Array extends TypedArray { } export class Uint32Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: u32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint32Array { return FILL(this, value, start, end); @@ -334,7 +334,7 @@ export class Uint32Array extends TypedArray { } export class Int64Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: i64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Int64Array { return FILL(this, value, start, end); @@ -380,7 +380,7 @@ export class Int64Array extends TypedArray { } export class Uint64Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: u64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Uint64Array { return FILL(this, value, start, end); @@ -426,7 +426,7 @@ export class Uint64Array extends TypedArray { } export class Float32Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: f32, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float32Array { return FILL(this, value, start, end); @@ -472,7 +472,7 @@ export class Float32Array extends TypedArray { } export class Float64Array extends TypedArray { - static readonly BYTES_PER_ELEMENT: usize = sizeof(); + @lazy static readonly BYTES_PER_ELEMENT: usize = sizeof(); fill(value: f64, start: i32 = 0, end: i32 = i32.MAX_VALUE): Float64Array { return FILL(this, value, start, end); diff --git a/std/portable/index.d.ts b/std/portable/index.d.ts index 51ec236184..9e0785bc1b 100644 --- a/std/portable/index.d.ts +++ b/std/portable/index.d.ts @@ -32,8 +32,6 @@ declare type f64 = number; /** Compiler target. 0 = JS, 1 = WASM32, 2 = WASM64. */ declare const ASC_TARGET: i32; -/** Provided noTreeshaking option. */ -declare const ASC_NO_TREESHAKING: bool; /** Provided noAssert option. */ declare const ASC_NO_ASSERT: bool; /** Provided memoryBase option. */ diff --git a/std/portable/index.js b/std/portable/index.js index c772b7c451..fa71873c16 100644 --- a/std/portable/index.js +++ b/std/portable/index.js @@ -3,7 +3,6 @@ var globalScope = typeof window !== "undefined" && window || typeof global !== "undefined" && global || self; globalScope.ASC_TARGET = 0; // JS -globalScope.ASC_NO_TREESHAKING = false; globalScope.ASC_NO_ASSERT = false; globalScope.ASC_MEMORY_BASE = 0; globalScope.ASC_OPTIMIZE_LEVEL = 3; diff --git a/tests/allocators/arena/optimized.wat b/tests/allocators/arena/optimized.wat index 5230aa5963..0756cb695a 100644 --- a/tests/allocators/arena/optimized.wat +++ b/tests/allocators/arena/optimized.wat @@ -1,3193 +1,159 @@ (module - (type $iiiv (func (param i32 i32 i32))) + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $iv (func (param i32))) - (type $v (func)) + (type $i_ (func (param i32))) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (memory $0 0) (export "memory" (memory $0)) - (export "memory.fill" (func $~lib/memory/memory.fill)) - (export "memory.copy" (func $~lib/memory/memory.copy)) + (export "table" (table $0)) (export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.allocate" (func $~lib/memory/memory.allocate)) (export "memory.free" (func $~lib/memory/memory.free)) (export "memory.reset" (func $~lib/memory/memory.reset)) (start $start) - (func $~lib/memory/memset (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i64) - (local $4 i32) - ;;@ ~lib/memory.ts:244:2 - (if - ;;@ ~lib/memory.ts:244:6 - (i32.eqz - ;;@ ~lib/memory.ts:244:7 - (get_local $2) - ) - ;;@ ~lib/memory.ts:244:10 - (return) - ) - ;;@ ~lib/memory.ts:245:2 - (i32.store8 - ;;@ ~lib/memory.ts:245:12 - (get_local $0) - ;;@ ~lib/memory.ts:245:18 - (get_local $1) - ) - ;;@ ~lib/memory.ts:246:2 - (i32.store8 - ;;@ ~lib/memory.ts:246:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:246:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:246:23 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:246:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:247:2 - (if - ;;@ ~lib/memory.ts:247:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:247:11 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:247:14 - (return) - ) - ;;@ ~lib/memory.ts:249:2 - (i32.store8 - ;;@ ~lib/memory.ts:249:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:249:19 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:249:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:250:2 - (i32.store8 - ;;@ ~lib/memory.ts:250:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:250:19 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:250:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:251:2 - (i32.store8 - ;;@ ~lib/memory.ts:251:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:251:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:251:23 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:251:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:252:2 - (i32.store8 - ;;@ ~lib/memory.ts:252:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:252:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:252:23 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:252:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:253:2 - (if - ;;@ ~lib/memory.ts:253:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:253:11 - (i32.const 6) - ) - ;;@ ~lib/memory.ts:253:14 - (return) - ) - ;;@ ~lib/memory.ts:254:2 - (i32.store8 - ;;@ ~lib/memory.ts:254:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:254:19 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:254:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:255:2 - (i32.store8 - ;;@ ~lib/memory.ts:255:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:255:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:255:23 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:255:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:256:2 - (if - ;;@ ~lib/memory.ts:256:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:256:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:256:14 - (return) - ) - ;;@ ~lib/memory.ts:267:2 - (i32.store - ;;@ ~lib/memory.ts:260:2 - (tee_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:259:2 - (tee_local $4 - ;;@ ~lib/memory.ts:259:17 - (i32.and - (i32.sub - (i32.const 0) - ;;@ ~lib/memory.ts:259:18 - (get_local $0) - ) - ;;@ ~lib/memory.ts:259:25 - (i32.const 3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:264:2 - (tee_local $1 - ;;@ ~lib/memory.ts:264:17 - (i32.mul - (i32.and - ;;@ ~lib/memory.ts:264:33 - (get_local $1) - (i32.const 255) - ) - (i32.const 16843009) - ) - ) - ) - ;;@ ~lib/memory.ts:268:2 - (i32.store - ;;@ ~lib/memory.ts:268:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:262:2 - (tee_local $2 - (i32.and - (i32.sub - ;;@ ~lib/memory.ts:261:2 - (get_local $2) - ;;@ ~lib/memory.ts:261:7 - (get_local $4) - ) - ;;@ ~lib/memory.ts:262:7 - (i32.const -4) - ) - ) - ) - ;;@ ~lib/memory.ts:268:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:268:27 - (get_local $1) - ) - ;;@ ~lib/memory.ts:269:2 - (if - ;;@ ~lib/memory.ts:269:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:269:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:269:14 - (return) - ) - ;;@ ~lib/memory.ts:270:2 - (i32.store - ;;@ ~lib/memory.ts:270:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:270:20 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:270:23 - (get_local $1) - ) - ;;@ ~lib/memory.ts:271:2 - (i32.store - ;;@ ~lib/memory.ts:271:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:271:20 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:271:23 - (get_local $1) - ) - ;;@ ~lib/memory.ts:272:2 - (i32.store - ;;@ ~lib/memory.ts:272:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:272:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:272:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:272:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:273:2 - (i32.store - ;;@ ~lib/memory.ts:273:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:273:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:273:24 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:273:27 - (get_local $1) - ) - ;;@ ~lib/memory.ts:274:2 - (if - ;;@ ~lib/memory.ts:274:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:274:11 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:274:15 - (return) - ) - ;;@ ~lib/memory.ts:275:2 - (i32.store - ;;@ ~lib/memory.ts:275:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:275:20 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:275:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:276:2 - (i32.store - ;;@ ~lib/memory.ts:276:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:276:20 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:276:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:277:2 - (i32.store - ;;@ ~lib/memory.ts:277:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:277:20 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:277:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:278:2 - (i32.store - ;;@ ~lib/memory.ts:278:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:278:20 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:278:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:279:2 - (i32.store - ;;@ ~lib/memory.ts:279:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:279:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:279:24 - (i32.const 28) - ) - ;;@ ~lib/memory.ts:279:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:280:2 - (i32.store - ;;@ ~lib/memory.ts:280:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:280:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:280:24 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:280:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:281:2 - (i32.store - ;;@ ~lib/memory.ts:281:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:281:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:281:24 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:281:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:282:2 - (i32.store - ;;@ ~lib/memory.ts:282:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:282:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:282:24 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:282:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:286:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:285:2 - (tee_local $4 - ;;@ ~lib/memory.ts:285:6 - (i32.add - ;;@ ~lib/memory.ts:285:11 - (i32.and - ;;@ ~lib/memory.ts:285:12 - (get_local $0) - ;;@ ~lib/memory.ts:285:19 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:285:6 - (i32.const 24) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:287:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:287:7 - (get_local $4) - ) - ) - ;;@ ~lib/memory.ts:290:2 - (set_local $3 - ;;@ ~lib/memory.ts:290:17 - (i64.or - (i64.extend_u/i32 - (get_local $1) - ) - ;;@ ~lib/memory.ts:290:28 - (i64.shl - ;;@ ~lib/memory.ts:290:29 - (i64.extend_u/i32 - (get_local $1) - ) - ;;@ ~lib/memory.ts:290:41 - (i64.const 32) - ) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:291:9 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:291:14 - (i32.const 32) - ) - (block - ;;@ ~lib/memory.ts:292:4 - (i64.store - ;;@ ~lib/memory.ts:292:15 - (get_local $0) - ;;@ ~lib/memory.ts:292:21 - (get_local $3) - ) - ;;@ ~lib/memory.ts:293:4 - (i64.store - ;;@ ~lib/memory.ts:293:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:293:22 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:293:25 - (get_local $3) - ) - ;;@ ~lib/memory.ts:294:4 - (i64.store - ;;@ ~lib/memory.ts:294:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:294:22 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:294:26 - (get_local $3) - ) - ;;@ ~lib/memory.ts:295:4 - (i64.store - ;;@ ~lib/memory.ts:295:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:295:22 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:295:26 - (get_local $3) - ) - ;;@ ~lib/memory.ts:296:4 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:296:9 - (i32.const 32) - ) - ) - ;;@ ~lib/memory.ts:297:4 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:297:12 - (i32.const 32) - ) - ) - (br $continue|0) - ) - ) - ) - ) - (func $~lib/memory/memory.fill (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:11:4 - (call $~lib/memory/memset - ;;@ ~lib/memory.ts:11:11 - (get_local $0) - ;;@ ~lib/memory.ts:11:17 - (get_local $1) - ;;@ ~lib/memory.ts:11:20 - (get_local $2) - ) - ) - (func $~lib/memory/memcpy (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (loop $continue|0 - (if - (select - ;;@ ~lib/memory.ts:59:14 - (i32.and - ;;@ ~lib/memory.ts:59:15 - (get_local $1) - ;;@ ~lib/memory.ts:59:21 - (i32.const 3) - ) - (get_local $2) - ;;@ ~lib/memory.ts:59:9 - (get_local $2) - ) - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:60:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:60:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:60:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:60:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:61:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/memory.ts:65:2 - (if - (i32.eqz - ;;@ ~lib/memory.ts:65:6 - (i32.and - ;;@ ~lib/memory.ts:65:7 - (get_local $0) - ;;@ ~lib/memory.ts:65:14 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:65:23 - (block - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:66:11 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:66:16 - (i32.const 16) - ) - (block - ;;@ ~lib/memory.ts:67:6 - (i32.store - ;;@ ~lib/memory.ts:67:17 - (get_local $0) - ;;@ ~lib/memory.ts:67:28 - (i32.load - ;;@ ~lib/memory.ts:67:38 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:68:6 - (i32.store - ;;@ ~lib/memory.ts:68:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:68:25 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:68:28 - (i32.load - ;;@ ~lib/memory.ts:68:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:68:45 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:69:6 - (i32.store - ;;@ ~lib/memory.ts:69:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:69:25 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:69:28 - (i32.load - ;;@ ~lib/memory.ts:69:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:69:45 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:70:6 - (i32.store - ;;@ ~lib/memory.ts:70:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:70:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:70:28 - (i32.load - ;;@ ~lib/memory.ts:70:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:70:44 - (i32.const 12) - ) - ) - ) - ;;@ ~lib/memory.ts:71:6 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:71:13 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:17 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:71:25 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:29 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:71:34 - (i32.const 16) - ) - ) - (br $continue|1) - ) - ) - ) - ;;@ ~lib/memory.ts:73:4 - (if - ;;@ ~lib/memory.ts:73:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:73:12 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:73:15 - (block - ;;@ ~lib/memory.ts:74:6 - (i32.store - ;;@ ~lib/memory.ts:74:17 - (get_local $0) - ;;@ ~lib/memory.ts:74:27 - (i32.load - ;;@ ~lib/memory.ts:74:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:75:6 - (i32.store - ;;@ ~lib/memory.ts:75:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:75:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:75:27 - (i32.load - ;;@ ~lib/memory.ts:75:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:75:43 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:76:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:76:14 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:76:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:76:24 - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:78:4 - (if - ;;@ ~lib/memory.ts:78:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:78:12 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:78:15 - (block - ;;@ ~lib/memory.ts:79:6 - (i32.store - ;;@ ~lib/memory.ts:79:17 - (get_local $0) - ;;@ ~lib/memory.ts:79:23 - (i32.load - ;;@ ~lib/memory.ts:79:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:80:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:80:14 - (i32.const 4) - ) - ) - ;;@ ~lib/memory.ts:80:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:80:24 - (i32.const 4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:82:4 - (if - ;;@ ~lib/memory.ts:82:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:82:12 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:82:15 - (block - ;;@ ~lib/memory.ts:83:6 - (i32.store16 - ;;@ ~lib/memory.ts:83:17 - (get_local $0) - ;;@ ~lib/memory.ts:83:23 - (i32.load16_u - ;;@ ~lib/memory.ts:83:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:84:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:84:14 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:84:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:84:24 - (i32.const 2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:86:4 - (if - ;;@ ~lib/memory.ts:86:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:86:12 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:87:16 - (block - (set_local $3 - (get_local $0) - ) - ;;@ ~lib/memory.ts:86:15 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:87:33 - (block (result i32) - (set_local $3 - (get_local $1) - ) - ;;@ ~lib/memory.ts:87:24 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:89:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:94:2 - (if - ;;@ ~lib/memory.ts:94:6 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:94:11 - (i32.const 32) - ) - ;;@ ~lib/memory.ts:94:15 - (block $break|2 - (block $case2|2 - (block $case1|2 - (block $case0|2 - (block $tablify|0 - (br_table $case0|2 $case1|2 $case2|2 $tablify|0 - (i32.sub - ;;@ ~lib/memory.ts:95:12 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:95:19 - (i32.const 3) - ) - (i32.const 1) - ) - ) - ) - (br $break|2) - ) - ;;@ ~lib/memory.ts:98:8 - (set_local $4 - ;;@ ~lib/memory.ts:98:12 - (i32.load - ;;@ ~lib/memory.ts:98:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:99:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:99:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:99:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:99:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:100:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:100:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:100:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:100:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:101:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:101:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:101:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:101:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:102:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:102:13 - (i32.const 3) - ) - ) - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:103:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:103:20 - (i32.const 17) - ) - (block - ;;@ ~lib/memory.ts:105:10 - (i32.store - ;;@ ~lib/memory.ts:105:21 - (get_local $0) - ;;@ ~lib/memory.ts:105:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:105:32 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:105:37 - (i32.shl - ;;@ ~lib/memory.ts:104:10 - (tee_local $3 - ;;@ ~lib/memory.ts:104:14 - (i32.load - ;;@ ~lib/memory.ts:104:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:104:30 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:105:42 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:107:10 - (i32.store - ;;@ ~lib/memory.ts:107:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:107:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:107:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:107:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:107:41 - (i32.shl - ;;@ ~lib/memory.ts:106:10 - (tee_local $4 - ;;@ ~lib/memory.ts:106:14 - (i32.load - ;;@ ~lib/memory.ts:106:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:106:30 - (i32.const 5) - ) - ) - ) - ;;@ ~lib/memory.ts:107:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:109:10 - (i32.store - ;;@ ~lib/memory.ts:109:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:109:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:109:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:109:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:109:41 - (i32.shl - ;;@ ~lib/memory.ts:108:10 - (tee_local $3 - ;;@ ~lib/memory.ts:108:14 - (i32.load - ;;@ ~lib/memory.ts:108:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:108:30 - (i32.const 9) - ) - ) - ) - ;;@ ~lib/memory.ts:109:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:111:10 - (i32.store - ;;@ ~lib/memory.ts:111:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:111:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:111:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:111:37 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:111:42 - (i32.shl - ;;@ ~lib/memory.ts:110:10 - (tee_local $4 - ;;@ ~lib/memory.ts:110:14 - (i32.load - ;;@ ~lib/memory.ts:110:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:110:30 - (i32.const 13) - ) - ) - ) - ;;@ ~lib/memory.ts:111:47 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:112:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:112:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:112:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:112:38 - (i32.const 16) - ) - ) - (br $continue|3) - ) - ) - ) - ;;@ ~lib/memory.ts:114:8 - (br $break|2) - ) - ;;@ ~lib/memory.ts:117:8 - (set_local $4 - ;;@ ~lib/memory.ts:117:12 - (i32.load - ;;@ ~lib/memory.ts:117:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:118:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:118:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:118:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:118:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:119:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:119:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:119:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:119:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:120:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:120:13 - (i32.const 2) - ) - ) - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:121:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:121:20 - (i32.const 18) - ) - (block - ;;@ ~lib/memory.ts:123:10 - (i32.store - ;;@ ~lib/memory.ts:123:21 - (get_local $0) - ;;@ ~lib/memory.ts:123:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:123:32 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:123:37 - (i32.shl - ;;@ ~lib/memory.ts:122:10 - (tee_local $3 - ;;@ ~lib/memory.ts:122:14 - (i32.load - ;;@ ~lib/memory.ts:122:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:122:30 - (i32.const 2) - ) - ) - ) - ;;@ ~lib/memory.ts:123:42 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:125:10 - (i32.store - ;;@ ~lib/memory.ts:125:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:125:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:125:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:125:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:125:41 - (i32.shl - ;;@ ~lib/memory.ts:124:10 - (tee_local $4 - ;;@ ~lib/memory.ts:124:14 - (i32.load - ;;@ ~lib/memory.ts:124:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:124:30 - (i32.const 6) - ) - ) - ) - ;;@ ~lib/memory.ts:125:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:127:10 - (i32.store - ;;@ ~lib/memory.ts:127:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:127:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:127:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:127:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:127:41 - (i32.shl - ;;@ ~lib/memory.ts:126:10 - (tee_local $3 - ;;@ ~lib/memory.ts:126:14 - (i32.load - ;;@ ~lib/memory.ts:126:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:126:30 - (i32.const 10) - ) - ) - ) - ;;@ ~lib/memory.ts:127:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:129:10 - (i32.store - ;;@ ~lib/memory.ts:129:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:129:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:129:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:129:37 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:129:42 - (i32.shl - ;;@ ~lib/memory.ts:128:10 - (tee_local $4 - ;;@ ~lib/memory.ts:128:14 - (i32.load - ;;@ ~lib/memory.ts:128:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:128:30 - (i32.const 14) - ) - ) - ) - ;;@ ~lib/memory.ts:129:47 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:130:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:130:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:130:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:130:38 - (i32.const 16) - ) - ) - (br $continue|4) - ) - ) - ) - ;;@ ~lib/memory.ts:132:8 - (br $break|2) - ) - ;;@ ~lib/memory.ts:135:8 - (set_local $4 - ;;@ ~lib/memory.ts:135:12 - (i32.load - ;;@ ~lib/memory.ts:135:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:136:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:136:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:136:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:136:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:137:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:137:13 - (i32.const 1) - ) - ) - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:138:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:138:20 - (i32.const 19) - ) - (block - ;;@ ~lib/memory.ts:140:10 - (i32.store - ;;@ ~lib/memory.ts:140:21 - (get_local $0) - ;;@ ~lib/memory.ts:140:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:140:32 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:140:36 - (i32.shl - ;;@ ~lib/memory.ts:139:10 - (tee_local $3 - ;;@ ~lib/memory.ts:139:14 - (i32.load - ;;@ ~lib/memory.ts:139:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:139:30 - (i32.const 3) - ) - ) - ) - ;;@ ~lib/memory.ts:140:41 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:142:10 - (i32.store - ;;@ ~lib/memory.ts:142:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:142:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:142:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:142:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:142:40 - (i32.shl - ;;@ ~lib/memory.ts:141:10 - (tee_local $4 - ;;@ ~lib/memory.ts:141:14 - (i32.load - ;;@ ~lib/memory.ts:141:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:141:30 - (i32.const 7) - ) - ) - ) - ;;@ ~lib/memory.ts:142:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:144:10 - (i32.store - ;;@ ~lib/memory.ts:144:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:144:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:144:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:40 - (i32.shl - ;;@ ~lib/memory.ts:143:10 - (tee_local $3 - ;;@ ~lib/memory.ts:143:14 - (i32.load - ;;@ ~lib/memory.ts:143:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:143:30 - (i32.const 11) - ) - ) - ) - ;;@ ~lib/memory.ts:144:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:146:10 - (i32.store - ;;@ ~lib/memory.ts:146:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:146:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:146:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:146:37 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:146:41 - (i32.shl - ;;@ ~lib/memory.ts:145:10 - (tee_local $4 - ;;@ ~lib/memory.ts:145:14 - (i32.load - ;;@ ~lib/memory.ts:145:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:145:30 - (i32.const 15) - ) - ) - ) - ;;@ ~lib/memory.ts:146:46 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:147:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:147:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:147:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:147:38 - (i32.const 16) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:155:2 - (if - ;;@ ~lib/memory.ts:155:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:155:10 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:155:14 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:156:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:156:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:156:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:156:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:157:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:157:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:157:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:157:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:158:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:158:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:158:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:158:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:159:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:159:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:159:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:159:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:160:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:160:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:160:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:160:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:161:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:161:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:161:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:161:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:162:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:162:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:162:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:162:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:163:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:163:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:163:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:163:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:164:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:164:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:164:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:164:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:165:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:165:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:165:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:165:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:166:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:166:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:166:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:166:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:167:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:167:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:167:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:167:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:168:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:168:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:168:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:168:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:169:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:169:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:169:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:169:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:170:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:170:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:170:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:170:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:171:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:171:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:171:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:171:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:173:2 - (if - ;;@ ~lib/memory.ts:173:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:173:10 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:173:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:174:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:174:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:174:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:174:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:175:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:175:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:175:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:175:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:176:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:176:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:176:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:176:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:177:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:177:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:177:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:177:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:178:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:178:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:178:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:178:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:179:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:179:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:179:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:179:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:180:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:180:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:180:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:180:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:181:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:181:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:181:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:181:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:183:2 - (if - ;;@ ~lib/memory.ts:183:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:183:10 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:183:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:184:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:184:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:184:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:184:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:185:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:185:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:185:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:185:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:186:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:186:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:186:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:186:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:187:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:187:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:187:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:187:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:189:2 - (if - ;;@ ~lib/memory.ts:189:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:189:10 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:189:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:190:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:190:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:190:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:190:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:191:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:191:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:191:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:191:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:193:2 - (if - ;;@ ~lib/memory.ts:193:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:193:10 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:194:14 - (block - (set_local $3 - (get_local $0) - ) - ;;@ ~lib/memory.ts:193:13 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:194:31 - (block (result i32) - (set_local $3 - (get_local $1) - ) - ;;@ ~lib/memory.ts:194:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ) - (func $~lib/memory/memmove (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - ;;@ ~lib/memory.ts:200:2 - (if - ;;@ ~lib/memory.ts:200:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:200:14 - (get_local $1) - ) - ;;@ ~lib/memory.ts:200:19 - (return) - ) - ;;@ ~lib/memory.ts:201:2 - (if - ;;@ ~lib/memory.ts:201:6 - (if (result i32) - (tee_local $3 - (i32.le_u - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:201:12 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:17 - (get_local $0) - ) - ) - (get_local $3) - ;;@ ~lib/memory.ts:201:25 - (i32.le_u - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:201:32 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:201:42 - (block - ;;@ ~lib/memory.ts:202:4 - (call $~lib/memory/memcpy - ;;@ ~lib/memory.ts:202:11 - (get_local $0) - ;;@ ~lib/memory.ts:202:17 - (get_local $1) - ;;@ ~lib/memory.ts:202:22 - (get_local $2) - ) - ;;@ ~lib/memory.ts:203:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:205:2 - (if - ;;@ ~lib/memory.ts:205:6 - (i32.lt_u - (get_local $0) - ;;@ ~lib/memory.ts:205:13 - (get_local $1) - ) - ;;@ ~lib/memory.ts:205:18 - (block - ;;@ ~lib/memory.ts:206:4 - (if - ;;@ ~lib/memory.ts:206:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:206:9 - (get_local $1) - ;;@ ~lib/memory.ts:206:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:206:21 - (i32.and - ;;@ ~lib/memory.ts:206:22 - (get_local $0) - ;;@ ~lib/memory.ts:206:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:206:33 - (block - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:207:13 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:207:20 - (i32.const 7) - ) - (block - ;;@ ~lib/memory.ts:208:8 - (if - ;;@ ~lib/memory.ts:208:12 - (i32.eqz - ;;@ ~lib/memory.ts:208:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:208:16 - (return) - ) - ;;@ ~lib/memory.ts:209:8 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:209:10 - (get_local $2) - (i32.const 1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:210:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:210:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (br $continue|0) - ) - ) - ) - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:212:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:212:18 - (i32.const 8) - ) - (block - ;;@ ~lib/memory.ts:213:8 - (i64.store - ;;@ ~lib/memory.ts:213:19 - (get_local $0) - ;;@ ~lib/memory.ts:213:25 - (i64.load - ;;@ ~lib/memory.ts:213:35 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:214:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:214:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:215:8 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:215:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:216:8 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:216:16 - (i32.const 8) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ) - (loop $continue|2 - (if - ;;@ ~lib/memory.ts:219:11 - (get_local $2) - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:220:16 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:220:6 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:220:33 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:220:24 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:221:6 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:221:8 - (get_local $2) - (i32.const 1) - ) - ) - (br $continue|2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:223:9 - (block - ;;@ ~lib/memory.ts:224:4 - (if - ;;@ ~lib/memory.ts:224:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:224:9 - (get_local $1) - ;;@ ~lib/memory.ts:224:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:224:21 - (i32.and - ;;@ ~lib/memory.ts:224:22 - (get_local $0) - ;;@ ~lib/memory.ts:224:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:224:33 - (block - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:225:13 - (i32.and - (i32.add - ;;@ ~lib/memory.ts:225:14 - (get_local $0) - ;;@ ~lib/memory.ts:225:21 - (get_local $2) - ) - ;;@ ~lib/memory.ts:225:26 - (i32.const 7) - ) - (block - ;;@ ~lib/memory.ts:226:8 - (if - ;;@ ~lib/memory.ts:226:12 - (i32.eqz - ;;@ ~lib/memory.ts:226:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:226:16 - (return) - ) - ;;@ ~lib/memory.ts:227:8 - (i32.store8 - ;;@ ~lib/memory.ts:227:18 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:227:25 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:227:27 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:227:30 - (i32.load8_u - ;;@ ~lib/memory.ts:227:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:227:45 - (get_local $2) - ) - ) - ) - (br $continue|3) - ) - ) - ) - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:229:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:229:18 - (i32.const 8) - ) - (block - ;;@ ~lib/memory.ts:231:8 - (i64.store - ;;@ ~lib/memory.ts:231:19 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:230:8 - (tee_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:230:13 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:231:29 - (i64.load - ;;@ ~lib/memory.ts:231:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:231:45 - (get_local $2) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ) - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:234:11 - (get_local $2) - (block - ;;@ ~lib/memory.ts:234:14 - (i32.store8 - ;;@ ~lib/memory.ts:235:16 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:235:23 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:235:25 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:235:28 - (i32.load8_u - ;;@ ~lib/memory.ts:235:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:235:43 - (get_local $2) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ) - (func $~lib/memory/memory.copy (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:16:4 - (call $~lib/memory/memmove - ;;@ ~lib/memory.ts:16:12 - (get_local $0) - ;;@ ~lib/memory.ts:16:18 - (get_local $1) - ;;@ ~lib/memory.ts:16:23 - (get_local $2) - ) - ) - (func $~lib/memory/memcmp (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/memory/memcmp (; 0 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - ;;@ ~lib/memory.ts:302:2 - (if - ;;@ ~lib/memory.ts:302:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:302:12 - (get_local $1) - ) - ;;@ ~lib/memory.ts:302:23 - (return - (i32.const 0) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:303:9 - (if (result i32) - (tee_local $3 - (i32.ne - (get_local $2) - ;;@ ~lib/memory.ts:303:14 - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:19 - (i32.eq - (i32.load8_u - ;;@ ~lib/memory.ts:303:28 - (get_local $0) - ) - ;;@ ~lib/memory.ts:303:35 - (i32.load8_u - ;;@ ~lib/memory.ts:303:44 - (get_local $1) - ) - ) - (get_local $3) - ) - (block - ;;@ ~lib/memory.ts:304:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:9 - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:15 - (set_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (if (result i32) - ;;@ ~lib/memory.ts:306:9 - (get_local $2) - ;;@ ~lib/memory.ts:306:13 - (i32.sub - (i32.load8_u - ;;@ ~lib/memory.ts:306:27 - (get_local $0) - ) - ;;@ ~lib/memory.ts:306:33 - (i32.load8_u - ;;@ ~lib/memory.ts:306:47 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (i32.const 0) - ) + local.get $0 + local.get $1 + i32.eq + if + i32.const 0 + return + end + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + local.tee $3 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.eq + else + local.get $3 + end + if + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $continue|0 + end + end + local.get $2 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.sub + else + i32.const 0 + end ) - (func $~lib/memory/memory.compare (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/memory.ts:21:27 - (call $~lib/memory/memcmp - ;;@ ~lib/memory.ts:21:18 - (get_local $0) - ;;@ ~lib/memory.ts:21:22 - (get_local $1) - ;;@ ~lib/memory.ts:21:26 - (get_local $2) - ) + (func $~lib/memory/memory.compare (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + local.get $2 + call $~lib/internal/memory/memcmp ) - (func $~lib/allocator/arena/__memory_allocate (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) - ;;@ ~lib/allocator/arena.ts:17:2 - (if - ;;@ ~lib/allocator/arena.ts:17:6 - (get_local $0) - ;;@ ~lib/allocator/arena.ts:17:12 - (block - ;;@ ~lib/allocator/arena.ts:18:4 - (if - ;;@ ~lib/allocator/arena.ts:18:8 - (i32.gt_u - (get_local $0) - (i32.const 1073741824) - ) - ;;@ ~lib/allocator/arena.ts:18:28 - (unreachable) - ) - ;;@ ~lib/allocator/arena.ts:22:4 - (if - ;;@ ~lib/allocator/arena.ts:22:8 - (i32.gt_u - ;;@ ~lib/allocator/arena.ts:20:4 - (tee_local $0 - ;;@ ~lib/allocator/arena.ts:20:17 - (i32.and - (i32.add - ;;@ ~lib/allocator/arena.ts:20:18 - (i32.add - ;;@ ~lib/allocator/arena.ts:19:4 - (tee_local $1 - ;;@ ~lib/allocator/arena.ts:19:14 - (get_global $~lib/allocator/arena/offset) - ) - ;;@ ~lib/allocator/arena.ts:20:24 - (get_local $0) - ) - (i32.const 7) - ) - (i32.const -8) - ) - ) - ;;@ ~lib/allocator/arena.ts:22:17 - (i32.shl - ;;@ ~lib/allocator/arena.ts:21:4 - (tee_local $2 - ;;@ ~lib/allocator/arena.ts:21:29 - (current_memory) - ) - ;;@ ~lib/allocator/arena.ts:22:39 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/arena.ts:25:6 - (if - ;;@ ~lib/allocator/arena.ts:25:10 - (i32.lt_s - ;;@ ~lib/allocator/arena.ts:25:17 - (grow_memory - ;;@ ~lib/allocator/arena.ts:24:24 - (select - ;;@ ~lib/allocator/arena.ts:24:28 - (get_local $2) - (tee_local $4 - ;;@ ~lib/allocator/arena.ts:23:6 - (tee_local $3 - ;;@ ~lib/allocator/arena.ts:23:24 - (i32.shr_u - (i32.and - ;;@ ~lib/allocator/arena.ts:23:25 - (i32.add - ;;@ ~lib/allocator/arena.ts:23:26 - (i32.sub - (get_local $0) - ;;@ ~lib/allocator/arena.ts:23:35 - (get_local $1) - ) - ;;@ ~lib/allocator/arena.ts:23:41 - (i32.const 65535) - ) - (i32.const -65536) - ) - ;;@ ~lib/allocator/arena.ts:23:64 - (i32.const 16) - ) - ) - ) - (i32.gt_s - (get_local $2) - (get_local $4) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:25:37 - (i32.const 0) - ) - ;;@ ~lib/allocator/arena.ts:25:40 - (if - ;;@ ~lib/allocator/arena.ts:26:12 - (i32.lt_s - ;;@ ~lib/allocator/arena.ts:26:19 - (grow_memory - ;;@ ~lib/allocator/arena.ts:26:24 - (get_local $3) - ) - ;;@ ~lib/allocator/arena.ts:26:39 - (i32.const 0) - ) - ;;@ ~lib/allocator/arena.ts:26:42 - (unreachable) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:31:4 - (set_global $~lib/allocator/arena/offset - ;;@ ~lib/allocator/arena.ts:31:13 - (get_local $0) - ) - ;;@ ~lib/allocator/arena.ts:32:11 - (return - (get_local $1) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:34:9 - (i32.const 0) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.tee $2 + local.get $0 + i32.const 1 + local.tee $1 + local.get $0 + local.get $1 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $3 + current_memory + local.tee $1 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $1 + local.get $3 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $0 + local.tee $4 + local.get $1 + local.get $4 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $0 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $3 + global.set $~lib/allocator/arena/offset + local.get $2 + ) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/allocator/arena/__memory_allocate ) - (func $~lib/memory/memory.allocate (; 8 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/memory.ts:37:45 - (call $~lib/allocator/arena/__memory_allocate - ;;@ ~lib/memory.ts:37:63 - (get_local $0) - ) + (func $~lib/memory/memory.free (; 4 ;) (type $i_) (param $0 i32) + nop ) - (func $~lib/memory/memory.free (; 9 ;) (type $iv) (param $0 i32) - (nop) + (func $~lib/memory/memory.reset (; 5 ;) (type $_) + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset ) - (func $~lib/memory/memory.reset (; 10 ;) (type $v) - (set_global $~lib/allocator/arena/offset - (get_global $~lib/allocator/arena/startOffset) - ) + (func $start (; 6 ;) (type $_) + i32.const 8 + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset ) - (func $start (; 11 ;) (type $v) - (set_global $~lib/allocator/arena/startOffset - (i32.const 8) - ) - (set_global $~lib/allocator/arena/offset - ;;@ ~lib/allocator/arena.ts:13:20 - (get_global $~lib/allocator/arena/startOffset) - ) + (func $null (; 7 ;) (type $_) + nop ) ) diff --git a/tests/allocators/arena/package.json b/tests/allocators/arena/package.json index 709cf1096f..68fede664c 100644 --- a/tests/allocators/arena/package.json +++ b/tests/allocators/arena/package.json @@ -3,6 +3,6 @@ "scripts": { "build": "npm run build:untouched && npm run build:optimized", "build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --validate --sourceMap --measure", - "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noDebug --noAssert --optimize" + "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noAssert --optimize" } } diff --git a/tests/allocators/arena/untouched.wat b/tests/allocators/arena/untouched.wat index 7f58e1743a..664649377e 100644 --- a/tests/allocators/arena/untouched.wat +++ b/tests/allocators/arena/untouched.wat @@ -1,3562 +1,199 @@ (module - (type $iiiv (func (param i32 i32 i32))) + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $iv (func (param i32))) - (type $v (func)) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) + (type $i_ (func (param i32))) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) - (memory $0 0) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) - (export "memory.fill" (func $~lib/memory/memory.fill)) - (export "memory.copy" (func $~lib/memory/memory.copy)) + (export "table" (table $0)) (export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.allocate" (func $~lib/memory/memory.allocate)) (export "memory.free" (func $~lib/memory/memory.free)) (export "memory.reset" (func $~lib/memory/memory.reset)) (start $start) - (func $~lib/memory/memset (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - ;;@ ~lib/memory.ts:244:2 - (if - ;;@ ~lib/memory.ts:244:6 - (i32.eqz - ;;@ ~lib/memory.ts:244:7 - (get_local $2) - ) - ;;@ ~lib/memory.ts:244:10 - (return) - ) - ;;@ ~lib/memory.ts:245:2 - (i32.store8 - ;;@ ~lib/memory.ts:245:12 - (get_local $0) - ;;@ ~lib/memory.ts:245:18 - (get_local $1) - ) - ;;@ ~lib/memory.ts:246:2 - (i32.store8 - ;;@ ~lib/memory.ts:246:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:246:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:246:23 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:246:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:247:2 - (if - ;;@ ~lib/memory.ts:247:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:247:11 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:247:14 - (return) - ) - ;;@ ~lib/memory.ts:249:2 - (i32.store8 - ;;@ ~lib/memory.ts:249:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:249:19 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:249:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:250:2 - (i32.store8 - ;;@ ~lib/memory.ts:250:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:250:19 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:250:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:251:2 - (i32.store8 - ;;@ ~lib/memory.ts:251:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:251:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:251:23 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:251:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:252:2 - (i32.store8 - ;;@ ~lib/memory.ts:252:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:252:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:252:23 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:252:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:253:2 - (if - ;;@ ~lib/memory.ts:253:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:253:11 - (i32.const 6) - ) - ;;@ ~lib/memory.ts:253:14 - (return) - ) - ;;@ ~lib/memory.ts:254:2 - (i32.store8 - ;;@ ~lib/memory.ts:254:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:254:19 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:254:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:255:2 - (i32.store8 - ;;@ ~lib/memory.ts:255:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:255:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:255:23 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:255:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:256:2 - (if - ;;@ ~lib/memory.ts:256:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:256:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:256:14 - (return) - ) - ;;@ ~lib/memory.ts:259:2 - (set_local $3 - ;;@ ~lib/memory.ts:259:17 - (i32.and - (i32.sub - (i32.const 0) - ;;@ ~lib/memory.ts:259:18 - (get_local $0) - ) - ;;@ ~lib/memory.ts:259:25 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:260:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:260:10 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:261:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:261:7 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:262:2 - (set_local $2 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:262:7 - (i32.const -4) - ) - ) - ;;@ ~lib/memory.ts:264:2 - (set_local $4 - ;;@ ~lib/memory.ts:264:17 - (i32.mul - (i32.div_u - (i32.const -1) - ;;@ ~lib/memory.ts:264:27 - (i32.const 255) - ) - (i32.and - ;;@ ~lib/memory.ts:264:33 - (get_local $1) - (i32.const 255) - ) - ) - ) - ;;@ ~lib/memory.ts:267:2 - (i32.store - ;;@ ~lib/memory.ts:267:13 - (get_local $0) - ;;@ ~lib/memory.ts:267:19 - (get_local $4) - ) - ;;@ ~lib/memory.ts:268:2 - (i32.store - ;;@ ~lib/memory.ts:268:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:268:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:268:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:268:27 - (get_local $4) - ) - ;;@ ~lib/memory.ts:269:2 - (if - ;;@ ~lib/memory.ts:269:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:269:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:269:14 - (return) - ) - ;;@ ~lib/memory.ts:270:2 - (i32.store - ;;@ ~lib/memory.ts:270:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:270:20 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:270:23 - (get_local $4) - ) - ;;@ ~lib/memory.ts:271:2 - (i32.store - ;;@ ~lib/memory.ts:271:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:271:20 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:271:23 - (get_local $4) - ) - ;;@ ~lib/memory.ts:272:2 - (i32.store - ;;@ ~lib/memory.ts:272:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:272:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:272:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:272:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:273:2 - (i32.store - ;;@ ~lib/memory.ts:273:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:273:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:273:24 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:273:27 - (get_local $4) - ) - ;;@ ~lib/memory.ts:274:2 - (if - ;;@ ~lib/memory.ts:274:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:274:11 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:274:15 - (return) - ) - ;;@ ~lib/memory.ts:275:2 - (i32.store - ;;@ ~lib/memory.ts:275:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:275:20 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:275:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:276:2 - (i32.store - ;;@ ~lib/memory.ts:276:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:276:20 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:276:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:277:2 - (i32.store - ;;@ ~lib/memory.ts:277:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:277:20 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:277:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:278:2 - (i32.store - ;;@ ~lib/memory.ts:278:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:278:20 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:278:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:279:2 - (i32.store - ;;@ ~lib/memory.ts:279:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:279:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:279:24 - (i32.const 28) - ) - ;;@ ~lib/memory.ts:279:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:280:2 - (i32.store - ;;@ ~lib/memory.ts:280:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:280:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:280:24 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:280:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:281:2 - (i32.store - ;;@ ~lib/memory.ts:281:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:281:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:281:24 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:281:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:282:2 - (i32.store - ;;@ ~lib/memory.ts:282:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:282:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:282:24 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:282:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:285:2 - (set_local $3 - ;;@ ~lib/memory.ts:285:6 - (i32.add - (i32.const 24) - ;;@ ~lib/memory.ts:285:11 - (i32.and - ;;@ ~lib/memory.ts:285:12 - (get_local $0) - ;;@ ~lib/memory.ts:285:19 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:286:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:286:10 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:287:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:287:7 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:290:2 - (set_local $5 - ;;@ ~lib/memory.ts:290:17 - (i64.or - (i64.extend_u/i32 - (get_local $4) - ) - ;;@ ~lib/memory.ts:290:28 - (i64.shl - ;;@ ~lib/memory.ts:290:29 - (i64.extend_u/i32 - (get_local $4) - ) - ;;@ ~lib/memory.ts:290:41 - (i64.const 32) - ) - ) - ) - ;;@ ~lib/memory.ts:291:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:291:9 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:291:14 - (i32.const 32) - ) - (block - (block - ;;@ ~lib/memory.ts:292:4 - (i64.store - ;;@ ~lib/memory.ts:292:15 - (get_local $0) - ;;@ ~lib/memory.ts:292:21 - (get_local $5) - ) - ;;@ ~lib/memory.ts:293:4 - (i64.store - ;;@ ~lib/memory.ts:293:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:293:22 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:293:25 - (get_local $5) - ) - ;;@ ~lib/memory.ts:294:4 - (i64.store - ;;@ ~lib/memory.ts:294:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:294:22 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:294:26 - (get_local $5) - ) - ;;@ ~lib/memory.ts:295:4 - (i64.store - ;;@ ~lib/memory.ts:295:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:295:22 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:295:26 - (get_local $5) - ) - ;;@ ~lib/memory.ts:296:4 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:296:9 - (i32.const 32) - ) - ) - ;;@ ~lib/memory.ts:297:4 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:297:12 - (i32.const 32) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ) - (func $~lib/memory/memory.fill (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:11:4 - (call $~lib/memory/memset - ;;@ ~lib/memory.ts:11:11 - (get_local $0) - ;;@ ~lib/memory.ts:11:17 - (get_local $1) - ;;@ ~lib/memory.ts:11:20 - (get_local $2) - ) - ) - (func $~lib/memory/memcpy (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - ;;@ ~lib/memory.ts:59:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:59:9 - (if (result i32) - (get_local $2) - ;;@ ~lib/memory.ts:59:14 - (i32.and - ;;@ ~lib/memory.ts:59:15 - (get_local $1) - ;;@ ~lib/memory.ts:59:21 - (i32.const 3) - ) - (get_local $2) - ) - (block - (block - ;;@ ~lib/memory.ts:60:4 - (i32.store8 - ;;@ ~lib/memory.ts:60:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:60:22 - (i32.load8_u - ;;@ ~lib/memory.ts:60:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:61:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:65:2 - (if - ;;@ ~lib/memory.ts:65:6 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:65:7 - (get_local $0) - ;;@ ~lib/memory.ts:65:14 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:65:20 - (i32.const 0) - ) - ;;@ ~lib/memory.ts:65:23 - (block - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:66:11 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:66:16 - (i32.const 16) - ) - (block - (block - ;;@ ~lib/memory.ts:67:6 - (i32.store - ;;@ ~lib/memory.ts:67:17 - (get_local $0) - ;;@ ~lib/memory.ts:67:28 - (i32.load - ;;@ ~lib/memory.ts:67:38 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:68:6 - (i32.store - ;;@ ~lib/memory.ts:68:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:68:25 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:68:28 - (i32.load - ;;@ ~lib/memory.ts:68:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:68:45 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:69:6 - (i32.store - ;;@ ~lib/memory.ts:69:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:69:25 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:69:28 - (i32.load - ;;@ ~lib/memory.ts:69:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:69:45 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:70:6 - (i32.store - ;;@ ~lib/memory.ts:70:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:70:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:70:28 - (i32.load - ;;@ ~lib/memory.ts:70:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:70:44 - (i32.const 12) - ) - ) - ) - ;;@ ~lib/memory.ts:71:6 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:71:13 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:17 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:71:25 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:29 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:71:34 - (i32.const 16) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:73:4 - (if - ;;@ ~lib/memory.ts:73:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:73:12 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:73:15 - (block - ;;@ ~lib/memory.ts:74:6 - (i32.store - ;;@ ~lib/memory.ts:74:17 - (get_local $0) - ;;@ ~lib/memory.ts:74:27 - (i32.load - ;;@ ~lib/memory.ts:74:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:75:6 - (i32.store - ;;@ ~lib/memory.ts:75:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:75:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:75:27 - (i32.load - ;;@ ~lib/memory.ts:75:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:75:43 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:76:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:76:14 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:76:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:76:24 - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:78:4 - (if - ;;@ ~lib/memory.ts:78:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:78:12 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:78:15 - (block - ;;@ ~lib/memory.ts:79:6 - (i32.store - ;;@ ~lib/memory.ts:79:17 - (get_local $0) - ;;@ ~lib/memory.ts:79:23 - (i32.load - ;;@ ~lib/memory.ts:79:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:80:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:80:14 - (i32.const 4) - ) - ) - ;;@ ~lib/memory.ts:80:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:80:24 - (i32.const 4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:82:4 - (if - ;;@ ~lib/memory.ts:82:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:82:12 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:82:15 - (block - ;;@ ~lib/memory.ts:83:6 - (i32.store16 - ;;@ ~lib/memory.ts:83:17 - (get_local $0) - ;;@ ~lib/memory.ts:83:23 - (i32.load16_u - ;;@ ~lib/memory.ts:83:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:84:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:84:14 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:84:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:84:24 - (i32.const 2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:86:4 - (if - ;;@ ~lib/memory.ts:86:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:86:12 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:86:15 - (i32.store8 - ;;@ ~lib/memory.ts:87:16 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:87:24 - (i32.load8_u - ;;@ ~lib/memory.ts:87:33 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:89:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:94:2 - (if - ;;@ ~lib/memory.ts:94:6 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:94:11 - (i32.const 32) - ) - ;;@ ~lib/memory.ts:94:15 - (block $break|2 - (block $case2|2 - (block $case1|2 - (block $case0|2 - (set_local $5 - ;;@ ~lib/memory.ts:95:12 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:95:19 - (i32.const 3) - ) - ) - (br_if $case0|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:97:11 - (i32.const 1) - ) - ) - (br_if $case1|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:116:11 - (i32.const 2) - ) - ) - (br_if $case2|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:134:11 - (i32.const 3) - ) - ) - (br $break|2) - ) - ;;@ ~lib/memory.ts:97:14 - (block - ;;@ ~lib/memory.ts:98:8 - (set_local $3 - ;;@ ~lib/memory.ts:98:12 - (i32.load - ;;@ ~lib/memory.ts:98:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:99:8 - (i32.store8 - ;;@ ~lib/memory.ts:99:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:99:26 - (i32.load8_u - ;;@ ~lib/memory.ts:99:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:100:8 - (i32.store8 - ;;@ ~lib/memory.ts:100:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:100:26 - (i32.load8_u - ;;@ ~lib/memory.ts:100:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:101:8 - (i32.store8 - ;;@ ~lib/memory.ts:101:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:101:26 - (i32.load8_u - ;;@ ~lib/memory.ts:101:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:102:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:102:13 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:103:8 - (block $break|3 - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:103:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:103:20 - (i32.const 17) - ) - (block - (block - ;;@ ~lib/memory.ts:104:10 - (set_local $4 - ;;@ ~lib/memory.ts:104:14 - (i32.load - ;;@ ~lib/memory.ts:104:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:104:30 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:105:10 - (i32.store - ;;@ ~lib/memory.ts:105:21 - (get_local $0) - ;;@ ~lib/memory.ts:105:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:105:32 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:105:37 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:105:42 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:106:10 - (set_local $3 - ;;@ ~lib/memory.ts:106:14 - (i32.load - ;;@ ~lib/memory.ts:106:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:106:30 - (i32.const 5) - ) - ) - ) - ;;@ ~lib/memory.ts:107:10 - (i32.store - ;;@ ~lib/memory.ts:107:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:107:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:107:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:107:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:107:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:107:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:108:10 - (set_local $4 - ;;@ ~lib/memory.ts:108:14 - (i32.load - ;;@ ~lib/memory.ts:108:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:108:30 - (i32.const 9) - ) - ) - ) - ;;@ ~lib/memory.ts:109:10 - (i32.store - ;;@ ~lib/memory.ts:109:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:109:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:109:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:109:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:109:41 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:109:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:110:10 - (set_local $3 - ;;@ ~lib/memory.ts:110:14 - (i32.load - ;;@ ~lib/memory.ts:110:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:110:30 - (i32.const 13) - ) - ) - ) - ;;@ ~lib/memory.ts:111:10 - (i32.store - ;;@ ~lib/memory.ts:111:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:111:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:111:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:111:37 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:111:42 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:111:47 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:112:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:112:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:112:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:112:38 - (i32.const 16) - ) - ) - ) - (br $continue|3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:114:8 - (br $break|2) - ) - ) - ;;@ ~lib/memory.ts:116:14 - (block - ;;@ ~lib/memory.ts:117:8 - (set_local $3 - ;;@ ~lib/memory.ts:117:12 - (i32.load - ;;@ ~lib/memory.ts:117:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:118:8 - (i32.store8 - ;;@ ~lib/memory.ts:118:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:118:26 - (i32.load8_u - ;;@ ~lib/memory.ts:118:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:119:8 - (i32.store8 - ;;@ ~lib/memory.ts:119:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:119:26 - (i32.load8_u - ;;@ ~lib/memory.ts:119:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:120:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:120:13 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:121:8 - (block $break|4 - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:121:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:121:20 - (i32.const 18) - ) - (block - (block - ;;@ ~lib/memory.ts:122:10 - (set_local $4 - ;;@ ~lib/memory.ts:122:14 - (i32.load - ;;@ ~lib/memory.ts:122:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:122:30 - (i32.const 2) - ) - ) - ) - ;;@ ~lib/memory.ts:123:10 - (i32.store - ;;@ ~lib/memory.ts:123:21 - (get_local $0) - ;;@ ~lib/memory.ts:123:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:123:32 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:123:37 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:123:42 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:124:10 - (set_local $3 - ;;@ ~lib/memory.ts:124:14 - (i32.load - ;;@ ~lib/memory.ts:124:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:124:30 - (i32.const 6) - ) - ) - ) - ;;@ ~lib/memory.ts:125:10 - (i32.store - ;;@ ~lib/memory.ts:125:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:125:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:125:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:125:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:125:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:125:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:126:10 - (set_local $4 - ;;@ ~lib/memory.ts:126:14 - (i32.load - ;;@ ~lib/memory.ts:126:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:126:30 - (i32.const 10) - ) - ) - ) - ;;@ ~lib/memory.ts:127:10 - (i32.store - ;;@ ~lib/memory.ts:127:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:127:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:127:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:127:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:127:41 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:127:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:128:10 - (set_local $3 - ;;@ ~lib/memory.ts:128:14 - (i32.load - ;;@ ~lib/memory.ts:128:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:128:30 - (i32.const 14) - ) - ) - ) - ;;@ ~lib/memory.ts:129:10 - (i32.store - ;;@ ~lib/memory.ts:129:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:129:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:129:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:129:37 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:129:42 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:129:47 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:130:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:130:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:130:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:130:38 - (i32.const 16) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:132:8 - (br $break|2) - ) - ) - ;;@ ~lib/memory.ts:134:14 - (block - ;;@ ~lib/memory.ts:135:8 - (set_local $3 - ;;@ ~lib/memory.ts:135:12 - (i32.load - ;;@ ~lib/memory.ts:135:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:136:8 - (i32.store8 - ;;@ ~lib/memory.ts:136:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:136:26 - (i32.load8_u - ;;@ ~lib/memory.ts:136:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:137:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:137:13 - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:138:8 - (block $break|5 - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:138:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:138:20 - (i32.const 19) - ) - (block - (block - ;;@ ~lib/memory.ts:139:10 - (set_local $4 - ;;@ ~lib/memory.ts:139:14 - (i32.load - ;;@ ~lib/memory.ts:139:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:139:30 - (i32.const 3) - ) - ) - ) - ;;@ ~lib/memory.ts:140:10 - (i32.store - ;;@ ~lib/memory.ts:140:21 - (get_local $0) - ;;@ ~lib/memory.ts:140:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:140:32 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:140:36 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:140:41 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:141:10 - (set_local $3 - ;;@ ~lib/memory.ts:141:14 - (i32.load - ;;@ ~lib/memory.ts:141:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:141:30 - (i32.const 7) - ) - ) - ) - ;;@ ~lib/memory.ts:142:10 - (i32.store - ;;@ ~lib/memory.ts:142:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:142:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:142:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:142:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:142:40 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:142:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:143:10 - (set_local $4 - ;;@ ~lib/memory.ts:143:14 - (i32.load - ;;@ ~lib/memory.ts:143:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:143:30 - (i32.const 11) - ) - ) - ) - ;;@ ~lib/memory.ts:144:10 - (i32.store - ;;@ ~lib/memory.ts:144:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:144:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:144:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:40 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:144:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:145:10 - (set_local $3 - ;;@ ~lib/memory.ts:145:14 - (i32.load - ;;@ ~lib/memory.ts:145:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:145:30 - (i32.const 15) - ) - ) - ) - ;;@ ~lib/memory.ts:146:10 - (i32.store - ;;@ ~lib/memory.ts:146:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:146:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:146:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:146:37 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:146:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:146:46 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:147:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:147:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:147:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:147:38 - (i32.const 16) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:149:8 - (br $break|2) - ) - ) - ) - ;;@ ~lib/memory.ts:155:2 - (if - ;;@ ~lib/memory.ts:155:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:155:10 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:155:14 - (block - ;;@ ~lib/memory.ts:156:4 - (i32.store8 - ;;@ ~lib/memory.ts:156:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:156:22 - (i32.load8_u - ;;@ ~lib/memory.ts:156:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:157:4 - (i32.store8 - ;;@ ~lib/memory.ts:157:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:157:22 - (i32.load8_u - ;;@ ~lib/memory.ts:157:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:158:4 - (i32.store8 - ;;@ ~lib/memory.ts:158:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:158:22 - (i32.load8_u - ;;@ ~lib/memory.ts:158:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:159:4 - (i32.store8 - ;;@ ~lib/memory.ts:159:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:159:22 - (i32.load8_u - ;;@ ~lib/memory.ts:159:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:160:4 - (i32.store8 - ;;@ ~lib/memory.ts:160:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:160:22 - (i32.load8_u - ;;@ ~lib/memory.ts:160:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:161:4 - (i32.store8 - ;;@ ~lib/memory.ts:161:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:161:22 - (i32.load8_u - ;;@ ~lib/memory.ts:161:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:162:4 - (i32.store8 - ;;@ ~lib/memory.ts:162:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:162:22 - (i32.load8_u - ;;@ ~lib/memory.ts:162:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:163:4 - (i32.store8 - ;;@ ~lib/memory.ts:163:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:163:22 - (i32.load8_u - ;;@ ~lib/memory.ts:163:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:164:4 - (i32.store8 - ;;@ ~lib/memory.ts:164:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:164:22 - (i32.load8_u - ;;@ ~lib/memory.ts:164:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:165:4 - (i32.store8 - ;;@ ~lib/memory.ts:165:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:165:22 - (i32.load8_u - ;;@ ~lib/memory.ts:165:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:166:4 - (i32.store8 - ;;@ ~lib/memory.ts:166:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:166:22 - (i32.load8_u - ;;@ ~lib/memory.ts:166:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:167:4 - (i32.store8 - ;;@ ~lib/memory.ts:167:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:167:22 - (i32.load8_u - ;;@ ~lib/memory.ts:167:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:168:4 - (i32.store8 - ;;@ ~lib/memory.ts:168:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:168:22 - (i32.load8_u - ;;@ ~lib/memory.ts:168:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:169:4 - (i32.store8 - ;;@ ~lib/memory.ts:169:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:169:22 - (i32.load8_u - ;;@ ~lib/memory.ts:169:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:170:4 - (i32.store8 - ;;@ ~lib/memory.ts:170:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:170:22 - (i32.load8_u - ;;@ ~lib/memory.ts:170:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:171:4 - (i32.store8 - ;;@ ~lib/memory.ts:171:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:171:22 - (i32.load8_u - ;;@ ~lib/memory.ts:171:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:173:2 - (if - ;;@ ~lib/memory.ts:173:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:173:10 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:173:13 - (block - ;;@ ~lib/memory.ts:174:4 - (i32.store8 - ;;@ ~lib/memory.ts:174:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:174:22 - (i32.load8_u - ;;@ ~lib/memory.ts:174:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:175:4 - (i32.store8 - ;;@ ~lib/memory.ts:175:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:175:22 - (i32.load8_u - ;;@ ~lib/memory.ts:175:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:176:4 - (i32.store8 - ;;@ ~lib/memory.ts:176:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:176:22 - (i32.load8_u - ;;@ ~lib/memory.ts:176:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:177:4 - (i32.store8 - ;;@ ~lib/memory.ts:177:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:177:22 - (i32.load8_u - ;;@ ~lib/memory.ts:177:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:178:4 - (i32.store8 - ;;@ ~lib/memory.ts:178:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:178:22 - (i32.load8_u - ;;@ ~lib/memory.ts:178:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:179:4 - (i32.store8 - ;;@ ~lib/memory.ts:179:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:179:22 - (i32.load8_u - ;;@ ~lib/memory.ts:179:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:180:4 - (i32.store8 - ;;@ ~lib/memory.ts:180:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:180:22 - (i32.load8_u - ;;@ ~lib/memory.ts:180:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:181:4 - (i32.store8 - ;;@ ~lib/memory.ts:181:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:181:22 - (i32.load8_u - ;;@ ~lib/memory.ts:181:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:183:2 - (if - ;;@ ~lib/memory.ts:183:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:183:10 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:183:13 - (block - ;;@ ~lib/memory.ts:184:4 - (i32.store8 - ;;@ ~lib/memory.ts:184:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:184:22 - (i32.load8_u - ;;@ ~lib/memory.ts:184:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:185:4 - (i32.store8 - ;;@ ~lib/memory.ts:185:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:185:22 - (i32.load8_u - ;;@ ~lib/memory.ts:185:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:186:4 - (i32.store8 - ;;@ ~lib/memory.ts:186:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:186:22 - (i32.load8_u - ;;@ ~lib/memory.ts:186:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:187:4 - (i32.store8 - ;;@ ~lib/memory.ts:187:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:187:22 - (i32.load8_u - ;;@ ~lib/memory.ts:187:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:189:2 - (if - ;;@ ~lib/memory.ts:189:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:189:10 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:189:13 - (block - ;;@ ~lib/memory.ts:190:4 - (i32.store8 - ;;@ ~lib/memory.ts:190:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:190:22 - (i32.load8_u - ;;@ ~lib/memory.ts:190:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:191:4 - (i32.store8 - ;;@ ~lib/memory.ts:191:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:191:22 - (i32.load8_u - ;;@ ~lib/memory.ts:191:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:193:2 - (if - ;;@ ~lib/memory.ts:193:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:193:10 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:193:13 - (i32.store8 - ;;@ ~lib/memory.ts:194:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:194:22 - (i32.load8_u - ;;@ ~lib/memory.ts:194:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset ) - (func $~lib/memory/memmove (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - ;;@ ~lib/memory.ts:200:2 - (if - ;;@ ~lib/memory.ts:200:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:200:14 - (get_local $1) - ) - ;;@ ~lib/memory.ts:200:19 - (return) - ) - ;;@ ~lib/memory.ts:201:2 - (if - ;;@ ~lib/memory.ts:201:6 - (if (result i32) - (tee_local $3 - (i32.le_u - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:201:12 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:17 - (get_local $0) - ) - ) - (get_local $3) - ;;@ ~lib/memory.ts:201:25 - (i32.le_u - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:201:32 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:201:42 - (block - ;;@ ~lib/memory.ts:202:4 - (call $~lib/memory/memcpy - ;;@ ~lib/memory.ts:202:11 - (get_local $0) - ;;@ ~lib/memory.ts:202:17 - (get_local $1) - ;;@ ~lib/memory.ts:202:22 - (get_local $2) - ) - ;;@ ~lib/memory.ts:203:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:205:2 - (if - ;;@ ~lib/memory.ts:205:6 - (i32.lt_u - (get_local $0) - ;;@ ~lib/memory.ts:205:13 - (get_local $1) - ) - ;;@ ~lib/memory.ts:205:18 - (block - ;;@ ~lib/memory.ts:206:4 - (if - ;;@ ~lib/memory.ts:206:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:206:9 - (get_local $1) - ;;@ ~lib/memory.ts:206:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:206:21 - (i32.and - ;;@ ~lib/memory.ts:206:22 - (get_local $0) - ;;@ ~lib/memory.ts:206:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:206:33 - (block - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:207:13 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:207:20 - (i32.const 7) - ) - (block - (block - ;;@ ~lib/memory.ts:208:8 - (if - ;;@ ~lib/memory.ts:208:12 - (i32.eqz - ;;@ ~lib/memory.ts:208:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:208:16 - (return) - ) - ;;@ ~lib/memory.ts:209:8 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:209:10 - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:8 - (i32.store8 - ;;@ ~lib/memory.ts:210:18 - (block (result i32) - (set_local $3 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ;;@ ~lib/memory.ts:210:26 - (i32.load8_u - ;;@ ~lib/memory.ts:210:35 - (block (result i32) - (set_local $3 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:212:6 - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:212:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:212:18 - (i32.const 8) - ) - (block - (block - ;;@ ~lib/memory.ts:213:8 - (i64.store - ;;@ ~lib/memory.ts:213:19 - (get_local $0) - ;;@ ~lib/memory.ts:213:25 - (i64.load - ;;@ ~lib/memory.ts:213:35 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:214:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:214:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:215:8 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:215:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:216:8 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:216:16 - (i32.const 8) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:219:4 - (block $break|2 - (loop $continue|2 - (if - ;;@ ~lib/memory.ts:219:11 - (get_local $2) - (block - (block - ;;@ ~lib/memory.ts:220:6 - (i32.store8 - ;;@ ~lib/memory.ts:220:16 - (block (result i32) - (set_local $3 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ;;@ ~lib/memory.ts:220:24 - (i32.load8_u - ;;@ ~lib/memory.ts:220:33 - (block (result i32) - (set_local $3 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:221:6 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:221:8 - (get_local $2) - (i32.const 1) - ) - ) - ) - (br $continue|2) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:223:9 - (block - ;;@ ~lib/memory.ts:224:4 - (if - ;;@ ~lib/memory.ts:224:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:224:9 - (get_local $1) - ;;@ ~lib/memory.ts:224:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:224:21 - (i32.and - ;;@ ~lib/memory.ts:224:22 - (get_local $0) - ;;@ ~lib/memory.ts:224:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:224:33 - (block - (block $break|3 - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:225:13 - (i32.and - (i32.add - ;;@ ~lib/memory.ts:225:14 - (get_local $0) - ;;@ ~lib/memory.ts:225:21 - (get_local $2) - ) - ;;@ ~lib/memory.ts:225:26 - (i32.const 7) - ) - (block - (block - ;;@ ~lib/memory.ts:226:8 - (if - ;;@ ~lib/memory.ts:226:12 - (i32.eqz - ;;@ ~lib/memory.ts:226:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:226:16 - (return) - ) - ;;@ ~lib/memory.ts:227:8 - (i32.store8 - ;;@ ~lib/memory.ts:227:18 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:227:25 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:227:27 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:227:30 - (i32.load8_u - ;;@ ~lib/memory.ts:227:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:227:45 - (get_local $2) - ) - ) - ) - ) - (br $continue|3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:229:6 - (block $break|4 - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:229:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:229:18 - (i32.const 8) - ) - (block - (block - ;;@ ~lib/memory.ts:230:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:230:13 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:231:8 - (i64.store - ;;@ ~lib/memory.ts:231:19 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:231:26 - (get_local $2) - ) - ;;@ ~lib/memory.ts:231:29 - (i64.load - ;;@ ~lib/memory.ts:231:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:231:45 - (get_local $2) - ) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:234:4 - (block $break|5 - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:234:11 - (get_local $2) - (block - ;;@ ~lib/memory.ts:234:14 - (i32.store8 - ;;@ ~lib/memory.ts:235:16 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:235:23 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:235:25 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:235:28 - (i32.load8_u - ;;@ ~lib/memory.ts:235:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:235:43 - (get_local $2) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ) - ) - (func $~lib/memory/memory.copy (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:16:4 - (call $~lib/memory/memmove - ;;@ ~lib/memory.ts:16:12 - (get_local $0) - ;;@ ~lib/memory.ts:16:18 - (get_local $1) - ;;@ ~lib/memory.ts:16:23 - (get_local $2) - ) + (func $start:assembly/index (; 1 ;) (type $_) + call $start:~lib/allocator/arena ) - (func $~lib/memory/memcmp (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/memory/memcmp (; 2 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - ;;@ ~lib/memory.ts:302:2 - (if - ;;@ ~lib/memory.ts:302:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:302:12 - (get_local $1) - ) - ;;@ ~lib/memory.ts:302:23 - (return - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:303:9 - (if (result i32) - (tee_local $3 - (i32.ne - (get_local $2) - ;;@ ~lib/memory.ts:303:14 - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:19 - (i32.eq - (i32.load8_u - ;;@ ~lib/memory.ts:303:28 - (get_local $0) - ) - ;;@ ~lib/memory.ts:303:35 - (i32.load8_u - ;;@ ~lib/memory.ts:303:44 - (get_local $1) - ) - ) - (get_local $3) - ) - (block - (block - ;;@ ~lib/memory.ts:304:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:9 - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:15 - (set_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (if (result i32) - ;;@ ~lib/memory.ts:306:9 - (get_local $2) - ;;@ ~lib/memory.ts:306:13 - (i32.sub - (i32.load8_u - ;;@ ~lib/memory.ts:306:27 - (get_local $0) - ) - ;;@ ~lib/memory.ts:306:33 - (i32.load8_u - ;;@ ~lib/memory.ts:306:47 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (i32.const 0) - ) + local.get $0 + local.get $1 + i32.eq + if + i32.const 0 + return + end + block $break|0 + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + local.tee $3 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.eq + else + local.get $3 + end + if + block + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.set $1 + end + br $continue|0 + end + end + end + local.get $2 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.sub + else + i32.const 0 + end ) - (func $~lib/memory/memory.compare (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/memory.ts:21:27 - (call $~lib/memory/memcmp - ;;@ ~lib/memory.ts:21:18 - (get_local $0) - ;;@ ~lib/memory.ts:21:22 - (get_local $1) - ;;@ ~lib/memory.ts:21:26 - (get_local $2) - ) + (func $~lib/memory/memory.compare (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + local.get $2 + call $~lib/internal/memory/memcmp ) - (func $~lib/allocator/arena/__memory_allocate (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) - ;;@ ~lib/allocator/arena.ts:17:2 - (if - ;;@ ~lib/allocator/arena.ts:17:6 - (get_local $0) - ;;@ ~lib/allocator/arena.ts:17:12 - (block - ;;@ ~lib/allocator/arena.ts:18:4 - (if - ;;@ ~lib/allocator/arena.ts:18:8 - (i32.gt_u - (get_local $0) - ;;@ ~lib/allocator/arena.ts:18:15 - (get_global $~lib/internal/allocator/MAX_SIZE_32) - ) - ;;@ ~lib/allocator/arena.ts:18:28 - (unreachable) - ) - ;;@ ~lib/allocator/arena.ts:19:4 - (set_local $1 - ;;@ ~lib/allocator/arena.ts:19:14 - (get_global $~lib/allocator/arena/offset) - ) - ;;@ ~lib/allocator/arena.ts:20:4 - (set_local $2 - ;;@ ~lib/allocator/arena.ts:20:17 - (i32.and - (i32.add - ;;@ ~lib/allocator/arena.ts:20:18 - (i32.add - (get_local $1) - ;;@ ~lib/allocator/arena.ts:20:24 - (get_local $0) - ) - ;;@ ~lib/allocator/arena.ts:20:31 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ;;@ ~lib/allocator/arena.ts:20:42 - (i32.xor - ;;@ ~lib/allocator/arena.ts:20:43 - (get_global $~lib/internal/allocator/AL_MASK) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:21:4 - (set_local $3 - ;;@ ~lib/allocator/arena.ts:21:29 - (current_memory) - ) - ;;@ ~lib/allocator/arena.ts:22:4 - (if - ;;@ ~lib/allocator/arena.ts:22:8 - (i32.gt_u - (get_local $2) - ;;@ ~lib/allocator/arena.ts:22:17 - (i32.shl - (get_local $3) - ;;@ ~lib/allocator/arena.ts:22:39 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/arena.ts:22:43 - (block - ;;@ ~lib/allocator/arena.ts:23:6 - (set_local $4 - ;;@ ~lib/allocator/arena.ts:23:24 - (i32.shr_u - (i32.and - ;;@ ~lib/allocator/arena.ts:23:25 - (i32.add - ;;@ ~lib/allocator/arena.ts:23:26 - (i32.sub - (get_local $2) - ;;@ ~lib/allocator/arena.ts:23:35 - (get_local $1) - ) - ;;@ ~lib/allocator/arena.ts:23:41 - (i32.const 65535) - ) - ;;@ ~lib/allocator/arena.ts:23:51 - (i32.xor - ;;@ ~lib/allocator/arena.ts:23:52 - (i32.const 65535) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/arena.ts:23:64 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/arena.ts:24:6 - (set_local $5 - ;;@ ~lib/allocator/arena.ts:24:24 - (select - (tee_local $5 - ;;@ ~lib/allocator/arena.ts:24:28 - (get_local $3) - ) - (tee_local $6 - ;;@ ~lib/allocator/arena.ts:24:41 - (get_local $4) - ) - (i32.gt_s - (get_local $5) - (get_local $6) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:25:6 - (if - ;;@ ~lib/allocator/arena.ts:25:10 - (i32.lt_s - ;;@ ~lib/allocator/arena.ts:25:17 - (grow_memory - ;;@ ~lib/allocator/arena.ts:25:22 - (get_local $5) - ) - ;;@ ~lib/allocator/arena.ts:25:37 - (i32.const 0) - ) - ;;@ ~lib/allocator/arena.ts:25:40 - (if - ;;@ ~lib/allocator/arena.ts:26:12 - (i32.lt_s - ;;@ ~lib/allocator/arena.ts:26:19 - (grow_memory - ;;@ ~lib/allocator/arena.ts:26:24 - (get_local $4) - ) - ;;@ ~lib/allocator/arena.ts:26:39 - (i32.const 0) - ) - ;;@ ~lib/allocator/arena.ts:26:42 - (unreachable) - ) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:31:4 - (set_global $~lib/allocator/arena/offset - ;;@ ~lib/allocator/arena.ts:31:13 - (get_local $2) - ) - ;;@ ~lib/allocator/arena.ts:32:11 - (return - (get_local $1) - ) - ) - ) - ;;@ ~lib/allocator/arena.ts:34:9 - (i32.const 0) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.set $1 + local.get $1 + local.get $0 + local.tee $2 + i32.const 1 + local.tee $3 + local.get $2 + local.get $3 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $4 + current_memory + local.set $5 + local.get $4 + local.get $5 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $4 + local.get $1 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $2 + local.get $5 + local.tee $3 + local.get $2 + local.tee $6 + local.get $3 + local.get $6 + i32.gt_s + select + local.set $3 + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $2 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $4 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/allocator/arena/__memory_allocate + return ) - (func $~lib/memory/memory.allocate (; 8 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/memory.ts:37:4 - (return - ;;@ ~lib/memory.ts:37:45 - (call $~lib/allocator/arena/__memory_allocate - ;;@ ~lib/memory.ts:37:63 - (get_local $0) - ) - ) + (func $~lib/allocator/arena/__memory_free (; 6 ;) (type $i_) (param $0 i32) + nop ) - (func $~lib/allocator/arena/__memory_free (; 9 ;) (type $iv) (param $0 i32) - (nop) + (func $~lib/memory/memory.free (; 7 ;) (type $i_) (param $0 i32) + local.get $0 + call $~lib/allocator/arena/__memory_free + return ) - (func $~lib/memory/memory.free (; 10 ;) (type $iv) (param $0 i32) - ;;@ ~lib/memory.ts:43:36 - (call $~lib/allocator/arena/__memory_free - ;;@ ~lib/memory.ts:43:50 - (get_local $0) - ) - ;;@ ~lib/memory.ts:43:56 - (return) + (func $~lib/allocator/arena/__memory_reset (; 8 ;) (type $_) + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset ) - (func $~lib/allocator/arena/__memory_reset (; 11 ;) (type $v) - ;;@ ~lib/allocator/arena.ts:44:2 - (set_global $~lib/allocator/arena/offset - ;;@ ~lib/allocator/arena.ts:44:11 - (get_global $~lib/allocator/arena/startOffset) - ) + (func $~lib/memory/memory.reset (; 9 ;) (type $_) + call $~lib/allocator/arena/__memory_reset + return ) - (func $~lib/memory/memory.reset (; 12 ;) (type $v) - ;;@ ~lib/memory.ts:49:37 - (call $~lib/allocator/arena/__memory_reset) - ;;@ ~lib/memory.ts:49:55 - (return) + (func $start (; 10 ;) (type $_) + call $start:assembly/index ) - (func $start (; 13 ;) (type $v) - (set_global $~lib/allocator/arena/startOffset - ;;@ ~lib/allocator/arena.ts:12:25 - (i32.and - (i32.add - ;;@ ~lib/allocator/arena.ts:12:26 - (get_global $HEAP_BASE) - ;;@ ~lib/allocator/arena.ts:12:38 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ;;@ ~lib/allocator/arena.ts:12:49 - (i32.xor - ;;@ ~lib/allocator/arena.ts:12:50 - (get_global $~lib/internal/allocator/AL_MASK) - (i32.const -1) - ) - ) - ) - (set_global $~lib/allocator/arena/offset - ;;@ ~lib/allocator/arena.ts:13:20 - (get_global $~lib/allocator/arena/startOffset) - ) + (func $null (; 11 ;) (type $_) ) ) diff --git a/tests/allocators/buddy/optimized.wat b/tests/allocators/buddy/optimized.wat index 1256781b5a..234ec45d80 100644 --- a/tests/allocators/buddy/optimized.wat +++ b/tests/allocators/buddy/optimized.wat @@ -1,11 +1,13 @@ (module - (type $iiiv (func (param i32 i32 i32))) + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $iv (func (param i32))) - (type $iiv (func (param i32 i32))) + (type $i_ (func (param i32))) + (type $ii_ (func (param i32 i32))) (type $iii (func (param i32 i32) (result i32))) - (type $v (func)) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) (global $~lib/allocator/buddy/BUCKETS_START (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/BUCKETS_END (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/bucket_limit (mut i32) (i32.const 0)) @@ -13,4127 +15,609 @@ (global $~lib/allocator/buddy/NODE_IS_SPLIT_END (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/base_ptr (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/max_ptr (mut i32) (i32.const 0)) - (memory $0 0) (export "memory" (memory $0)) - (export "memory.fill" (func $~lib/memory/memory.fill)) - (export "memory.copy" (func $~lib/memory/memory.copy)) + (export "table" (table $0)) (export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.allocate" (func $~lib/memory/memory.allocate)) (export "memory.free" (func $~lib/memory/memory.free)) (export "memory.reset" (func $~lib/memory/memory.reset)) (start $start) - (func $~lib/memory/memset (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i64) - (local $4 i32) - ;;@ ~lib/memory.ts:244:2 - (if - ;;@ ~lib/memory.ts:244:6 - (i32.eqz - ;;@ ~lib/memory.ts:244:7 - (get_local $2) - ) - ;;@ ~lib/memory.ts:244:10 - (return) - ) - ;;@ ~lib/memory.ts:245:2 - (i32.store8 - ;;@ ~lib/memory.ts:245:12 - (get_local $0) - ;;@ ~lib/memory.ts:245:18 - (get_local $1) - ) - ;;@ ~lib/memory.ts:246:2 - (i32.store8 - ;;@ ~lib/memory.ts:246:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:246:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:246:23 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:246:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:247:2 - (if - ;;@ ~lib/memory.ts:247:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:247:11 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:247:14 - (return) - ) - ;;@ ~lib/memory.ts:249:2 - (i32.store8 - ;;@ ~lib/memory.ts:249:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:249:19 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:249:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:250:2 - (i32.store8 - ;;@ ~lib/memory.ts:250:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:250:19 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:250:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:251:2 - (i32.store8 - ;;@ ~lib/memory.ts:251:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:251:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:251:23 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:251:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:252:2 - (i32.store8 - ;;@ ~lib/memory.ts:252:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:252:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:252:23 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:252:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:253:2 - (if - ;;@ ~lib/memory.ts:253:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:253:11 - (i32.const 6) - ) - ;;@ ~lib/memory.ts:253:14 - (return) - ) - ;;@ ~lib/memory.ts:254:2 - (i32.store8 - ;;@ ~lib/memory.ts:254:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:254:19 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:254:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:255:2 - (i32.store8 - ;;@ ~lib/memory.ts:255:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:255:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:255:23 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:255:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:256:2 - (if - ;;@ ~lib/memory.ts:256:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:256:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:256:14 - (return) - ) - ;;@ ~lib/memory.ts:267:2 - (i32.store - ;;@ ~lib/memory.ts:260:2 - (tee_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:259:2 - (tee_local $4 - ;;@ ~lib/memory.ts:259:17 - (i32.and - (i32.sub - (i32.const 0) - ;;@ ~lib/memory.ts:259:18 - (get_local $0) - ) - ;;@ ~lib/memory.ts:259:25 - (i32.const 3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:264:2 - (tee_local $1 - ;;@ ~lib/memory.ts:264:17 - (i32.mul - (i32.and - ;;@ ~lib/memory.ts:264:33 - (get_local $1) - (i32.const 255) - ) - (i32.const 16843009) - ) - ) - ) - ;;@ ~lib/memory.ts:268:2 - (i32.store - ;;@ ~lib/memory.ts:268:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:262:2 - (tee_local $2 - (i32.and - (i32.sub - ;;@ ~lib/memory.ts:261:2 - (get_local $2) - ;;@ ~lib/memory.ts:261:7 - (get_local $4) - ) - ;;@ ~lib/memory.ts:262:7 - (i32.const -4) - ) - ) - ) - ;;@ ~lib/memory.ts:268:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:268:27 - (get_local $1) - ) - ;;@ ~lib/memory.ts:269:2 - (if - ;;@ ~lib/memory.ts:269:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:269:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:269:14 - (return) - ) - ;;@ ~lib/memory.ts:270:2 - (i32.store - ;;@ ~lib/memory.ts:270:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:270:20 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:270:23 - (get_local $1) - ) - ;;@ ~lib/memory.ts:271:2 - (i32.store - ;;@ ~lib/memory.ts:271:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:271:20 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:271:23 - (get_local $1) - ) - ;;@ ~lib/memory.ts:272:2 - (i32.store - ;;@ ~lib/memory.ts:272:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:272:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:272:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:272:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:273:2 - (i32.store - ;;@ ~lib/memory.ts:273:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:273:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:273:24 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:273:27 - (get_local $1) - ) - ;;@ ~lib/memory.ts:274:2 - (if - ;;@ ~lib/memory.ts:274:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:274:11 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:274:15 - (return) - ) - ;;@ ~lib/memory.ts:275:2 - (i32.store - ;;@ ~lib/memory.ts:275:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:275:20 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:275:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:276:2 - (i32.store - ;;@ ~lib/memory.ts:276:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:276:20 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:276:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:277:2 - (i32.store - ;;@ ~lib/memory.ts:277:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:277:20 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:277:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:278:2 - (i32.store - ;;@ ~lib/memory.ts:278:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:278:20 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:278:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:279:2 - (i32.store - ;;@ ~lib/memory.ts:279:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:279:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:279:24 - (i32.const 28) - ) - ;;@ ~lib/memory.ts:279:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:280:2 - (i32.store - ;;@ ~lib/memory.ts:280:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:280:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:280:24 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:280:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:281:2 - (i32.store - ;;@ ~lib/memory.ts:281:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:281:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:281:24 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:281:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:282:2 - (i32.store - ;;@ ~lib/memory.ts:282:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:282:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:282:24 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:282:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:286:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:285:2 - (tee_local $4 - ;;@ ~lib/memory.ts:285:6 - (i32.add - ;;@ ~lib/memory.ts:285:11 - (i32.and - ;;@ ~lib/memory.ts:285:12 - (get_local $0) - ;;@ ~lib/memory.ts:285:19 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:285:6 - (i32.const 24) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:287:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:287:7 - (get_local $4) - ) - ) - ;;@ ~lib/memory.ts:290:2 - (set_local $3 - ;;@ ~lib/memory.ts:290:17 - (i64.or - (i64.extend_u/i32 - (get_local $1) - ) - ;;@ ~lib/memory.ts:290:28 - (i64.shl - ;;@ ~lib/memory.ts:290:29 - (i64.extend_u/i32 - (get_local $1) - ) - ;;@ ~lib/memory.ts:290:41 - (i64.const 32) - ) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:291:9 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:291:14 - (i32.const 32) - ) - (block - ;;@ ~lib/memory.ts:292:4 - (i64.store - ;;@ ~lib/memory.ts:292:15 - (get_local $0) - ;;@ ~lib/memory.ts:292:21 - (get_local $3) - ) - ;;@ ~lib/memory.ts:293:4 - (i64.store - ;;@ ~lib/memory.ts:293:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:293:22 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:293:25 - (get_local $3) - ) - ;;@ ~lib/memory.ts:294:4 - (i64.store - ;;@ ~lib/memory.ts:294:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:294:22 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:294:26 - (get_local $3) - ) - ;;@ ~lib/memory.ts:295:4 - (i64.store - ;;@ ~lib/memory.ts:295:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:295:22 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:295:26 - (get_local $3) - ) - ;;@ ~lib/memory.ts:296:4 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:296:9 - (i32.const 32) - ) - ) - ;;@ ~lib/memory.ts:297:4 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:297:12 - (i32.const 32) - ) - ) - (br $continue|0) - ) - ) - ) - ) - (func $~lib/memory/memory.fill (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:11:4 - (call $~lib/memory/memset - ;;@ ~lib/memory.ts:11:11 - (get_local $0) - ;;@ ~lib/memory.ts:11:17 - (get_local $1) - ;;@ ~lib/memory.ts:11:20 - (get_local $2) - ) - ) - (func $~lib/memory/memcpy (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (loop $continue|0 - (if - (select - ;;@ ~lib/memory.ts:59:14 - (i32.and - ;;@ ~lib/memory.ts:59:15 - (get_local $1) - ;;@ ~lib/memory.ts:59:21 - (i32.const 3) - ) - (get_local $2) - ;;@ ~lib/memory.ts:59:9 - (get_local $2) - ) - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:60:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:60:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:60:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:60:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:61:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/memory.ts:65:2 - (if - (i32.eqz - ;;@ ~lib/memory.ts:65:6 - (i32.and - ;;@ ~lib/memory.ts:65:7 - (get_local $0) - ;;@ ~lib/memory.ts:65:14 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:65:23 - (block - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:66:11 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:66:16 - (i32.const 16) - ) - (block - ;;@ ~lib/memory.ts:67:6 - (i32.store - ;;@ ~lib/memory.ts:67:17 - (get_local $0) - ;;@ ~lib/memory.ts:67:28 - (i32.load - ;;@ ~lib/memory.ts:67:38 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:68:6 - (i32.store - ;;@ ~lib/memory.ts:68:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:68:25 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:68:28 - (i32.load - ;;@ ~lib/memory.ts:68:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:68:45 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:69:6 - (i32.store - ;;@ ~lib/memory.ts:69:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:69:25 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:69:28 - (i32.load - ;;@ ~lib/memory.ts:69:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:69:45 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:70:6 - (i32.store - ;;@ ~lib/memory.ts:70:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:70:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:70:28 - (i32.load - ;;@ ~lib/memory.ts:70:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:70:44 - (i32.const 12) - ) - ) - ) - ;;@ ~lib/memory.ts:71:6 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:71:13 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:17 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:71:25 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:29 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:71:34 - (i32.const 16) - ) - ) - (br $continue|1) - ) - ) - ) - ;;@ ~lib/memory.ts:73:4 - (if - ;;@ ~lib/memory.ts:73:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:73:12 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:73:15 - (block - ;;@ ~lib/memory.ts:74:6 - (i32.store - ;;@ ~lib/memory.ts:74:17 - (get_local $0) - ;;@ ~lib/memory.ts:74:27 - (i32.load - ;;@ ~lib/memory.ts:74:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:75:6 - (i32.store - ;;@ ~lib/memory.ts:75:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:75:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:75:27 - (i32.load - ;;@ ~lib/memory.ts:75:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:75:43 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:76:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:76:14 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:76:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:76:24 - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:78:4 - (if - ;;@ ~lib/memory.ts:78:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:78:12 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:78:15 - (block - ;;@ ~lib/memory.ts:79:6 - (i32.store - ;;@ ~lib/memory.ts:79:17 - (get_local $0) - ;;@ ~lib/memory.ts:79:23 - (i32.load - ;;@ ~lib/memory.ts:79:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:80:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:80:14 - (i32.const 4) - ) - ) - ;;@ ~lib/memory.ts:80:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:80:24 - (i32.const 4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:82:4 - (if - ;;@ ~lib/memory.ts:82:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:82:12 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:82:15 - (block - ;;@ ~lib/memory.ts:83:6 - (i32.store16 - ;;@ ~lib/memory.ts:83:17 - (get_local $0) - ;;@ ~lib/memory.ts:83:23 - (i32.load16_u - ;;@ ~lib/memory.ts:83:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:84:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:84:14 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:84:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:84:24 - (i32.const 2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:86:4 - (if - ;;@ ~lib/memory.ts:86:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:86:12 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:87:16 - (block - (set_local $3 - (get_local $0) - ) - ;;@ ~lib/memory.ts:86:15 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:87:33 - (block (result i32) - (set_local $3 - (get_local $1) - ) - ;;@ ~lib/memory.ts:87:24 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:89:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:94:2 - (if - ;;@ ~lib/memory.ts:94:6 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:94:11 - (i32.const 32) - ) - ;;@ ~lib/memory.ts:94:15 - (block $break|2 - (block $case2|2 - (block $case1|2 - (block $case0|2 - (block $tablify|0 - (br_table $case0|2 $case1|2 $case2|2 $tablify|0 - (i32.sub - ;;@ ~lib/memory.ts:95:12 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:95:19 - (i32.const 3) - ) - (i32.const 1) - ) - ) - ) - (br $break|2) - ) - ;;@ ~lib/memory.ts:98:8 - (set_local $4 - ;;@ ~lib/memory.ts:98:12 - (i32.load - ;;@ ~lib/memory.ts:98:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:99:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:99:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:99:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:99:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:100:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:100:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:100:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:100:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:101:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:101:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:101:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:101:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:102:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:102:13 - (i32.const 3) - ) - ) - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:103:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:103:20 - (i32.const 17) - ) - (block - ;;@ ~lib/memory.ts:105:10 - (i32.store - ;;@ ~lib/memory.ts:105:21 - (get_local $0) - ;;@ ~lib/memory.ts:105:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:105:32 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:105:37 - (i32.shl - ;;@ ~lib/memory.ts:104:10 - (tee_local $3 - ;;@ ~lib/memory.ts:104:14 - (i32.load - ;;@ ~lib/memory.ts:104:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:104:30 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:105:42 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:107:10 - (i32.store - ;;@ ~lib/memory.ts:107:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:107:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:107:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:107:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:107:41 - (i32.shl - ;;@ ~lib/memory.ts:106:10 - (tee_local $4 - ;;@ ~lib/memory.ts:106:14 - (i32.load - ;;@ ~lib/memory.ts:106:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:106:30 - (i32.const 5) - ) - ) - ) - ;;@ ~lib/memory.ts:107:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:109:10 - (i32.store - ;;@ ~lib/memory.ts:109:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:109:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:109:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:109:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:109:41 - (i32.shl - ;;@ ~lib/memory.ts:108:10 - (tee_local $3 - ;;@ ~lib/memory.ts:108:14 - (i32.load - ;;@ ~lib/memory.ts:108:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:108:30 - (i32.const 9) - ) - ) - ) - ;;@ ~lib/memory.ts:109:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:111:10 - (i32.store - ;;@ ~lib/memory.ts:111:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:111:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:111:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:111:37 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:111:42 - (i32.shl - ;;@ ~lib/memory.ts:110:10 - (tee_local $4 - ;;@ ~lib/memory.ts:110:14 - (i32.load - ;;@ ~lib/memory.ts:110:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:110:30 - (i32.const 13) - ) - ) - ) - ;;@ ~lib/memory.ts:111:47 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:112:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:112:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:112:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:112:38 - (i32.const 16) - ) - ) - (br $continue|3) - ) - ) - ) - ;;@ ~lib/memory.ts:114:8 - (br $break|2) - ) - ;;@ ~lib/memory.ts:117:8 - (set_local $4 - ;;@ ~lib/memory.ts:117:12 - (i32.load - ;;@ ~lib/memory.ts:117:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:118:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:118:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:118:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:118:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:119:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:119:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:119:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:119:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:120:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:120:13 - (i32.const 2) - ) - ) - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:121:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:121:20 - (i32.const 18) - ) - (block - ;;@ ~lib/memory.ts:123:10 - (i32.store - ;;@ ~lib/memory.ts:123:21 - (get_local $0) - ;;@ ~lib/memory.ts:123:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:123:32 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:123:37 - (i32.shl - ;;@ ~lib/memory.ts:122:10 - (tee_local $3 - ;;@ ~lib/memory.ts:122:14 - (i32.load - ;;@ ~lib/memory.ts:122:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:122:30 - (i32.const 2) - ) - ) - ) - ;;@ ~lib/memory.ts:123:42 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:125:10 - (i32.store - ;;@ ~lib/memory.ts:125:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:125:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:125:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:125:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:125:41 - (i32.shl - ;;@ ~lib/memory.ts:124:10 - (tee_local $4 - ;;@ ~lib/memory.ts:124:14 - (i32.load - ;;@ ~lib/memory.ts:124:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:124:30 - (i32.const 6) - ) - ) - ) - ;;@ ~lib/memory.ts:125:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:127:10 - (i32.store - ;;@ ~lib/memory.ts:127:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:127:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:127:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:127:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:127:41 - (i32.shl - ;;@ ~lib/memory.ts:126:10 - (tee_local $3 - ;;@ ~lib/memory.ts:126:14 - (i32.load - ;;@ ~lib/memory.ts:126:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:126:30 - (i32.const 10) - ) - ) - ) - ;;@ ~lib/memory.ts:127:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:129:10 - (i32.store - ;;@ ~lib/memory.ts:129:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:129:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:129:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:129:37 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:129:42 - (i32.shl - ;;@ ~lib/memory.ts:128:10 - (tee_local $4 - ;;@ ~lib/memory.ts:128:14 - (i32.load - ;;@ ~lib/memory.ts:128:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:128:30 - (i32.const 14) - ) - ) - ) - ;;@ ~lib/memory.ts:129:47 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:130:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:130:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:130:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:130:38 - (i32.const 16) - ) - ) - (br $continue|4) - ) - ) - ) - ;;@ ~lib/memory.ts:132:8 - (br $break|2) - ) - ;;@ ~lib/memory.ts:135:8 - (set_local $4 - ;;@ ~lib/memory.ts:135:12 - (i32.load - ;;@ ~lib/memory.ts:135:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:136:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:136:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:136:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:136:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:137:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:137:13 - (i32.const 1) - ) - ) - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:138:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:138:20 - (i32.const 19) - ) - (block - ;;@ ~lib/memory.ts:140:10 - (i32.store - ;;@ ~lib/memory.ts:140:21 - (get_local $0) - ;;@ ~lib/memory.ts:140:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:140:32 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:140:36 - (i32.shl - ;;@ ~lib/memory.ts:139:10 - (tee_local $3 - ;;@ ~lib/memory.ts:139:14 - (i32.load - ;;@ ~lib/memory.ts:139:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:139:30 - (i32.const 3) - ) - ) - ) - ;;@ ~lib/memory.ts:140:41 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:142:10 - (i32.store - ;;@ ~lib/memory.ts:142:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:142:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:142:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:142:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:142:40 - (i32.shl - ;;@ ~lib/memory.ts:141:10 - (tee_local $4 - ;;@ ~lib/memory.ts:141:14 - (i32.load - ;;@ ~lib/memory.ts:141:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:141:30 - (i32.const 7) - ) - ) - ) - ;;@ ~lib/memory.ts:142:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:144:10 - (i32.store - ;;@ ~lib/memory.ts:144:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:144:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:144:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:40 - (i32.shl - ;;@ ~lib/memory.ts:143:10 - (tee_local $3 - ;;@ ~lib/memory.ts:143:14 - (i32.load - ;;@ ~lib/memory.ts:143:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:143:30 - (i32.const 11) - ) - ) - ) - ;;@ ~lib/memory.ts:144:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:146:10 - (i32.store - ;;@ ~lib/memory.ts:146:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:146:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:146:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:146:37 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:146:41 - (i32.shl - ;;@ ~lib/memory.ts:145:10 - (tee_local $4 - ;;@ ~lib/memory.ts:145:14 - (i32.load - ;;@ ~lib/memory.ts:145:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:145:30 - (i32.const 15) - ) - ) - ) - ;;@ ~lib/memory.ts:146:46 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:147:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:147:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:147:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:147:38 - (i32.const 16) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:155:2 - (if - ;;@ ~lib/memory.ts:155:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:155:10 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:155:14 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:156:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:156:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:156:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:156:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:157:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:157:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:157:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:157:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:158:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:158:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:158:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:158:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:159:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:159:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:159:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:159:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:160:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:160:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:160:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:160:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:161:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:161:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:161:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:161:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:162:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:162:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:162:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:162:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:163:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:163:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:163:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:163:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:164:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:164:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:164:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:164:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:165:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:165:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:165:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:165:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:166:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:166:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:166:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:166:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:167:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:167:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:167:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:167:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:168:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:168:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:168:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:168:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:169:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:169:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:169:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:169:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:170:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:170:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:170:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:170:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:171:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:171:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:171:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:171:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:173:2 - (if - ;;@ ~lib/memory.ts:173:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:173:10 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:173:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:174:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:174:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:174:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:174:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:175:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:175:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:175:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:175:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:176:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:176:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:176:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:176:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:177:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:177:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:177:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:177:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:178:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:178:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:178:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:178:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:179:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:179:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:179:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:179:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:180:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:180:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:180:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:180:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:181:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:181:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:181:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:181:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:183:2 - (if - ;;@ ~lib/memory.ts:183:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:183:10 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:183:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:184:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:184:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:184:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:184:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:185:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:185:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:185:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:185:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:186:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:186:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:186:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:186:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:187:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:187:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:187:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:187:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:189:2 - (if - ;;@ ~lib/memory.ts:189:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:189:10 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:189:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:190:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:190:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:190:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:190:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:191:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:191:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:191:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:191:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:193:2 - (if - ;;@ ~lib/memory.ts:193:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:193:10 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:194:14 - (block - (set_local $3 - (get_local $0) - ) - ;;@ ~lib/memory.ts:193:13 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:194:31 - (block (result i32) - (set_local $3 - (get_local $1) - ) - ;;@ ~lib/memory.ts:194:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ) - (func $~lib/memory/memmove (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - ;;@ ~lib/memory.ts:200:2 - (if - ;;@ ~lib/memory.ts:200:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:200:14 - (get_local $1) - ) - ;;@ ~lib/memory.ts:200:19 - (return) - ) - ;;@ ~lib/memory.ts:201:2 - (if - ;;@ ~lib/memory.ts:201:6 - (if (result i32) - (tee_local $3 - (i32.le_u - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:201:12 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:17 - (get_local $0) - ) - ) - (get_local $3) - ;;@ ~lib/memory.ts:201:25 - (i32.le_u - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:201:32 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:201:42 - (block - ;;@ ~lib/memory.ts:202:4 - (call $~lib/memory/memcpy - ;;@ ~lib/memory.ts:202:11 - (get_local $0) - ;;@ ~lib/memory.ts:202:17 - (get_local $1) - ;;@ ~lib/memory.ts:202:22 - (get_local $2) - ) - ;;@ ~lib/memory.ts:203:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:205:2 - (if - ;;@ ~lib/memory.ts:205:6 - (i32.lt_u - (get_local $0) - ;;@ ~lib/memory.ts:205:13 - (get_local $1) - ) - ;;@ ~lib/memory.ts:205:18 - (block - ;;@ ~lib/memory.ts:206:4 - (if - ;;@ ~lib/memory.ts:206:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:206:9 - (get_local $1) - ;;@ ~lib/memory.ts:206:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:206:21 - (i32.and - ;;@ ~lib/memory.ts:206:22 - (get_local $0) - ;;@ ~lib/memory.ts:206:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:206:33 - (block - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:207:13 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:207:20 - (i32.const 7) - ) - (block - ;;@ ~lib/memory.ts:208:8 - (if - ;;@ ~lib/memory.ts:208:12 - (i32.eqz - ;;@ ~lib/memory.ts:208:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:208:16 - (return) - ) - ;;@ ~lib/memory.ts:209:8 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:209:10 - (get_local $2) - (i32.const 1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:210:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:210:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (br $continue|0) - ) - ) - ) - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:212:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:212:18 - (i32.const 8) - ) - (block - ;;@ ~lib/memory.ts:213:8 - (i64.store - ;;@ ~lib/memory.ts:213:19 - (get_local $0) - ;;@ ~lib/memory.ts:213:25 - (i64.load - ;;@ ~lib/memory.ts:213:35 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:214:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:214:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:215:8 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:215:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:216:8 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:216:16 - (i32.const 8) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ) - (loop $continue|2 - (if - ;;@ ~lib/memory.ts:219:11 - (get_local $2) - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:220:16 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:220:6 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:220:33 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:220:24 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:221:6 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:221:8 - (get_local $2) - (i32.const 1) - ) - ) - (br $continue|2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:223:9 - (block - ;;@ ~lib/memory.ts:224:4 - (if - ;;@ ~lib/memory.ts:224:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:224:9 - (get_local $1) - ;;@ ~lib/memory.ts:224:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:224:21 - (i32.and - ;;@ ~lib/memory.ts:224:22 - (get_local $0) - ;;@ ~lib/memory.ts:224:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:224:33 - (block - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:225:13 - (i32.and - (i32.add - ;;@ ~lib/memory.ts:225:14 - (get_local $0) - ;;@ ~lib/memory.ts:225:21 - (get_local $2) - ) - ;;@ ~lib/memory.ts:225:26 - (i32.const 7) - ) - (block - ;;@ ~lib/memory.ts:226:8 - (if - ;;@ ~lib/memory.ts:226:12 - (i32.eqz - ;;@ ~lib/memory.ts:226:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:226:16 - (return) - ) - ;;@ ~lib/memory.ts:227:8 - (i32.store8 - ;;@ ~lib/memory.ts:227:18 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:227:25 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:227:27 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:227:30 - (i32.load8_u - ;;@ ~lib/memory.ts:227:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:227:45 - (get_local $2) - ) - ) - ) - (br $continue|3) - ) - ) - ) - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:229:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:229:18 - (i32.const 8) - ) - (block - ;;@ ~lib/memory.ts:231:8 - (i64.store - ;;@ ~lib/memory.ts:231:19 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:230:8 - (tee_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:230:13 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:231:29 - (i64.load - ;;@ ~lib/memory.ts:231:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:231:45 - (get_local $2) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ) - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:234:11 - (get_local $2) - (block - ;;@ ~lib/memory.ts:234:14 - (i32.store8 - ;;@ ~lib/memory.ts:235:16 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:235:23 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:235:25 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:235:28 - (i32.load8_u - ;;@ ~lib/memory.ts:235:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:235:43 - (get_local $2) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ) - (func $~lib/memory/memory.copy (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:16:4 - (call $~lib/memory/memmove - ;;@ ~lib/memory.ts:16:12 - (get_local $0) - ;;@ ~lib/memory.ts:16:18 - (get_local $1) - ;;@ ~lib/memory.ts:16:23 - (get_local $2) - ) - ) - (func $~lib/memory/memcmp (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/memory/memcmp (; 0 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - ;;@ ~lib/memory.ts:302:2 - (if - ;;@ ~lib/memory.ts:302:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:302:12 - (get_local $1) - ) - ;;@ ~lib/memory.ts:302:23 - (return - (i32.const 0) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:303:9 - (if (result i32) - (tee_local $3 - (i32.ne - (get_local $2) - ;;@ ~lib/memory.ts:303:14 - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:19 - (i32.eq - (i32.load8_u - ;;@ ~lib/memory.ts:303:28 - (get_local $0) - ) - ;;@ ~lib/memory.ts:303:35 - (i32.load8_u - ;;@ ~lib/memory.ts:303:44 - (get_local $1) - ) - ) - (get_local $3) - ) - (block - ;;@ ~lib/memory.ts:304:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:9 - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:15 - (set_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (if (result i32) - ;;@ ~lib/memory.ts:306:9 - (get_local $2) - ;;@ ~lib/memory.ts:306:13 - (i32.sub - (i32.load8_u - ;;@ ~lib/memory.ts:306:27 - (get_local $0) - ) - ;;@ ~lib/memory.ts:306:33 - (i32.load8_u - ;;@ ~lib/memory.ts:306:47 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (i32.const 0) - ) + local.get $0 + local.get $1 + i32.eq + if + i32.const 0 + return + end + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + local.tee $3 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.eq + else + local.get $3 + end + if + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $continue|0 + end + end + local.get $2 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.sub + else + i32.const 0 + end ) - (func $~lib/memory/memory.compare (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/memory.ts:21:27 - (call $~lib/memory/memcmp - ;;@ ~lib/memory.ts:21:18 - (get_local $0) - ;;@ ~lib/memory.ts:21:22 - (get_local $1) - ;;@ ~lib/memory.ts:21:26 - (get_local $2) - ) + (func $~lib/memory/memory.compare (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + local.get $2 + call $~lib/internal/memory/memcmp ) - (func $~lib/allocator/buddy/update_max_ptr (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/update_max_ptr (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - ;;@ ~lib/allocator/buddy.ts:175:2 - (if - ;;@ ~lib/allocator/buddy.ts:175:6 - (i32.gt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:175:18 - (get_global $~lib/allocator/buddy/max_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:175:27 - (block - ;;@ ~lib/allocator/buddy.ts:182:4 - (if - ;;@ ~lib/allocator/buddy.ts:182:8 - (i32.lt_s - ;;@ ~lib/allocator/buddy.ts:182:15 - (grow_memory - ;;@ ~lib/allocator/buddy.ts:182:20 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:180:4 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:180:19 - (i32.shr_u - ;;@ ~lib/allocator/buddy.ts:180:25 - (i32.and - ;;@ ~lib/allocator/buddy.ts:180:26 - (i32.add - ;;@ ~lib/allocator/buddy.ts:180:27 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:180:39 - (i32.const 65535) - ) - (i32.const -65536) - ) - ;;@ ~lib/allocator/buddy.ts:180:62 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/buddy.ts:179:19 - (current_memory) - ) - ) - ;;@ ~lib/allocator/buddy.ts:182:43 - (i32.const 0) - ) - ;;@ ~lib/allocator/buddy.ts:182:46 - (return - ;;@ ~lib/allocator/buddy.ts:183:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:186:4 - (set_global $~lib/allocator/buddy/max_ptr - ;;@ ~lib/allocator/buddy.ts:186:14 - (i32.shl - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:186:33 - (i32.const 16) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:188:9 - (i32.const 1) + local.get $0 + global.get $~lib/allocator/buddy/max_ptr + i32.gt_u + if + local.get $0 + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $1 + current_memory + i32.sub + grow_memory + i32.const 0 + i32.lt_s + if + i32.const 0 + return + end + local.get $1 + i32.const 16 + i32.shl + global.set $~lib/allocator/buddy/max_ptr + end + i32.const 1 ) - (func $~lib/allocator/buddy/buckets$get (; 8 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:102:59 - (i32.add - ;;@ ~lib/allocator/buddy.ts:102:26 - (get_global $~lib/allocator/buddy/BUCKETS_START) - ;;@ ~lib/allocator/buddy.ts:102:42 - (i32.shl - (get_local $0) - (i32.const 3) - ) - ) + (func $~lib/allocator/buddy/buckets$get (; 3 ;) (type $ii) (param $0 i32) (result i32) + global.get $~lib/allocator/buddy/BUCKETS_START + local.get $0 + i32.const 3 + i32.shl + i32.add ) - (func $~lib/allocator/buddy/list_init (; 9 ;) (type $iv) (param $0 i32) - ;;@ ~lib/allocator/buddy.ts:197:2 - (i32.store - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:197:14 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:198:2 - (i32.store offset=4 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:198:14 - (get_local $0) - ) + (func $~lib/allocator/buddy/list_init (; 4 ;) (type $i_) (param $0 i32) + local.get $0 + local.get $0 + i32.store + local.get $0 + local.get $0 + i32.store offset=4 ) - (func $~lib/allocator/buddy/list_push (; 10 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $~lib/allocator/buddy/list_push (; 5 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:207:2 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:206:2 - (tee_local $2 - ;;@ ~lib/allocator/buddy.ts:206:13 - (i32.load - (get_local $0) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:208:2 - (i32.store offset=4 - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:208:15 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:209:2 - (i32.store offset=4 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:209:14 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:210:2 - (i32.store - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:210:14 - (get_local $1) - ) + local.get $1 + local.get $0 + i32.load + local.tee $2 + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $2 + local.get $1 + i32.store offset=4 + local.get $0 + local.get $1 + i32.store ) - (func $~lib/allocator/buddy/bucket_for_request (; 11 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/bucket_for_request (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:279:2 - (set_local $1 - (i32.const 26) - ) - ;;@ ~lib/allocator/buddy.ts:280:2 - (set_local $2 - (i32.const 16) - ) - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:282:9 - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:282:16 - (get_local $0) - ) - (block - ;;@ ~lib/allocator/buddy.ts:283:4 - (set_local $1 - (i32.sub - (get_local $1) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:284:4 - (set_local $2 - (i32.shl - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:284:12 - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:287:9 - (get_local $1) + i32.const 26 + local.set $1 + i32.const 16 + local.set $2 + loop $continue|0 + local.get $2 + local.get $0 + i32.lt_u + if + local.get $1 + i32.const 1 + i32.sub + local.set $1 + local.get $2 + i32.const 1 + i32.shl + local.set $2 + br $continue|0 + end + end + local.get $1 ) - (func $~lib/allocator/buddy/node_for_ptr (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:252:75 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:252:9 - (i32.add - (i32.shr_u - ;;@ ~lib/allocator/buddy.ts:252:10 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:252:11 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:252:17 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:252:30 - (i32.sub - (i32.const 30) - ;;@ ~lib/allocator/buddy.ts:252:48 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:252:59 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:252:60 - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:252:65 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:252:75 - (i32.const 1) - ) + (func $~lib/allocator/buddy/node_for_ptr (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + i32.const 1 + local.get $1 + i32.shl + local.get $0 + global.get $~lib/allocator/buddy/base_ptr + i32.sub + i32.const 30 + local.get $1 + i32.sub + i32.shr_u + i32.add + i32.const 1 + i32.sub ) - (func $~lib/allocator/buddy/node_is_split$get (; 13 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:148:45 - (i32.load8_u - ;;@ ~lib/allocator/buddy.ts:148:18 - (i32.add - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_START) - ;;@ ~lib/allocator/buddy.ts:148:40 - (get_local $0) - ) - ) + (func $~lib/allocator/buddy/node_is_split$get (; 8 ;) (type $ii) (param $0 i32) (result i32) + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_START + local.get $0 + i32.add + i32.load8_u ) - (func $~lib/allocator/buddy/parent_is_split (; 14 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:260:70 - (i32.eq - ;;@ ~lib/allocator/buddy.ts:260:9 - (i32.and - ;;@ ~lib/allocator/buddy.ts:260:10 - (i32.shr_u - ;;@ ~lib/allocator/buddy.ts:260:11 - (call $~lib/allocator/buddy/node_is_split$get - ;;@ ~lib/allocator/buddy.ts:260:29 - (i32.div_u - ;;@ ~lib/allocator/buddy.ts:259:2 - (tee_local $0 - ;;@ ~lib/allocator/buddy.ts:259:10 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:259:11 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:259:19 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:259:24 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:260:37 - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/buddy.ts:260:44 - (i32.and - ;;@ ~lib/allocator/buddy.ts:260:50 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:260:58 - (i32.const 7) - ) - ) - ;;@ ~lib/allocator/buddy.ts:260:64 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:260:70 - (i32.const 1) - ) + (func $~lib/allocator/buddy/parent_is_split (; 9 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.tee $0 + i32.const 8 + i32.div_u + call $~lib/allocator/buddy/node_is_split$get + local.get $0 + i32.const 7 + i32.and + i32.shr_u + i32.const 1 + i32.and + i32.const 1 + i32.eq ) - (func $~lib/allocator/buddy/list_remove (; 15 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/buddy/list_remove (; 10 ;) (type $i_) (param $0 i32) (local $1 i32) - ;;@ ~lib/allocator/buddy.ts:222:2 - (i32.store offset=4 - ;;@ ~lib/allocator/buddy.ts:220:2 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:220:13 - (i32.load - (get_local $0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:221:2 - (tee_local $0 - ;;@ ~lib/allocator/buddy.ts:221:13 - (i32.load offset=4 - (get_local $0) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:223:2 - (i32.store - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:223:14 - (get_local $1) - ) + local.get $0 + i32.load + local.tee $1 + local.get $0 + i32.load offset=4 + local.tee $0 + i32.store offset=4 + local.get $0 + local.get $1 + i32.store ) - (func $~lib/allocator/buddy/ptr_for_node (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:243:77 - (i32.add - ;;@ ~lib/allocator/buddy.ts:243:9 - (get_global $~lib/allocator/buddy/base_ptr) - ;;@ ~lib/allocator/buddy.ts:243:20 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:243:21 - (i32.add - ;;@ ~lib/allocator/buddy.ts:243:22 - (i32.sub - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:243:30 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:243:31 - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:243:36 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:243:46 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:243:52 - (i32.sub - (i32.const 30) - ;;@ ~lib/allocator/buddy.ts:243:70 - (get_local $1) - ) - ) - ) + (func $~lib/allocator/buddy/ptr_for_node (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + global.get $~lib/allocator/buddy/base_ptr + local.get $0 + i32.const 1 + local.get $1 + i32.shl + i32.sub + i32.const 1 + i32.add + i32.const 30 + local.get $1 + i32.sub + i32.shl + i32.add ) - (func $~lib/allocator/buddy/flip_parent_is_split (; 17 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/buddy/flip_parent_is_split (; 12 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:268:2 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:268:18 - (i32.div_u - ;;@ ~lib/allocator/buddy.ts:267:2 - (tee_local $0 - ;;@ ~lib/allocator/buddy.ts:267:10 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:267:11 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:267:19 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:267:24 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:268:26 - (i32.const 8) - ) - ) - ) - (set_local $0 - ;;@ ~lib/allocator/buddy.ts:270:4 - (i32.xor - (call $~lib/allocator/buddy/node_is_split$get - ;;@ ~lib/allocator/buddy.ts:270:22 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:270:35 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:270:41 - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:270:46 - (i32.and - ;;@ ~lib/allocator/buddy.ts:270:47 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:270:55 - (i32.const 7) - ) - ) - ) - ) - (i32.store8 - (i32.add - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_START) - (get_local $2) - ) - (get_local $0) - ) + local.get $0 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.tee $0 + i32.const 8 + i32.div_u + local.tee $1 + local.set $2 + local.get $1 + call $~lib/allocator/buddy/node_is_split$get + i32.const 1 + local.get $0 + i32.const 7 + i32.and + i32.shl + i32.xor + local.set $0 + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_START + local.get $2 + i32.add + local.get $0 + i32.store8 ) - (func $~lib/allocator/buddy/lower_bucket_limit (; 18 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/lower_bucket_limit (; 13 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:296:9 - (i32.lt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:296:18 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - (block - ;;@ ~lib/allocator/buddy.ts:306:4 - (if - ;;@ ~lib/allocator/buddy.ts:306:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:306:9 - (call $~lib/allocator/buddy/parent_is_split - ;;@ ~lib/allocator/buddy.ts:297:4 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:297:15 - (call $~lib/allocator/buddy/node_for_ptr - ;;@ ~lib/allocator/buddy.ts:297:28 - (get_global $~lib/allocator/buddy/base_ptr) - ;;@ ~lib/allocator/buddy.ts:297:38 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:306:32 - (block - ;;@ ~lib/allocator/buddy.ts:307:6 - (call $~lib/allocator/buddy/list_remove - ;;@ ~lib/allocator/buddy.ts:307:18 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:308:6 - (call $~lib/allocator/buddy/list_init - ;;@ ~lib/allocator/buddy.ts:308:16 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:308:28 - (block (result i32) - (set_global $~lib/allocator/buddy/bucket_limit - (i32.sub - ;;@ ~lib/allocator/buddy.ts:308:30 - (get_global $~lib/allocator/buddy/bucket_limit) - (i32.const 1) - ) - ) - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:309:6 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:309:16 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:309:28 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ;;@ ~lib/allocator/buddy.ts:309:43 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:310:6 - (br $continue|0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:322:4 - (if - ;;@ ~lib/allocator/buddy.ts:322:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:322:9 - (call $~lib/allocator/buddy/update_max_ptr - ;;@ ~lib/allocator/buddy.ts:322:24 - (i32.add - ;;@ ~lib/allocator/buddy.ts:321:4 - (tee_local $2 - ;;@ ~lib/allocator/buddy.ts:321:18 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:321:31 - (i32.add - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:321:38 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:321:41 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - (i32.const 8) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:322:50 - (return - ;;@ ~lib/allocator/buddy.ts:323:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:325:4 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:325:14 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:325:26 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ;;@ ~lib/allocator/buddy.ts:325:41 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:326:4 - (call $~lib/allocator/buddy/list_init - ;;@ ~lib/allocator/buddy.ts:326:14 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:326:26 - (block (result i32) - (set_global $~lib/allocator/buddy/bucket_limit - (i32.sub - ;;@ ~lib/allocator/buddy.ts:326:28 - (get_global $~lib/allocator/buddy/bucket_limit) - (i32.const 1) - ) - ) - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:333:4 - (if - ;;@ ~lib/allocator/buddy.ts:332:4 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:332:11 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:332:12 - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:332:19 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:332:24 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:333:19 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:334:27 - (get_local $1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:338:9 - (i32.const 1) + loop $continue|0 + local.get $0 + global.get $~lib/allocator/buddy/bucket_limit + i32.lt_u + if + global.get $~lib/allocator/buddy/base_ptr + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/node_for_ptr + local.tee $1 + call $~lib/allocator/buddy/parent_is_split + i32.eqz + if + global.get $~lib/allocator/buddy/base_ptr + call $~lib/allocator/buddy/list_remove + block (result i32) + global.get $~lib/allocator/buddy/bucket_limit + i32.const 1 + i32.sub + global.set $~lib/allocator/buddy/bucket_limit + global.get $~lib/allocator/buddy/bucket_limit + end + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_init + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/buckets$get + global.get $~lib/allocator/buddy/base_ptr + call $~lib/allocator/buddy/list_push + br $continue|0 + end + local.get $1 + i32.const 1 + i32.add + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/ptr_for_node + local.tee $2 + i32.const 8 + i32.add + call $~lib/allocator/buddy/update_max_ptr + i32.eqz + if + i32.const 0 + return + end + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/buckets$get + local.get $2 + call $~lib/allocator/buddy/list_push + block (result i32) + global.get $~lib/allocator/buddy/bucket_limit + i32.const 1 + i32.sub + global.set $~lib/allocator/buddy/bucket_limit + global.get $~lib/allocator/buddy/bucket_limit + end + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_init + local.get $1 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.tee $1 + if + local.get $1 + call $~lib/allocator/buddy/flip_parent_is_split + end + br $continue|0 + end + end + i32.const 1 ) - (func $~lib/allocator/buddy/list_pop (; 19 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/list_pop (; 14 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - ;;@ ~lib/allocator/buddy.ts:231:2 - (if - ;;@ ~lib/allocator/buddy.ts:231:6 - (i32.eq - ;;@ ~lib/allocator/buddy.ts:230:2 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:230:13 - (i32.load - (get_local $0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:231:14 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:231:27 - (return - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:232:2 - (call $~lib/allocator/buddy/list_remove - ;;@ ~lib/allocator/buddy.ts:232:14 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:233:9 - (get_local $1) + local.get $0 + i32.load + local.tee $1 + local.get $0 + i32.eq + if + i32.const 0 + return + end + local.get $1 + call $~lib/allocator/buddy/list_remove + local.get $1 ) - (func $~lib/allocator/buddy/__memory_allocate (; 20 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/__memory_allocate (; 15 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) - ;;@ ~lib/allocator/buddy.ts:350:2 - (if - ;;@ ~lib/allocator/buddy.ts:350:6 - (i32.gt_u - (get_local $0) - (i32.const 1073741816) - ) - ;;@ ~lib/allocator/buddy.ts:350:41 - (unreachable) - ) - ;;@ ~lib/allocator/buddy.ts:357:2 - (if - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:357:6 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:357:21 - (block - ;;@ ~lib/allocator/buddy.ts:359:4 - (set_global $~lib/allocator/buddy/base_ptr - ;;@ ~lib/allocator/buddy.ts:359:15 - (i32.and - (i32.add - ;;@ ~lib/allocator/buddy.ts:359:16 - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_END) - ;;@ ~lib/allocator/buddy.ts:359:36 - (i32.const 7) - ) - (i32.const -8) - ) - ) - ;;@ ~lib/allocator/buddy.ts:360:4 - (set_global $~lib/allocator/buddy/max_ptr - ;;@ ~lib/allocator/buddy.ts:360:14 - (i32.shl - (current_memory) - ;;@ ~lib/allocator/buddy.ts:360:38 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/buddy.ts:361:4 - (set_global $~lib/allocator/buddy/bucket_limit - (i32.const 26) - ) - ;;@ ~lib/allocator/buddy.ts:362:4 - (if - ;;@ ~lib/allocator/buddy.ts:362:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:362:9 - (call $~lib/allocator/buddy/update_max_ptr - ;;@ ~lib/allocator/buddy.ts:362:24 - (i32.add - (get_global $~lib/allocator/buddy/base_ptr) - (i32.const 8) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:362:47 - (return - ;;@ ~lib/allocator/buddy.ts:363:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:365:4 - (call $~lib/allocator/buddy/list_init - ;;@ ~lib/allocator/buddy.ts:365:14 - (call $~lib/allocator/buddy/buckets$get - (i32.const 26) - ) - ) - ;;@ ~lib/allocator/buddy.ts:366:4 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:366:14 - (call $~lib/allocator/buddy/buckets$get - (i32.const 26) - ) - ;;@ ~lib/allocator/buddy.ts:366:45 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:374:2 - (set_local $4 - ;;@ ~lib/allocator/buddy.ts:373:2 - (tee_local $1 - ;;@ ~lib/allocator/buddy.ts:373:11 - (call $~lib/allocator/buddy/bucket_for_request - ;;@ ~lib/allocator/buddy.ts:373:30 - (i32.add - (get_local $0) - (i32.const 8) - ) - ) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:381:9 - (i32.ne - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:381:23 - (i32.const -1) - ) - ;;@ ~lib/allocator/buddy.ts:381:26 - (block - ;;@ ~lib/allocator/buddy.ts:389:4 - (if - ;;@ ~lib/allocator/buddy.ts:389:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:389:9 - (call $~lib/allocator/buddy/lower_bucket_limit - ;;@ ~lib/allocator/buddy.ts:389:28 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:389:37 - (return - ;;@ ~lib/allocator/buddy.ts:390:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:398:4 - (if - ;;@ ~lib/allocator/buddy.ts:398:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:397:4 - (tee_local $2 - ;;@ ~lib/allocator/buddy.ts:397:10 - (call $~lib/allocator/buddy/list_pop - ;;@ ~lib/allocator/buddy.ts:397:37 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:397:49 - (get_local $1) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:398:14 - (block - ;;@ ~lib/allocator/buddy.ts:403:6 - (if - ;;@ ~lib/allocator/buddy.ts:403:10 - (if (result i32) - (tee_local $2 - (i32.ne - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:403:20 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - (get_local $2) - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:403:36 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:403:49 - (block - ;;@ ~lib/allocator/buddy.ts:404:8 - (set_local $1 - (i32.sub - (get_local $1) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:405:8 - (br $continue|0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:415:6 - (if - ;;@ ~lib/allocator/buddy.ts:415:10 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:415:11 - (call $~lib/allocator/buddy/lower_bucket_limit - ;;@ ~lib/allocator/buddy.ts:415:30 - (i32.sub - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:415:39 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:415:43 - (return - ;;@ ~lib/allocator/buddy.ts:416:15 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:418:6 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:418:12 - (call $~lib/allocator/buddy/list_pop - ;;@ ~lib/allocator/buddy.ts:418:39 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:418:51 - (get_local $1) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:425:4 - (set_local $3 - ;;@ ~lib/allocator/buddy.ts:425:11 - (i32.shl - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:425:16 - (i32.sub - (i32.const 30) - ;;@ ~lib/allocator/buddy.ts:425:34 - (get_local $1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:427:4 - (if - ;;@ ~lib/allocator/buddy.ts:427:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:427:9 - (call $~lib/allocator/buddy/update_max_ptr - ;;@ ~lib/allocator/buddy.ts:427:24 - (i32.add - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:426:19 - (if (result i32) - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:426:28 - (get_local $4) - ) - ;;@ ~lib/allocator/buddy.ts:426:46 - (i32.add - (i32.div_u - (get_local $3) - ;;@ ~lib/allocator/buddy.ts:426:53 - (i32.const 2) - ) - (i32.const 8) - ) - ;;@ ~lib/allocator/buddy.ts:426:69 - (get_local $3) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:427:45 - (block - ;;@ ~lib/allocator/buddy.ts:428:6 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:428:16 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:428:28 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:428:37 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:429:13 - (return - (i32.const 0) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:444:4 - (if - ;;@ ~lib/allocator/buddy.ts:443:4 - (tee_local $3 - ;;@ ~lib/allocator/buddy.ts:443:8 - (call $~lib/allocator/buddy/node_for_ptr - ;;@ ~lib/allocator/buddy.ts:443:21 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:443:26 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:444:16 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:445:27 - (get_local $3) - ) - ) - (loop $continue|1 - (if - ;;@ ~lib/allocator/buddy.ts:455:11 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:455:20 - (get_local $4) - ) - (block - ;;@ ~lib/allocator/buddy.ts:458:6 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:456:6 - (tee_local $3 - ;;@ ~lib/allocator/buddy.ts:456:10 - (i32.add - (i32.shl - (get_local $3) - ;;@ ~lib/allocator/buddy.ts:456:14 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:456:18 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:459:6 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:460:8 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:457:6 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:461:8 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:461:38 - (i32.add - (get_local $3) - ;;@ ~lib/allocator/buddy.ts:461:42 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:461:45 - (get_local $1) - ) - ) - (br $continue|1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:469:4 - (i32.store - ;;@ ~lib/allocator/buddy.ts:469:17 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:469:22 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:470:17 - (return - ;;@ ~lib/allocator/buddy.ts:470:11 - (i32.add - (get_local $2) - (i32.const 8) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:473:9 - (i32.const 0) + local.get $0 + i32.const 1073741816 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/buddy/base_ptr + i32.eqz + if + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_END + i32.const 7 + i32.add + i32.const -8 + i32.and + global.set $~lib/allocator/buddy/base_ptr + current_memory + i32.const 16 + i32.shl + global.set $~lib/allocator/buddy/max_ptr + i32.const 26 + global.set $~lib/allocator/buddy/bucket_limit + global.get $~lib/allocator/buddy/base_ptr + i32.const 8 + i32.add + call $~lib/allocator/buddy/update_max_ptr + i32.eqz + if + i32.const 0 + return + end + i32.const 26 + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_init + i32.const 26 + call $~lib/allocator/buddy/buckets$get + global.get $~lib/allocator/buddy/base_ptr + call $~lib/allocator/buddy/list_push + end + local.get $0 + i32.const 8 + i32.add + call $~lib/allocator/buddy/bucket_for_request + local.tee $1 + local.set $4 + loop $continue|0 + local.get $1 + i32.const -1 + i32.ne + if + local.get $1 + call $~lib/allocator/buddy/lower_bucket_limit + i32.eqz + if + i32.const 0 + return + end + local.get $1 + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_pop + local.tee $2 + i32.eqz + if + local.get $1 + global.get $~lib/allocator/buddy/bucket_limit + i32.ne + local.tee $2 + if (result i32) + local.get $2 + else + local.get $1 + i32.eqz + end + if + local.get $1 + i32.const 1 + i32.sub + local.set $1 + br $continue|0 + end + local.get $1 + i32.const 1 + i32.sub + call $~lib/allocator/buddy/lower_bucket_limit + i32.eqz + if + i32.const 0 + return + end + local.get $1 + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_pop + local.set $2 + end + i32.const 1 + i32.const 30 + local.get $1 + i32.sub + i32.shl + local.set $3 + local.get $1 + local.get $4 + i32.lt_u + if (result i32) + local.get $3 + i32.const 2 + i32.div_u + i32.const 8 + i32.add + else + local.get $3 + end + local.get $2 + i32.add + call $~lib/allocator/buddy/update_max_ptr + i32.eqz + if + local.get $1 + call $~lib/allocator/buddy/buckets$get + local.get $2 + call $~lib/allocator/buddy/list_push + i32.const 0 + return + end + local.get $2 + local.get $1 + call $~lib/allocator/buddy/node_for_ptr + local.tee $3 + if + local.get $3 + call $~lib/allocator/buddy/flip_parent_is_split + end + loop $continue|1 + local.get $1 + local.get $4 + i32.lt_u + if + local.get $3 + i32.const 1 + i32.shl + i32.const 1 + i32.add + local.tee $3 + call $~lib/allocator/buddy/flip_parent_is_split + local.get $1 + i32.const 1 + i32.add + local.tee $1 + call $~lib/allocator/buddy/buckets$get + local.get $3 + i32.const 1 + i32.add + local.get $1 + call $~lib/allocator/buddy/ptr_for_node + call $~lib/allocator/buddy/list_push + br $continue|1 + end + end + local.get $2 + local.get $0 + i32.store + local.get $2 + i32.const 8 + i32.add + return + end + end + i32.const 0 ) - (func $~lib/memory/memory.allocate (; 21 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/memory.ts:37:45 - (call $~lib/allocator/buddy/__memory_allocate - ;;@ ~lib/memory.ts:37:63 - (get_local $0) - ) + (func $~lib/memory/memory.allocate (; 16 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/allocator/buddy/__memory_allocate ) - (func $~lib/allocator/buddy/__memory_free (; 22 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/buddy/__memory_free (; 17 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:483:2 - (if - ;;@ ~lib/allocator/buddy.ts:483:6 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:483:7 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:483:12 - (return) - ) - ;;@ ~lib/allocator/buddy.ts:493:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:493:11 - (call $~lib/allocator/buddy/bucket_for_request - ;;@ ~lib/allocator/buddy.ts:493:30 - (i32.add - (i32.load - ;;@ ~lib/allocator/buddy.ts:492:2 - (tee_local $0 - ;;@ ~lib/allocator/buddy.ts:492:8 - (i32.sub - (get_local $0) - (i32.const 8) - ) - ) - ) - (i32.const 8) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:494:2 - (set_local $0 - ;;@ ~lib/allocator/buddy.ts:494:6 - (call $~lib/allocator/buddy/node_for_ptr - ;;@ ~lib/allocator/buddy.ts:494:19 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:494:24 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:500:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:500:9 - (get_local $0) - (block - ;;@ ~lib/allocator/buddy.ts:507:4 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:507:25 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:517:54 - (br_if $break|0 - ;;@ ~lib/allocator/buddy.ts:517:8 - (if (result i32) - (tee_local $2 - (call $~lib/allocator/buddy/parent_is_split - ;;@ ~lib/allocator/buddy.ts:517:24 - (get_local $0) - ) - ) - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:517:30 - (i32.eq - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:517:40 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:528:4 - (call $~lib/allocator/buddy/list_remove - ;;@ ~lib/allocator/buddy.ts:528:16 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:528:46 - (i32.add - (i32.xor - ;;@ ~lib/allocator/buddy.ts:528:47 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:528:48 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:528:52 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:528:57 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:528:62 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:528:65 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:529:4 - (set_local $0 - ;;@ ~lib/allocator/buddy.ts:529:8 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:529:9 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:529:13 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:529:18 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:530:4 - (set_local $1 - (i32.sub - (get_local $1) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:539:2 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:539:12 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:539:24 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:539:33 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:539:63 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:539:66 - (get_local $1) - ) - ) + local.get $0 + i32.eqz + if + return + end + local.get $0 + i32.const 8 + i32.sub + local.tee $0 + i32.load + i32.const 8 + i32.add + call $~lib/allocator/buddy/bucket_for_request + local.set $1 + local.get $0 + local.get $1 + call $~lib/allocator/buddy/node_for_ptr + local.set $0 + loop $continue|0 + local.get $0 + if + block $break|0 + local.get $0 + call $~lib/allocator/buddy/flip_parent_is_split + local.get $0 + call $~lib/allocator/buddy/parent_is_split + local.tee $2 + if (result i32) + local.get $2 + else + local.get $1 + global.get $~lib/allocator/buddy/bucket_limit + i32.eq + end + br_if $break|0 + local.get $0 + i32.const 1 + i32.sub + i32.const 1 + i32.xor + i32.const 1 + i32.add + local.get $1 + call $~lib/allocator/buddy/ptr_for_node + call $~lib/allocator/buddy/list_remove + local.get $0 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.set $0 + local.get $1 + i32.const 1 + i32.sub + local.set $1 + br $continue|0 + end + end + end + local.get $1 + call $~lib/allocator/buddy/buckets$get + local.get $0 + local.get $1 + call $~lib/allocator/buddy/ptr_for_node + call $~lib/allocator/buddy/list_push + ) + (func $~lib/memory/memory.free (; 18 ;) (type $i_) (param $0 i32) + local.get $0 + call $~lib/allocator/buddy/__memory_free ) - (func $~lib/memory/memory.free (; 23 ;) (type $iv) (param $0 i32) - ;;@ ~lib/memory.ts:43:36 - (call $~lib/allocator/buddy/__memory_free - ;;@ ~lib/memory.ts:43:50 - (get_local $0) - ) + (func $~lib/memory/memory.reset (; 19 ;) (type $_) + unreachable ) - (func $~lib/memory/memory.reset (; 24 ;) (type $v) - (unreachable) + (func $start (; 20 ;) (type $_) + i32.const 8 + global.set $~lib/allocator/buddy/BUCKETS_START + global.get $~lib/allocator/buddy/BUCKETS_START + i32.const 216 + i32.add + global.set $~lib/allocator/buddy/BUCKETS_END + global.get $~lib/allocator/buddy/BUCKETS_END + global.set $~lib/allocator/buddy/NODE_IS_SPLIT_START + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_START + i32.const 8388608 + i32.add + global.set $~lib/allocator/buddy/NODE_IS_SPLIT_END ) - (func $start (; 25 ;) (type $v) - (set_global $~lib/allocator/buddy/BUCKETS_START - (i32.const 8) - ) - (set_global $~lib/allocator/buddy/BUCKETS_END - ;;@ ~lib/allocator/buddy.ts:98:25 - (i32.add - (get_global $~lib/allocator/buddy/BUCKETS_START) - (i32.const 216) - ) - ) - (set_global $~lib/allocator/buddy/NODE_IS_SPLIT_START - ;;@ ~lib/allocator/buddy.ts:143:33 - (get_global $~lib/allocator/buddy/BUCKETS_END) - ) - (set_global $~lib/allocator/buddy/NODE_IS_SPLIT_END - ;;@ ~lib/allocator/buddy.ts:144:31 - (i32.add - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_START) - (i32.const 8388608) - ) - ) + (func $null (; 21 ;) (type $_) + nop ) ) diff --git a/tests/allocators/buddy/package.json b/tests/allocators/buddy/package.json index 709cf1096f..68fede664c 100644 --- a/tests/allocators/buddy/package.json +++ b/tests/allocators/buddy/package.json @@ -3,6 +3,6 @@ "scripts": { "build": "npm run build:untouched && npm run build:optimized", "build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --validate --sourceMap --measure", - "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noDebug --noAssert --optimize" + "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noAssert --optimize" } } diff --git a/tests/allocators/buddy/untouched.wat b/tests/allocators/buddy/untouched.wat index 3518776b8b..b67987cb56 100644 --- a/tests/allocators/buddy/untouched.wat +++ b/tests/allocators/buddy/untouched.wat @@ -1,21 +1,24 @@ (module - (type $iiiv (func (param i32 i32 i32))) + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $iiiiv (func (param i32 i32 i32 i32))) - (type $iv (func (param i32))) - (type $iiv (func (param i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) + (type $i_ (func (param i32))) + (type $ii_ (func (param i32 i32))) (type $iii (func (param i32 i32) (result i32))) - (type $v (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\17\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00b\00u\00d\00d\00y\00.\00t\00s\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) (global $~lib/allocator/buddy/HEADER_SIZE i32 (i32.const 8)) (global $~lib/allocator/buddy/MIN_ALLOC_LOG2 i32 (i32.const 4)) (global $~lib/allocator/buddy/MIN_ALLOC i32 (i32.const 16)) (global $~lib/allocator/buddy/MAX_ALLOC_LOG2 i32 (i32.const 30)) (global $~lib/allocator/buddy/MAX_ALLOC i32 (i32.const 1073741824)) (global $~lib/allocator/buddy/BUCKET_COUNT i32 (i32.const 27)) - (global $~lib/allocator/buddy/BUCKETS_START (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/List.SIZE i32 (i32.const 8)) + (global $~lib/allocator/buddy/BUCKETS_START (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/BUCKETS_END (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/bucket_limit (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/SPLIT_COUNT i32 (i32.const 8388608)) @@ -23,4028 +26,445 @@ (global $~lib/allocator/buddy/NODE_IS_SPLIT_END (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/base_ptr (mut i32) (i32.const 0)) (global $~lib/allocator/buddy/max_ptr (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 60)) - (memory $0 1) - (data (i32.const 8) "\17\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00b\00u\00d\00d\00y\00.\00t\00s\00") + (global $~lib/memory/HEAP_BASE i32 (i32.const 60)) (export "memory" (memory $0)) - (export "memory.fill" (func $~lib/memory/memory.fill)) - (export "memory.copy" (func $~lib/memory/memory.copy)) + (export "table" (table $0)) (export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.allocate" (func $~lib/memory/memory.allocate)) (export "memory.free" (func $~lib/memory/memory.free)) (export "memory.reset" (func $~lib/memory/memory.reset)) (start $start) - (func $~lib/memory/memset (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - ;;@ ~lib/memory.ts:244:2 - (if - ;;@ ~lib/memory.ts:244:6 - (i32.eqz - ;;@ ~lib/memory.ts:244:7 - (get_local $2) - ) - ;;@ ~lib/memory.ts:244:10 - (return) - ) - ;;@ ~lib/memory.ts:245:2 - (i32.store8 - ;;@ ~lib/memory.ts:245:12 - (get_local $0) - ;;@ ~lib/memory.ts:245:18 - (get_local $1) - ) - ;;@ ~lib/memory.ts:246:2 - (i32.store8 - ;;@ ~lib/memory.ts:246:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:246:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:246:23 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:246:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:247:2 - (if - ;;@ ~lib/memory.ts:247:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:247:11 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:247:14 - (return) - ) - ;;@ ~lib/memory.ts:249:2 - (i32.store8 - ;;@ ~lib/memory.ts:249:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:249:19 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:249:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:250:2 - (i32.store8 - ;;@ ~lib/memory.ts:250:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:250:19 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:250:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:251:2 - (i32.store8 - ;;@ ~lib/memory.ts:251:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:251:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:251:23 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:251:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:252:2 - (i32.store8 - ;;@ ~lib/memory.ts:252:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:252:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:252:23 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:252:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:253:2 - (if - ;;@ ~lib/memory.ts:253:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:253:11 - (i32.const 6) - ) - ;;@ ~lib/memory.ts:253:14 - (return) - ) - ;;@ ~lib/memory.ts:254:2 - (i32.store8 - ;;@ ~lib/memory.ts:254:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:254:19 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:254:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:255:2 - (i32.store8 - ;;@ ~lib/memory.ts:255:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:255:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:255:23 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:255:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:256:2 - (if - ;;@ ~lib/memory.ts:256:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:256:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:256:14 - (return) - ) - ;;@ ~lib/memory.ts:259:2 - (set_local $3 - ;;@ ~lib/memory.ts:259:17 - (i32.and - (i32.sub - (i32.const 0) - ;;@ ~lib/memory.ts:259:18 - (get_local $0) - ) - ;;@ ~lib/memory.ts:259:25 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:260:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:260:10 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:261:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:261:7 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:262:2 - (set_local $2 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:262:7 - (i32.const -4) - ) - ) - ;;@ ~lib/memory.ts:264:2 - (set_local $4 - ;;@ ~lib/memory.ts:264:17 - (i32.mul - (i32.div_u - (i32.const -1) - ;;@ ~lib/memory.ts:264:27 - (i32.const 255) - ) - (i32.and - ;;@ ~lib/memory.ts:264:33 - (get_local $1) - (i32.const 255) - ) - ) - ) - ;;@ ~lib/memory.ts:267:2 - (i32.store - ;;@ ~lib/memory.ts:267:13 - (get_local $0) - ;;@ ~lib/memory.ts:267:19 - (get_local $4) - ) - ;;@ ~lib/memory.ts:268:2 - (i32.store - ;;@ ~lib/memory.ts:268:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:268:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:268:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:268:27 - (get_local $4) - ) - ;;@ ~lib/memory.ts:269:2 - (if - ;;@ ~lib/memory.ts:269:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:269:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:269:14 - (return) - ) - ;;@ ~lib/memory.ts:270:2 - (i32.store - ;;@ ~lib/memory.ts:270:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:270:20 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:270:23 - (get_local $4) - ) - ;;@ ~lib/memory.ts:271:2 - (i32.store - ;;@ ~lib/memory.ts:271:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:271:20 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:271:23 - (get_local $4) - ) - ;;@ ~lib/memory.ts:272:2 - (i32.store - ;;@ ~lib/memory.ts:272:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:272:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:272:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:272:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:273:2 - (i32.store - ;;@ ~lib/memory.ts:273:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:273:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:273:24 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:273:27 - (get_local $4) - ) - ;;@ ~lib/memory.ts:274:2 - (if - ;;@ ~lib/memory.ts:274:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:274:11 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:274:15 - (return) - ) - ;;@ ~lib/memory.ts:275:2 - (i32.store - ;;@ ~lib/memory.ts:275:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:275:20 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:275:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:276:2 - (i32.store - ;;@ ~lib/memory.ts:276:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:276:20 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:276:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:277:2 - (i32.store - ;;@ ~lib/memory.ts:277:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:277:20 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:277:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:278:2 - (i32.store - ;;@ ~lib/memory.ts:278:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:278:20 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:278:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:279:2 - (i32.store - ;;@ ~lib/memory.ts:279:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:279:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:279:24 - (i32.const 28) - ) - ;;@ ~lib/memory.ts:279:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:280:2 - (i32.store - ;;@ ~lib/memory.ts:280:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:280:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:280:24 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:280:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:281:2 - (i32.store - ;;@ ~lib/memory.ts:281:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:281:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:281:24 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:281:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:282:2 - (i32.store - ;;@ ~lib/memory.ts:282:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:282:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:282:24 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:282:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:285:2 - (set_local $3 - ;;@ ~lib/memory.ts:285:6 - (i32.add - (i32.const 24) - ;;@ ~lib/memory.ts:285:11 - (i32.and - ;;@ ~lib/memory.ts:285:12 - (get_local $0) - ;;@ ~lib/memory.ts:285:19 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:286:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:286:10 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:287:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:287:7 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:290:2 - (set_local $5 - ;;@ ~lib/memory.ts:290:17 - (i64.or - (i64.extend_u/i32 - (get_local $4) - ) - ;;@ ~lib/memory.ts:290:28 - (i64.shl - ;;@ ~lib/memory.ts:290:29 - (i64.extend_u/i32 - (get_local $4) - ) - ;;@ ~lib/memory.ts:290:41 - (i64.const 32) - ) - ) - ) - ;;@ ~lib/memory.ts:291:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:291:9 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:291:14 - (i32.const 32) - ) - (block - (block - ;;@ ~lib/memory.ts:292:4 - (i64.store - ;;@ ~lib/memory.ts:292:15 - (get_local $0) - ;;@ ~lib/memory.ts:292:21 - (get_local $5) - ) - ;;@ ~lib/memory.ts:293:4 - (i64.store - ;;@ ~lib/memory.ts:293:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:293:22 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:293:25 - (get_local $5) - ) - ;;@ ~lib/memory.ts:294:4 - (i64.store - ;;@ ~lib/memory.ts:294:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:294:22 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:294:26 - (get_local $5) - ) - ;;@ ~lib/memory.ts:295:4 - (i64.store - ;;@ ~lib/memory.ts:295:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:295:22 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:295:26 - (get_local $5) - ) - ;;@ ~lib/memory.ts:296:4 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:296:9 - (i32.const 32) - ) - ) - ;;@ ~lib/memory.ts:297:4 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:297:12 - (i32.const 32) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ) - (func $~lib/memory/memory.fill (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:11:4 - (call $~lib/memory/memset - ;;@ ~lib/memory.ts:11:11 - (get_local $0) - ;;@ ~lib/memory.ts:11:17 - (get_local $1) - ;;@ ~lib/memory.ts:11:20 - (get_local $2) - ) - ) - (func $~lib/memory/memcpy (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - ;;@ ~lib/memory.ts:59:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:59:9 - (if (result i32) - (get_local $2) - ;;@ ~lib/memory.ts:59:14 - (i32.and - ;;@ ~lib/memory.ts:59:15 - (get_local $1) - ;;@ ~lib/memory.ts:59:21 - (i32.const 3) - ) - (get_local $2) - ) - (block - (block - ;;@ ~lib/memory.ts:60:4 - (i32.store8 - ;;@ ~lib/memory.ts:60:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:60:22 - (i32.load8_u - ;;@ ~lib/memory.ts:60:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:61:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:65:2 - (if - ;;@ ~lib/memory.ts:65:6 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:65:7 - (get_local $0) - ;;@ ~lib/memory.ts:65:14 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:65:20 - (i32.const 0) - ) - ;;@ ~lib/memory.ts:65:23 - (block - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:66:11 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:66:16 - (i32.const 16) - ) - (block - (block - ;;@ ~lib/memory.ts:67:6 - (i32.store - ;;@ ~lib/memory.ts:67:17 - (get_local $0) - ;;@ ~lib/memory.ts:67:28 - (i32.load - ;;@ ~lib/memory.ts:67:38 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:68:6 - (i32.store - ;;@ ~lib/memory.ts:68:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:68:25 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:68:28 - (i32.load - ;;@ ~lib/memory.ts:68:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:68:45 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:69:6 - (i32.store - ;;@ ~lib/memory.ts:69:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:69:25 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:69:28 - (i32.load - ;;@ ~lib/memory.ts:69:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:69:45 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:70:6 - (i32.store - ;;@ ~lib/memory.ts:70:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:70:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:70:28 - (i32.load - ;;@ ~lib/memory.ts:70:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:70:44 - (i32.const 12) - ) - ) - ) - ;;@ ~lib/memory.ts:71:6 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:71:13 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:17 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:71:25 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:29 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:71:34 - (i32.const 16) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:73:4 - (if - ;;@ ~lib/memory.ts:73:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:73:12 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:73:15 - (block - ;;@ ~lib/memory.ts:74:6 - (i32.store - ;;@ ~lib/memory.ts:74:17 - (get_local $0) - ;;@ ~lib/memory.ts:74:27 - (i32.load - ;;@ ~lib/memory.ts:74:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:75:6 - (i32.store - ;;@ ~lib/memory.ts:75:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:75:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:75:27 - (i32.load - ;;@ ~lib/memory.ts:75:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:75:43 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:76:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:76:14 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:76:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:76:24 - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:78:4 - (if - ;;@ ~lib/memory.ts:78:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:78:12 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:78:15 - (block - ;;@ ~lib/memory.ts:79:6 - (i32.store - ;;@ ~lib/memory.ts:79:17 - (get_local $0) - ;;@ ~lib/memory.ts:79:23 - (i32.load - ;;@ ~lib/memory.ts:79:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:80:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:80:14 - (i32.const 4) - ) - ) - ;;@ ~lib/memory.ts:80:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:80:24 - (i32.const 4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:82:4 - (if - ;;@ ~lib/memory.ts:82:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:82:12 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:82:15 - (block - ;;@ ~lib/memory.ts:83:6 - (i32.store16 - ;;@ ~lib/memory.ts:83:17 - (get_local $0) - ;;@ ~lib/memory.ts:83:23 - (i32.load16_u - ;;@ ~lib/memory.ts:83:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:84:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:84:14 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:84:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:84:24 - (i32.const 2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:86:4 - (if - ;;@ ~lib/memory.ts:86:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:86:12 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:86:15 - (i32.store8 - ;;@ ~lib/memory.ts:87:16 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:87:24 - (i32.load8_u - ;;@ ~lib/memory.ts:87:33 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:89:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:94:2 - (if - ;;@ ~lib/memory.ts:94:6 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:94:11 - (i32.const 32) - ) - ;;@ ~lib/memory.ts:94:15 - (block $break|2 - (block $case2|2 - (block $case1|2 - (block $case0|2 - (set_local $5 - ;;@ ~lib/memory.ts:95:12 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:95:19 - (i32.const 3) - ) - ) - (br_if $case0|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:97:11 - (i32.const 1) - ) - ) - (br_if $case1|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:116:11 - (i32.const 2) - ) - ) - (br_if $case2|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:134:11 - (i32.const 3) - ) - ) - (br $break|2) - ) - ;;@ ~lib/memory.ts:97:14 - (block - ;;@ ~lib/memory.ts:98:8 - (set_local $3 - ;;@ ~lib/memory.ts:98:12 - (i32.load - ;;@ ~lib/memory.ts:98:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:99:8 - (i32.store8 - ;;@ ~lib/memory.ts:99:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:99:26 - (i32.load8_u - ;;@ ~lib/memory.ts:99:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:100:8 - (i32.store8 - ;;@ ~lib/memory.ts:100:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:100:26 - (i32.load8_u - ;;@ ~lib/memory.ts:100:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:101:8 - (i32.store8 - ;;@ ~lib/memory.ts:101:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:101:26 - (i32.load8_u - ;;@ ~lib/memory.ts:101:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:102:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:102:13 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:103:8 - (block $break|3 - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:103:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:103:20 - (i32.const 17) - ) - (block - (block - ;;@ ~lib/memory.ts:104:10 - (set_local $4 - ;;@ ~lib/memory.ts:104:14 - (i32.load - ;;@ ~lib/memory.ts:104:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:104:30 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:105:10 - (i32.store - ;;@ ~lib/memory.ts:105:21 - (get_local $0) - ;;@ ~lib/memory.ts:105:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:105:32 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:105:37 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:105:42 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:106:10 - (set_local $3 - ;;@ ~lib/memory.ts:106:14 - (i32.load - ;;@ ~lib/memory.ts:106:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:106:30 - (i32.const 5) - ) - ) - ) - ;;@ ~lib/memory.ts:107:10 - (i32.store - ;;@ ~lib/memory.ts:107:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:107:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:107:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:107:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:107:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:107:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:108:10 - (set_local $4 - ;;@ ~lib/memory.ts:108:14 - (i32.load - ;;@ ~lib/memory.ts:108:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:108:30 - (i32.const 9) - ) - ) - ) - ;;@ ~lib/memory.ts:109:10 - (i32.store - ;;@ ~lib/memory.ts:109:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:109:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:109:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:109:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:109:41 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:109:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:110:10 - (set_local $3 - ;;@ ~lib/memory.ts:110:14 - (i32.load - ;;@ ~lib/memory.ts:110:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:110:30 - (i32.const 13) - ) - ) - ) - ;;@ ~lib/memory.ts:111:10 - (i32.store - ;;@ ~lib/memory.ts:111:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:111:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:111:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:111:37 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:111:42 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:111:47 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:112:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:112:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:112:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:112:38 - (i32.const 16) - ) - ) - ) - (br $continue|3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:114:8 - (br $break|2) - ) - ) - ;;@ ~lib/memory.ts:116:14 - (block - ;;@ ~lib/memory.ts:117:8 - (set_local $3 - ;;@ ~lib/memory.ts:117:12 - (i32.load - ;;@ ~lib/memory.ts:117:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:118:8 - (i32.store8 - ;;@ ~lib/memory.ts:118:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:118:26 - (i32.load8_u - ;;@ ~lib/memory.ts:118:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:119:8 - (i32.store8 - ;;@ ~lib/memory.ts:119:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:119:26 - (i32.load8_u - ;;@ ~lib/memory.ts:119:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:120:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:120:13 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:121:8 - (block $break|4 - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:121:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:121:20 - (i32.const 18) - ) - (block - (block - ;;@ ~lib/memory.ts:122:10 - (set_local $4 - ;;@ ~lib/memory.ts:122:14 - (i32.load - ;;@ ~lib/memory.ts:122:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:122:30 - (i32.const 2) - ) - ) - ) - ;;@ ~lib/memory.ts:123:10 - (i32.store - ;;@ ~lib/memory.ts:123:21 - (get_local $0) - ;;@ ~lib/memory.ts:123:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:123:32 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:123:37 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:123:42 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:124:10 - (set_local $3 - ;;@ ~lib/memory.ts:124:14 - (i32.load - ;;@ ~lib/memory.ts:124:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:124:30 - (i32.const 6) - ) - ) - ) - ;;@ ~lib/memory.ts:125:10 - (i32.store - ;;@ ~lib/memory.ts:125:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:125:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:125:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:125:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:125:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:125:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:126:10 - (set_local $4 - ;;@ ~lib/memory.ts:126:14 - (i32.load - ;;@ ~lib/memory.ts:126:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:126:30 - (i32.const 10) - ) - ) - ) - ;;@ ~lib/memory.ts:127:10 - (i32.store - ;;@ ~lib/memory.ts:127:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:127:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:127:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:127:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:127:41 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:127:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:128:10 - (set_local $3 - ;;@ ~lib/memory.ts:128:14 - (i32.load - ;;@ ~lib/memory.ts:128:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:128:30 - (i32.const 14) - ) - ) - ) - ;;@ ~lib/memory.ts:129:10 - (i32.store - ;;@ ~lib/memory.ts:129:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:129:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:129:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:129:37 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:129:42 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:129:47 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:130:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:130:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:130:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:130:38 - (i32.const 16) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:132:8 - (br $break|2) - ) - ) - ;;@ ~lib/memory.ts:134:14 - (block - ;;@ ~lib/memory.ts:135:8 - (set_local $3 - ;;@ ~lib/memory.ts:135:12 - (i32.load - ;;@ ~lib/memory.ts:135:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:136:8 - (i32.store8 - ;;@ ~lib/memory.ts:136:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:136:26 - (i32.load8_u - ;;@ ~lib/memory.ts:136:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:137:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:137:13 - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:138:8 - (block $break|5 - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:138:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:138:20 - (i32.const 19) - ) - (block - (block - ;;@ ~lib/memory.ts:139:10 - (set_local $4 - ;;@ ~lib/memory.ts:139:14 - (i32.load - ;;@ ~lib/memory.ts:139:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:139:30 - (i32.const 3) - ) - ) - ) - ;;@ ~lib/memory.ts:140:10 - (i32.store - ;;@ ~lib/memory.ts:140:21 - (get_local $0) - ;;@ ~lib/memory.ts:140:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:140:32 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:140:36 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:140:41 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:141:10 - (set_local $3 - ;;@ ~lib/memory.ts:141:14 - (i32.load - ;;@ ~lib/memory.ts:141:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:141:30 - (i32.const 7) - ) - ) - ) - ;;@ ~lib/memory.ts:142:10 - (i32.store - ;;@ ~lib/memory.ts:142:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:142:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:142:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:142:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:142:40 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:142:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:143:10 - (set_local $4 - ;;@ ~lib/memory.ts:143:14 - (i32.load - ;;@ ~lib/memory.ts:143:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:143:30 - (i32.const 11) - ) - ) - ) - ;;@ ~lib/memory.ts:144:10 - (i32.store - ;;@ ~lib/memory.ts:144:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:144:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:144:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:40 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:144:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:145:10 - (set_local $3 - ;;@ ~lib/memory.ts:145:14 - (i32.load - ;;@ ~lib/memory.ts:145:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:145:30 - (i32.const 15) - ) - ) - ) - ;;@ ~lib/memory.ts:146:10 - (i32.store - ;;@ ~lib/memory.ts:146:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:146:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:146:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:146:37 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:146:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:146:46 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:147:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:147:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:147:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:147:38 - (i32.const 16) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:149:8 - (br $break|2) - ) - ) - ) - ;;@ ~lib/memory.ts:155:2 - (if - ;;@ ~lib/memory.ts:155:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:155:10 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:155:14 - (block - ;;@ ~lib/memory.ts:156:4 - (i32.store8 - ;;@ ~lib/memory.ts:156:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:156:22 - (i32.load8_u - ;;@ ~lib/memory.ts:156:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:157:4 - (i32.store8 - ;;@ ~lib/memory.ts:157:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:157:22 - (i32.load8_u - ;;@ ~lib/memory.ts:157:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:158:4 - (i32.store8 - ;;@ ~lib/memory.ts:158:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:158:22 - (i32.load8_u - ;;@ ~lib/memory.ts:158:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:159:4 - (i32.store8 - ;;@ ~lib/memory.ts:159:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:159:22 - (i32.load8_u - ;;@ ~lib/memory.ts:159:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:160:4 - (i32.store8 - ;;@ ~lib/memory.ts:160:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:160:22 - (i32.load8_u - ;;@ ~lib/memory.ts:160:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:161:4 - (i32.store8 - ;;@ ~lib/memory.ts:161:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:161:22 - (i32.load8_u - ;;@ ~lib/memory.ts:161:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:162:4 - (i32.store8 - ;;@ ~lib/memory.ts:162:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:162:22 - (i32.load8_u - ;;@ ~lib/memory.ts:162:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:163:4 - (i32.store8 - ;;@ ~lib/memory.ts:163:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:163:22 - (i32.load8_u - ;;@ ~lib/memory.ts:163:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:164:4 - (i32.store8 - ;;@ ~lib/memory.ts:164:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:164:22 - (i32.load8_u - ;;@ ~lib/memory.ts:164:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:165:4 - (i32.store8 - ;;@ ~lib/memory.ts:165:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:165:22 - (i32.load8_u - ;;@ ~lib/memory.ts:165:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:166:4 - (i32.store8 - ;;@ ~lib/memory.ts:166:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:166:22 - (i32.load8_u - ;;@ ~lib/memory.ts:166:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:167:4 - (i32.store8 - ;;@ ~lib/memory.ts:167:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:167:22 - (i32.load8_u - ;;@ ~lib/memory.ts:167:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:168:4 - (i32.store8 - ;;@ ~lib/memory.ts:168:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:168:22 - (i32.load8_u - ;;@ ~lib/memory.ts:168:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:169:4 - (i32.store8 - ;;@ ~lib/memory.ts:169:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:169:22 - (i32.load8_u - ;;@ ~lib/memory.ts:169:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:170:4 - (i32.store8 - ;;@ ~lib/memory.ts:170:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:170:22 - (i32.load8_u - ;;@ ~lib/memory.ts:170:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:171:4 - (i32.store8 - ;;@ ~lib/memory.ts:171:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:171:22 - (i32.load8_u - ;;@ ~lib/memory.ts:171:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:173:2 - (if - ;;@ ~lib/memory.ts:173:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:173:10 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:173:13 - (block - ;;@ ~lib/memory.ts:174:4 - (i32.store8 - ;;@ ~lib/memory.ts:174:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:174:22 - (i32.load8_u - ;;@ ~lib/memory.ts:174:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:175:4 - (i32.store8 - ;;@ ~lib/memory.ts:175:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:175:22 - (i32.load8_u - ;;@ ~lib/memory.ts:175:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:176:4 - (i32.store8 - ;;@ ~lib/memory.ts:176:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:176:22 - (i32.load8_u - ;;@ ~lib/memory.ts:176:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:177:4 - (i32.store8 - ;;@ ~lib/memory.ts:177:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:177:22 - (i32.load8_u - ;;@ ~lib/memory.ts:177:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:178:4 - (i32.store8 - ;;@ ~lib/memory.ts:178:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:178:22 - (i32.load8_u - ;;@ ~lib/memory.ts:178:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:179:4 - (i32.store8 - ;;@ ~lib/memory.ts:179:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:179:22 - (i32.load8_u - ;;@ ~lib/memory.ts:179:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:180:4 - (i32.store8 - ;;@ ~lib/memory.ts:180:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:180:22 - (i32.load8_u - ;;@ ~lib/memory.ts:180:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:181:4 - (i32.store8 - ;;@ ~lib/memory.ts:181:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:181:22 - (i32.load8_u - ;;@ ~lib/memory.ts:181:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:183:2 - (if - ;;@ ~lib/memory.ts:183:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:183:10 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:183:13 - (block - ;;@ ~lib/memory.ts:184:4 - (i32.store8 - ;;@ ~lib/memory.ts:184:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:184:22 - (i32.load8_u - ;;@ ~lib/memory.ts:184:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:185:4 - (i32.store8 - ;;@ ~lib/memory.ts:185:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:185:22 - (i32.load8_u - ;;@ ~lib/memory.ts:185:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:186:4 - (i32.store8 - ;;@ ~lib/memory.ts:186:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:186:22 - (i32.load8_u - ;;@ ~lib/memory.ts:186:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:187:4 - (i32.store8 - ;;@ ~lib/memory.ts:187:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:187:22 - (i32.load8_u - ;;@ ~lib/memory.ts:187:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:189:2 - (if - ;;@ ~lib/memory.ts:189:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:189:10 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:189:13 - (block - ;;@ ~lib/memory.ts:190:4 - (i32.store8 - ;;@ ~lib/memory.ts:190:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:190:22 - (i32.load8_u - ;;@ ~lib/memory.ts:190:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:191:4 - (i32.store8 - ;;@ ~lib/memory.ts:191:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:191:22 - (i32.load8_u - ;;@ ~lib/memory.ts:191:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:193:2 - (if - ;;@ ~lib/memory.ts:193:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:193:10 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:193:13 - (i32.store8 - ;;@ ~lib/memory.ts:194:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:194:22 - (i32.load8_u - ;;@ ~lib/memory.ts:194:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - (func $~lib/memory/memmove (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - ;;@ ~lib/memory.ts:200:2 - (if - ;;@ ~lib/memory.ts:200:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:200:14 - (get_local $1) - ) - ;;@ ~lib/memory.ts:200:19 - (return) - ) - ;;@ ~lib/memory.ts:201:2 - (if - ;;@ ~lib/memory.ts:201:6 - (if (result i32) - (tee_local $3 - (i32.le_u - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:201:12 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:17 - (get_local $0) - ) - ) - (get_local $3) - ;;@ ~lib/memory.ts:201:25 - (i32.le_u - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:201:32 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:201:42 - (block - ;;@ ~lib/memory.ts:202:4 - (call $~lib/memory/memcpy - ;;@ ~lib/memory.ts:202:11 - (get_local $0) - ;;@ ~lib/memory.ts:202:17 - (get_local $1) - ;;@ ~lib/memory.ts:202:22 - (get_local $2) - ) - ;;@ ~lib/memory.ts:203:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:205:2 - (if - ;;@ ~lib/memory.ts:205:6 - (i32.lt_u - (get_local $0) - ;;@ ~lib/memory.ts:205:13 - (get_local $1) - ) - ;;@ ~lib/memory.ts:205:18 - (block - ;;@ ~lib/memory.ts:206:4 - (if - ;;@ ~lib/memory.ts:206:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:206:9 - (get_local $1) - ;;@ ~lib/memory.ts:206:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:206:21 - (i32.and - ;;@ ~lib/memory.ts:206:22 - (get_local $0) - ;;@ ~lib/memory.ts:206:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:206:33 - (block - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:207:13 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:207:20 - (i32.const 7) - ) - (block - (block - ;;@ ~lib/memory.ts:208:8 - (if - ;;@ ~lib/memory.ts:208:12 - (i32.eqz - ;;@ ~lib/memory.ts:208:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:208:16 - (return) - ) - ;;@ ~lib/memory.ts:209:8 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:209:10 - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:8 - (i32.store8 - ;;@ ~lib/memory.ts:210:18 - (block (result i32) - (set_local $3 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ;;@ ~lib/memory.ts:210:26 - (i32.load8_u - ;;@ ~lib/memory.ts:210:35 - (block (result i32) - (set_local $3 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:212:6 - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:212:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:212:18 - (i32.const 8) - ) - (block - (block - ;;@ ~lib/memory.ts:213:8 - (i64.store - ;;@ ~lib/memory.ts:213:19 - (get_local $0) - ;;@ ~lib/memory.ts:213:25 - (i64.load - ;;@ ~lib/memory.ts:213:35 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:214:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:214:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:215:8 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:215:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:216:8 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:216:16 - (i32.const 8) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:219:4 - (block $break|2 - (loop $continue|2 - (if - ;;@ ~lib/memory.ts:219:11 - (get_local $2) - (block - (block - ;;@ ~lib/memory.ts:220:6 - (i32.store8 - ;;@ ~lib/memory.ts:220:16 - (block (result i32) - (set_local $3 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ;;@ ~lib/memory.ts:220:24 - (i32.load8_u - ;;@ ~lib/memory.ts:220:33 - (block (result i32) - (set_local $3 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:221:6 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:221:8 - (get_local $2) - (i32.const 1) - ) - ) - ) - (br $continue|2) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:223:9 - (block - ;;@ ~lib/memory.ts:224:4 - (if - ;;@ ~lib/memory.ts:224:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:224:9 - (get_local $1) - ;;@ ~lib/memory.ts:224:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:224:21 - (i32.and - ;;@ ~lib/memory.ts:224:22 - (get_local $0) - ;;@ ~lib/memory.ts:224:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:224:33 - (block - (block $break|3 - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:225:13 - (i32.and - (i32.add - ;;@ ~lib/memory.ts:225:14 - (get_local $0) - ;;@ ~lib/memory.ts:225:21 - (get_local $2) - ) - ;;@ ~lib/memory.ts:225:26 - (i32.const 7) - ) - (block - (block - ;;@ ~lib/memory.ts:226:8 - (if - ;;@ ~lib/memory.ts:226:12 - (i32.eqz - ;;@ ~lib/memory.ts:226:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:226:16 - (return) - ) - ;;@ ~lib/memory.ts:227:8 - (i32.store8 - ;;@ ~lib/memory.ts:227:18 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:227:25 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:227:27 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:227:30 - (i32.load8_u - ;;@ ~lib/memory.ts:227:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:227:45 - (get_local $2) - ) - ) - ) - ) - (br $continue|3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:229:6 - (block $break|4 - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:229:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:229:18 - (i32.const 8) - ) - (block - (block - ;;@ ~lib/memory.ts:230:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:230:13 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:231:8 - (i64.store - ;;@ ~lib/memory.ts:231:19 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:231:26 - (get_local $2) - ) - ;;@ ~lib/memory.ts:231:29 - (i64.load - ;;@ ~lib/memory.ts:231:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:231:45 - (get_local $2) - ) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:234:4 - (block $break|5 - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:234:11 - (get_local $2) - (block - ;;@ ~lib/memory.ts:234:14 - (i32.store8 - ;;@ ~lib/memory.ts:235:16 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:235:23 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:235:25 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:235:28 - (i32.load8_u - ;;@ ~lib/memory.ts:235:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:235:43 - (get_local $2) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ) + (func $start:~lib/allocator/buddy (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + global.set $~lib/allocator/buddy/BUCKETS_START + global.get $~lib/allocator/buddy/BUCKETS_START + global.get $~lib/allocator/buddy/BUCKET_COUNT + global.get $~lib/allocator/buddy/List.SIZE + i32.mul + i32.add + global.set $~lib/allocator/buddy/BUCKETS_END + global.get $~lib/allocator/buddy/BUCKETS_END + global.set $~lib/allocator/buddy/NODE_IS_SPLIT_START + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_START + global.get $~lib/allocator/buddy/SPLIT_COUNT + i32.const 1 + i32.mul + i32.add + global.set $~lib/allocator/buddy/NODE_IS_SPLIT_END ) - (func $~lib/memory/memory.copy (; 5 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:16:4 - (call $~lib/memory/memmove - ;;@ ~lib/memory.ts:16:12 - (get_local $0) - ;;@ ~lib/memory.ts:16:18 - (get_local $1) - ;;@ ~lib/memory.ts:16:23 - (get_local $2) - ) + (func $start:assembly/index (; 2 ;) (type $_) + call $start:~lib/allocator/buddy ) - (func $~lib/memory/memcmp (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/memory/memcmp (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - ;;@ ~lib/memory.ts:302:2 - (if - ;;@ ~lib/memory.ts:302:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:302:12 - (get_local $1) - ) - ;;@ ~lib/memory.ts:302:23 - (return - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:303:9 - (if (result i32) - (tee_local $3 - (i32.ne - (get_local $2) - ;;@ ~lib/memory.ts:303:14 - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:19 - (i32.eq - (i32.load8_u - ;;@ ~lib/memory.ts:303:28 - (get_local $0) - ) - ;;@ ~lib/memory.ts:303:35 - (i32.load8_u - ;;@ ~lib/memory.ts:303:44 - (get_local $1) - ) - ) - (get_local $3) - ) - (block - (block - ;;@ ~lib/memory.ts:304:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:9 - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:15 - (set_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (if (result i32) - ;;@ ~lib/memory.ts:306:9 - (get_local $2) - ;;@ ~lib/memory.ts:306:13 - (i32.sub - (i32.load8_u - ;;@ ~lib/memory.ts:306:27 - (get_local $0) - ) - ;;@ ~lib/memory.ts:306:33 - (i32.load8_u - ;;@ ~lib/memory.ts:306:47 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (i32.const 0) - ) + local.get $0 + local.get $1 + i32.eq + if + i32.const 0 + return + end + block $break|0 + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + local.tee $3 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.eq + else + local.get $3 + end + if + block + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.set $1 + end + br $continue|0 + end + end + end + local.get $2 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.sub + else + i32.const 0 + end ) - (func $~lib/memory/memory.compare (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/memory.ts:21:27 - (call $~lib/memory/memcmp - ;;@ ~lib/memory.ts:21:18 - (get_local $0) - ;;@ ~lib/memory.ts:21:22 - (get_local $1) - ;;@ ~lib/memory.ts:21:26 - (get_local $2) - ) + (func $~lib/memory/memory.compare (; 4 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + local.get $2 + call $~lib/internal/memory/memcmp ) - (func $~lib/allocator/buddy/update_max_ptr (; 8 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/update_max_ptr (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:175:2 - (if - ;;@ ~lib/allocator/buddy.ts:175:6 - (i32.gt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:175:18 - (get_global $~lib/allocator/buddy/max_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:175:27 - (block - ;;@ ~lib/allocator/buddy.ts:179:4 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:179:19 - (current_memory) - ) - ;;@ ~lib/allocator/buddy.ts:180:4 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:180:19 - (i32.shr_u - ;;@ ~lib/allocator/buddy.ts:180:25 - (i32.and - ;;@ ~lib/allocator/buddy.ts:180:26 - (i32.add - ;;@ ~lib/allocator/buddy.ts:180:27 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:180:39 - (i32.const 65535) - ) - ;;@ ~lib/allocator/buddy.ts:180:49 - (i32.xor - ;;@ ~lib/allocator/buddy.ts:180:50 - (i32.const 65535) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:180:62 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/buddy.ts:181:4 - (if - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:181:11 - (i32.gt_s - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:181:22 - (get_local $1) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 181) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/buddy.ts:182:4 - (if - ;;@ ~lib/allocator/buddy.ts:182:8 - (i32.lt_s - ;;@ ~lib/allocator/buddy.ts:182:15 - (grow_memory - ;;@ ~lib/allocator/buddy.ts:182:20 - (i32.sub - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:182:31 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:182:43 - (i32.const 0) - ) - ;;@ ~lib/allocator/buddy.ts:182:46 - (return - ;;@ ~lib/allocator/buddy.ts:183:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:186:4 - (set_global $~lib/allocator/buddy/max_ptr - ;;@ ~lib/allocator/buddy.ts:186:14 - (i32.shl - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:186:33 - (i32.const 16) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:188:9 - (i32.const 1) + local.get $0 + global.get $~lib/allocator/buddy/max_ptr + i32.gt_u + if + current_memory + local.set $1 + local.get $0 + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $2 + local.get $2 + local.get $1 + i32.gt_s + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 181 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + local.get $1 + i32.sub + grow_memory + i32.const 0 + i32.lt_s + if + i32.const 0 + return + end + local.get $2 + i32.const 16 + i32.shl + global.set $~lib/allocator/buddy/max_ptr + end + i32.const 1 ) - (func $~lib/allocator/buddy/buckets$get (; 9 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:101:2 - (if - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:101:9 - (i32.lt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:101:17 - (get_global $~lib/allocator/buddy/BUCKET_COUNT) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 101) - (i32.const 2) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/buddy.ts:102:59 - (i32.add - ;;@ ~lib/allocator/buddy.ts:102:26 - (get_global $~lib/allocator/buddy/BUCKETS_START) - ;;@ ~lib/allocator/buddy.ts:102:42 - (i32.mul - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:102:50 - (get_global $~lib/allocator/buddy/List.SIZE) - ) - ) + (func $~lib/allocator/buddy/buckets$get (; 6 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + global.get $~lib/allocator/buddy/BUCKET_COUNT + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 101 + i32.const 2 + call $~lib/env/abort + unreachable + end + global.get $~lib/allocator/buddy/BUCKETS_START + local.get $0 + global.get $~lib/allocator/buddy/List.SIZE + i32.mul + i32.add ) - (func $~lib/allocator/buddy/list_init (; 10 ;) (type $iv) (param $0 i32) - ;;@ ~lib/allocator/buddy.ts:197:2 - (i32.store - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:197:14 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:198:2 - (i32.store offset=4 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:198:14 - (get_local $0) - ) + (func $~lib/allocator/buddy/list_init (; 7 ;) (type $i_) (param $0 i32) + local.get $0 + local.get $0 + i32.store + local.get $0 + local.get $0 + i32.store offset=4 ) - (func $~lib/allocator/buddy/list_push (; 11 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $~lib/allocator/buddy/list_push (; 8 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:206:2 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:206:13 - (i32.load - (get_local $0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:207:2 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:207:15 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:208:2 - (i32.store offset=4 - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:208:15 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:209:2 - (i32.store offset=4 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:209:14 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:210:2 - (i32.store - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:210:14 - (get_local $1) - ) + local.get $0 + i32.load + local.set $2 + local.get $1 + local.get $2 + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $2 + local.get $1 + i32.store offset=4 + local.get $0 + local.get $1 + i32.store ) - (func $~lib/allocator/buddy/bucket_for_request (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/bucket_for_request (; 9 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:279:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:279:15 - (i32.sub - (get_global $~lib/allocator/buddy/BUCKET_COUNT) - ;;@ ~lib/allocator/buddy.ts:279:30 - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:280:2 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:280:13 - (get_global $~lib/allocator/buddy/MIN_ALLOC) - ) - ;;@ ~lib/allocator/buddy.ts:282:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:282:9 - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:282:16 - (get_local $0) - ) - (block - (block - ;;@ ~lib/allocator/buddy.ts:283:4 - (set_local $1 - (i32.sub - (get_local $1) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:284:4 - (set_local $2 - (i32.mul - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:284:12 - (i32.const 2) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:287:9 - (get_local $1) + global.get $~lib/allocator/buddy/BUCKET_COUNT + i32.const 1 + i32.sub + local.set $1 + global.get $~lib/allocator/buddy/MIN_ALLOC + local.set $2 + block $break|0 + loop $continue|0 + local.get $2 + local.get $0 + i32.lt_u + if + block + local.get $1 + i32.const 1 + i32.sub + local.set $1 + local.get $2 + i32.const 2 + i32.mul + local.set $2 + end + br $continue|0 + end + end + end + local.get $1 ) - (func $~lib/allocator/buddy/node_for_ptr (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:252:75 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:252:9 - (i32.add - (i32.shr_u - ;;@ ~lib/allocator/buddy.ts:252:10 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:252:11 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:252:17 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:252:30 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:252:31 - (get_global $~lib/allocator/buddy/MAX_ALLOC_LOG2) - ;;@ ~lib/allocator/buddy.ts:252:48 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:252:59 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:252:60 - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:252:65 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:252:75 - (i32.const 1) - ) + (func $~lib/allocator/buddy/node_for_ptr (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + global.get $~lib/allocator/buddy/base_ptr + i32.sub + global.get $~lib/allocator/buddy/MAX_ALLOC_LOG2 + local.get $1 + i32.sub + i32.shr_u + i32.const 1 + local.get $1 + i32.shl + i32.add + i32.const 1 + i32.sub ) - (func $~lib/allocator/buddy/node_is_split$get (; 14 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:147:2 - (if - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:147:9 - (i32.lt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:147:17 - (get_global $~lib/allocator/buddy/SPLIT_COUNT) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 147) - (i32.const 2) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/buddy.ts:148:45 - (i32.load8_u - ;;@ ~lib/allocator/buddy.ts:148:18 - (i32.add - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_START) - ;;@ ~lib/allocator/buddy.ts:148:40 - (get_local $0) - ) - ) + (func $~lib/allocator/buddy/node_is_split$get (; 11 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + global.get $~lib/allocator/buddy/SPLIT_COUNT + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 147 + i32.const 2 + call $~lib/env/abort + unreachable + end + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_START + local.get $0 + i32.add + i32.load8_u ) - (func $~lib/allocator/buddy/parent_is_split (; 15 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:259:2 - (set_local $0 - ;;@ ~lib/allocator/buddy.ts:259:10 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:259:11 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:259:19 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:259:24 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:260:70 - (i32.eq - ;;@ ~lib/allocator/buddy.ts:260:9 - (i32.and - ;;@ ~lib/allocator/buddy.ts:260:10 - (i32.shr_u - ;;@ ~lib/allocator/buddy.ts:260:11 - (call $~lib/allocator/buddy/node_is_split$get - ;;@ ~lib/allocator/buddy.ts:260:29 - (i32.div_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:260:37 - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/buddy.ts:260:44 - (i32.rem_u - ;;@ ~lib/allocator/buddy.ts:260:50 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:260:58 - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/buddy.ts:260:64 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:260:70 - (i32.const 1) - ) + (func $~lib/allocator/buddy/parent_is_split (; 12 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.set $0 + local.get $0 + i32.const 8 + i32.div_u + call $~lib/allocator/buddy/node_is_split$get + local.get $0 + i32.const 8 + i32.rem_u + i32.shr_u + i32.const 1 + i32.and + i32.const 1 + i32.eq ) - (func $~lib/allocator/buddy/list_remove (; 16 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/buddy/list_remove (; 13 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:220:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:220:13 - (i32.load - (get_local $0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:221:2 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:221:13 - (i32.load offset=4 - (get_local $0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:222:2 - (i32.store offset=4 - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:222:14 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:223:2 - (i32.store - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:223:14 - (get_local $1) - ) + local.get $0 + i32.load + local.set $1 + local.get $0 + i32.load offset=4 + local.set $2 + local.get $1 + local.get $2 + i32.store offset=4 + local.get $2 + local.get $1 + i32.store ) - (func $~lib/allocator/buddy/ptr_for_node (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - ;;@ ~lib/allocator/buddy.ts:243:77 - (i32.add - ;;@ ~lib/allocator/buddy.ts:243:9 - (get_global $~lib/allocator/buddy/base_ptr) - ;;@ ~lib/allocator/buddy.ts:243:20 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:243:21 - (i32.add - ;;@ ~lib/allocator/buddy.ts:243:22 - (i32.sub - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:243:30 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:243:31 - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:243:36 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:243:46 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:243:52 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:243:53 - (get_global $~lib/allocator/buddy/MAX_ALLOC_LOG2) - ;;@ ~lib/allocator/buddy.ts:243:70 - (get_local $1) - ) - ) - ) + (func $~lib/allocator/buddy/ptr_for_node (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + global.get $~lib/allocator/buddy/base_ptr + local.get $0 + i32.const 1 + local.get $1 + i32.shl + i32.sub + i32.const 1 + i32.add + global.get $~lib/allocator/buddy/MAX_ALLOC_LOG2 + local.get $1 + i32.sub + i32.shl + i32.add ) - (func $~lib/allocator/buddy/node_is_split$set (; 18 ;) (type $iiv) (param $0 i32) (param $1 i32) - ;;@ ~lib/allocator/buddy.ts:152:2 - (if - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:152:9 - (i32.lt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:152:17 - (get_global $~lib/allocator/buddy/SPLIT_COUNT) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 152) - (i32.const 2) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/buddy.ts:153:2 - (i32.store8 - ;;@ ~lib/allocator/buddy.ts:153:12 - (i32.add - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_START) - ;;@ ~lib/allocator/buddy.ts:153:34 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:153:41 - (get_local $1) - ) + (func $~lib/allocator/buddy/node_is_split$set (; 15 ;) (type $ii_) (param $0 i32) (param $1 i32) + local.get $0 + global.get $~lib/allocator/buddy/SPLIT_COUNT + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 152 + i32.const 2 + call $~lib/env/abort + unreachable + end + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_START + local.get $0 + i32.add + local.get $1 + i32.store8 ) - (func $~lib/allocator/buddy/flip_parent_is_split (; 19 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/buddy/flip_parent_is_split (; 16 ;) (type $i_) (param $0 i32) (local $1 i32) - ;;@ ~lib/allocator/buddy.ts:267:2 - (set_local $0 - ;;@ ~lib/allocator/buddy.ts:267:10 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:267:11 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:267:19 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:267:24 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:268:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:268:18 - (i32.div_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:268:26 - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/buddy.ts:269:2 - (call $~lib/allocator/buddy/node_is_split$set - ;;@ ~lib/allocator/buddy.ts:269:20 - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:270:4 - (i32.xor - (call $~lib/allocator/buddy/node_is_split$get - ;;@ ~lib/allocator/buddy.ts:270:22 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:270:35 - (i32.shl - ;;@ ~lib/allocator/buddy.ts:270:41 - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:270:46 - (i32.rem_u - ;;@ ~lib/allocator/buddy.ts:270:47 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:270:55 - (i32.const 8) - ) - ) - ) - ) + local.get $0 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.set $0 + local.get $0 + i32.const 8 + i32.div_u + local.set $1 + local.get $1 + local.get $1 + call $~lib/allocator/buddy/node_is_split$get + i32.const 1 + local.get $0 + i32.const 8 + i32.rem_u + i32.shl + i32.xor + call $~lib/allocator/buddy/node_is_split$set ) - (func $~lib/allocator/buddy/lower_bucket_limit (; 20 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/lower_bucket_limit (; 17 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/buddy.ts:296:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:296:9 - (i32.lt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:296:18 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - (block - (block - ;;@ ~lib/allocator/buddy.ts:297:4 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:297:15 - (call $~lib/allocator/buddy/node_for_ptr - ;;@ ~lib/allocator/buddy.ts:297:28 - (get_global $~lib/allocator/buddy/base_ptr) - ;;@ ~lib/allocator/buddy.ts:297:38 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ;;@ ~lib/allocator/buddy.ts:306:4 - (if - ;;@ ~lib/allocator/buddy.ts:306:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:306:9 - (call $~lib/allocator/buddy/parent_is_split - ;;@ ~lib/allocator/buddy.ts:306:25 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:306:32 - (block - ;;@ ~lib/allocator/buddy.ts:307:6 - (call $~lib/allocator/buddy/list_remove - ;;@ ~lib/allocator/buddy.ts:307:18 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:308:6 - (call $~lib/allocator/buddy/list_init - ;;@ ~lib/allocator/buddy.ts:308:16 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:308:28 - (block (result i32) - (set_global $~lib/allocator/buddy/bucket_limit - (i32.sub - ;;@ ~lib/allocator/buddy.ts:308:30 - (get_global $~lib/allocator/buddy/bucket_limit) - (i32.const 1) - ) - ) - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:309:6 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:309:16 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:309:28 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ;;@ ~lib/allocator/buddy.ts:309:43 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ;;@ ~lib/allocator/buddy.ts:310:6 - (br $continue|0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:321:4 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:321:18 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:321:31 - (i32.add - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:321:38 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:321:41 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ;;@ ~lib/allocator/buddy.ts:322:4 - (if - ;;@ ~lib/allocator/buddy.ts:322:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:322:9 - (call $~lib/allocator/buddy/update_max_ptr - ;;@ ~lib/allocator/buddy.ts:322:24 - (i32.add - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:322:38 - (get_global $~lib/allocator/buddy/List.SIZE) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:322:50 - (return - ;;@ ~lib/allocator/buddy.ts:323:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:325:4 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:325:14 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:325:26 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ;;@ ~lib/allocator/buddy.ts:325:41 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:326:4 - (call $~lib/allocator/buddy/list_init - ;;@ ~lib/allocator/buddy.ts:326:14 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:326:26 - (block (result i32) - (set_global $~lib/allocator/buddy/bucket_limit - (i32.sub - ;;@ ~lib/allocator/buddy.ts:326:28 - (get_global $~lib/allocator/buddy/bucket_limit) - (i32.const 1) - ) - ) - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:332:4 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:332:11 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:332:12 - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:332:19 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:332:24 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:333:4 - (if - ;;@ ~lib/allocator/buddy.ts:333:8 - (i32.ne - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:333:16 - (i32.const 0) - ) - ;;@ ~lib/allocator/buddy.ts:333:19 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:334:27 - (get_local $1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:338:9 - (i32.const 1) + block $break|0 + loop $continue|0 + local.get $0 + global.get $~lib/allocator/buddy/bucket_limit + i32.lt_u + if + block + global.get $~lib/allocator/buddy/base_ptr + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/node_for_ptr + local.set $1 + local.get $1 + call $~lib/allocator/buddy/parent_is_split + i32.eqz + if + global.get $~lib/allocator/buddy/base_ptr + call $~lib/allocator/buddy/list_remove + block (result i32) + global.get $~lib/allocator/buddy/bucket_limit + i32.const 1 + i32.sub + global.set $~lib/allocator/buddy/bucket_limit + global.get $~lib/allocator/buddy/bucket_limit + end + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_init + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/buckets$get + global.get $~lib/allocator/buddy/base_ptr + call $~lib/allocator/buddy/list_push + br $continue|0 + end + local.get $1 + i32.const 1 + i32.add + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/ptr_for_node + local.set $2 + local.get $2 + global.get $~lib/allocator/buddy/List.SIZE + i32.add + call $~lib/allocator/buddy/update_max_ptr + i32.eqz + if + i32.const 0 + return + end + global.get $~lib/allocator/buddy/bucket_limit + call $~lib/allocator/buddy/buckets$get + local.get $2 + call $~lib/allocator/buddy/list_push + block (result i32) + global.get $~lib/allocator/buddy/bucket_limit + i32.const 1 + i32.sub + global.set $~lib/allocator/buddy/bucket_limit + global.get $~lib/allocator/buddy/bucket_limit + end + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_init + local.get $1 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.set $1 + local.get $1 + i32.const 0 + i32.ne + if + local.get $1 + call $~lib/allocator/buddy/flip_parent_is_split + end + end + br $continue|0 + end + end + end + i32.const 1 ) - (func $~lib/allocator/buddy/list_pop (; 21 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/list_pop (; 18 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - ;;@ ~lib/allocator/buddy.ts:230:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:230:13 - (i32.load - (get_local $0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:231:2 - (if - ;;@ ~lib/allocator/buddy.ts:231:6 - (i32.eq - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:231:14 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:231:27 - (return - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:232:2 - (call $~lib/allocator/buddy/list_remove - ;;@ ~lib/allocator/buddy.ts:232:14 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:233:9 - (get_local $1) + local.get $0 + i32.load + local.set $1 + local.get $1 + local.get $0 + i32.eq + if + i32.const 0 + return + end + local.get $1 + call $~lib/allocator/buddy/list_remove + local.get $1 ) - (func $~lib/allocator/buddy/__memory_allocate (; 22 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/buddy/__memory_allocate (; 19 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -4052,641 +472,296 @@ (local $5 i32) (local $6 i32) (local $7 i32) - ;;@ ~lib/allocator/buddy.ts:350:2 - (if - ;;@ ~lib/allocator/buddy.ts:350:6 - (i32.gt_u - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:350:16 - (i32.sub - (get_global $~lib/allocator/buddy/MAX_ALLOC) - ;;@ ~lib/allocator/buddy.ts:350:28 - (get_global $~lib/allocator/buddy/HEADER_SIZE) - ) - ) - ;;@ ~lib/allocator/buddy.ts:350:41 - (unreachable) - ) - ;;@ ~lib/allocator/buddy.ts:357:2 - (if - ;;@ ~lib/allocator/buddy.ts:357:6 - (i32.eq - (get_global $~lib/allocator/buddy/base_ptr) - ;;@ ~lib/allocator/buddy.ts:357:18 - (i32.const 0) - ) - ;;@ ~lib/allocator/buddy.ts:357:21 - (block - ;;@ ~lib/allocator/buddy.ts:359:4 - (set_global $~lib/allocator/buddy/base_ptr - ;;@ ~lib/allocator/buddy.ts:359:15 - (i32.and - (i32.add - ;;@ ~lib/allocator/buddy.ts:359:16 - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_END) - ;;@ ~lib/allocator/buddy.ts:359:36 - (i32.const 7) - ) - ;;@ ~lib/allocator/buddy.ts:359:41 - (i32.xor - ;;@ ~lib/allocator/buddy.ts:359:42 - (i32.const 7) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:360:4 - (set_global $~lib/allocator/buddy/max_ptr - ;;@ ~lib/allocator/buddy.ts:360:14 - (i32.shl - (current_memory) - ;;@ ~lib/allocator/buddy.ts:360:38 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/buddy.ts:361:4 - (set_global $~lib/allocator/buddy/bucket_limit - ;;@ ~lib/allocator/buddy.ts:361:19 - (i32.sub - (get_global $~lib/allocator/buddy/BUCKET_COUNT) - ;;@ ~lib/allocator/buddy.ts:361:34 - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:362:4 - (if - ;;@ ~lib/allocator/buddy.ts:362:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:362:9 - (call $~lib/allocator/buddy/update_max_ptr - ;;@ ~lib/allocator/buddy.ts:362:24 - (i32.add - (get_global $~lib/allocator/buddy/base_ptr) - ;;@ ~lib/allocator/buddy.ts:362:35 - (get_global $~lib/allocator/buddy/List.SIZE) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:362:47 - (return - ;;@ ~lib/allocator/buddy.ts:363:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:365:4 - (call $~lib/allocator/buddy/list_init - ;;@ ~lib/allocator/buddy.ts:365:14 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:365:26 - (i32.sub - (get_global $~lib/allocator/buddy/BUCKET_COUNT) - ;;@ ~lib/allocator/buddy.ts:365:41 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:366:4 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:366:14 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:366:26 - (i32.sub - (get_global $~lib/allocator/buddy/BUCKET_COUNT) - ;;@ ~lib/allocator/buddy.ts:366:41 - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:366:45 - (get_global $~lib/allocator/buddy/base_ptr) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:373:2 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:373:11 - (call $~lib/allocator/buddy/bucket_for_request - ;;@ ~lib/allocator/buddy.ts:373:30 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:373:40 - (get_global $~lib/allocator/buddy/HEADER_SIZE) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:374:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:374:20 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:381:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:381:9 - (i32.ne - (i32.add - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:381:18 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:381:23 - (i32.const 0) - ) - ;;@ ~lib/allocator/buddy.ts:381:26 - (block - ;;@ ~lib/allocator/buddy.ts:389:4 - (if - ;;@ ~lib/allocator/buddy.ts:389:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:389:9 - (call $~lib/allocator/buddy/lower_bucket_limit - ;;@ ~lib/allocator/buddy.ts:389:28 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:389:37 - (return - ;;@ ~lib/allocator/buddy.ts:390:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:397:4 - (set_local $6 - ;;@ ~lib/allocator/buddy.ts:397:10 - (call $~lib/allocator/buddy/list_pop - ;;@ ~lib/allocator/buddy.ts:397:37 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:397:49 - (get_local $2) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:398:4 - (if - ;;@ ~lib/allocator/buddy.ts:398:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:398:9 - (get_local $6) - ) - ;;@ ~lib/allocator/buddy.ts:398:14 - (block - ;;@ ~lib/allocator/buddy.ts:403:6 - (if - ;;@ ~lib/allocator/buddy.ts:403:10 - (if (result i32) - (tee_local $7 - (i32.ne - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:403:20 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - (get_local $7) - ;;@ ~lib/allocator/buddy.ts:403:36 - (i32.eq - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:403:46 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:403:49 - (block - ;;@ ~lib/allocator/buddy.ts:404:8 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:405:8 - (br $continue|0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:415:6 - (if - ;;@ ~lib/allocator/buddy.ts:415:10 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:415:11 - (call $~lib/allocator/buddy/lower_bucket_limit - ;;@ ~lib/allocator/buddy.ts:415:30 - (i32.sub - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:415:39 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:415:43 - (return - ;;@ ~lib/allocator/buddy.ts:416:15 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/buddy.ts:418:6 - (set_local $6 - ;;@ ~lib/allocator/buddy.ts:418:12 - (call $~lib/allocator/buddy/list_pop - ;;@ ~lib/allocator/buddy.ts:418:39 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:418:51 - (get_local $2) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:425:4 - (set_local $3 - ;;@ ~lib/allocator/buddy.ts:425:11 - (i32.shl - (i32.const 1) - ;;@ ~lib/allocator/buddy.ts:425:16 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:425:17 - (get_global $~lib/allocator/buddy/MAX_ALLOC_LOG2) - ;;@ ~lib/allocator/buddy.ts:425:34 - (get_local $2) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:426:4 - (set_local $4 - ;;@ ~lib/allocator/buddy.ts:426:19 - (if (result i32) - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:426:28 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:426:46 - (i32.add - (i32.div_u - (get_local $3) - ;;@ ~lib/allocator/buddy.ts:426:53 - (i32.const 2) - ) - ;;@ ~lib/allocator/buddy.ts:426:57 - (get_global $~lib/allocator/buddy/List.SIZE) - ) - ;;@ ~lib/allocator/buddy.ts:426:69 - (get_local $3) - ) - ) - ;;@ ~lib/allocator/buddy.ts:427:4 - (if - ;;@ ~lib/allocator/buddy.ts:427:8 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:427:9 - (call $~lib/allocator/buddy/update_max_ptr - ;;@ ~lib/allocator/buddy.ts:427:24 - (i32.add - (get_local $6) - ;;@ ~lib/allocator/buddy.ts:427:30 - (get_local $4) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:427:45 - (block - ;;@ ~lib/allocator/buddy.ts:428:6 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:428:16 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:428:28 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:428:37 - (get_local $6) - ) - ;;@ ~lib/allocator/buddy.ts:429:13 - (return - (i32.const 0) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:443:4 - (set_local $5 - ;;@ ~lib/allocator/buddy.ts:443:8 - (call $~lib/allocator/buddy/node_for_ptr - ;;@ ~lib/allocator/buddy.ts:443:21 - (get_local $6) - ;;@ ~lib/allocator/buddy.ts:443:26 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:444:4 - (if - ;;@ ~lib/allocator/buddy.ts:444:8 - (i32.ne - (get_local $5) - ;;@ ~lib/allocator/buddy.ts:444:13 - (i32.const 0) - ) - ;;@ ~lib/allocator/buddy.ts:444:16 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:445:27 - (get_local $5) - ) - ) - ;;@ ~lib/allocator/buddy.ts:455:4 - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/allocator/buddy.ts:455:11 - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:455:20 - (get_local $1) - ) - (block - (block - ;;@ ~lib/allocator/buddy.ts:456:6 - (set_local $5 - ;;@ ~lib/allocator/buddy.ts:456:10 - (i32.add - (i32.mul - (get_local $5) - ;;@ ~lib/allocator/buddy.ts:456:14 - (i32.const 2) - ) - ;;@ ~lib/allocator/buddy.ts:456:18 - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:457:6 - (set_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:458:6 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:458:27 - (get_local $5) - ) - ;;@ ~lib/allocator/buddy.ts:459:6 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:460:8 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:460:20 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:461:8 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:461:38 - (i32.add - (get_local $5) - ;;@ ~lib/allocator/buddy.ts:461:42 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:461:45 - (get_local $2) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:469:4 - (i32.store - ;;@ ~lib/allocator/buddy.ts:469:17 - (get_local $6) - ;;@ ~lib/allocator/buddy.ts:469:22 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:470:17 - (return - ;;@ ~lib/allocator/buddy.ts:470:11 - (i32.add - (get_local $6) - ;;@ ~lib/allocator/buddy.ts:470:17 - (get_global $~lib/allocator/buddy/HEADER_SIZE) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:473:9 - (i32.const 0) + local.get $0 + global.get $~lib/allocator/buddy/MAX_ALLOC + global.get $~lib/allocator/buddy/HEADER_SIZE + i32.sub + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/buddy/base_ptr + i32.const 0 + i32.eq + if + global.get $~lib/allocator/buddy/NODE_IS_SPLIT_END + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/buddy/base_ptr + current_memory + i32.const 16 + i32.shl + global.set $~lib/allocator/buddy/max_ptr + global.get $~lib/allocator/buddy/BUCKET_COUNT + i32.const 1 + i32.sub + global.set $~lib/allocator/buddy/bucket_limit + global.get $~lib/allocator/buddy/base_ptr + global.get $~lib/allocator/buddy/List.SIZE + i32.add + call $~lib/allocator/buddy/update_max_ptr + i32.eqz + if + i32.const 0 + return + end + global.get $~lib/allocator/buddy/BUCKET_COUNT + i32.const 1 + i32.sub + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_init + global.get $~lib/allocator/buddy/BUCKET_COUNT + i32.const 1 + i32.sub + call $~lib/allocator/buddy/buckets$get + global.get $~lib/allocator/buddy/base_ptr + call $~lib/allocator/buddy/list_push + end + local.get $0 + global.get $~lib/allocator/buddy/HEADER_SIZE + i32.add + call $~lib/allocator/buddy/bucket_for_request + local.set $2 + local.get $2 + local.set $1 + block $break|0 + loop $continue|0 + local.get $2 + i32.const 1 + i32.add + i32.const 0 + i32.ne + if + local.get $2 + call $~lib/allocator/buddy/lower_bucket_limit + i32.eqz + if + i32.const 0 + return + end + local.get $2 + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_pop + local.set $6 + local.get $6 + i32.eqz + if + local.get $2 + global.get $~lib/allocator/buddy/bucket_limit + i32.ne + local.tee $7 + if (result i32) + local.get $7 + else + local.get $2 + i32.const 0 + i32.eq + end + if + local.get $2 + i32.const 1 + i32.sub + local.set $2 + br $continue|0 + end + local.get $2 + i32.const 1 + i32.sub + call $~lib/allocator/buddy/lower_bucket_limit + i32.eqz + if + i32.const 0 + return + end + local.get $2 + call $~lib/allocator/buddy/buckets$get + call $~lib/allocator/buddy/list_pop + local.set $6 + end + i32.const 1 + global.get $~lib/allocator/buddy/MAX_ALLOC_LOG2 + local.get $2 + i32.sub + i32.shl + local.set $3 + local.get $2 + local.get $1 + i32.lt_u + if (result i32) + local.get $3 + i32.const 2 + i32.div_u + global.get $~lib/allocator/buddy/List.SIZE + i32.add + else + local.get $3 + end + local.set $4 + local.get $6 + local.get $4 + i32.add + call $~lib/allocator/buddy/update_max_ptr + i32.eqz + if + local.get $2 + call $~lib/allocator/buddy/buckets$get + local.get $6 + call $~lib/allocator/buddy/list_push + i32.const 0 + return + end + local.get $6 + local.get $2 + call $~lib/allocator/buddy/node_for_ptr + local.set $5 + local.get $5 + i32.const 0 + i32.ne + if + local.get $5 + call $~lib/allocator/buddy/flip_parent_is_split + end + block $break|1 + loop $continue|1 + local.get $2 + local.get $1 + i32.lt_u + if + block + local.get $5 + i32.const 2 + i32.mul + i32.const 1 + i32.add + local.set $5 + local.get $2 + i32.const 1 + i32.add + local.set $2 + local.get $5 + call $~lib/allocator/buddy/flip_parent_is_split + local.get $2 + call $~lib/allocator/buddy/buckets$get + local.get $5 + i32.const 1 + i32.add + local.get $2 + call $~lib/allocator/buddy/ptr_for_node + call $~lib/allocator/buddy/list_push + end + br $continue|1 + end + end + end + local.get $6 + local.get $0 + i32.store + local.get $6 + global.get $~lib/allocator/buddy/HEADER_SIZE + i32.add + return + end + end + end + i32.const 0 ) - (func $~lib/memory/memory.allocate (; 23 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/memory.ts:37:4 - (return - ;;@ ~lib/memory.ts:37:45 - (call $~lib/allocator/buddy/__memory_allocate - ;;@ ~lib/memory.ts:37:63 - (get_local $0) - ) - ) + (func $~lib/memory/memory.allocate (; 20 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/allocator/buddy/__memory_allocate + return ) - (func $~lib/allocator/buddy/__memory_free (; 24 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/buddy/__memory_free (; 21 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) - ;;@ ~lib/allocator/buddy.ts:483:2 - (if - ;;@ ~lib/allocator/buddy.ts:483:6 - (i32.eqz - ;;@ ~lib/allocator/buddy.ts:483:7 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:483:12 - (return) - ) - ;;@ ~lib/allocator/buddy.ts:492:2 - (set_local $0 - ;;@ ~lib/allocator/buddy.ts:492:8 - (i32.sub - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:492:14 - (get_global $~lib/allocator/buddy/HEADER_SIZE) - ) - ) - ;;@ ~lib/allocator/buddy.ts:493:2 - (set_local $1 - ;;@ ~lib/allocator/buddy.ts:493:11 - (call $~lib/allocator/buddy/bucket_for_request - ;;@ ~lib/allocator/buddy.ts:493:30 - (i32.add - (i32.load - ;;@ ~lib/allocator/buddy.ts:493:42 - (get_local $0) - ) - ;;@ ~lib/allocator/buddy.ts:493:49 - (get_global $~lib/allocator/buddy/HEADER_SIZE) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:494:2 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:494:6 - (call $~lib/allocator/buddy/node_for_ptr - ;;@ ~lib/allocator/buddy.ts:494:19 - (get_local $0) - ;;@ ~lib/allocator/buddy.ts:494:24 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:500:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/allocator/buddy.ts:500:9 - (i32.ne - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:500:14 - (i32.const 0) - ) - (block - (block - ;;@ ~lib/allocator/buddy.ts:507:4 - (call $~lib/allocator/buddy/flip_parent_is_split - ;;@ ~lib/allocator/buddy.ts:507:25 - (get_local $2) - ) - ;;@ ~lib/allocator/buddy.ts:517:4 - (if - ;;@ ~lib/allocator/buddy.ts:517:8 - (if (result i32) - (tee_local $3 - (call $~lib/allocator/buddy/parent_is_split - ;;@ ~lib/allocator/buddy.ts:517:24 - (get_local $2) - ) - ) - (get_local $3) - ;;@ ~lib/allocator/buddy.ts:517:30 - (i32.eq - (get_local $1) - ;;@ ~lib/allocator/buddy.ts:517:40 - (get_global $~lib/allocator/buddy/bucket_limit) - ) - ) - ;;@ ~lib/allocator/buddy.ts:517:54 - (br $break|0) - ) - ;;@ ~lib/allocator/buddy.ts:528:4 - (call $~lib/allocator/buddy/list_remove - ;;@ ~lib/allocator/buddy.ts:528:16 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:528:46 - (i32.add - (i32.xor - ;;@ ~lib/allocator/buddy.ts:528:47 - (i32.sub - ;;@ ~lib/allocator/buddy.ts:528:48 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:528:52 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:528:57 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:528:62 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:528:65 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/buddy.ts:529:4 - (set_local $2 - ;;@ ~lib/allocator/buddy.ts:529:8 - (i32.div_u - (i32.sub - ;;@ ~lib/allocator/buddy.ts:529:9 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:529:13 - (i32.const 1) - ) - ;;@ ~lib/allocator/buddy.ts:529:18 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/buddy.ts:530:4 - (set_local $1 - (i32.sub - (get_local $1) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/allocator/buddy.ts:539:2 - (call $~lib/allocator/buddy/list_push - ;;@ ~lib/allocator/buddy.ts:539:12 - (call $~lib/allocator/buddy/buckets$get - ;;@ ~lib/allocator/buddy.ts:539:24 - (get_local $1) - ) - ;;@ ~lib/allocator/buddy.ts:539:33 - (call $~lib/allocator/buddy/ptr_for_node - ;;@ ~lib/allocator/buddy.ts:539:63 - (get_local $2) - ;;@ ~lib/allocator/buddy.ts:539:66 - (get_local $1) - ) - ) + local.get $0 + i32.eqz + if + return + end + local.get $0 + global.get $~lib/allocator/buddy/HEADER_SIZE + i32.sub + local.set $0 + local.get $0 + i32.load + global.get $~lib/allocator/buddy/HEADER_SIZE + i32.add + call $~lib/allocator/buddy/bucket_for_request + local.set $1 + local.get $0 + local.get $1 + call $~lib/allocator/buddy/node_for_ptr + local.set $2 + block $break|0 + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + if + block + local.get $2 + call $~lib/allocator/buddy/flip_parent_is_split + local.get $2 + call $~lib/allocator/buddy/parent_is_split + local.tee $3 + if (result i32) + local.get $3 + else + local.get $1 + global.get $~lib/allocator/buddy/bucket_limit + i32.eq + end + if + br $break|0 + end + local.get $2 + i32.const 1 + i32.sub + i32.const 1 + i32.xor + i32.const 1 + i32.add + local.get $1 + call $~lib/allocator/buddy/ptr_for_node + call $~lib/allocator/buddy/list_remove + local.get $2 + i32.const 1 + i32.sub + i32.const 2 + i32.div_u + local.set $2 + local.get $1 + i32.const 1 + i32.sub + local.set $1 + end + br $continue|0 + end + end + end + local.get $1 + call $~lib/allocator/buddy/buckets$get + local.get $2 + local.get $1 + call $~lib/allocator/buddy/ptr_for_node + call $~lib/allocator/buddy/list_push ) - (func $~lib/memory/memory.free (; 25 ;) (type $iv) (param $0 i32) - ;;@ ~lib/memory.ts:43:36 - (call $~lib/allocator/buddy/__memory_free - ;;@ ~lib/memory.ts:43:50 - (get_local $0) - ) - ;;@ ~lib/memory.ts:43:56 - (return) + (func $~lib/memory/memory.free (; 22 ;) (type $i_) (param $0 i32) + local.get $0 + call $~lib/allocator/buddy/__memory_free + return ) - (func $~lib/allocator/buddy/__memory_reset (; 26 ;) (type $v) - ;;@ ~lib/allocator/buddy.ts:544:2 - (unreachable) + (func $~lib/memory/memory.reset (; 23 ;) (type $_) + unreachable ) - (func $~lib/memory/memory.reset (; 27 ;) (type $v) - ;;@ ~lib/memory.ts:49:37 - (call $~lib/allocator/buddy/__memory_reset) - ;;@ ~lib/memory.ts:49:55 - (return) + (func $start (; 24 ;) (type $_) + call $start:assembly/index ) - (func $start (; 28 ;) (type $v) - (set_global $~lib/allocator/buddy/BUCKETS_START - ;;@ ~lib/allocator/buddy.ts:97:27 - (get_global $HEAP_BASE) - ) - (set_global $~lib/allocator/buddy/BUCKETS_END - ;;@ ~lib/allocator/buddy.ts:98:25 - (i32.add - (get_global $~lib/allocator/buddy/BUCKETS_START) - ;;@ ~lib/allocator/buddy.ts:98:41 - (i32.mul - (get_global $~lib/allocator/buddy/BUCKET_COUNT) - ;;@ ~lib/allocator/buddy.ts:98:56 - (get_global $~lib/allocator/buddy/List.SIZE) - ) - ) - ) - (set_global $~lib/allocator/buddy/NODE_IS_SPLIT_START - ;;@ ~lib/allocator/buddy.ts:143:33 - (get_global $~lib/allocator/buddy/BUCKETS_END) - ) - (set_global $~lib/allocator/buddy/NODE_IS_SPLIT_END - ;;@ ~lib/allocator/buddy.ts:144:31 - (i32.add - (get_global $~lib/allocator/buddy/NODE_IS_SPLIT_START) - ;;@ ~lib/allocator/buddy.ts:144:53 - (i32.mul - (get_global $~lib/allocator/buddy/SPLIT_COUNT) - ;;@ ~lib/allocator/buddy.ts:144:67 - (i32.const 1) - ) - ) - ) + (func $null (; 25 ;) (type $_) ) ) diff --git a/tests/allocators/tlsf/optimized.wat b/tests/allocators/tlsf/optimized.wat index 33eb34d5c0..a0da81d08a 100644 --- a/tests/allocators/tlsf/optimized.wat +++ b/tests/allocators/tlsf/optimized.wat @@ -1,4508 +1,785 @@ (module - (type $iiiv (func (param i32 i32 i32))) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $iiv (func (param i32 i32))) - (type $iiiiv (func (param i32 i32 i32 i32))) + (type $ii_ (func (param i32 i32))) + (type $iii_ (func (param i32 i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) - (type $iv (func (param i32))) - (type $v (func)) - (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) + (type $i_ (func (param i32))) + (type $_ (func)) + (type $FUNCSIG$vi (func (param i32))) (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) (export "memory" (memory $0)) - (export "memory.fill" (func $~lib/memory/memory.fill)) - (export "memory.copy" (func $~lib/memory/memory.copy)) + (export "table" (table $0)) (export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.allocate" (func $~lib/memory/memory.allocate)) (export "memory.free" (func $~lib/memory/memory.free)) (export "memory.reset" (func $~lib/memory/memory.reset)) - (func $~lib/memory/memset (; 0 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i64) - (local $4 i32) - ;;@ ~lib/memory.ts:244:2 - (if - ;;@ ~lib/memory.ts:244:6 - (i32.eqz - ;;@ ~lib/memory.ts:244:7 - (get_local $2) - ) - ;;@ ~lib/memory.ts:244:10 - (return) - ) - ;;@ ~lib/memory.ts:245:2 - (i32.store8 - ;;@ ~lib/memory.ts:245:12 - (get_local $0) - ;;@ ~lib/memory.ts:245:18 - (get_local $1) - ) - ;;@ ~lib/memory.ts:246:2 - (i32.store8 - ;;@ ~lib/memory.ts:246:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:246:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:246:23 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:246:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:247:2 - (if - ;;@ ~lib/memory.ts:247:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:247:11 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:247:14 - (return) - ) - ;;@ ~lib/memory.ts:249:2 - (i32.store8 - ;;@ ~lib/memory.ts:249:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:249:19 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:249:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:250:2 - (i32.store8 - ;;@ ~lib/memory.ts:250:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:250:19 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:250:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:251:2 - (i32.store8 - ;;@ ~lib/memory.ts:251:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:251:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:251:23 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:251:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:252:2 - (i32.store8 - ;;@ ~lib/memory.ts:252:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:252:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:252:23 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:252:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:253:2 - (if - ;;@ ~lib/memory.ts:253:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:253:11 - (i32.const 6) - ) - ;;@ ~lib/memory.ts:253:14 - (return) - ) - ;;@ ~lib/memory.ts:254:2 - (i32.store8 - ;;@ ~lib/memory.ts:254:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:254:19 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:254:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:255:2 - (i32.store8 - ;;@ ~lib/memory.ts:255:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:255:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:255:23 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:255:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:256:2 - (if - ;;@ ~lib/memory.ts:256:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:256:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:256:14 - (return) - ) - ;;@ ~lib/memory.ts:267:2 - (i32.store - ;;@ ~lib/memory.ts:260:2 - (tee_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:259:2 - (tee_local $4 - ;;@ ~lib/memory.ts:259:17 - (i32.and - (i32.sub - (i32.const 0) - ;;@ ~lib/memory.ts:259:18 - (get_local $0) - ) - ;;@ ~lib/memory.ts:259:25 - (i32.const 3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:264:2 - (tee_local $1 - ;;@ ~lib/memory.ts:264:17 - (i32.mul - (i32.and - ;;@ ~lib/memory.ts:264:33 - (get_local $1) - (i32.const 255) - ) - (i32.const 16843009) - ) - ) - ) - ;;@ ~lib/memory.ts:268:2 - (i32.store - ;;@ ~lib/memory.ts:268:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:262:2 - (tee_local $2 - (i32.and - (i32.sub - ;;@ ~lib/memory.ts:261:2 - (get_local $2) - ;;@ ~lib/memory.ts:261:7 - (get_local $4) - ) - ;;@ ~lib/memory.ts:262:7 - (i32.const -4) - ) - ) - ) - ;;@ ~lib/memory.ts:268:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:268:27 - (get_local $1) - ) - ;;@ ~lib/memory.ts:269:2 - (if - ;;@ ~lib/memory.ts:269:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:269:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:269:14 - (return) - ) - ;;@ ~lib/memory.ts:270:2 - (i32.store - ;;@ ~lib/memory.ts:270:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:270:20 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:270:23 - (get_local $1) - ) - ;;@ ~lib/memory.ts:271:2 - (i32.store - ;;@ ~lib/memory.ts:271:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:271:20 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:271:23 - (get_local $1) - ) - ;;@ ~lib/memory.ts:272:2 - (i32.store - ;;@ ~lib/memory.ts:272:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:272:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:272:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:272:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:273:2 - (i32.store - ;;@ ~lib/memory.ts:273:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:273:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:273:24 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:273:27 - (get_local $1) - ) - ;;@ ~lib/memory.ts:274:2 - (if - ;;@ ~lib/memory.ts:274:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:274:11 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:274:15 - (return) - ) - ;;@ ~lib/memory.ts:275:2 - (i32.store - ;;@ ~lib/memory.ts:275:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:275:20 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:275:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:276:2 - (i32.store - ;;@ ~lib/memory.ts:276:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:276:20 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:276:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:277:2 - (i32.store - ;;@ ~lib/memory.ts:277:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:277:20 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:277:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:278:2 - (i32.store - ;;@ ~lib/memory.ts:278:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:278:20 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:278:24 - (get_local $1) - ) - ;;@ ~lib/memory.ts:279:2 - (i32.store - ;;@ ~lib/memory.ts:279:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:279:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:279:24 - (i32.const 28) - ) - ;;@ ~lib/memory.ts:279:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:280:2 - (i32.store - ;;@ ~lib/memory.ts:280:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:280:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:280:24 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:280:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:281:2 - (i32.store - ;;@ ~lib/memory.ts:281:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:281:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:281:24 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:281:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:282:2 - (i32.store - ;;@ ~lib/memory.ts:282:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:282:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:282:24 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:282:28 - (get_local $1) - ) - ;;@ ~lib/memory.ts:286:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:285:2 - (tee_local $4 - ;;@ ~lib/memory.ts:285:6 - (i32.add - ;;@ ~lib/memory.ts:285:11 - (i32.and - ;;@ ~lib/memory.ts:285:12 - (get_local $0) - ;;@ ~lib/memory.ts:285:19 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:285:6 - (i32.const 24) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:287:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:287:7 - (get_local $4) - ) - ) - ;;@ ~lib/memory.ts:290:2 - (set_local $3 - ;;@ ~lib/memory.ts:290:17 - (i64.or - (i64.extend_u/i32 - (get_local $1) - ) - ;;@ ~lib/memory.ts:290:28 - (i64.shl - ;;@ ~lib/memory.ts:290:29 - (i64.extend_u/i32 - (get_local $1) - ) - ;;@ ~lib/memory.ts:290:41 - (i64.const 32) - ) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:291:9 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:291:14 - (i32.const 32) - ) - (block - ;;@ ~lib/memory.ts:292:4 - (i64.store - ;;@ ~lib/memory.ts:292:15 - (get_local $0) - ;;@ ~lib/memory.ts:292:21 - (get_local $3) - ) - ;;@ ~lib/memory.ts:293:4 - (i64.store - ;;@ ~lib/memory.ts:293:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:293:22 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:293:25 - (get_local $3) - ) - ;;@ ~lib/memory.ts:294:4 - (i64.store - ;;@ ~lib/memory.ts:294:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:294:22 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:294:26 - (get_local $3) - ) - ;;@ ~lib/memory.ts:295:4 - (i64.store - ;;@ ~lib/memory.ts:295:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:295:22 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:295:26 - (get_local $3) - ) - ;;@ ~lib/memory.ts:296:4 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:296:9 - (i32.const 32) - ) - ) - ;;@ ~lib/memory.ts:297:4 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:297:12 - (i32.const 32) - ) - ) - (br $continue|0) - ) - ) - ) - ) - (func $~lib/memory/memory.fill (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:11:4 - (call $~lib/memory/memset - ;;@ ~lib/memory.ts:11:11 - (get_local $0) - ;;@ ~lib/memory.ts:11:17 - (get_local $1) - ;;@ ~lib/memory.ts:11:20 - (get_local $2) - ) - ) - (func $~lib/memory/memcpy (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcmp (; 0 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - (loop $continue|0 - (if - (select - ;;@ ~lib/memory.ts:59:14 - (i32.and - ;;@ ~lib/memory.ts:59:15 - (get_local $1) - ;;@ ~lib/memory.ts:59:21 - (i32.const 3) - ) - (get_local $2) - ;;@ ~lib/memory.ts:59:9 - (get_local $2) - ) - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:60:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:60:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:60:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:60:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:61:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/memory.ts:65:2 - (if - (i32.eqz - ;;@ ~lib/memory.ts:65:6 - (i32.and - ;;@ ~lib/memory.ts:65:7 - (get_local $0) - ;;@ ~lib/memory.ts:65:14 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:65:23 - (block - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:66:11 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:66:16 - (i32.const 16) - ) - (block - ;;@ ~lib/memory.ts:67:6 - (i32.store - ;;@ ~lib/memory.ts:67:17 - (get_local $0) - ;;@ ~lib/memory.ts:67:28 - (i32.load - ;;@ ~lib/memory.ts:67:38 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:68:6 - (i32.store - ;;@ ~lib/memory.ts:68:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:68:25 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:68:28 - (i32.load - ;;@ ~lib/memory.ts:68:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:68:45 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:69:6 - (i32.store - ;;@ ~lib/memory.ts:69:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:69:25 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:69:28 - (i32.load - ;;@ ~lib/memory.ts:69:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:69:45 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:70:6 - (i32.store - ;;@ ~lib/memory.ts:70:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:70:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:70:28 - (i32.load - ;;@ ~lib/memory.ts:70:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:70:44 - (i32.const 12) - ) - ) - ) - ;;@ ~lib/memory.ts:71:6 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:71:13 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:17 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:71:25 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:29 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:71:34 - (i32.const 16) - ) - ) - (br $continue|1) - ) - ) - ) - ;;@ ~lib/memory.ts:73:4 - (if - ;;@ ~lib/memory.ts:73:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:73:12 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:73:15 - (block - ;;@ ~lib/memory.ts:74:6 - (i32.store - ;;@ ~lib/memory.ts:74:17 - (get_local $0) - ;;@ ~lib/memory.ts:74:27 - (i32.load - ;;@ ~lib/memory.ts:74:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:75:6 - (i32.store - ;;@ ~lib/memory.ts:75:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:75:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:75:27 - (i32.load - ;;@ ~lib/memory.ts:75:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:75:43 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:76:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:76:14 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:76:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:76:24 - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:78:4 - (if - ;;@ ~lib/memory.ts:78:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:78:12 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:78:15 - (block - ;;@ ~lib/memory.ts:79:6 - (i32.store - ;;@ ~lib/memory.ts:79:17 - (get_local $0) - ;;@ ~lib/memory.ts:79:23 - (i32.load - ;;@ ~lib/memory.ts:79:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:80:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:80:14 - (i32.const 4) - ) - ) - ;;@ ~lib/memory.ts:80:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:80:24 - (i32.const 4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:82:4 - (if - ;;@ ~lib/memory.ts:82:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:82:12 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:82:15 - (block - ;;@ ~lib/memory.ts:83:6 - (i32.store16 - ;;@ ~lib/memory.ts:83:17 - (get_local $0) - ;;@ ~lib/memory.ts:83:23 - (i32.load16_u - ;;@ ~lib/memory.ts:83:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:84:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:84:14 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:84:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:84:24 - (i32.const 2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:86:4 - (if - ;;@ ~lib/memory.ts:86:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:86:12 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:87:16 - (block - (set_local $3 - (get_local $0) - ) - ;;@ ~lib/memory.ts:86:15 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:87:33 - (block (result i32) - (set_local $3 - (get_local $1) - ) - ;;@ ~lib/memory.ts:87:24 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:89:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:94:2 - (if - ;;@ ~lib/memory.ts:94:6 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:94:11 - (i32.const 32) - ) - ;;@ ~lib/memory.ts:94:15 - (block $break|2 - (block $case2|2 - (block $case1|2 - (block $case0|2 - (block $tablify|0 - (br_table $case0|2 $case1|2 $case2|2 $tablify|0 - (i32.sub - ;;@ ~lib/memory.ts:95:12 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:95:19 - (i32.const 3) - ) - (i32.const 1) - ) - ) - ) - (br $break|2) - ) - ;;@ ~lib/memory.ts:98:8 - (set_local $4 - ;;@ ~lib/memory.ts:98:12 - (i32.load - ;;@ ~lib/memory.ts:98:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:99:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:99:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:99:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:99:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:100:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:100:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:100:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:100:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:101:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:101:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:101:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:101:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:102:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:102:13 - (i32.const 3) - ) - ) - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:103:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:103:20 - (i32.const 17) - ) - (block - ;;@ ~lib/memory.ts:105:10 - (i32.store - ;;@ ~lib/memory.ts:105:21 - (get_local $0) - ;;@ ~lib/memory.ts:105:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:105:32 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:105:37 - (i32.shl - ;;@ ~lib/memory.ts:104:10 - (tee_local $3 - ;;@ ~lib/memory.ts:104:14 - (i32.load - ;;@ ~lib/memory.ts:104:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:104:30 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:105:42 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:107:10 - (i32.store - ;;@ ~lib/memory.ts:107:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:107:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:107:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:107:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:107:41 - (i32.shl - ;;@ ~lib/memory.ts:106:10 - (tee_local $4 - ;;@ ~lib/memory.ts:106:14 - (i32.load - ;;@ ~lib/memory.ts:106:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:106:30 - (i32.const 5) - ) - ) - ) - ;;@ ~lib/memory.ts:107:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:109:10 - (i32.store - ;;@ ~lib/memory.ts:109:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:109:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:109:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:109:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:109:41 - (i32.shl - ;;@ ~lib/memory.ts:108:10 - (tee_local $3 - ;;@ ~lib/memory.ts:108:14 - (i32.load - ;;@ ~lib/memory.ts:108:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:108:30 - (i32.const 9) - ) - ) - ) - ;;@ ~lib/memory.ts:109:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:111:10 - (i32.store - ;;@ ~lib/memory.ts:111:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:111:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:111:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:111:37 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:111:42 - (i32.shl - ;;@ ~lib/memory.ts:110:10 - (tee_local $4 - ;;@ ~lib/memory.ts:110:14 - (i32.load - ;;@ ~lib/memory.ts:110:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:110:30 - (i32.const 13) - ) - ) - ) - ;;@ ~lib/memory.ts:111:47 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:112:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:112:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:112:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:112:38 - (i32.const 16) - ) - ) - (br $continue|3) - ) - ) - ) - ;;@ ~lib/memory.ts:114:8 - (br $break|2) - ) - ;;@ ~lib/memory.ts:117:8 - (set_local $4 - ;;@ ~lib/memory.ts:117:12 - (i32.load - ;;@ ~lib/memory.ts:117:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:118:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:118:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:118:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:118:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:119:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:119:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:119:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:119:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:120:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:120:13 - (i32.const 2) - ) - ) - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:121:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:121:20 - (i32.const 18) - ) - (block - ;;@ ~lib/memory.ts:123:10 - (i32.store - ;;@ ~lib/memory.ts:123:21 - (get_local $0) - ;;@ ~lib/memory.ts:123:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:123:32 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:123:37 - (i32.shl - ;;@ ~lib/memory.ts:122:10 - (tee_local $3 - ;;@ ~lib/memory.ts:122:14 - (i32.load - ;;@ ~lib/memory.ts:122:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:122:30 - (i32.const 2) - ) - ) - ) - ;;@ ~lib/memory.ts:123:42 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:125:10 - (i32.store - ;;@ ~lib/memory.ts:125:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:125:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:125:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:125:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:125:41 - (i32.shl - ;;@ ~lib/memory.ts:124:10 - (tee_local $4 - ;;@ ~lib/memory.ts:124:14 - (i32.load - ;;@ ~lib/memory.ts:124:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:124:30 - (i32.const 6) - ) - ) - ) - ;;@ ~lib/memory.ts:125:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:127:10 - (i32.store - ;;@ ~lib/memory.ts:127:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:127:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:127:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:127:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:127:41 - (i32.shl - ;;@ ~lib/memory.ts:126:10 - (tee_local $3 - ;;@ ~lib/memory.ts:126:14 - (i32.load - ;;@ ~lib/memory.ts:126:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:126:30 - (i32.const 10) - ) - ) - ) - ;;@ ~lib/memory.ts:127:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:129:10 - (i32.store - ;;@ ~lib/memory.ts:129:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:129:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:129:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:129:37 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:129:42 - (i32.shl - ;;@ ~lib/memory.ts:128:10 - (tee_local $4 - ;;@ ~lib/memory.ts:128:14 - (i32.load - ;;@ ~lib/memory.ts:128:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:128:30 - (i32.const 14) - ) - ) - ) - ;;@ ~lib/memory.ts:129:47 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:130:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:130:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:130:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:130:38 - (i32.const 16) - ) - ) - (br $continue|4) - ) - ) - ) - ;;@ ~lib/memory.ts:132:8 - (br $break|2) - ) - ;;@ ~lib/memory.ts:135:8 - (set_local $4 - ;;@ ~lib/memory.ts:135:12 - (i32.load - ;;@ ~lib/memory.ts:135:22 - (get_local $1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:136:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:136:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:136:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:136:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:137:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:137:13 - (i32.const 1) - ) - ) - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:138:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:138:20 - (i32.const 19) - ) - (block - ;;@ ~lib/memory.ts:140:10 - (i32.store - ;;@ ~lib/memory.ts:140:21 - (get_local $0) - ;;@ ~lib/memory.ts:140:27 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:140:32 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:140:36 - (i32.shl - ;;@ ~lib/memory.ts:139:10 - (tee_local $3 - ;;@ ~lib/memory.ts:139:14 - (i32.load - ;;@ ~lib/memory.ts:139:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:139:30 - (i32.const 3) - ) - ) - ) - ;;@ ~lib/memory.ts:140:41 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:142:10 - (i32.store - ;;@ ~lib/memory.ts:142:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:142:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:142:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:142:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:142:40 - (i32.shl - ;;@ ~lib/memory.ts:141:10 - (tee_local $4 - ;;@ ~lib/memory.ts:141:14 - (i32.load - ;;@ ~lib/memory.ts:141:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:141:30 - (i32.const 7) - ) - ) - ) - ;;@ ~lib/memory.ts:142:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:144:10 - (i32.store - ;;@ ~lib/memory.ts:144:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:144:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:144:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:40 - (i32.shl - ;;@ ~lib/memory.ts:143:10 - (tee_local $3 - ;;@ ~lib/memory.ts:143:14 - (i32.load - ;;@ ~lib/memory.ts:143:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:143:30 - (i32.const 11) - ) - ) - ) - ;;@ ~lib/memory.ts:144:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:146:10 - (i32.store - ;;@ ~lib/memory.ts:146:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:146:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:146:32 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:146:37 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:146:41 - (i32.shl - ;;@ ~lib/memory.ts:145:10 - (tee_local $4 - ;;@ ~lib/memory.ts:145:14 - (i32.load - ;;@ ~lib/memory.ts:145:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:145:30 - (i32.const 15) - ) - ) - ) - ;;@ ~lib/memory.ts:146:46 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:147:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:147:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:147:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:147:38 - (i32.const 16) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:155:2 - (if - ;;@ ~lib/memory.ts:155:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:155:10 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:155:14 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:156:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:156:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:156:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:156:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:157:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:157:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:157:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:157:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:158:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:158:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:158:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:158:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:159:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:159:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:159:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:159:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:160:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:160:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:160:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:160:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:161:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:161:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:161:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:161:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:162:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:162:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:162:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:162:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:163:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:163:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:163:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:163:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:164:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:164:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:164:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:164:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:165:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:165:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:165:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:165:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:166:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:166:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:166:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:166:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:167:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:167:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:167:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:167:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:168:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:168:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:168:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:168:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:169:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:169:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:169:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:169:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:170:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:170:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:170:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:170:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:171:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:171:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:171:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:171:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:173:2 - (if - ;;@ ~lib/memory.ts:173:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:173:10 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:173:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:174:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:174:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:174:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:174:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:175:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:175:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:175:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:175:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:176:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:176:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:176:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:176:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:177:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:177:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:177:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:177:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:178:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:178:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:178:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:178:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:179:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:179:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:179:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:179:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:180:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:180:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:180:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:180:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:181:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:181:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:181:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:181:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:183:2 - (if - ;;@ ~lib/memory.ts:183:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:183:10 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:183:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:184:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:184:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:184:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:184:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:185:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:185:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:185:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:185:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:186:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:186:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:186:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:186:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:187:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:187:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:187:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:187:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:189:2 - (if - ;;@ ~lib/memory.ts:189:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:189:10 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:189:13 - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:190:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:190:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:190:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:190:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:191:14 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:191:4 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:191:31 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:191:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:193:2 - (if - ;;@ ~lib/memory.ts:193:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:193:10 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:194:14 - (block - (set_local $3 - (get_local $0) - ) - ;;@ ~lib/memory.ts:193:13 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:194:31 - (block (result i32) - (set_local $3 - (get_local $1) - ) - ;;@ ~lib/memory.ts:194:22 - (i32.load8_u - (get_local $3) - ) - ) - ) - ) - ) + local.get $0 + local.get $1 + i32.eq + if + i32.const 0 + return + end + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + local.tee $3 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.eq + else + local.get $3 + end + if + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.set $1 + br $continue|0 + end + end + local.get $2 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.sub + else + i32.const 0 + end ) - (func $~lib/memory/memmove (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - ;;@ ~lib/memory.ts:200:2 - (if - ;;@ ~lib/memory.ts:200:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:200:14 - (get_local $1) - ) - ;;@ ~lib/memory.ts:200:19 - (return) - ) - ;;@ ~lib/memory.ts:201:2 - (if - ;;@ ~lib/memory.ts:201:6 - (if (result i32) - (tee_local $3 - (i32.le_u - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:201:12 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:17 - (get_local $0) - ) - ) - (get_local $3) - ;;@ ~lib/memory.ts:201:25 - (i32.le_u - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:201:32 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:201:42 - (block - ;;@ ~lib/memory.ts:202:4 - (call $~lib/memory/memcpy - ;;@ ~lib/memory.ts:202:11 - (get_local $0) - ;;@ ~lib/memory.ts:202:17 - (get_local $1) - ;;@ ~lib/memory.ts:202:22 - (get_local $2) - ) - ;;@ ~lib/memory.ts:203:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:205:2 - (if - ;;@ ~lib/memory.ts:205:6 - (i32.lt_u - (get_local $0) - ;;@ ~lib/memory.ts:205:13 - (get_local $1) - ) - ;;@ ~lib/memory.ts:205:18 - (block - ;;@ ~lib/memory.ts:206:4 - (if - ;;@ ~lib/memory.ts:206:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:206:9 - (get_local $1) - ;;@ ~lib/memory.ts:206:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:206:21 - (i32.and - ;;@ ~lib/memory.ts:206:22 - (get_local $0) - ;;@ ~lib/memory.ts:206:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:206:33 - (block - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:207:13 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:207:20 - (i32.const 7) - ) - (block - ;;@ ~lib/memory.ts:208:8 - (if - ;;@ ~lib/memory.ts:208:12 - (i32.eqz - ;;@ ~lib/memory.ts:208:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:208:16 - (return) - ) - ;;@ ~lib/memory.ts:209:8 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:209:10 - (get_local $2) - (i32.const 1) - ) - ) - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:210:18 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:8 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:210:35 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:26 - (i32.load8_u - (get_local $3) - ) - ) - ) - (br $continue|0) - ) - ) - ) - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:212:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:212:18 - (i32.const 8) - ) - (block - ;;@ ~lib/memory.ts:213:8 - (i64.store - ;;@ ~lib/memory.ts:213:19 - (get_local $0) - ;;@ ~lib/memory.ts:213:25 - (i64.load - ;;@ ~lib/memory.ts:213:35 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:214:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:214:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:215:8 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:215:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:216:8 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:216:16 - (i32.const 8) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ) - (loop $continue|2 - (if - ;;@ ~lib/memory.ts:219:11 - (get_local $2) - (block - (set_local $0 - (i32.add - (tee_local $3 - ;;@ ~lib/memory.ts:220:16 - (get_local $0) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:220:6 - (i32.store8 - (get_local $3) - ;;@ ~lib/memory.ts:220:33 - (block (result i32) - (set_local $1 - (i32.add - (tee_local $3 - (get_local $1) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:220:24 - (i32.load8_u - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:221:6 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:221:8 - (get_local $2) - (i32.const 1) - ) - ) - (br $continue|2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:223:9 - (block - ;;@ ~lib/memory.ts:224:4 - (if - ;;@ ~lib/memory.ts:224:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:224:9 - (get_local $1) - ;;@ ~lib/memory.ts:224:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:224:21 - (i32.and - ;;@ ~lib/memory.ts:224:22 - (get_local $0) - ;;@ ~lib/memory.ts:224:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:224:33 - (block - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:225:13 - (i32.and - (i32.add - ;;@ ~lib/memory.ts:225:14 - (get_local $0) - ;;@ ~lib/memory.ts:225:21 - (get_local $2) - ) - ;;@ ~lib/memory.ts:225:26 - (i32.const 7) - ) - (block - ;;@ ~lib/memory.ts:226:8 - (if - ;;@ ~lib/memory.ts:226:12 - (i32.eqz - ;;@ ~lib/memory.ts:226:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:226:16 - (return) - ) - ;;@ ~lib/memory.ts:227:8 - (i32.store8 - ;;@ ~lib/memory.ts:227:18 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:227:25 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:227:27 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:227:30 - (i32.load8_u - ;;@ ~lib/memory.ts:227:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:227:45 - (get_local $2) - ) - ) - ) - (br $continue|3) - ) - ) - ) - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:229:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:229:18 - (i32.const 8) - ) - (block - ;;@ ~lib/memory.ts:231:8 - (i64.store - ;;@ ~lib/memory.ts:231:19 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:230:8 - (tee_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:230:13 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:231:29 - (i64.load - ;;@ ~lib/memory.ts:231:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:231:45 - (get_local $2) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ) - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:234:11 - (get_local $2) - (block - ;;@ ~lib/memory.ts:234:14 - (i32.store8 - ;;@ ~lib/memory.ts:235:16 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:235:23 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:235:25 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:235:28 - (i32.load8_u - ;;@ ~lib/memory.ts:235:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:235:43 - (get_local $2) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) + (func $~lib/memory/memory.compare (; 1 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + local.get $2 + call $~lib/internal/memory/memcmp ) - (func $~lib/memory/memory.copy (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:16:4 - (call $~lib/memory/memmove - ;;@ ~lib/memory.ts:16:12 - (get_local $0) - ;;@ ~lib/memory.ts:16:18 - (get_local $1) - ;;@ ~lib/memory.ts:16:23 - (get_local $2) - ) + (func $~lib/allocator/tlsf/Root#set:tailRef (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 2912 + local.get $0 + i32.store ) - (func $~lib/memory/memcmp (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - ;;@ ~lib/memory.ts:302:2 - (if - ;;@ ~lib/memory.ts:302:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:302:12 - (get_local $1) - ) - ;;@ ~lib/memory.ts:302:23 - (return - (i32.const 0) - ) - ) - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:303:9 - (if (result i32) - (tee_local $3 - (i32.ne - (get_local $2) - ;;@ ~lib/memory.ts:303:14 - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:19 - (i32.eq - (i32.load8_u - ;;@ ~lib/memory.ts:303:28 - (get_local $0) - ) - ;;@ ~lib/memory.ts:303:35 - (i32.load8_u - ;;@ ~lib/memory.ts:303:44 - (get_local $1) - ) - ) - (get_local $3) - ) - (block - ;;@ ~lib/memory.ts:304:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:9 - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:15 - (set_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (br $continue|0) - ) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (if (result i32) - ;;@ ~lib/memory.ts:306:9 - (get_local $2) - ;;@ ~lib/memory.ts:306:13 - (i32.sub - (i32.load8_u - ;;@ ~lib/memory.ts:306:27 - (get_local $0) - ) - ;;@ ~lib/memory.ts:306:33 - (i32.load8_u - ;;@ ~lib/memory.ts:306:47 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (i32.const 0) - ) - ) - (func $~lib/memory/memory.compare (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/memory.ts:21:27 - (call $~lib/memory/memcmp - ;;@ ~lib/memory.ts:21:18 - (get_local $0) - ;;@ ~lib/memory.ts:21:22 - (get_local $1) - ;;@ ~lib/memory.ts:21:26 - (get_local $2) - ) - ) - (func $~lib/allocator/tlsf/Root#set:tailRef (; 7 ;) (type $iiv) (param $0 i32) (param $1 i32) - ;;@ ~lib/allocator/tlsf.ts:181:30 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:181:43 - (i32.const 2912) - ;;@ ~lib/allocator/tlsf.ts:181:46 - (get_local $1) - ) + (func $~lib/allocator/tlsf/Root#setSLMap (; 3 ;) (type $iii_) (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 offset=4 ) - (func $~lib/allocator/tlsf/Root#setSLMap (; 8 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/allocator/tlsf.ts:145:4 - (i32.store offset=4 - ;;@ ~lib/allocator/tlsf.ts:145:15 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:145:41 - (i32.shl - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:145:46 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:145:49 - (get_local $2) - ) + (func $~lib/allocator/tlsf/Root#setHead (; 4 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $0 + local.get $1 + i32.const 5 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + i32.add + local.get $3 + i32.store offset=96 ) - (func $~lib/allocator/tlsf/Root#setHead (; 9 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - ;;@ ~lib/allocator/tlsf.ts:169:4 - (i32.store offset=96 - ;;@ ~lib/allocator/tlsf.ts:170:6 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:170:32 - (i32.shl - (i32.add - ;;@ ~lib/allocator/tlsf.ts:170:33 - (i32.shl - (get_local $1) - (i32.const 5) - ) - ;;@ ~lib/allocator/tlsf.ts:170:48 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:170:61 - (i32.const 2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:171:6 - (get_local $3) - ) + (func $~lib/allocator/tlsf/Block#get:right (; 5 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 8 + i32.add + local.get $0 + i32.load + i32.const -4 + i32.and + i32.add ) - (func $~lib/allocator/tlsf/Block#get:right (; 10 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:94:4 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:92:8 - (i32.add - (get_local $0) - (i32.const 8) - ) - ;;@ ~lib/allocator/tlsf.ts:92:47 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:92:48 - (i32.load - (get_local $0) - ) - (i32.const -4) - ) - ) + (func $~lib/allocator/tlsf/fls (; 6 ;) (type $ii) (param $0 i32) (result i32) + i32.const 31 + local.get $0 + i32.clz + i32.sub ) - (func $~lib/allocator/tlsf/fls (; 11 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:430:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:430:9 - (i32.const 31) - ;;@ ~lib/allocator/tlsf.ts:430:15 - (i32.clz - ;;@ ~lib/allocator/tlsf.ts:430:22 - (get_local $0) - ) - ) + (func $~lib/allocator/tlsf/Root#getHead (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + i32.const 5 + i32.shl + local.get $2 + i32.add + i32.const 2 + i32.shl + i32.add + i32.load offset=96 ) - (func $~lib/allocator/tlsf/Root#getHead (; 12 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:162:20 - (i32.load offset=96 - ;;@ ~lib/allocator/tlsf.ts:161:6 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:161:32 - (i32.shl - (i32.add - ;;@ ~lib/allocator/tlsf.ts:161:33 - (i32.shl - (get_local $1) - (i32.const 5) - ) - ;;@ ~lib/allocator/tlsf.ts:161:48 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:161:61 - (i32.const 2) - ) - ) - ) + (func $~lib/allocator/tlsf/Root#getSLMap (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + local.get $1 + i32.const 2 + i32.shl + i32.add + i32.load offset=4 ) - (func $~lib/allocator/tlsf/Root#getSLMap (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:139:68 - (i32.load offset=4 - ;;@ ~lib/allocator/tlsf.ts:139:21 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:139:47 - (i32.shl - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:139:52 - (i32.const 2) - ) - ) - ) - ) - (func $~lib/allocator/tlsf/Root#remove (; 14 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $~lib/allocator/tlsf/Root#remove (; 9 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:264:4 - (if (result i32) - ;;@ ~lib/allocator/tlsf.ts:264:8 - (i32.lt_u - ;;@ ~lib/allocator/tlsf.ts:259:4 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:259:15 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:257:20 - (i32.load - (get_local $1) - ) - (i32.const -4) - ) - ) - (i32.const 256) - ) - ;;@ ~lib/allocator/tlsf.ts:264:24 - (block (result i32) - ;;@ ~lib/allocator/tlsf.ts:266:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:266:11 - (i32.div_u - ;;@ ~lib/allocator/tlsf.ts:266:17 - (get_local $2) - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:265:11 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:267:11 - (block (result i32) - ;;@ ~lib/allocator/tlsf.ts:269:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:269:11 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:269:17 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:269:18 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:269:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:268:6 - (tee_local $3 - ;;@ ~lib/allocator/tlsf.ts:268:11 - (call $~lib/allocator/tlsf/fls - ;;@ ~lib/allocator/tlsf.ts:268:22 - (get_local $2) - ) - ) - (i32.const 5) - ) - ) - (i32.const 32) - ) - ) - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:270:6 - (get_local $3) - (i32.const 7) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:275:4 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:275:15 - (i32.load offset=8 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:276:4 - (if - ;;@ ~lib/allocator/tlsf.ts:274:4 - (tee_local $5 - ;;@ ~lib/allocator/tlsf.ts:274:15 - (i32.load offset=4 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:276:14 - (i32.store offset=8 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:276:26 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:277:4 - (if - ;;@ ~lib/allocator/tlsf.ts:277:8 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:277:14 - (i32.store offset=4 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:277:26 - (get_local $5) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:280:4 - (if - ;;@ ~lib/allocator/tlsf.ts:280:8 - (i32.eq - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:280:22 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:280:17 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:280:30 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:280:34 - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:280:39 - (block - ;;@ ~lib/allocator/tlsf.ts:281:11 - (call $~lib/allocator/tlsf/Root#setHead - ;;@ ~lib/allocator/tlsf.ts:281:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:281:19 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:281:23 - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:281:27 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:284:6 - (if - ;;@ ~lib/allocator/tlsf.ts:284:10 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:284:11 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:284:17 - (block - ;;@ ~lib/allocator/tlsf.ts:286:13 - (call $~lib/allocator/tlsf/Root#setSLMap - ;;@ ~lib/allocator/tlsf.ts:286:8 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:286:22 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:286:26 - (tee_local $1 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:285:25 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:285:20 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:285:34 - (get_local $3) - ) - ;;@ ~lib/allocator/tlsf.ts:286:35 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:286:36 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:286:37 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:286:42 - (get_local $4) - ) - (i32.const -1) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:289:8 - (if - ;;@ ~lib/allocator/tlsf.ts:289:12 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:289:13 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:289:20 - (i32.store - (get_local $0) - (i32.and - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:289:34 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:289:35 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:289:36 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:289:41 - (get_local $3) - ) - (i32.const -1) - ) - ) - ) - ) - ) - ) - ) - ) + local.get $1 + i32.load + i32.const -4 + i32.and + local.tee $2 + i32.const 256 + i32.lt_u + if (result i32) + local.get $2 + i32.const 8 + i32.div_u + local.set $4 + i32.const 0 + else + local.get $2 + local.get $2 + call $~lib/allocator/tlsf/fls + local.tee $3 + i32.const 5 + i32.sub + i32.shr_u + i32.const 32 + i32.xor + local.set $4 + local.get $3 + i32.const 7 + i32.sub + end + local.set $3 + local.get $1 + i32.load offset=8 + local.set $2 + local.get $1 + i32.load offset=4 + local.tee $5 + if + local.get $5 + local.get $2 + i32.store offset=8 + end + local.get $2 + if + local.get $2 + local.get $5 + i32.store offset=4 + end + local.get $0 + local.get $3 + local.get $4 + call $~lib/allocator/tlsf/Root#getHead + local.get $1 + i32.eq + if + local.get $0 + local.get $3 + local.get $4 + local.get $2 + call $~lib/allocator/tlsf/Root#setHead + local.get $2 + i32.eqz + if + local.get $0 + local.get $3 + local.get $0 + local.get $3 + call $~lib/allocator/tlsf/Root#getSLMap + i32.const 1 + local.get $4 + i32.shl + i32.const -1 + i32.xor + i32.and + local.tee $1 + call $~lib/allocator/tlsf/Root#setSLMap + local.get $1 + i32.eqz + if + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $3 + i32.shl + i32.const -1 + i32.xor + i32.and + i32.store + end + end + end ) - (func $~lib/allocator/tlsf/Root#insert (; 15 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $~lib/allocator/tlsf/Root#insert (; 10 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - ;;@ ~lib/allocator/tlsf.ts:190:4 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:190:20 - (i32.load - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:201:4 - (if - ;;@ ~lib/allocator/tlsf.ts:201:8 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:198:4 - (tee_local $5 - ;;@ ~lib/allocator/tlsf.ts:198:20 - (i32.load - ;;@ ~lib/allocator/tlsf.ts:197:4 - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:197:23 - (call $~lib/allocator/tlsf/Block#get:right - ;;@ ~lib/allocator/tlsf.ts:197:30 - (get_local $1) - ) - ) - ) - ) - (i32.const 1) - ) - ;;@ ~lib/allocator/tlsf.ts:201:26 - (block - ;;@ ~lib/allocator/tlsf.ts:202:11 - (call $~lib/allocator/tlsf/Root#remove - ;;@ ~lib/allocator/tlsf.ts:202:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:202:18 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:203:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:203:19 - (tee_local $2 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:203:20 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:203:33 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:203:46 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:203:47 - (get_local $5) - (i32.const -4) - ) - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:205:6 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:205:18 - (i32.load - ;;@ ~lib/allocator/tlsf.ts:204:6 - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:204:14 - (call $~lib/allocator/tlsf/Block#get:right - (get_local $1) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:210:4 - (if - ;;@ ~lib/allocator/tlsf.ts:210:8 - (i32.and - (get_local $2) - (i32.const 2) - ) - ;;@ ~lib/allocator/tlsf.ts:210:31 - (block - ;;@ ~lib/allocator/tlsf.ts:212:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:212:21 - (i32.load - ;;@ ~lib/allocator/tlsf.ts:211:6 - (tee_local $1 - (i32.load - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:211:31 - (get_local $1) - (i32.const 4) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:214:11 - (call $~lib/allocator/tlsf/Root#remove - ;;@ ~lib/allocator/tlsf.ts:214:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:214:18 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:215:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:215:18 - (tee_local $3 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:215:19 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:215:31 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:215:44 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:215:45 - (get_local $2) - (i32.const -4) - ) - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:217:6 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:217:18 - (get_local $3) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:221:4 - (i32.store - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:221:17 - (i32.or - (get_local $5) - (i32.const 2) - ) - ) - (i32.store - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:222:24 - (get_local $4) - (i32.const 4) - ) - ;;@ ~lib/allocator/tlsf.ts:222:17 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:240:4 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:240:20 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:240:15 - (get_local $0) - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:230:4 - (if (result i32) - ;;@ ~lib/allocator/tlsf.ts:230:8 - (i32.lt_u - ;;@ ~lib/allocator/tlsf.ts:225:4 - (tee_local $3 - ;;@ ~lib/allocator/tlsf.ts:225:11 - (i32.and - (get_local $2) - (i32.const -4) - ) - ) - (i32.const 256) - ) - ;;@ ~lib/allocator/tlsf.ts:230:24 - (block (result i32) - ;;@ ~lib/allocator/tlsf.ts:232:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:232:11 - (i32.div_u - ;;@ ~lib/allocator/tlsf.ts:232:17 - (get_local $3) - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:231:11 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:233:11 - (block (result i32) - ;;@ ~lib/allocator/tlsf.ts:235:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:235:11 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:235:17 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:235:18 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:235:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:234:6 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:234:11 - (call $~lib/allocator/tlsf/fls - ;;@ ~lib/allocator/tlsf.ts:234:22 - (get_local $3) - ) - ) - (i32.const 5) - ) - ) - (i32.const 32) - ) - ) - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:236:6 - (get_local $2) - (i32.const 7) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:240:32 - (get_local $3) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:241:4 - (i32.store offset=4 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:241:17 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:242:4 - (i32.store offset=8 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:242:17 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:243:4 - (if - ;;@ ~lib/allocator/tlsf.ts:243:8 - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:243:14 - (i32.store offset=4 - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:243:26 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:244:9 - (call $~lib/allocator/tlsf/Root#setHead - ;;@ ~lib/allocator/tlsf.ts:244:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:244:17 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:244:21 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:244:25 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:247:4 - (i32.store - (get_local $0) - (i32.or - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:247:18 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:247:19 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:247:24 - (get_local $2) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:248:9 - (call $~lib/allocator/tlsf/Root#setSLMap - ;;@ ~lib/allocator/tlsf.ts:248:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:248:18 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:248:22 - (i32.or - ;;@ ~lib/allocator/tlsf.ts:248:27 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:248:22 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:248:36 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:248:42 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:248:43 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:248:48 - (get_local $3) - ) - ) - ) + local.get $1 + i32.load + local.set $2 + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.tee $4 + i32.load + local.tee $5 + i32.const 1 + i32.and + if + local.get $0 + local.get $4 + call $~lib/allocator/tlsf/Root#remove + local.get $1 + local.get $2 + local.get $5 + i32.const -4 + i32.and + i32.const 8 + i32.add + i32.add + local.tee $2 + i32.store + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.tee $4 + i32.load + local.set $5 + end + local.get $2 + i32.const 2 + i32.and + if + local.get $1 + i32.const 4 + i32.sub + i32.load + local.tee $1 + i32.load + local.set $3 + local.get $0 + local.get $1 + call $~lib/allocator/tlsf/Root#remove + local.get $1 + local.get $3 + local.get $2 + i32.const -4 + i32.and + i32.const 8 + i32.add + i32.add + local.tee $3 + i32.store + local.get $3 + local.set $2 + end + local.get $4 + local.get $5 + i32.const 2 + i32.or + i32.store + local.get $4 + i32.const 4 + i32.sub + local.get $1 + i32.store + local.get $0 + local.get $2 + i32.const -4 + i32.and + local.tee $3 + i32.const 256 + i32.lt_u + if (result i32) + local.get $3 + i32.const 8 + i32.div_u + local.set $3 + i32.const 0 + else + local.get $3 + local.get $3 + call $~lib/allocator/tlsf/fls + local.tee $2 + i32.const 5 + i32.sub + i32.shr_u + i32.const 32 + i32.xor + local.set $3 + local.get $2 + i32.const 7 + i32.sub + end + local.tee $2 + local.get $3 + call $~lib/allocator/tlsf/Root#getHead + local.set $4 + local.get $1 + i32.const 0 + i32.store offset=4 + local.get $1 + local.get $4 + i32.store offset=8 + local.get $4 + if + local.get $4 + local.get $1 + i32.store offset=4 + end + local.get $0 + local.get $2 + local.get $3 + local.get $1 + call $~lib/allocator/tlsf/Root#setHead + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $2 + i32.shl + i32.or + i32.store + local.get $0 + local.get $2 + local.get $0 + local.get $2 + call $~lib/allocator/tlsf/Root#getSLMap + i32.const 1 + local.get $3 + i32.shl + i32.or + call $~lib/allocator/tlsf/Root#setSLMap ) - (func $~lib/allocator/tlsf/Root#addMemory (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/allocator/tlsf/Root#addMemory (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - ;;@ ~lib/allocator/tlsf.ts:383:4 - (if - ;;@ ~lib/allocator/tlsf.ts:381:4 - (tee_local $3 - (i32.load - (i32.const 2912) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:383:17 - (if - ;;@ ~lib/allocator/tlsf.ts:387:10 - (i32.eq - (i32.sub - (get_local $1) - (i32.const 8) - ) - ;;@ ~lib/allocator/tlsf.ts:387:32 - (get_local $3) - ) - ;;@ ~lib/allocator/tlsf.ts:387:41 - (block - ;;@ ~lib/allocator/tlsf.ts:388:8 - (set_local $1 - (i32.sub - (get_local $1) - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:389:8 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:389:19 - (i32.load - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:398:4 - (if - ;;@ ~lib/allocator/tlsf.ts:398:8 - (i32.lt_u - ;;@ ~lib/allocator/tlsf.ts:397:4 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:397:15 - (i32.sub - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:397:21 - (get_local $1) - ) - ) - (i32.const 32) - ) - ;;@ ~lib/allocator/tlsf.ts:398:57 - (return - ;;@ ~lib/allocator/tlsf.ts:399:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:405:4 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:404:15 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:405:16 - (i32.or - (i32.or - ;;@ ~lib/allocator/tlsf.ts:403:19 - (i32.sub - (get_local $2) - (i32.const 16) - ) - (i32.const 1) - ) - ;;@ ~lib/allocator/tlsf.ts:405:34 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:405:35 - (get_local $4) - (i32.const 2) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:406:4 - (i32.store offset=4 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:406:16 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:407:4 - (i32.store offset=8 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:407:16 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:411:4 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:410:4 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:410:15 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:410:33 - (i32.add - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:410:41 - (get_local $2) - ) - (i32.const 8) - ) - ) - (i32.const 2) - ) - ;;@ ~lib/allocator/tlsf.ts:412:4 - (call $~lib/allocator/tlsf/Root#set:tailRef - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:412:19 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:414:9 - (call $~lib/allocator/tlsf/Root#insert - ;;@ ~lib/allocator/tlsf.ts:414:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:414:16 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:416:11 - (i32.const 1) + local.get $2 + block (result i32) + i32.const 2912 + i32.load + local.tee $2 + if + local.get $1 + i32.const 8 + i32.sub + local.get $2 + i32.eq + if + local.get $2 + i32.load + local.set $3 + local.get $1 + i32.const 8 + i32.sub + local.set $1 + end + end + local.get $1 + end + i32.sub + local.tee $2 + i32.const 32 + i32.lt_u + if + i32.const 0 + return + end + local.get $1 + local.get $3 + i32.const 2 + i32.and + local.get $2 + i32.const 16 + i32.sub + i32.const 1 + i32.or + i32.or + i32.store + local.get $1 + i32.const 0 + i32.store offset=4 + local.get $1 + i32.const 0 + i32.store offset=8 + local.get $1 + local.get $2 + i32.add + i32.const 8 + i32.sub + local.tee $2 + i32.const 2 + i32.store + local.get $2 + call $~lib/allocator/tlsf/Root#set:tailRef + local.get $0 + local.get $1 + call $~lib/allocator/tlsf/Root#insert + i32.const 1 ) - (func $~lib/allocator/tlsf/Root#search (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/allocator/tlsf/Root#search (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:300:4 - (if (result i32) - ;;@ ~lib/allocator/tlsf.ts:300:8 - (i32.lt_u - (get_local $1) - (i32.const 256) - ) - ;;@ ~lib/allocator/tlsf.ts:302:11 - (i32.div_u - ;;@ ~lib/allocator/tlsf.ts:302:17 - (get_local $1) - (i32.const 8) - ) - ;;@ ~lib/allocator/tlsf.ts:303:11 - (block (result i32) - ;;@ ~lib/allocator/tlsf.ts:306:6 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:306:11 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:306:17 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:306:18 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:306:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:305:6 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:305:11 - (call $~lib/allocator/tlsf/fls - ;;@ ~lib/allocator/tlsf.ts:305:22 - (get_local $1) - ) - ) - (i32.const 5) - ) - ) - (i32.const 32) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:307:6 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 7) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:309:6 - (if (result i32) - ;;@ ~lib/allocator/tlsf.ts:309:10 - (i32.lt_u - (get_local $1) - (i32.const 31) - ) - (i32.add - ;;@ ~lib/allocator/tlsf.ts:309:30 - (get_local $1) - (i32.const 1) - ) - ;;@ ~lib/allocator/tlsf.ts:310:11 - (block (result i32) - (set_local $2 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:310:13 - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:310:22 - (i32.const 0) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:316:4 - (if (result i32) - ;;@ ~lib/allocator/tlsf.ts:314:4 - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:314:16 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:314:21 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:314:16 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:314:30 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:314:36 - (i32.shl - (i32.const -1) - ;;@ ~lib/allocator/tlsf.ts:314:43 - (get_local $1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:327:18 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:327:13 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:327:26 - (get_local $2) - (i32.ctz - ;;@ ~lib/allocator/tlsf.ts:327:39 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:319:6 - (if (result i32) - ;;@ ~lib/allocator/tlsf.ts:318:6 - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:318:18 - (i32.and - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:318:31 - (i32.shl - (i32.const -1) - ;;@ ~lib/allocator/tlsf.ts:318:38 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:318:39 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:318:44 - (i32.const 1) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:321:13 - (block (result i32) - ;;@ ~lib/allocator/tlsf.ts:323:8 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:323:16 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:323:23 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:322:8 - (tee_local $2 - (i32.ctz - ;;@ ~lib/allocator/tlsf.ts:322:24 - (get_local $1) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:324:20 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:324:15 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:324:28 - (get_local $2) - (i32.ctz - ;;@ ~lib/allocator/tlsf.ts:324:41 - (get_local $1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:320:15 - (i32.const 0) - ) - ) + local.get $1 + i32.const 256 + i32.lt_u + if (result i32) + local.get $1 + i32.const 8 + i32.div_u + else + local.get $1 + local.get $1 + call $~lib/allocator/tlsf/fls + local.tee $2 + i32.const 5 + i32.sub + i32.shr_u + i32.const 32 + i32.xor + local.set $1 + local.get $2 + i32.const 7 + i32.sub + local.set $2 + local.get $1 + i32.const 31 + i32.lt_u + if (result i32) + local.get $1 + i32.const 1 + i32.add + else + local.get $2 + i32.const 1 + i32.add + local.set $2 + i32.const 0 + end + end + local.set $1 + local.get $0 + local.get $2 + call $~lib/allocator/tlsf/Root#getSLMap + i32.const -1 + local.get $1 + i32.shl + i32.and + local.tee $1 + if (result i32) + local.get $0 + local.get $2 + local.get $1 + i32.ctz + call $~lib/allocator/tlsf/Root#getHead + else + local.get $0 + i32.load + i32.const -1 + local.get $2 + i32.const 1 + i32.add + i32.shl + i32.and + local.tee $1 + if (result i32) + local.get $0 + local.get $1 + i32.ctz + local.tee $2 + call $~lib/allocator/tlsf/Root#getSLMap + local.set $1 + local.get $0 + local.get $2 + local.get $1 + i32.ctz + call $~lib/allocator/tlsf/Root#getHead + else + i32.const 0 + end + end ) - (func $~lib/allocator/tlsf/Root#use (; 18 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/allocator/tlsf/Root#use (; 13 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) - ;;@ ~lib/allocator/tlsf.ts:347:4 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:347:20 - (i32.load - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:352:9 - (call $~lib/allocator/tlsf/Root#remove - ;;@ ~lib/allocator/tlsf.ts:352:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:352:16 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:356:4 - (if - ;;@ ~lib/allocator/tlsf.ts:356:8 - (i32.ge_u - ;;@ ~lib/allocator/tlsf.ts:355:4 - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:355:20 - (i32.sub - (i32.and - ;;@ ~lib/allocator/tlsf.ts:355:21 - (get_local $3) - (i32.const -4) - ) - ;;@ ~lib/allocator/tlsf.ts:355:42 - (get_local $2) - ) - ) - (i32.const 24) - ) - ;;@ ~lib/allocator/tlsf.ts:356:50 - (block - ;;@ ~lib/allocator/tlsf.ts:357:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:357:19 - (i32.or - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:357:26 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:357:27 - (get_local $3) - (i32.const 2) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:362:6 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:359:6 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:359:18 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:360:8 - (i32.add - (get_local $1) - (i32.const 8) - ) - ;;@ ~lib/allocator/tlsf.ts:360:48 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:362:19 - (i32.or - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:362:20 - (get_local $4) - (i32.const 8) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:363:11 - (call $~lib/allocator/tlsf/Root#insert - ;;@ ~lib/allocator/tlsf.ts:363:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:363:18 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:366:11 - (block - ;;@ ~lib/allocator/tlsf.ts:367:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:367:19 - (i32.and - (get_local $3) - (i32.const -2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:369:6 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:368:6 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:368:25 - (call $~lib/allocator/tlsf/Block#get:right - ;;@ ~lib/allocator/tlsf.ts:368:32 - (get_local $1) - ) - ) - (i32.and - ;;@ ~lib/allocator/tlsf.ts:369:6 - (i32.load - (get_local $2) - ) - (i32.const -3) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:372:44 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:372:11 - (get_local $1) - (i32.const 8) - ) + local.get $1 + i32.load + local.set $3 + local.get $0 + local.get $1 + call $~lib/allocator/tlsf/Root#remove + local.get $3 + i32.const -4 + i32.and + local.get $2 + i32.sub + local.tee $4 + i32.const 24 + i32.ge_u + if + local.get $1 + local.get $2 + local.get $3 + i32.const 2 + i32.and + i32.or + i32.store + local.get $1 + i32.const 8 + i32.add + local.get $2 + i32.add + local.tee $2 + local.get $4 + i32.const 8 + i32.sub + i32.const 1 + i32.or + i32.store + local.get $0 + local.get $2 + call $~lib/allocator/tlsf/Root#insert + else + local.get $1 + local.get $3 + i32.const -2 + i32.and + i32.store + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.tee $2 + local.get $2 + i32.load + i32.const -3 + i32.and + i32.store + end + local.get $1 + i32.const 8 + i32.add ) - (func $~lib/allocator/tlsf/__memory_allocate (; 19 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/tlsf/__memory_allocate (; 14 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - ;;@ ~lib/allocator/tlsf.ts:444:2 - (if - ;;@ ~lib/allocator/tlsf.ts:444:6 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:443:2 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:443:13 - (get_global $~lib/allocator/tlsf/ROOT) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:444:13 - (block - ;;@ ~lib/allocator/tlsf.ts:448:4 - (if - ;;@ ~lib/allocator/tlsf.ts:448:8 - (if (result i32) - (tee_local $3 - (i32.gt_s - ;;@ ~lib/allocator/tlsf.ts:447:4 - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:447:22 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:447:28 - (i32.and - (i32.add - ;;@ ~lib/allocator/tlsf.ts:445:4 - (tee_local $4 - (i32.const 8) - ) - (i32.const 68451) - ) - (i32.const -65536) - ) - ;;@ ~lib/allocator/tlsf.ts:447:80 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:446:4 - (tee_local $5 - ;;@ ~lib/allocator/tlsf.ts:446:29 - (current_memory) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:448:37 - (i32.lt_s - ;;@ ~lib/allocator/tlsf.ts:448:44 - (grow_memory - ;;@ ~lib/allocator/tlsf.ts:448:49 - (i32.sub - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:448:63 - (get_local $5) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:448:78 - (i32.const 0) - ) - (get_local $3) - ) - ;;@ ~lib/allocator/tlsf.ts:448:81 - (unreachable) - ) - ;;@ ~lib/allocator/tlsf.ts:449:4 - (set_global $~lib/allocator/tlsf/ROOT - ;;@ ~lib/allocator/tlsf.ts:449:11 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:449:18 - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:450:4 - (call $~lib/allocator/tlsf/Root#set:tailRef - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:450:19 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:451:4 - (i32.store - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:451:17 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:452:4 - (block $break|0 - ;;@ ~lib/allocator/tlsf.ts:452:9 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:452:25 - (i32.const 0) - ) - (loop $repeat|0 - (br_if $break|0 - ;;@ ~lib/allocator/tlsf.ts:452:28 - (i32.ge_u - (get_local $3) - (i32.const 22) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:453:11 - (call $~lib/allocator/tlsf/Root#setSLMap - ;;@ ~lib/allocator/tlsf.ts:453:6 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:453:20 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:453:24 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:454:6 - (block $break|1 - ;;@ ~lib/allocator/tlsf.ts:454:11 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:454:25 - (i32.const 0) - ) - (loop $repeat|1 - (br_if $break|1 - ;;@ ~lib/allocator/tlsf.ts:454:28 - (i32.ge_u - (get_local $1) - (i32.const 32) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:454:48 - (call $~lib/allocator/tlsf/Root#setHead - ;;@ ~lib/allocator/tlsf.ts:455:8 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:455:21 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:455:25 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:455:29 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:454:42 - (set_local $1 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:454:44 - (get_local $1) - (i32.const 1) - ) - ) - (br $repeat|1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:452:42 - (set_local $3 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:452:44 - (get_local $3) - (i32.const 1) - ) - ) - (br $repeat|0) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:458:9 - (drop - (call $~lib/allocator/tlsf/Root#addMemory - ;;@ ~lib/allocator/tlsf.ts:458:4 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:458:19 - (i32.and - (i32.add - ;;@ ~lib/allocator/tlsf.ts:458:20 - (get_local $4) - (i32.const 2923) - ) - (i32.const -8) - ) - ;;@ ~lib/allocator/tlsf.ts:458:66 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:458:73 - (current_memory) - ;;@ ~lib/allocator/tlsf.ts:458:83 - (i32.const 16) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:462:2 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:462:20 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:463:2 - (if - ;;@ ~lib/allocator/tlsf.ts:463:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:463:12 - (block - ;;@ ~lib/allocator/tlsf.ts:464:4 - (if - ;;@ ~lib/allocator/tlsf.ts:464:8 - (i32.gt_u - (get_local $0) - (i32.const 1073741824) - ) - ;;@ ~lib/allocator/tlsf.ts:464:31 - (unreachable) - ) - ;;@ ~lib/allocator/tlsf.ts:469:4 - (if - ;;@ ~lib/allocator/tlsf.ts:469:8 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:468:4 - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:468:21 - (call $~lib/allocator/tlsf/Root#search - ;;@ ~lib/allocator/tlsf.ts:468:16 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:466:4 - (tee_local $0 - ;;@ ~lib/allocator/tlsf.ts:466:11 - (select - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:466:22 - (i32.and - (i32.add - ;;@ ~lib/allocator/tlsf.ts:466:23 - (get_local $0) - (i32.const 7) - ) - (i32.const -8) - ) - ) - (tee_local $5 - (i32.const 16) - ) - (i32.gt_u - (get_local $1) - (get_local $5) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:469:16 - (block - ;;@ ~lib/allocator/tlsf.ts:475:6 - (if - ;;@ ~lib/allocator/tlsf.ts:475:10 - (i32.lt_s - ;;@ ~lib/allocator/tlsf.ts:475:17 - (grow_memory - ;;@ ~lib/allocator/tlsf.ts:474:24 - (select - (tee_local $3 - ;;@ ~lib/allocator/tlsf.ts:472:6 - (tee_local $5 - ;;@ ~lib/allocator/tlsf.ts:472:31 - (current_memory) - ) - ) - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:473:6 - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:473:24 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:473:30 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:473:31 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:473:32 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:473:39 - (i32.const 65535) - ) - (i32.const -65536) - ) - ;;@ ~lib/allocator/tlsf.ts:473:62 - (i32.const 16) - ) - ) - ) - (i32.gt_s - (get_local $3) - (get_local $1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:475:37 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:475:40 - (if - ;;@ ~lib/allocator/tlsf.ts:476:12 - (i32.lt_s - ;;@ ~lib/allocator/tlsf.ts:476:19 - (grow_memory - ;;@ ~lib/allocator/tlsf.ts:476:24 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:476:39 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:476:42 - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:481:11 - (drop - (call $~lib/allocator/tlsf/Root#addMemory - ;;@ ~lib/allocator/tlsf.ts:481:6 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:481:21 - (i32.shl - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:481:43 - (i32.const 16) - ) - ;;@ ~lib/allocator/tlsf.ts:481:47 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:480:30 - (current_memory) - ;;@ ~lib/allocator/tlsf.ts:481:68 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:482:6 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:482:14 - (call $~lib/allocator/tlsf/Root#search - ;;@ ~lib/allocator/tlsf.ts:482:21 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:482:33 - (get_local $0) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:486:4 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:486:16 - (call $~lib/allocator/tlsf/Root#use - ;;@ ~lib/allocator/tlsf.ts:486:11 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:486:20 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:486:34 - (get_local $0) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:489:9 - (get_local $4) + global.get $~lib/allocator/tlsf/ROOT + local.tee $1 + i32.eqz + if + i32.const 8 + local.tee $4 + i32.const 68451 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $5 + current_memory + local.tee $2 + i32.gt_s + local.tee $3 + if (result i32) + local.get $5 + local.get $2 + i32.sub + grow_memory + i32.const 0 + i32.lt_s + else + local.get $3 + end + if + unreachable + end + local.get $4 + local.tee $1 + global.set $~lib/allocator/tlsf/ROOT + i32.const 0 + call $~lib/allocator/tlsf/Root#set:tailRef + local.get $1 + i32.const 0 + i32.store + i32.const 0 + local.set $3 + loop $repeat|0 + block $break|0 + local.get $3 + i32.const 22 + i32.ge_u + br_if $break|0 + local.get $1 + local.get $3 + i32.const 0 + call $~lib/allocator/tlsf/Root#setSLMap + i32.const 0 + local.set $2 + loop $repeat|1 + block $break|1 + local.get $2 + i32.const 32 + i32.ge_u + br_if $break|1 + local.get $1 + local.get $3 + local.get $2 + i32.const 0 + call $~lib/allocator/tlsf/Root#setHead + local.get $2 + i32.const 1 + i32.add + local.set $2 + br $repeat|1 + end + end + local.get $3 + i32.const 1 + i32.add + local.set $3 + br $repeat|0 + end + end + local.get $1 + local.get $4 + i32.const 2923 + i32.add + i32.const -8 + i32.and + current_memory + i32.const 16 + i32.shl + call $~lib/allocator/tlsf/Root#addMemory + drop + end + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + local.get $1 + local.get $1 + local.get $0 + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $5 + i32.const 16 + local.tee $2 + local.get $5 + local.get $2 + i32.gt_u + select + local.tee $0 + call $~lib/allocator/tlsf/Root#search + local.tee $4 + if (result i32) + local.get $4 + else + current_memory + local.tee $5 + local.tee $4 + local.get $0 + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $2 + local.tee $3 + local.get $4 + local.get $3 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $2 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + local.get $1 + local.get $5 + i32.const 16 + i32.shl + current_memory + i32.const 16 + i32.shl + call $~lib/allocator/tlsf/Root#addMemory + drop + local.get $1 + local.get $0 + call $~lib/allocator/tlsf/Root#search + end + local.get $0 + call $~lib/allocator/tlsf/Root#use ) - (func $~lib/memory/memory.allocate (; 20 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/memory.ts:37:45 - (call $~lib/allocator/tlsf/__memory_allocate - ;;@ ~lib/memory.ts:37:63 - (get_local $0) - ) + (func $~lib/memory/memory.allocate (; 15 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/allocator/tlsf/__memory_allocate ) - (func $~lib/allocator/tlsf/__memory_free (; 21 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/tlsf/__memory_free (; 16 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) - ;;@ ~lib/allocator/tlsf.ts:495:2 - (if - ;;@ ~lib/allocator/tlsf.ts:495:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:497:4 - (if - ;;@ ~lib/allocator/tlsf.ts:496:4 - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:496:15 - (get_global $~lib/allocator/tlsf/ROOT) - ) - ;;@ ~lib/allocator/tlsf.ts:497:14 - (block - ;;@ ~lib/allocator/tlsf.ts:501:6 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:498:6 - (tee_local $2 - ;;@ ~lib/allocator/tlsf.ts:498:18 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:498:36 - (get_local $0) - (i32.const 8) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:501:19 - (i32.or - ;;@ ~lib/allocator/tlsf.ts:499:22 - (i32.load - (get_local $2) - ) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:502:11 - (call $~lib/allocator/tlsf/Root#insert - ;;@ ~lib/allocator/tlsf.ts:502:6 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:502:18 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:502:36 - (get_local $0) - (i32.const 8) - ) - ) - ) - ) - ) + local.get $0 + if + global.get $~lib/allocator/tlsf/ROOT + local.tee $1 + if + local.get $0 + i32.const 8 + i32.sub + local.tee $2 + local.get $2 + i32.load + i32.const 1 + i32.or + i32.store + local.get $1 + local.get $0 + i32.const 8 + i32.sub + call $~lib/allocator/tlsf/Root#insert + end + end + ) + (func $~lib/memory/memory.free (; 17 ;) (type $i_) (param $0 i32) + local.get $0 + call $~lib/allocator/tlsf/__memory_free ) - (func $~lib/memory/memory.free (; 22 ;) (type $iv) (param $0 i32) - ;;@ ~lib/memory.ts:43:36 - (call $~lib/allocator/tlsf/__memory_free - ;;@ ~lib/memory.ts:43:50 - (get_local $0) - ) + (func $~lib/memory/memory.reset (; 18 ;) (type $_) + unreachable ) - (func $~lib/memory/memory.reset (; 23 ;) (type $v) - (unreachable) + (func $null (; 19 ;) (type $_) + nop ) ) diff --git a/tests/allocators/tlsf/package.json b/tests/allocators/tlsf/package.json index 709cf1096f..68fede664c 100644 --- a/tests/allocators/tlsf/package.json +++ b/tests/allocators/tlsf/package.json @@ -3,6 +3,6 @@ "scripts": { "build": "npm run build:untouched && npm run build:optimized", "build:untouched": "node ../../../bin/asc assembly/index.ts -t untouched.wat -b untouched.wasm --validate --sourceMap --measure", - "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noDebug --noAssert --optimize" + "build:optimized": "node ../../../bin/asc assembly/index.ts -t optimized.wat -b optimized.wasm --validate --sourceMap --measure --noAssert --optimize" } } diff --git a/tests/allocators/tlsf/untouched.wat b/tests/allocators/tlsf/untouched.wat index 2698672655..ba07ee7756 100644 --- a/tests/allocators/tlsf/untouched.wat +++ b/tests/allocators/tlsf/untouched.wat @@ -1,17 +1,17 @@ (module - (type $iiiiv (func (param i32 i32 i32 i32))) - (type $iiiv (func (param i32 i32 i32))) + (type $iiii_ (func (param i32 i32 i32 i32))) + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $iiv (func (param i32 i32))) + (type $ii_ (func (param i32 i32))) + (type $iii_ (func (param i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) - (type $iv (func (param i32))) - (type $v (func)) + (type $i_ (func (param i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) + (memory $0 1) + (data (i32.const 8) "\16\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) (global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) (global $~lib/allocator/tlsf/SL_SIZE i32 (i32.const 32)) (global $~lib/allocator/tlsf/SB_BITS i32 (i32.const 8)) @@ -20,3667 +20,284 @@ (global $~lib/allocator/tlsf/FREE i32 (i32.const 1)) (global $~lib/allocator/tlsf/LEFT_FREE i32 (i32.const 2)) (global $~lib/allocator/tlsf/TAGS i32 (i32.const 3)) - (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/allocator/tlsf/Block.INFO i32 (i32.const 8)) + (global $~lib/allocator/tlsf/Block.MIN_SIZE i32 (i32.const 16)) + (global $~lib/allocator/tlsf/Block.MAX_SIZE i32 (i32.const 1073741824)) (global $~lib/allocator/tlsf/Root.SL_START i32 (i32.const 4)) (global $~lib/allocator/tlsf/Root.SL_END i32 (i32.const 92)) (global $~lib/allocator/tlsf/Root.HL_START i32 (i32.const 96)) (global $~lib/allocator/tlsf/Root.HL_END i32 (i32.const 2912)) (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) - (global $~lib/allocator/tlsf/Block.INFO i32 (i32.const 8)) - (global $~lib/allocator/tlsf/Block.MIN_SIZE i32 (i32.const 16)) - (global $~lib/allocator/tlsf/Block.MAX_SIZE i32 (i32.const 1073741824)) - (global $HEAP_BASE i32 (i32.const 56)) - (memory $0 1) - (data (i32.const 8) "\16\00\00\00~\00l\00i\00b\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00/\00t\00l\00s\00f\00.\00t\00s\00") + (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 56)) (export "memory" (memory $0)) - (export "memory.fill" (func $~lib/memory/memory.fill)) - (export "memory.copy" (func $~lib/memory/memory.copy)) + (export "table" (table $0)) (export "memory.compare" (func $~lib/memory/memory.compare)) (export "memory.allocate" (func $~lib/memory/memory.allocate)) (export "memory.free" (func $~lib/memory/memory.free)) (export "memory.reset" (func $~lib/memory/memory.reset)) (start $start) - (func $~lib/memory/memset (; 1 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - ;;@ ~lib/memory.ts:244:2 - (if - ;;@ ~lib/memory.ts:244:6 - (i32.eqz - ;;@ ~lib/memory.ts:244:7 - (get_local $2) - ) - ;;@ ~lib/memory.ts:244:10 - (return) - ) - ;;@ ~lib/memory.ts:245:2 - (i32.store8 - ;;@ ~lib/memory.ts:245:12 - (get_local $0) - ;;@ ~lib/memory.ts:245:18 - (get_local $1) - ) - ;;@ ~lib/memory.ts:246:2 - (i32.store8 - ;;@ ~lib/memory.ts:246:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:246:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:246:23 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:246:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:247:2 - (if - ;;@ ~lib/memory.ts:247:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:247:11 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:247:14 - (return) - ) - ;;@ ~lib/memory.ts:249:2 - (i32.store8 - ;;@ ~lib/memory.ts:249:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:249:19 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:249:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:250:2 - (i32.store8 - ;;@ ~lib/memory.ts:250:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:250:19 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:250:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:251:2 - (i32.store8 - ;;@ ~lib/memory.ts:251:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:251:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:251:23 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:251:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:252:2 - (i32.store8 - ;;@ ~lib/memory.ts:252:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:252:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:252:23 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:252:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:253:2 - (if - ;;@ ~lib/memory.ts:253:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:253:11 - (i32.const 6) - ) - ;;@ ~lib/memory.ts:253:14 - (return) - ) - ;;@ ~lib/memory.ts:254:2 - (i32.store8 - ;;@ ~lib/memory.ts:254:12 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:254:19 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:254:22 - (get_local $1) - ) - ;;@ ~lib/memory.ts:255:2 - (i32.store8 - ;;@ ~lib/memory.ts:255:12 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:255:19 - (get_local $2) - ) - ;;@ ~lib/memory.ts:255:23 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:255:26 - (get_local $1) - ) - ;;@ ~lib/memory.ts:256:2 - (if - ;;@ ~lib/memory.ts:256:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:256:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:256:14 - (return) - ) - ;;@ ~lib/memory.ts:259:2 - (set_local $3 - ;;@ ~lib/memory.ts:259:17 - (i32.and - (i32.sub - (i32.const 0) - ;;@ ~lib/memory.ts:259:18 - (get_local $0) - ) - ;;@ ~lib/memory.ts:259:25 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:260:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:260:10 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:261:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:261:7 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:262:2 - (set_local $2 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:262:7 - (i32.const -4) - ) - ) - ;;@ ~lib/memory.ts:264:2 - (set_local $4 - ;;@ ~lib/memory.ts:264:17 - (i32.mul - (i32.div_u - (i32.const -1) - ;;@ ~lib/memory.ts:264:27 - (i32.const 255) - ) - (i32.and - ;;@ ~lib/memory.ts:264:33 - (get_local $1) - (i32.const 255) - ) - ) - ) - ;;@ ~lib/memory.ts:267:2 - (i32.store - ;;@ ~lib/memory.ts:267:13 - (get_local $0) - ;;@ ~lib/memory.ts:267:19 - (get_local $4) - ) - ;;@ ~lib/memory.ts:268:2 - (i32.store - ;;@ ~lib/memory.ts:268:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:268:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:268:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:268:27 - (get_local $4) - ) - ;;@ ~lib/memory.ts:269:2 - (if - ;;@ ~lib/memory.ts:269:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:269:11 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:269:14 - (return) - ) - ;;@ ~lib/memory.ts:270:2 - (i32.store - ;;@ ~lib/memory.ts:270:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:270:20 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:270:23 - (get_local $4) - ) - ;;@ ~lib/memory.ts:271:2 - (i32.store - ;;@ ~lib/memory.ts:271:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:271:20 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:271:23 - (get_local $4) - ) - ;;@ ~lib/memory.ts:272:2 - (i32.store - ;;@ ~lib/memory.ts:272:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:272:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:272:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:272:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:273:2 - (i32.store - ;;@ ~lib/memory.ts:273:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:273:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:273:24 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:273:27 - (get_local $4) - ) - ;;@ ~lib/memory.ts:274:2 - (if - ;;@ ~lib/memory.ts:274:6 - (i32.le_u - (get_local $2) - ;;@ ~lib/memory.ts:274:11 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:274:15 - (return) - ) - ;;@ ~lib/memory.ts:275:2 - (i32.store - ;;@ ~lib/memory.ts:275:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:275:20 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:275:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:276:2 - (i32.store - ;;@ ~lib/memory.ts:276:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:276:20 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:276:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:277:2 - (i32.store - ;;@ ~lib/memory.ts:277:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:277:20 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:277:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:278:2 - (i32.store - ;;@ ~lib/memory.ts:278:13 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:278:20 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:278:24 - (get_local $4) - ) - ;;@ ~lib/memory.ts:279:2 - (i32.store - ;;@ ~lib/memory.ts:279:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:279:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:279:24 - (i32.const 28) - ) - ;;@ ~lib/memory.ts:279:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:280:2 - (i32.store - ;;@ ~lib/memory.ts:280:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:280:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:280:24 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:280:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:281:2 - (i32.store - ;;@ ~lib/memory.ts:281:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:281:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:281:24 - (i32.const 20) - ) - ;;@ ~lib/memory.ts:281:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:282:2 - (i32.store - ;;@ ~lib/memory.ts:282:13 - (i32.sub - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:282:20 - (get_local $2) - ) - ;;@ ~lib/memory.ts:282:24 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:282:28 - (get_local $4) - ) - ;;@ ~lib/memory.ts:285:2 - (set_local $3 - ;;@ ~lib/memory.ts:285:6 - (i32.add - (i32.const 24) - ;;@ ~lib/memory.ts:285:11 - (i32.and - ;;@ ~lib/memory.ts:285:12 - (get_local $0) - ;;@ ~lib/memory.ts:285:19 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:286:2 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:286:10 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:287:2 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:287:7 - (get_local $3) - ) - ) - ;;@ ~lib/memory.ts:290:2 - (set_local $5 - ;;@ ~lib/memory.ts:290:17 - (i64.or - (i64.extend_u/i32 - (get_local $4) - ) - ;;@ ~lib/memory.ts:290:28 - (i64.shl - ;;@ ~lib/memory.ts:290:29 - (i64.extend_u/i32 - (get_local $4) - ) - ;;@ ~lib/memory.ts:290:41 - (i64.const 32) - ) - ) - ) - ;;@ ~lib/memory.ts:291:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:291:9 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:291:14 - (i32.const 32) - ) - (block - (block - ;;@ ~lib/memory.ts:292:4 - (i64.store - ;;@ ~lib/memory.ts:292:15 - (get_local $0) - ;;@ ~lib/memory.ts:292:21 - (get_local $5) - ) - ;;@ ~lib/memory.ts:293:4 - (i64.store - ;;@ ~lib/memory.ts:293:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:293:22 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:293:25 - (get_local $5) - ) - ;;@ ~lib/memory.ts:294:4 - (i64.store - ;;@ ~lib/memory.ts:294:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:294:22 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:294:26 - (get_local $5) - ) - ;;@ ~lib/memory.ts:295:4 - (i64.store - ;;@ ~lib/memory.ts:295:15 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:295:22 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:295:26 - (get_local $5) - ) - ;;@ ~lib/memory.ts:296:4 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:296:9 - (i32.const 32) - ) - ) - ;;@ ~lib/memory.ts:297:4 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:297:12 - (i32.const 32) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) + (func $start:~lib/allocator/tlsf (; 1 ;) (type $_) + i32.const 1 + global.get $~lib/allocator/tlsf/SL_BITS + i32.shl + i32.const 32 + i32.le_s + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 122 + i32.const 0 + call $~lib/env/abort + unreachable + end ) - (func $~lib/memory/memory.fill (; 2 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:11:4 - (call $~lib/memory/memset - ;;@ ~lib/memory.ts:11:11 - (get_local $0) - ;;@ ~lib/memory.ts:11:17 - (get_local $1) - ;;@ ~lib/memory.ts:11:20 - (get_local $2) - ) + (func $start:assembly/index (; 2 ;) (type $_) + call $start:~lib/allocator/tlsf ) - (func $~lib/memory/memcpy (; 3 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcmp (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - (local $5 i32) - ;;@ ~lib/memory.ts:59:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:59:9 - (if (result i32) - (get_local $2) - ;;@ ~lib/memory.ts:59:14 - (i32.and - ;;@ ~lib/memory.ts:59:15 - (get_local $1) - ;;@ ~lib/memory.ts:59:21 - (i32.const 3) - ) - (get_local $2) - ) - (block - (block - ;;@ ~lib/memory.ts:60:4 - (i32.store8 - ;;@ ~lib/memory.ts:60:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:60:22 - (i32.load8_u - ;;@ ~lib/memory.ts:60:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:61:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:65:2 - (if - ;;@ ~lib/memory.ts:65:6 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:65:7 - (get_local $0) - ;;@ ~lib/memory.ts:65:14 - (i32.const 3) - ) - ;;@ ~lib/memory.ts:65:20 - (i32.const 0) - ) - ;;@ ~lib/memory.ts:65:23 - (block - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:66:11 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:66:16 - (i32.const 16) - ) - (block - (block - ;;@ ~lib/memory.ts:67:6 - (i32.store - ;;@ ~lib/memory.ts:67:17 - (get_local $0) - ;;@ ~lib/memory.ts:67:28 - (i32.load - ;;@ ~lib/memory.ts:67:38 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:68:6 - (i32.store - ;;@ ~lib/memory.ts:68:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:68:25 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:68:28 - (i32.load - ;;@ ~lib/memory.ts:68:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:68:45 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:69:6 - (i32.store - ;;@ ~lib/memory.ts:69:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:69:25 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:69:28 - (i32.load - ;;@ ~lib/memory.ts:69:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:69:45 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:70:6 - (i32.store - ;;@ ~lib/memory.ts:70:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:70:24 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:70:28 - (i32.load - ;;@ ~lib/memory.ts:70:38 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:70:44 - (i32.const 12) - ) - ) - ) - ;;@ ~lib/memory.ts:71:6 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:71:13 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:17 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:71:25 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:71:29 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:71:34 - (i32.const 16) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:73:4 - (if - ;;@ ~lib/memory.ts:73:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:73:12 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:73:15 - (block - ;;@ ~lib/memory.ts:74:6 - (i32.store - ;;@ ~lib/memory.ts:74:17 - (get_local $0) - ;;@ ~lib/memory.ts:74:27 - (i32.load - ;;@ ~lib/memory.ts:74:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:75:6 - (i32.store - ;;@ ~lib/memory.ts:75:17 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:75:24 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:75:27 - (i32.load - ;;@ ~lib/memory.ts:75:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:75:43 - (i32.const 4) - ) - ) - ) - ;;@ ~lib/memory.ts:76:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:76:14 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:76:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:76:24 - (i32.const 8) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:78:4 - (if - ;;@ ~lib/memory.ts:78:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:78:12 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:78:15 - (block - ;;@ ~lib/memory.ts:79:6 - (i32.store - ;;@ ~lib/memory.ts:79:17 - (get_local $0) - ;;@ ~lib/memory.ts:79:23 - (i32.load - ;;@ ~lib/memory.ts:79:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:80:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:80:14 - (i32.const 4) - ) - ) - ;;@ ~lib/memory.ts:80:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:80:24 - (i32.const 4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:82:4 - (if - ;;@ ~lib/memory.ts:82:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:82:12 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:82:15 - (block - ;;@ ~lib/memory.ts:83:6 - (i32.store16 - ;;@ ~lib/memory.ts:83:17 - (get_local $0) - ;;@ ~lib/memory.ts:83:23 - (i32.load16_u - ;;@ ~lib/memory.ts:83:33 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:84:6 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:84:14 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:84:17 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:84:24 - (i32.const 2) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:86:4 - (if - ;;@ ~lib/memory.ts:86:8 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:86:12 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:86:15 - (i32.store8 - ;;@ ~lib/memory.ts:87:16 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:87:24 - (i32.load8_u - ;;@ ~lib/memory.ts:87:33 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:89:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:94:2 - (if - ;;@ ~lib/memory.ts:94:6 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:94:11 - (i32.const 32) - ) - ;;@ ~lib/memory.ts:94:15 - (block $break|2 - (block $case2|2 - (block $case1|2 - (block $case0|2 - (set_local $5 - ;;@ ~lib/memory.ts:95:12 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:95:19 - (i32.const 3) - ) - ) - (br_if $case0|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:97:11 - (i32.const 1) - ) - ) - (br_if $case1|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:116:11 - (i32.const 2) - ) - ) - (br_if $case2|2 - (i32.eq - (get_local $5) - ;;@ ~lib/memory.ts:134:11 - (i32.const 3) - ) - ) - (br $break|2) - ) - ;;@ ~lib/memory.ts:97:14 - (block - ;;@ ~lib/memory.ts:98:8 - (set_local $3 - ;;@ ~lib/memory.ts:98:12 - (i32.load - ;;@ ~lib/memory.ts:98:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:99:8 - (i32.store8 - ;;@ ~lib/memory.ts:99:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:99:26 - (i32.load8_u - ;;@ ~lib/memory.ts:99:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:100:8 - (i32.store8 - ;;@ ~lib/memory.ts:100:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:100:26 - (i32.load8_u - ;;@ ~lib/memory.ts:100:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:101:8 - (i32.store8 - ;;@ ~lib/memory.ts:101:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:101:26 - (i32.load8_u - ;;@ ~lib/memory.ts:101:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:102:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:102:13 - (i32.const 3) - ) - ) - ;;@ ~lib/memory.ts:103:8 - (block $break|3 - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:103:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:103:20 - (i32.const 17) - ) - (block - (block - ;;@ ~lib/memory.ts:104:10 - (set_local $4 - ;;@ ~lib/memory.ts:104:14 - (i32.load - ;;@ ~lib/memory.ts:104:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:104:30 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:105:10 - (i32.store - ;;@ ~lib/memory.ts:105:21 - (get_local $0) - ;;@ ~lib/memory.ts:105:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:105:32 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:105:37 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:105:42 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:106:10 - (set_local $3 - ;;@ ~lib/memory.ts:106:14 - (i32.load - ;;@ ~lib/memory.ts:106:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:106:30 - (i32.const 5) - ) - ) - ) - ;;@ ~lib/memory.ts:107:10 - (i32.store - ;;@ ~lib/memory.ts:107:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:107:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:107:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:107:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:107:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:107:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:108:10 - (set_local $4 - ;;@ ~lib/memory.ts:108:14 - (i32.load - ;;@ ~lib/memory.ts:108:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:108:30 - (i32.const 9) - ) - ) - ) - ;;@ ~lib/memory.ts:109:10 - (i32.store - ;;@ ~lib/memory.ts:109:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:109:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:109:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:109:36 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:109:41 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:109:46 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:110:10 - (set_local $3 - ;;@ ~lib/memory.ts:110:14 - (i32.load - ;;@ ~lib/memory.ts:110:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:110:30 - (i32.const 13) - ) - ) - ) - ;;@ ~lib/memory.ts:111:10 - (i32.store - ;;@ ~lib/memory.ts:111:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:111:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:111:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:111:37 - (i32.const 24) - ) - ;;@ ~lib/memory.ts:111:42 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:111:47 - (i32.const 8) - ) - ) - ) - ;;@ ~lib/memory.ts:112:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:112:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:112:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:112:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:112:38 - (i32.const 16) - ) - ) - ) - (br $continue|3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:114:8 - (br $break|2) - ) - ) - ;;@ ~lib/memory.ts:116:14 - (block - ;;@ ~lib/memory.ts:117:8 - (set_local $3 - ;;@ ~lib/memory.ts:117:12 - (i32.load - ;;@ ~lib/memory.ts:117:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:118:8 - (i32.store8 - ;;@ ~lib/memory.ts:118:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:118:26 - (i32.load8_u - ;;@ ~lib/memory.ts:118:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:119:8 - (i32.store8 - ;;@ ~lib/memory.ts:119:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:119:26 - (i32.load8_u - ;;@ ~lib/memory.ts:119:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:120:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:120:13 - (i32.const 2) - ) - ) - ;;@ ~lib/memory.ts:121:8 - (block $break|4 - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:121:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:121:20 - (i32.const 18) - ) - (block - (block - ;;@ ~lib/memory.ts:122:10 - (set_local $4 - ;;@ ~lib/memory.ts:122:14 - (i32.load - ;;@ ~lib/memory.ts:122:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:122:30 - (i32.const 2) - ) - ) - ) - ;;@ ~lib/memory.ts:123:10 - (i32.store - ;;@ ~lib/memory.ts:123:21 - (get_local $0) - ;;@ ~lib/memory.ts:123:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:123:32 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:123:37 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:123:42 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:124:10 - (set_local $3 - ;;@ ~lib/memory.ts:124:14 - (i32.load - ;;@ ~lib/memory.ts:124:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:124:30 - (i32.const 6) - ) - ) - ) - ;;@ ~lib/memory.ts:125:10 - (i32.store - ;;@ ~lib/memory.ts:125:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:125:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:125:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:125:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:125:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:125:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:126:10 - (set_local $4 - ;;@ ~lib/memory.ts:126:14 - (i32.load - ;;@ ~lib/memory.ts:126:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:126:30 - (i32.const 10) - ) - ) - ) - ;;@ ~lib/memory.ts:127:10 - (i32.store - ;;@ ~lib/memory.ts:127:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:127:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:127:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:127:36 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:127:41 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:127:46 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:128:10 - (set_local $3 - ;;@ ~lib/memory.ts:128:14 - (i32.load - ;;@ ~lib/memory.ts:128:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:128:30 - (i32.const 14) - ) - ) - ) - ;;@ ~lib/memory.ts:129:10 - (i32.store - ;;@ ~lib/memory.ts:129:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:129:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:129:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:129:37 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:129:42 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:129:47 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/memory.ts:130:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:130:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:130:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:130:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:130:38 - (i32.const 16) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:132:8 - (br $break|2) - ) - ) - ;;@ ~lib/memory.ts:134:14 - (block - ;;@ ~lib/memory.ts:135:8 - (set_local $3 - ;;@ ~lib/memory.ts:135:12 - (i32.load - ;;@ ~lib/memory.ts:135:22 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:136:8 - (i32.store8 - ;;@ ~lib/memory.ts:136:18 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:136:26 - (i32.load8_u - ;;@ ~lib/memory.ts:136:35 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:137:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:137:13 - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:138:8 - (block $break|5 - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:138:15 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:138:20 - (i32.const 19) - ) - (block - (block - ;;@ ~lib/memory.ts:139:10 - (set_local $4 - ;;@ ~lib/memory.ts:139:14 - (i32.load - ;;@ ~lib/memory.ts:139:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:139:30 - (i32.const 3) - ) - ) - ) - ;;@ ~lib/memory.ts:140:10 - (i32.store - ;;@ ~lib/memory.ts:140:21 - (get_local $0) - ;;@ ~lib/memory.ts:140:27 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:140:32 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:140:36 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:140:41 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:141:10 - (set_local $3 - ;;@ ~lib/memory.ts:141:14 - (i32.load - ;;@ ~lib/memory.ts:141:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:141:30 - (i32.const 7) - ) - ) - ) - ;;@ ~lib/memory.ts:142:10 - (i32.store - ;;@ ~lib/memory.ts:142:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:142:28 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:142:31 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:142:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:142:40 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:142:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:143:10 - (set_local $4 - ;;@ ~lib/memory.ts:143:14 - (i32.load - ;;@ ~lib/memory.ts:143:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:143:30 - (i32.const 11) - ) - ) - ) - ;;@ ~lib/memory.ts:144:10 - (i32.store - ;;@ ~lib/memory.ts:144:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:144:28 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:31 - (i32.or - (i32.shr_u - (get_local $3) - ;;@ ~lib/memory.ts:144:36 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:144:40 - (i32.shl - (get_local $4) - ;;@ ~lib/memory.ts:144:45 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:145:10 - (set_local $3 - ;;@ ~lib/memory.ts:145:14 - (i32.load - ;;@ ~lib/memory.ts:145:24 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:145:30 - (i32.const 15) - ) - ) - ) - ;;@ ~lib/memory.ts:146:10 - (i32.store - ;;@ ~lib/memory.ts:146:21 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:146:28 - (i32.const 12) - ) - ;;@ ~lib/memory.ts:146:32 - (i32.or - (i32.shr_u - (get_local $4) - ;;@ ~lib/memory.ts:146:37 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:146:41 - (i32.shl - (get_local $3) - ;;@ ~lib/memory.ts:146:46 - (i32.const 24) - ) - ) - ) - ;;@ ~lib/memory.ts:147:10 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:147:17 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:21 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:147:29 - (i32.const 16) - ) - ) - ;;@ ~lib/memory.ts:147:33 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:147:38 - (i32.const 16) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:149:8 - (br $break|2) - ) - ) - ) - ;;@ ~lib/memory.ts:155:2 - (if - ;;@ ~lib/memory.ts:155:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:155:10 - (i32.const 16) - ) - ;;@ ~lib/memory.ts:155:14 - (block - ;;@ ~lib/memory.ts:156:4 - (i32.store8 - ;;@ ~lib/memory.ts:156:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:156:22 - (i32.load8_u - ;;@ ~lib/memory.ts:156:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:157:4 - (i32.store8 - ;;@ ~lib/memory.ts:157:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:157:22 - (i32.load8_u - ;;@ ~lib/memory.ts:157:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:158:4 - (i32.store8 - ;;@ ~lib/memory.ts:158:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:158:22 - (i32.load8_u - ;;@ ~lib/memory.ts:158:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:159:4 - (i32.store8 - ;;@ ~lib/memory.ts:159:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:159:22 - (i32.load8_u - ;;@ ~lib/memory.ts:159:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:160:4 - (i32.store8 - ;;@ ~lib/memory.ts:160:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:160:22 - (i32.load8_u - ;;@ ~lib/memory.ts:160:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:161:4 - (i32.store8 - ;;@ ~lib/memory.ts:161:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:161:22 - (i32.load8_u - ;;@ ~lib/memory.ts:161:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:162:4 - (i32.store8 - ;;@ ~lib/memory.ts:162:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:162:22 - (i32.load8_u - ;;@ ~lib/memory.ts:162:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:163:4 - (i32.store8 - ;;@ ~lib/memory.ts:163:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:163:22 - (i32.load8_u - ;;@ ~lib/memory.ts:163:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:164:4 - (i32.store8 - ;;@ ~lib/memory.ts:164:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:164:22 - (i32.load8_u - ;;@ ~lib/memory.ts:164:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:165:4 - (i32.store8 - ;;@ ~lib/memory.ts:165:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:165:22 - (i32.load8_u - ;;@ ~lib/memory.ts:165:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:166:4 - (i32.store8 - ;;@ ~lib/memory.ts:166:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:166:22 - (i32.load8_u - ;;@ ~lib/memory.ts:166:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:167:4 - (i32.store8 - ;;@ ~lib/memory.ts:167:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:167:22 - (i32.load8_u - ;;@ ~lib/memory.ts:167:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:168:4 - (i32.store8 - ;;@ ~lib/memory.ts:168:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:168:22 - (i32.load8_u - ;;@ ~lib/memory.ts:168:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:169:4 - (i32.store8 - ;;@ ~lib/memory.ts:169:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:169:22 - (i32.load8_u - ;;@ ~lib/memory.ts:169:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:170:4 - (i32.store8 - ;;@ ~lib/memory.ts:170:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:170:22 - (i32.load8_u - ;;@ ~lib/memory.ts:170:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:171:4 - (i32.store8 - ;;@ ~lib/memory.ts:171:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:171:22 - (i32.load8_u - ;;@ ~lib/memory.ts:171:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:173:2 - (if - ;;@ ~lib/memory.ts:173:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:173:10 - (i32.const 8) - ) - ;;@ ~lib/memory.ts:173:13 - (block - ;;@ ~lib/memory.ts:174:4 - (i32.store8 - ;;@ ~lib/memory.ts:174:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:174:22 - (i32.load8_u - ;;@ ~lib/memory.ts:174:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:175:4 - (i32.store8 - ;;@ ~lib/memory.ts:175:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:175:22 - (i32.load8_u - ;;@ ~lib/memory.ts:175:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:176:4 - (i32.store8 - ;;@ ~lib/memory.ts:176:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:176:22 - (i32.load8_u - ;;@ ~lib/memory.ts:176:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:177:4 - (i32.store8 - ;;@ ~lib/memory.ts:177:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:177:22 - (i32.load8_u - ;;@ ~lib/memory.ts:177:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:178:4 - (i32.store8 - ;;@ ~lib/memory.ts:178:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:178:22 - (i32.load8_u - ;;@ ~lib/memory.ts:178:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:179:4 - (i32.store8 - ;;@ ~lib/memory.ts:179:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:179:22 - (i32.load8_u - ;;@ ~lib/memory.ts:179:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:180:4 - (i32.store8 - ;;@ ~lib/memory.ts:180:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:180:22 - (i32.load8_u - ;;@ ~lib/memory.ts:180:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:181:4 - (i32.store8 - ;;@ ~lib/memory.ts:181:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:181:22 - (i32.load8_u - ;;@ ~lib/memory.ts:181:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:183:2 - (if - ;;@ ~lib/memory.ts:183:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:183:10 - (i32.const 4) - ) - ;;@ ~lib/memory.ts:183:13 - (block - ;;@ ~lib/memory.ts:184:4 - (i32.store8 - ;;@ ~lib/memory.ts:184:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:184:22 - (i32.load8_u - ;;@ ~lib/memory.ts:184:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:185:4 - (i32.store8 - ;;@ ~lib/memory.ts:185:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:185:22 - (i32.load8_u - ;;@ ~lib/memory.ts:185:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:186:4 - (i32.store8 - ;;@ ~lib/memory.ts:186:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:186:22 - (i32.load8_u - ;;@ ~lib/memory.ts:186:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:187:4 - (i32.store8 - ;;@ ~lib/memory.ts:187:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:187:22 - (i32.load8_u - ;;@ ~lib/memory.ts:187:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:189:2 - (if - ;;@ ~lib/memory.ts:189:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:189:10 - (i32.const 2) - ) - ;;@ ~lib/memory.ts:189:13 - (block - ;;@ ~lib/memory.ts:190:4 - (i32.store8 - ;;@ ~lib/memory.ts:190:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:190:22 - (i32.load8_u - ;;@ ~lib/memory.ts:190:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ;;@ ~lib/memory.ts:191:4 - (i32.store8 - ;;@ ~lib/memory.ts:191:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:191:22 - (i32.load8_u - ;;@ ~lib/memory.ts:191:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:193:2 - (if - ;;@ ~lib/memory.ts:193:6 - (i32.and - (get_local $2) - ;;@ ~lib/memory.ts:193:10 - (i32.const 1) - ) - ;;@ ~lib/memory.ts:193:13 - (i32.store8 - ;;@ ~lib/memory.ts:194:14 - (block (result i32) - (set_local $5 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ;;@ ~lib/memory.ts:194:22 - (i32.load8_u - ;;@ ~lib/memory.ts:194:31 - (block (result i32) - (set_local $5 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (get_local $5) - ) - ) - ) - ) + local.get $0 + local.get $1 + i32.eq + if + i32.const 0 + return + end + block $break|0 + loop $continue|0 + local.get $2 + i32.const 0 + i32.ne + local.tee $3 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.eq + else + local.get $3 + end + if + block + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.set $1 + end + br $continue|0 + end + end + end + local.get $2 + if (result i32) + local.get $0 + i32.load8_u + local.get $1 + i32.load8_u + i32.sub + else + i32.const 0 + end ) - (func $~lib/memory/memmove (; 4 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - ;;@ ~lib/memory.ts:200:2 - (if - ;;@ ~lib/memory.ts:200:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:200:14 - (get_local $1) - ) - ;;@ ~lib/memory.ts:200:19 - (return) - ) - ;;@ ~lib/memory.ts:201:2 - (if - ;;@ ~lib/memory.ts:201:6 - (if (result i32) - (tee_local $3 - (i32.le_u - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:201:12 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:17 - (get_local $0) - ) - ) - (get_local $3) - ;;@ ~lib/memory.ts:201:25 - (i32.le_u - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:201:32 - (get_local $2) - ) - ;;@ ~lib/memory.ts:201:37 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:201:42 - (block - ;;@ ~lib/memory.ts:202:4 - (call $~lib/memory/memcpy - ;;@ ~lib/memory.ts:202:11 - (get_local $0) - ;;@ ~lib/memory.ts:202:17 - (get_local $1) - ;;@ ~lib/memory.ts:202:22 - (get_local $2) - ) - ;;@ ~lib/memory.ts:203:4 - (return) - ) - ) - ;;@ ~lib/memory.ts:205:2 - (if - ;;@ ~lib/memory.ts:205:6 - (i32.lt_u - (get_local $0) - ;;@ ~lib/memory.ts:205:13 - (get_local $1) - ) - ;;@ ~lib/memory.ts:205:18 - (block - ;;@ ~lib/memory.ts:206:4 - (if - ;;@ ~lib/memory.ts:206:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:206:9 - (get_local $1) - ;;@ ~lib/memory.ts:206:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:206:21 - (i32.and - ;;@ ~lib/memory.ts:206:22 - (get_local $0) - ;;@ ~lib/memory.ts:206:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:206:33 - (block - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:207:13 - (i32.and - (get_local $0) - ;;@ ~lib/memory.ts:207:20 - (i32.const 7) - ) - (block - (block - ;;@ ~lib/memory.ts:208:8 - (if - ;;@ ~lib/memory.ts:208:12 - (i32.eqz - ;;@ ~lib/memory.ts:208:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:208:16 - (return) - ) - ;;@ ~lib/memory.ts:209:8 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:209:10 - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:210:8 - (i32.store8 - ;;@ ~lib/memory.ts:210:18 - (block (result i32) - (set_local $3 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ;;@ ~lib/memory.ts:210:26 - (i32.load8_u - ;;@ ~lib/memory.ts:210:35 - (block (result i32) - (set_local $3 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:212:6 - (block $break|1 - (loop $continue|1 - (if - ;;@ ~lib/memory.ts:212:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:212:18 - (i32.const 8) - ) - (block - (block - ;;@ ~lib/memory.ts:213:8 - (i64.store - ;;@ ~lib/memory.ts:213:19 - (get_local $0) - ;;@ ~lib/memory.ts:213:25 - (i64.load - ;;@ ~lib/memory.ts:213:35 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:214:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:214:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:215:8 - (set_local $0 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:215:16 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:216:8 - (set_local $1 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:216:16 - (i32.const 8) - ) - ) - ) - (br $continue|1) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:219:4 - (block $break|2 - (loop $continue|2 - (if - ;;@ ~lib/memory.ts:219:11 - (get_local $2) - (block - (block - ;;@ ~lib/memory.ts:220:6 - (i32.store8 - ;;@ ~lib/memory.ts:220:16 - (block (result i32) - (set_local $3 - (get_local $0) - ) - (set_local $0 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ;;@ ~lib/memory.ts:220:24 - (i32.load8_u - ;;@ ~lib/memory.ts:220:33 - (block (result i32) - (set_local $3 - (get_local $1) - ) - (set_local $1 - (i32.add - (get_local $3) - (i32.const 1) - ) - ) - (get_local $3) - ) - ) - ) - ;;@ ~lib/memory.ts:221:6 - (set_local $2 - (i32.sub - ;;@ ~lib/memory.ts:221:8 - (get_local $2) - (i32.const 1) - ) - ) - ) - (br $continue|2) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:223:9 - (block - ;;@ ~lib/memory.ts:224:4 - (if - ;;@ ~lib/memory.ts:224:8 - (i32.eq - (i32.and - ;;@ ~lib/memory.ts:224:9 - (get_local $1) - ;;@ ~lib/memory.ts:224:15 - (i32.const 7) - ) - ;;@ ~lib/memory.ts:224:21 - (i32.and - ;;@ ~lib/memory.ts:224:22 - (get_local $0) - ;;@ ~lib/memory.ts:224:29 - (i32.const 7) - ) - ) - ;;@ ~lib/memory.ts:224:33 - (block - (block $break|3 - (loop $continue|3 - (if - ;;@ ~lib/memory.ts:225:13 - (i32.and - (i32.add - ;;@ ~lib/memory.ts:225:14 - (get_local $0) - ;;@ ~lib/memory.ts:225:21 - (get_local $2) - ) - ;;@ ~lib/memory.ts:225:26 - (i32.const 7) - ) - (block - (block - ;;@ ~lib/memory.ts:226:8 - (if - ;;@ ~lib/memory.ts:226:12 - (i32.eqz - ;;@ ~lib/memory.ts:226:13 - (get_local $2) - ) - ;;@ ~lib/memory.ts:226:16 - (return) - ) - ;;@ ~lib/memory.ts:227:8 - (i32.store8 - ;;@ ~lib/memory.ts:227:18 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:227:25 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:227:27 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:227:30 - (i32.load8_u - ;;@ ~lib/memory.ts:227:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:227:45 - (get_local $2) - ) - ) - ) - ) - (br $continue|3) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:229:6 - (block $break|4 - (loop $continue|4 - (if - ;;@ ~lib/memory.ts:229:13 - (i32.ge_u - (get_local $2) - ;;@ ~lib/memory.ts:229:18 - (i32.const 8) - ) - (block - (block - ;;@ ~lib/memory.ts:230:8 - (set_local $2 - (i32.sub - (get_local $2) - ;;@ ~lib/memory.ts:230:13 - (i32.const 8) - ) - ) - ;;@ ~lib/memory.ts:231:8 - (i64.store - ;;@ ~lib/memory.ts:231:19 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:231:26 - (get_local $2) - ) - ;;@ ~lib/memory.ts:231:29 - (i64.load - ;;@ ~lib/memory.ts:231:39 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:231:45 - (get_local $2) - ) - ) - ) - ) - (br $continue|4) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:234:4 - (block $break|5 - (loop $continue|5 - (if - ;;@ ~lib/memory.ts:234:11 - (get_local $2) - (block - ;;@ ~lib/memory.ts:234:14 - (i32.store8 - ;;@ ~lib/memory.ts:235:16 - (i32.add - (get_local $0) - ;;@ ~lib/memory.ts:235:23 - (tee_local $2 - (i32.sub - ;;@ ~lib/memory.ts:235:25 - (get_local $2) - (i32.const 1) - ) - ) - ) - ;;@ ~lib/memory.ts:235:28 - (i32.load8_u - ;;@ ~lib/memory.ts:235:37 - (i32.add - (get_local $1) - ;;@ ~lib/memory.ts:235:43 - (get_local $2) - ) - ) - ) - (br $continue|5) - ) - ) - ) - ) - ) - ) + (func $~lib/memory/memory.compare (; 4 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $0 + local.get $1 + local.get $2 + call $~lib/internal/memory/memcmp ) - (func $~lib/memory/memory.copy (; 5 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/memory.ts:16:4 - (call $~lib/memory/memmove - ;;@ ~lib/memory.ts:16:12 - (get_local $0) - ;;@ ~lib/memory.ts:16:18 - (get_local $1) - ;;@ ~lib/memory.ts:16:23 - (get_local $2) - ) + (func $~lib/allocator/tlsf/Root#set:tailRef (; 5 ;) (type $ii_) (param $0 i32) (param $1 i32) + i32.const 0 + local.get $1 + i32.store offset=2912 ) - (func $~lib/memory/memcmp (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - ;;@ ~lib/memory.ts:302:2 - (if - ;;@ ~lib/memory.ts:302:6 - (i32.eq - (get_local $0) - ;;@ ~lib/memory.ts:302:12 - (get_local $1) - ) - ;;@ ~lib/memory.ts:302:23 - (return - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:2 - (block $break|0 - (loop $continue|0 - (if - ;;@ ~lib/memory.ts:303:9 - (if (result i32) - (tee_local $3 - (i32.ne - (get_local $2) - ;;@ ~lib/memory.ts:303:14 - (i32.const 0) - ) - ) - ;;@ ~lib/memory.ts:303:19 - (i32.eq - (i32.load8_u - ;;@ ~lib/memory.ts:303:28 - (get_local $0) - ) - ;;@ ~lib/memory.ts:303:35 - (i32.load8_u - ;;@ ~lib/memory.ts:303:44 - (get_local $1) - ) - ) - (get_local $3) - ) - (block - (block - ;;@ ~lib/memory.ts:304:4 - (set_local $2 - (i32.sub - (get_local $2) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:9 - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ;;@ ~lib/memory.ts:304:15 - (set_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - ) - (br $continue|0) - ) - ) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (if (result i32) - ;;@ ~lib/memory.ts:306:9 - (get_local $2) - ;;@ ~lib/memory.ts:306:13 - (i32.sub - (i32.load8_u - ;;@ ~lib/memory.ts:306:27 - (get_local $0) - ) - ;;@ ~lib/memory.ts:306:33 - (i32.load8_u - ;;@ ~lib/memory.ts:306:47 - (get_local $1) - ) - ) - ;;@ ~lib/memory.ts:306:53 - (i32.const 0) - ) + (func $~lib/allocator/tlsf/Root#setSLMap (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + local.get $1 + global.get $~lib/allocator/tlsf/FL_BITS + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 144 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 4 + i32.mul + i32.add + local.get $2 + i32.store offset=4 ) - (func $~lib/memory/memory.compare (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/memory.ts:21:27 - (call $~lib/memory/memcmp - ;;@ ~lib/memory.ts:21:18 - (get_local $0) - ;;@ ~lib/memory.ts:21:22 - (get_local $1) - ;;@ ~lib/memory.ts:21:26 - (get_local $2) - ) + (func $~lib/allocator/tlsf/Root#setHead (; 7 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + local.get $1 + global.get $~lib/allocator/tlsf/FL_BITS + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 167 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + global.get $~lib/allocator/tlsf/SL_SIZE + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 168 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + local.get $1 + global.get $~lib/allocator/tlsf/SL_SIZE + i32.mul + local.get $2 + i32.add + i32.const 4 + i32.mul + i32.add + local.get $3 + i32.store offset=96 ) - (func $~lib/allocator/tlsf/Root#set:tailRef (; 8 ;) (type $iiv) (param $0 i32) (param $1 i32) - ;;@ ~lib/allocator/tlsf.ts:181:30 - (i32.store offset=2912 - ;;@ ~lib/allocator/tlsf.ts:181:43 - (i32.const 0) - ;;@ ~lib/allocator/tlsf.ts:181:46 - (get_local $1) - ) + (func $~lib/allocator/tlsf/Root#get:tailRef (; 8 ;) (type $ii) (param $0 i32) (result i32) + i32.const 0 + i32.load offset=2912 ) - (func $~lib/allocator/tlsf/Root#setSLMap (; 9 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/allocator/tlsf.ts:144:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:144:11 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:144:16 - (get_global $~lib/allocator/tlsf/FL_BITS) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 144) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:145:4 - (i32.store offset=4 - ;;@ ~lib/allocator/tlsf.ts:145:15 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:145:41 - (i32.mul - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:145:46 - (i32.const 4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:145:49 - (get_local $2) - ) - ) - (func $~lib/allocator/tlsf/Root#setHead (; 10 ;) (type $iiiiv) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) - ;;@ ~lib/allocator/tlsf.ts:167:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:167:11 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:167:16 - (get_global $~lib/allocator/tlsf/FL_BITS) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 167) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:168:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:168:11 - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:168:16 - (get_global $~lib/allocator/tlsf/SL_SIZE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 168) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:169:4 - (i32.store offset=96 - ;;@ ~lib/allocator/tlsf.ts:170:6 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:170:32 - (i32.mul - (i32.add - ;;@ ~lib/allocator/tlsf.ts:170:33 - (i32.mul - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:170:38 - (get_global $~lib/allocator/tlsf/SL_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:170:48 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:170:61 - (i32.const 4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:171:6 - (get_local $3) - ) - ) - (func $~lib/allocator/tlsf/Root#get:tailRef (; 11 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:180:58 - (i32.load offset=2912 - ;;@ ~lib/allocator/tlsf.ts:180:44 - (i32.const 0) - ) - ) - (func $~lib/allocator/tlsf/Block#get:right (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/tlsf/Block#get:right (; 9 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - ;;@ ~lib/allocator/tlsf.ts:89:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:89:11 - (i32.and - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:89:23 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:89:24 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 89) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:94:4 - (if (result i32) - (i32.eqz - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:91:6 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:92:8 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:92:34 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ;;@ ~lib/allocator/tlsf.ts:92:47 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:92:48 - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:92:60 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:92:61 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 90) - (i32.const 11) - ) - (unreachable) - ) - (get_local $1) - ) + local.get $0 + i32.load + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 89 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + global.get $~lib/allocator/tlsf/Block.INFO + i32.add + local.get $0 + i32.load + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + i32.add + local.tee $1 + i32.eqz + if (result i32) + i32.const 0 + i32.const 8 + i32.const 90 + i32.const 11 + call $~lib/env/abort + unreachable + else + local.get $1 + end ) - (func $~lib/allocator/tlsf/fls (; 13 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:428:2 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:428:9 - (i32.ne - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:428:17 - (i32.const 0) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 428) - (i32.const 2) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:430:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:430:9 - (i32.const 31) - ;;@ ~lib/allocator/tlsf.ts:430:15 - (i32.clz - ;;@ ~lib/allocator/tlsf.ts:430:22 - (get_local $0) - ) - ) + (func $~lib/allocator/tlsf/fls (; 10 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 428 + i32.const 2 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub ) - (func $~lib/allocator/tlsf/Root#getHead (; 14 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:158:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:158:11 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:158:16 - (get_global $~lib/allocator/tlsf/FL_BITS) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 158) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:159:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:159:11 - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:159:16 - (get_global $~lib/allocator/tlsf/SL_SIZE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 159) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:162:20 - (i32.load offset=96 - ;;@ ~lib/allocator/tlsf.ts:161:6 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:161:32 - (i32.mul - (i32.add - ;;@ ~lib/allocator/tlsf.ts:161:33 - (i32.mul - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:161:38 - (get_global $~lib/allocator/tlsf/SL_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:161:48 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:161:61 - (i32.const 4) - ) - ) - ) + (func $~lib/allocator/tlsf/Root#getHead (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + local.get $1 + global.get $~lib/allocator/tlsf/FL_BITS + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 158 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + global.get $~lib/allocator/tlsf/SL_SIZE + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 159 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + local.get $1 + global.get $~lib/allocator/tlsf/SL_SIZE + i32.mul + local.get $2 + i32.add + i32.const 4 + i32.mul + i32.add + i32.load offset=96 ) - (func $~lib/allocator/tlsf/Root#getSLMap (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:138:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:138:11 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:138:16 - (get_global $~lib/allocator/tlsf/FL_BITS) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 138) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:139:68 - (i32.load offset=4 - ;;@ ~lib/allocator/tlsf.ts:139:21 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:139:47 - (i32.mul - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:139:52 - (i32.const 4) - ) - ) - ) + (func $~lib/allocator/tlsf/Root#getSLMap (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + local.get $1 + global.get $~lib/allocator/tlsf/FL_BITS + i32.lt_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 138 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + local.get $1 + i32.const 4 + i32.mul + i32.add + i32.load offset=4 ) - (func $~lib/allocator/tlsf/Root#remove (; 16 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $~lib/allocator/tlsf/Root#remove (; 13 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3688,423 +305,222 @@ (local $6 i32) (local $7 i32) (local $8 i32) - ;;@ ~lib/allocator/tlsf.ts:257:4 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:257:20 - (i32.load - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:258:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:258:11 - (i32.and - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:258:23 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 258) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:259:4 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:259:15 - (i32.and - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:259:27 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:259:28 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:260:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:260:11 - (if (result i32) - (tee_local $4 - (i32.ge_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:260:19 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:260:37 - (i32.lt_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:260:44 - (get_global $~lib/allocator/tlsf/Block.MAX_SIZE) - ) - (get_local $4) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 260) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:264:4 - (if - ;;@ ~lib/allocator/tlsf.ts:264:8 - (i32.lt_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:264:15 - (get_global $~lib/allocator/tlsf/SB_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:264:24 - (block - ;;@ ~lib/allocator/tlsf.ts:265:6 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:265:11 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:266:6 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:266:11 - (i32.div_u - ;;@ ~lib/allocator/tlsf.ts:266:17 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:266:24 - (get_global $~lib/internal/allocator/AL_SIZE) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:267:11 - (block - ;;@ ~lib/allocator/tlsf.ts:268:6 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:268:11 - (call $~lib/allocator/tlsf/fls - ;;@ ~lib/allocator/tlsf.ts:268:22 - (get_local $3) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:269:6 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:269:11 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:269:17 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:269:18 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:269:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:269:27 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:269:32 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:269:44 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:269:45 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:269:50 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:270:6 - (set_local $5 - (i32.sub - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:270:12 - (i32.sub - (get_global $~lib/allocator/tlsf/SB_BITS) - ;;@ ~lib/allocator/tlsf.ts:270:22 - (i32.const 1) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:274:4 - (set_local $7 - ;;@ ~lib/allocator/tlsf.ts:274:15 - (i32.load offset=4 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:275:4 - (set_local $8 - ;;@ ~lib/allocator/tlsf.ts:275:15 - (i32.load offset=8 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:276:4 - (if - ;;@ ~lib/allocator/tlsf.ts:276:8 - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:276:14 - (i32.store offset=8 - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:276:26 - (get_local $8) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:277:4 - (if - ;;@ ~lib/allocator/tlsf.ts:277:8 - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:277:14 - (i32.store offset=4 - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:277:26 - (get_local $7) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:280:4 - (if - ;;@ ~lib/allocator/tlsf.ts:280:8 - (i32.eq - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:280:22 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:280:17 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:280:30 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:280:34 - (get_local $6) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:280:39 - (block - ;;@ ~lib/allocator/tlsf.ts:281:11 - (call $~lib/allocator/tlsf/Root#setHead - ;;@ ~lib/allocator/tlsf.ts:281:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:281:19 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:281:23 - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:281:27 - (get_local $8) - ) - ;;@ ~lib/allocator/tlsf.ts:284:6 - (if - ;;@ ~lib/allocator/tlsf.ts:284:10 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:284:11 - (get_local $8) - ) - ;;@ ~lib/allocator/tlsf.ts:284:17 - (block - ;;@ ~lib/allocator/tlsf.ts:285:8 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:285:25 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:285:20 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:285:34 - (get_local $5) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:286:13 - (call $~lib/allocator/tlsf/Root#setSLMap - ;;@ ~lib/allocator/tlsf.ts:286:8 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:286:22 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:286:26 - (tee_local $4 - (i32.and - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:286:35 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:286:36 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:286:37 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:286:42 - (get_local $6) - ) - (i32.const -1) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:289:8 - (if - ;;@ ~lib/allocator/tlsf.ts:289:12 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:289:13 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:289:20 - (i32.store - (get_local $0) - (i32.and - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:289:34 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:289:35 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:289:36 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:289:41 - (get_local $5) - ) - (i32.const -1) - ) - ) - ) - ) - ) - ) - ) - ) + local.get $1 + i32.load + local.set $2 + local.get $2 + global.get $~lib/allocator/tlsf/FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 258 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + local.set $3 + local.get $3 + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.ge_u + local.tee $4 + if (result i32) + local.get $3 + global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.lt_u + else + local.get $4 + end + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 260 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $3 + global.get $~lib/allocator/tlsf/SB_SIZE + i32.lt_u + if + i32.const 0 + local.set $5 + local.get $3 + i32.const 8 + i32.div_u + local.set $6 + else + local.get $3 + call $~lib/allocator/tlsf/fls + local.set $5 + local.get $3 + local.get $5 + global.get $~lib/allocator/tlsf/SL_BITS + i32.sub + i32.shr_u + i32.const 1 + global.get $~lib/allocator/tlsf/SL_BITS + i32.shl + i32.xor + local.set $6 + local.get $5 + global.get $~lib/allocator/tlsf/SB_BITS + i32.const 1 + i32.sub + i32.sub + local.set $5 + end + local.get $1 + i32.load offset=4 + local.set $7 + local.get $1 + i32.load offset=8 + local.set $8 + local.get $7 + if + local.get $7 + local.get $8 + i32.store offset=8 + end + local.get $8 + if + local.get $8 + local.get $7 + i32.store offset=4 + end + local.get $1 + local.get $0 + local.get $5 + local.get $6 + call $~lib/allocator/tlsf/Root#getHead + i32.eq + if + local.get $0 + local.get $5 + local.get $6 + local.get $8 + call $~lib/allocator/tlsf/Root#setHead + local.get $8 + i32.eqz + if + local.get $0 + local.get $5 + call $~lib/allocator/tlsf/Root#getSLMap + local.set $4 + local.get $0 + local.get $5 + local.get $4 + i32.const 1 + local.get $6 + i32.shl + i32.const -1 + i32.xor + i32.and + local.tee $4 + call $~lib/allocator/tlsf/Root#setSLMap + local.get $4 + i32.eqz + if + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $5 + i32.shl + i32.const -1 + i32.xor + i32.and + i32.store + end + end + end ) - (func $~lib/allocator/tlsf/Block#get:left (; 17 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/tlsf/Block#get:left (; 14 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - ;;@ ~lib/allocator/tlsf.ts:81:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:81:11 - (i32.and - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:81:23 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 81) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:84:4 - (if (result i32) - (i32.eqz - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:83:6 - (i32.load - ;;@ ~lib/allocator/tlsf.ts:83:18 - (i32.sub - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:83:44 - (i32.const 4) - ) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 82) - (i32.const 11) - ) - (unreachable) - ) - (get_local $1) - ) + local.get $0 + i32.load + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 81 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 4 + i32.sub + i32.load + local.tee $1 + i32.eqz + if (result i32) + i32.const 0 + i32.const 8 + i32.const 82 + i32.const 11 + call $~lib/env/abort + unreachable + else + local.get $1 + end ) - (func $~lib/allocator/tlsf/Root#setJump (; 18 ;) (type $iiiv) (param $0 i32) (param $1 i32) (param $2 i32) - ;;@ ~lib/allocator/tlsf.ts:334:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:334:11 - (i32.and - (i32.load - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:334:23 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 334) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:335:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:335:11 - (i32.eq - (call $~lib/allocator/tlsf/Block#get:right - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:335:25 - (get_local $2) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 335) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:336:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:336:11 - (i32.and - (i32.load - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:336:24 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 336) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:337:4 - (i32.store - ;;@ ~lib/allocator/tlsf.ts:338:6 - (i32.sub - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:338:33 - (i32.const 4) - ) - ;;@ ~lib/allocator/tlsf.ts:339:6 - (get_local $1) - ) + (func $~lib/allocator/tlsf/Root#setJump (; 15 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + local.get $1 + i32.load + global.get $~lib/allocator/tlsf/FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 334 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.get $2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 335 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + i32.load + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 336 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + i32.const 4 + i32.sub + local.get $1 + i32.store ) - (func $~lib/allocator/tlsf/Root#insert (; 19 ;) (type $iiv) (param $0 i32) (param $1 i32) + (func $~lib/allocator/tlsf/Root#insert (; 16 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4114,1396 +530,717 @@ (local $8 i32) (local $9 i32) (local $10 i32) - ;;@ ~lib/allocator/tlsf.ts:189:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:189:11 - (get_local $1) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 189) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:190:4 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:190:20 - (i32.load - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:191:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:191:11 - (i32.and - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:191:23 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 191) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:193:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:194:6 - (if (result i32) - (tee_local $4 - (i32.ge_u - (tee_local $3 - ;;@ ~lib/allocator/tlsf.ts:194:14 - (i32.and - (i32.load - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:194:27 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:194:28 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:194:37 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:194:55 - (i32.lt_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:194:62 - (get_global $~lib/allocator/tlsf/Block.MAX_SIZE) - ) - (get_local $4) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 193) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:197:4 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:197:23 - (if (result i32) - (i32.eqz - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:197:30 - (call $~lib/allocator/tlsf/Block#get:right - (get_local $1) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 197) - (i32.const 23) - ) - (unreachable) - ) - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:198:4 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:198:20 - (i32.load - (get_local $5) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:201:4 - (if - ;;@ ~lib/allocator/tlsf.ts:201:8 - (i32.and - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:201:20 - (get_global $~lib/allocator/tlsf/FREE) - ) - ;;@ ~lib/allocator/tlsf.ts:201:26 - (block - ;;@ ~lib/allocator/tlsf.ts:202:11 - (call $~lib/allocator/tlsf/Root#remove - ;;@ ~lib/allocator/tlsf.ts:202:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:202:18 - (get_local $5) - ) - ;;@ ~lib/allocator/tlsf.ts:203:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:203:19 - (tee_local $2 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:203:20 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:203:33 - (i32.add - (get_global $~lib/allocator/tlsf/Block.INFO) - ;;@ ~lib/allocator/tlsf.ts:203:46 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:203:47 - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:203:59 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:203:60 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:204:6 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:204:14 - (call $~lib/allocator/tlsf/Block#get:right - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:205:6 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:205:18 - (i32.load - (get_local $5) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:210:4 - (if - ;;@ ~lib/allocator/tlsf.ts:210:8 - (i32.and - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:210:20 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ;;@ ~lib/allocator/tlsf.ts:210:31 - (block - ;;@ ~lib/allocator/tlsf.ts:211:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:211:24 - (if (result i32) - (i32.eqz - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:211:31 - (call $~lib/allocator/tlsf/Block#get:left - (get_local $1) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 211) - (i32.const 24) - ) - (unreachable) - ) - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:212:6 - (set_local $7 - ;;@ ~lib/allocator/tlsf.ts:212:21 - (i32.load - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:213:6 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:213:13 - (i32.and - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:213:24 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 213) - (i32.const 6) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:214:11 - (call $~lib/allocator/tlsf/Root#remove - ;;@ ~lib/allocator/tlsf.ts:214:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:214:18 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:215:6 - (i32.store - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:215:18 - (tee_local $7 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:215:19 - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:215:31 - (i32.add - (get_global $~lib/allocator/tlsf/Block.INFO) - ;;@ ~lib/allocator/tlsf.ts:215:44 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:215:45 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:215:57 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:215:58 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:216:6 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:216:14 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:217:6 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:217:18 - (get_local $7) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:221:4 - (i32.store - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:221:17 - (i32.or - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:221:29 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:222:9 - (call $~lib/allocator/tlsf/Root#setJump - ;;@ ~lib/allocator/tlsf.ts:222:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:222:17 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:222:24 - (get_local $5) - ) - ;;@ ~lib/allocator/tlsf.ts:225:4 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:225:11 - (i32.and - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:225:23 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:225:24 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:226:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:226:11 - (if (result i32) - (tee_local $7 - (i32.ge_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:226:19 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:226:37 - (i32.lt_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:226:44 - (get_global $~lib/allocator/tlsf/Block.MAX_SIZE) - ) - (get_local $7) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 226) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:230:4 - (if - ;;@ ~lib/allocator/tlsf.ts:230:8 - (i32.lt_u - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:230:15 - (get_global $~lib/allocator/tlsf/SB_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:230:24 - (block - ;;@ ~lib/allocator/tlsf.ts:231:6 - (set_local $8 - ;;@ ~lib/allocator/tlsf.ts:231:11 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:232:6 - (set_local $9 - ;;@ ~lib/allocator/tlsf.ts:232:11 - (i32.div_u - ;;@ ~lib/allocator/tlsf.ts:232:17 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:232:24 - (get_global $~lib/internal/allocator/AL_SIZE) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:233:11 - (block - ;;@ ~lib/allocator/tlsf.ts:234:6 - (set_local $8 - ;;@ ~lib/allocator/tlsf.ts:234:11 - (call $~lib/allocator/tlsf/fls - ;;@ ~lib/allocator/tlsf.ts:234:22 - (get_local $3) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:235:6 - (set_local $9 - ;;@ ~lib/allocator/tlsf.ts:235:11 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:235:17 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:235:18 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:235:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:235:27 - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:235:32 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:235:44 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:235:45 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:235:50 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:236:6 - (set_local $8 - (i32.sub - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:236:12 - (i32.sub - (get_global $~lib/allocator/tlsf/SB_BITS) - ;;@ ~lib/allocator/tlsf.ts:236:22 - (i32.const 1) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:240:4 - (set_local $10 - ;;@ ~lib/allocator/tlsf.ts:240:20 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:240:15 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:240:28 - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:240:32 - (get_local $9) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:241:4 - (i32.store offset=4 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:241:17 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:242:4 - (i32.store offset=8 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:242:17 - (get_local $10) - ) - ;;@ ~lib/allocator/tlsf.ts:243:4 - (if - ;;@ ~lib/allocator/tlsf.ts:243:8 - (get_local $10) - ;;@ ~lib/allocator/tlsf.ts:243:14 - (i32.store offset=4 - (get_local $10) - ;;@ ~lib/allocator/tlsf.ts:243:26 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:244:9 - (call $~lib/allocator/tlsf/Root#setHead - ;;@ ~lib/allocator/tlsf.ts:244:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:244:17 - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:244:21 - (get_local $9) - ;;@ ~lib/allocator/tlsf.ts:244:25 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:247:4 - (i32.store - (get_local $0) - (i32.or - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:247:18 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:247:19 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:247:24 - (get_local $8) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:248:9 - (call $~lib/allocator/tlsf/Root#setSLMap - ;;@ ~lib/allocator/tlsf.ts:248:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:248:18 - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:248:22 - (i32.or - ;;@ ~lib/allocator/tlsf.ts:248:27 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:248:22 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:248:36 - (get_local $8) - ) - ;;@ ~lib/allocator/tlsf.ts:248:42 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:248:43 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:248:48 - (get_local $9) - ) - ) - ) + local.get $1 + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 189 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.load + local.set $2 + local.get $2 + global.get $~lib/allocator/tlsf/FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 191 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.load + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + local.tee $3 + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.ge_u + local.tee $4 + if (result i32) + local.get $3 + global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.lt_u + else + local.get $4 + end + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 193 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.tee $4 + i32.eqz + if (result i32) + i32.const 0 + i32.const 8 + i32.const 197 + i32.const 23 + call $~lib/env/abort + unreachable + else + local.get $4 + end + local.set $5 + local.get $5 + i32.load + local.set $6 + local.get $6 + global.get $~lib/allocator/tlsf/FREE + i32.and + if + local.get $0 + local.get $5 + call $~lib/allocator/tlsf/Root#remove + local.get $1 + local.get $2 + global.get $~lib/allocator/tlsf/Block.INFO + local.get $6 + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + i32.add + i32.add + local.tee $2 + i32.store + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.set $5 + local.get $5 + i32.load + local.set $6 + end + local.get $2 + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.and + if + local.get $1 + call $~lib/allocator/tlsf/Block#get:left + local.tee $4 + i32.eqz + if (result i32) + i32.const 0 + i32.const 8 + i32.const 211 + i32.const 24 + call $~lib/env/abort + unreachable + else + local.get $4 + end + local.set $4 + local.get $4 + i32.load + local.set $7 + local.get $7 + global.get $~lib/allocator/tlsf/FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 213 + i32.const 6 + call $~lib/env/abort + unreachable + end + local.get $0 + local.get $4 + call $~lib/allocator/tlsf/Root#remove + local.get $4 + local.get $7 + global.get $~lib/allocator/tlsf/Block.INFO + local.get $2 + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + i32.add + i32.add + local.tee $7 + i32.store + local.get $4 + local.set $1 + local.get $7 + local.set $2 + end + local.get $5 + local.get $6 + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.or + i32.store + local.get $0 + local.get $1 + local.get $5 + call $~lib/allocator/tlsf/Root#setJump + local.get $2 + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + local.set $3 + local.get $3 + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.ge_u + local.tee $7 + if (result i32) + local.get $3 + global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.lt_u + else + local.get $7 + end + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 226 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $3 + global.get $~lib/allocator/tlsf/SB_SIZE + i32.lt_u + if + i32.const 0 + local.set $8 + local.get $3 + i32.const 8 + i32.div_u + local.set $9 + else + local.get $3 + call $~lib/allocator/tlsf/fls + local.set $8 + local.get $3 + local.get $8 + global.get $~lib/allocator/tlsf/SL_BITS + i32.sub + i32.shr_u + i32.const 1 + global.get $~lib/allocator/tlsf/SL_BITS + i32.shl + i32.xor + local.set $9 + local.get $8 + global.get $~lib/allocator/tlsf/SB_BITS + i32.const 1 + i32.sub + i32.sub + local.set $8 + end + local.get $0 + local.get $8 + local.get $9 + call $~lib/allocator/tlsf/Root#getHead + local.set $10 + local.get $1 + i32.const 0 + i32.store offset=4 + local.get $1 + local.get $10 + i32.store offset=8 + local.get $10 + if + local.get $10 + local.get $1 + i32.store offset=4 + end + local.get $0 + local.get $8 + local.get $9 + local.get $1 + call $~lib/allocator/tlsf/Root#setHead + local.get $0 + local.get $0 + i32.load + i32.const 1 + local.get $8 + i32.shl + i32.or + i32.store + local.get $0 + local.get $8 + local.get $0 + local.get $8 + call $~lib/allocator/tlsf/Root#getSLMap + i32.const 1 + local.get $9 + i32.shl + i32.or + call $~lib/allocator/tlsf/Root#setSLMap ) - (func $~lib/allocator/tlsf/Root#addMemory (; 20 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/allocator/tlsf/Root#addMemory (; 17 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) (local $8 i32) - ;;@ ~lib/allocator/tlsf.ts:377:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:377:11 - (i32.le_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:377:20 - (get_local $2) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 377) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:378:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:378:11 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:378:12 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:378:13 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:378:21 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 378) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:379:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:379:11 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:379:12 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:379:13 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:379:19 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 379) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:381:4 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:381:18 - (call $~lib/allocator/tlsf/Root#get:tailRef - (get_local $0) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:382:4 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:382:26 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:383:4 - (if - ;;@ ~lib/allocator/tlsf.ts:383:8 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:383:17 - (block - ;;@ ~lib/allocator/tlsf.ts:384:6 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:384:13 - (i32.ge_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:384:22 - (i32.add - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:384:32 - (i32.const 4) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 384) - (i32.const 6) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:387:6 - (if - ;;@ ~lib/allocator/tlsf.ts:387:10 - (i32.eq - (i32.sub - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:387:18 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ;;@ ~lib/allocator/tlsf.ts:387:32 - (get_local $3) - ) - ;;@ ~lib/allocator/tlsf.ts:387:41 - (block - ;;@ ~lib/allocator/tlsf.ts:388:8 - (set_local $1 - (i32.sub - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:388:17 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:389:8 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:389:19 - (i32.load - (get_local $3) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:392:11 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:393:13 - (i32.ge_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:393:22 - (i32.add - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:393:48 - (get_global $~lib/allocator/tlsf/Root.SIZE) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 393) - (i32.const 6) - ) - (unreachable) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:397:4 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:397:15 - (i32.sub - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:397:21 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:398:4 - (if - ;;@ ~lib/allocator/tlsf.ts:398:8 - (i32.lt_u - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:398:15 - (i32.add - (i32.add - (get_global $~lib/allocator/tlsf/Block.INFO) - ;;@ ~lib/allocator/tlsf.ts:398:28 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:398:45 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:398:57 - (return - ;;@ ~lib/allocator/tlsf.ts:399:13 - (i32.const 0) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:403:4 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:403:19 - (i32.sub - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:403:26 - (i32.mul - (i32.const 2) - ;;@ ~lib/allocator/tlsf.ts:403:30 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:404:4 - (set_local $7 - ;;@ ~lib/allocator/tlsf.ts:404:15 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:405:4 - (i32.store - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:405:16 - (i32.or - (i32.or - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:405:27 - (get_global $~lib/allocator/tlsf/FREE) - ) - ;;@ ~lib/allocator/tlsf.ts:405:34 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:405:35 - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:405:46 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:406:4 - (i32.store offset=4 - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:406:16 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:407:4 - (i32.store offset=8 - (get_local $7) - ;;@ ~lib/allocator/tlsf.ts:407:16 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:410:4 - (set_local $8 - ;;@ ~lib/allocator/tlsf.ts:410:15 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:410:33 - (i32.add - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:410:41 - (get_local $5) - ) - ;;@ ~lib/allocator/tlsf.ts:410:48 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:411:4 - (i32.store - (get_local $8) - ;;@ ~lib/allocator/tlsf.ts:411:16 - (i32.or - (i32.const 0) - ;;@ ~lib/allocator/tlsf.ts:411:20 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:412:4 - (call $~lib/allocator/tlsf/Root#set:tailRef - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:412:19 - (get_local $8) - ) - ;;@ ~lib/allocator/tlsf.ts:414:9 - (call $~lib/allocator/tlsf/Root#insert - ;;@ ~lib/allocator/tlsf.ts:414:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:414:16 - (get_local $7) - ) - ;;@ ~lib/allocator/tlsf.ts:416:11 - (i32.const 1) + local.get $1 + local.get $2 + i32.le_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 377 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 378 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 379 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + call $~lib/allocator/tlsf/Root#get:tailRef + local.set $3 + i32.const 0 + local.set $4 + local.get $3 + if + local.get $1 + local.get $3 + i32.const 4 + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 384 + i32.const 6 + call $~lib/env/abort + unreachable + end + local.get $1 + global.get $~lib/allocator/tlsf/Block.INFO + i32.sub + local.get $3 + i32.eq + if + local.get $1 + global.get $~lib/allocator/tlsf/Block.INFO + i32.sub + local.set $1 + local.get $3 + i32.load + local.set $4 + end + else + local.get $1 + local.get $0 + global.get $~lib/allocator/tlsf/Root.SIZE + i32.add + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 393 + i32.const 6 + call $~lib/env/abort + unreachable + end + end + local.get $2 + local.get $1 + i32.sub + local.set $5 + local.get $5 + global.get $~lib/allocator/tlsf/Block.INFO + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.add + global.get $~lib/allocator/tlsf/Block.INFO + i32.add + i32.lt_u + if + i32.const 0 + return + end + local.get $5 + i32.const 2 + global.get $~lib/allocator/tlsf/Block.INFO + i32.mul + i32.sub + local.set $6 + local.get $1 + local.set $7 + local.get $7 + local.get $6 + global.get $~lib/allocator/tlsf/FREE + i32.or + local.get $4 + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.and + i32.or + i32.store + local.get $7 + i32.const 0 + i32.store offset=4 + local.get $7 + i32.const 0 + i32.store offset=8 + local.get $1 + local.get $5 + i32.add + global.get $~lib/allocator/tlsf/Block.INFO + i32.sub + local.set $8 + local.get $8 + i32.const 0 + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.or + i32.store + local.get $0 + local.get $8 + call $~lib/allocator/tlsf/Root#set:tailRef + local.get $0 + local.get $7 + call $~lib/allocator/tlsf/Root#insert + i32.const 1 ) - (func $~lib/allocator/tlsf/ffs (; 21 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:422:2 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:422:9 - (i32.ne - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:422:17 - (i32.const 0) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 422) - (i32.const 2) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:423:20 - (i32.ctz - ;;@ ~lib/allocator/tlsf.ts:423:16 - (get_local $0) - ) + (func $~lib/allocator/tlsf/ffs (; 18 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 422 + i32.const 2 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.ctz ) - (func $~lib/allocator/tlsf/ffs (; 22 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/allocator/tlsf.ts:422:2 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:422:9 - (i32.ne - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:422:17 - (i32.const 0) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 422) - (i32.const 2) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:423:20 - (i32.ctz - ;;@ ~lib/allocator/tlsf.ts:423:16 - (get_local $0) - ) + (func $~lib/allocator/tlsf/ffs (; 19 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 0 + i32.ne + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 422 + i32.const 2 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.ctz ) - (func $~lib/allocator/tlsf/Root#search (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/allocator/tlsf/Root#search (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) - ;;@ ~lib/allocator/tlsf.ts:296:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:296:11 - (if (result i32) - (tee_local $2 - (i32.ge_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:296:19 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:296:37 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:296:44 - (get_global $~lib/allocator/tlsf/Block.MAX_SIZE) - ) - (get_local $2) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 296) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:300:4 - (if - ;;@ ~lib/allocator/tlsf.ts:300:8 - (i32.lt_u - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:300:15 - (get_global $~lib/allocator/tlsf/SB_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:300:24 - (block - ;;@ ~lib/allocator/tlsf.ts:301:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:301:11 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:302:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:302:11 - (i32.div_u - ;;@ ~lib/allocator/tlsf.ts:302:17 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:302:24 - (get_global $~lib/internal/allocator/AL_SIZE) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:303:11 - (block - ;;@ ~lib/allocator/tlsf.ts:305:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:305:11 - (call $~lib/allocator/tlsf/fls - ;;@ ~lib/allocator/tlsf.ts:305:22 - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:306:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:306:11 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:306:17 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:306:18 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:306:26 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:306:27 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:306:32 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:306:44 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:306:45 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:306:50 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:307:6 - (set_local $3 - (i32.sub - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:307:12 - (i32.sub - (get_global $~lib/allocator/tlsf/SB_BITS) - ;;@ ~lib/allocator/tlsf.ts:307:22 - (i32.const 1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:309:6 - (if - ;;@ ~lib/allocator/tlsf.ts:309:10 - (i32.lt_u - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:309:15 - (i32.sub - (get_global $~lib/allocator/tlsf/SL_SIZE) - ;;@ ~lib/allocator/tlsf.ts:309:25 - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:309:28 - (set_local $4 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:309:30 - (get_local $4) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:310:11 - (block - (set_local $3 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:310:13 - (get_local $3) - (i32.const 1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:310:17 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:310:22 - (i32.const 0) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:314:4 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:314:16 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:314:21 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:314:16 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:314:30 - (get_local $3) - ) - ;;@ ~lib/allocator/tlsf.ts:314:36 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:314:37 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:314:38 - (i32.const 0) - (i32.const -1) - ) - ;;@ ~lib/allocator/tlsf.ts:314:43 - (get_local $4) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:316:4 - (if - ;;@ ~lib/allocator/tlsf.ts:316:8 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:316:9 - (get_local $5) - ) - ;;@ ~lib/allocator/tlsf.ts:316:16 - (block - ;;@ ~lib/allocator/tlsf.ts:318:6 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:318:18 - (i32.and - (i32.load - (get_local $0) - ) - ;;@ ~lib/allocator/tlsf.ts:318:31 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:318:32 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:318:33 - (i32.const 0) - (i32.const -1) - ) - ;;@ ~lib/allocator/tlsf.ts:318:38 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:318:39 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:318:44 - (i32.const 1) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:319:6 - (if - ;;@ ~lib/allocator/tlsf.ts:319:10 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:319:11 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:319:18 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:320:15 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:321:13 - (block - ;;@ ~lib/allocator/tlsf.ts:322:8 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:322:13 - (call $~lib/allocator/tlsf/ffs - ;;@ ~lib/allocator/tlsf.ts:322:24 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:323:8 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:323:16 - (if (result i32) - (tee_local $7 - ;;@ ~lib/allocator/tlsf.ts:323:28 - (call $~lib/allocator/tlsf/Root#getSLMap - ;;@ ~lib/allocator/tlsf.ts:323:23 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:323:37 - (get_local $3) - ) - ) - (get_local $7) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 323) - (i32.const 16) - ) - (unreachable) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:324:8 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:324:20 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:324:15 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:324:28 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:324:32 - (call $~lib/allocator/tlsf/ffs - ;;@ ~lib/allocator/tlsf.ts:324:41 - (get_local $5) - ) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:326:11 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:327:18 - (call $~lib/allocator/tlsf/Root#getHead - ;;@ ~lib/allocator/tlsf.ts:327:13 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:327:26 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:327:30 - (call $~lib/allocator/tlsf/ffs - ;;@ ~lib/allocator/tlsf.ts:327:39 - (get_local $5) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:329:11 - (get_local $6) + local.get $1 + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.ge_u + local.tee $2 + if (result i32) + local.get $1 + global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.lt_u + else + local.get $2 + end + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 296 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + global.get $~lib/allocator/tlsf/SB_SIZE + i32.lt_u + if + i32.const 0 + local.set $3 + local.get $1 + i32.const 8 + i32.div_u + local.set $4 + else + local.get $1 + call $~lib/allocator/tlsf/fls + local.set $3 + local.get $1 + local.get $3 + global.get $~lib/allocator/tlsf/SL_BITS + i32.sub + i32.shr_u + i32.const 1 + global.get $~lib/allocator/tlsf/SL_BITS + i32.shl + i32.xor + local.set $4 + local.get $3 + global.get $~lib/allocator/tlsf/SB_BITS + i32.const 1 + i32.sub + i32.sub + local.set $3 + local.get $4 + global.get $~lib/allocator/tlsf/SL_SIZE + i32.const 1 + i32.sub + i32.lt_u + if + local.get $4 + i32.const 1 + i32.add + local.set $4 + else + local.get $3 + i32.const 1 + i32.add + local.set $3 + i32.const 0 + local.set $4 + end + end + local.get $0 + local.get $3 + call $~lib/allocator/tlsf/Root#getSLMap + i32.const 0 + i32.const -1 + i32.xor + local.get $4 + i32.shl + i32.and + local.set $5 + local.get $5 + i32.eqz + if + local.get $0 + i32.load + i32.const 0 + i32.const -1 + i32.xor + local.get $3 + i32.const 1 + i32.add + i32.shl + i32.and + local.set $2 + local.get $2 + i32.eqz + if + i32.const 0 + local.set $6 + else + local.get $2 + call $~lib/allocator/tlsf/ffs + local.set $3 + local.get $0 + local.get $3 + call $~lib/allocator/tlsf/Root#getSLMap + local.tee $7 + if (result i32) + local.get $7 + else + i32.const 0 + i32.const 8 + i32.const 323 + i32.const 16 + call $~lib/env/abort + unreachable + end + local.set $5 + local.get $0 + local.get $3 + local.get $5 + call $~lib/allocator/tlsf/ffs + call $~lib/allocator/tlsf/Root#getHead + local.set $6 + end + else + local.get $0 + local.get $3 + local.get $5 + call $~lib/allocator/tlsf/ffs + call $~lib/allocator/tlsf/Root#getHead + local.set $6 + end + local.get $6 ) - (func $~lib/allocator/tlsf/Root#use (; 24 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/allocator/tlsf/Root#use (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) - ;;@ ~lib/allocator/tlsf.ts:347:4 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:347:20 - (i32.load - (get_local $1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:348:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:348:11 - (i32.and - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:348:23 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 348) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:349:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:349:11 - (if (result i32) - (tee_local $4 - (i32.ge_u - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:349:19 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:349:37 - (i32.lt_u - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:349:44 - (get_global $~lib/allocator/tlsf/Block.MAX_SIZE) - ) - (get_local $4) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 349) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:350:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:350:11 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:350:12 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:350:13 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:350:20 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 350) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:352:9 - (call $~lib/allocator/tlsf/Root#remove - ;;@ ~lib/allocator/tlsf.ts:352:4 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:352:16 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:355:4 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:355:20 - (i32.sub - (i32.and - ;;@ ~lib/allocator/tlsf.ts:355:21 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:355:33 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:355:34 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:355:42 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:356:4 - (if - ;;@ ~lib/allocator/tlsf.ts:356:8 - (i32.ge_u - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:356:21 - (i32.add - (get_global $~lib/allocator/tlsf/Block.INFO) - ;;@ ~lib/allocator/tlsf.ts:356:34 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:356:50 - (block - ;;@ ~lib/allocator/tlsf.ts:357:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:357:19 - (i32.or - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:357:26 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:357:27 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:357:39 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:359:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:359:18 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:360:8 - (i32.add - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:360:35 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ;;@ ~lib/allocator/tlsf.ts:360:48 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:362:6 - (i32.store - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:362:19 - (i32.or - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:362:20 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:362:32 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ;;@ ~lib/allocator/tlsf.ts:362:46 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:363:11 - (call $~lib/allocator/tlsf/Root#insert - ;;@ ~lib/allocator/tlsf.ts:363:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:363:18 - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:366:11 - (block - ;;@ ~lib/allocator/tlsf.ts:367:6 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:367:19 - (i32.and - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:367:31 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:367:32 - (get_global $~lib/allocator/tlsf/FREE) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:368:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:368:25 - (if (result i32) - (i32.eqz - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:368:32 - (call $~lib/allocator/tlsf/Block#get:right - (get_local $1) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 368) - (i32.const 25) - ) - (unreachable) - ) - (get_local $4) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:369:6 - (i32.store - (get_local $4) - (i32.and - (i32.load - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:369:20 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:369:21 - (get_global $~lib/allocator/tlsf/LEFT_FREE) - (i32.const -1) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:372:44 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:372:11 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:372:38 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) + local.get $1 + i32.load + local.set $3 + local.get $3 + global.get $~lib/allocator/tlsf/FREE + i32.and + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 348 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.ge_u + local.tee $4 + if (result i32) + local.get $2 + global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.lt_u + else + local.get $4 + end + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 349 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + i32.const 7 + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 350 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + local.get $1 + call $~lib/allocator/tlsf/Root#remove + local.get $3 + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + local.get $2 + i32.sub + local.set $5 + local.get $5 + global.get $~lib/allocator/tlsf/Block.INFO + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + i32.add + i32.ge_u + if + local.get $1 + local.get $2 + local.get $3 + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.and + i32.or + i32.store + local.get $1 + global.get $~lib/allocator/tlsf/Block.INFO + i32.add + local.get $2 + i32.add + local.set $4 + local.get $4 + local.get $5 + global.get $~lib/allocator/tlsf/Block.INFO + i32.sub + global.get $~lib/allocator/tlsf/FREE + i32.or + i32.store + local.get $0 + local.get $4 + call $~lib/allocator/tlsf/Root#insert + else + local.get $1 + local.get $3 + global.get $~lib/allocator/tlsf/FREE + i32.const -1 + i32.xor + i32.and + i32.store + local.get $1 + call $~lib/allocator/tlsf/Block#get:right + local.tee $4 + i32.eqz + if (result i32) + i32.const 0 + i32.const 8 + i32.const 368 + i32.const 25 + call $~lib/env/abort + unreachable + else + local.get $4 + end + local.set $4 + local.get $4 + local.get $4 + i32.load + global.get $~lib/allocator/tlsf/LEFT_FREE + i32.const -1 + i32.xor + i32.and + i32.store + end + local.get $1 + global.get $~lib/allocator/tlsf/Block.INFO + i32.add ) - (func $~lib/allocator/tlsf/__memory_allocate (; 25 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/tlsf/__memory_allocate (; 22 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -5511,630 +1248,297 @@ (local $5 i32) (local $6 i32) (local $7 i32) - (local $8 i32) - ;;@ ~lib/allocator/tlsf.ts:443:2 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:443:13 - (get_global $~lib/allocator/tlsf/ROOT) - ) - ;;@ ~lib/allocator/tlsf.ts:444:2 - (if - ;;@ ~lib/allocator/tlsf.ts:444:6 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:444:7 - (get_local $1) - ) - ;;@ ~lib/allocator/tlsf.ts:444:13 - (block - ;;@ ~lib/allocator/tlsf.ts:445:4 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:445:21 - (i32.and - (i32.add - ;;@ ~lib/allocator/tlsf.ts:445:22 - (get_global $HEAP_BASE) - ;;@ ~lib/allocator/tlsf.ts:445:34 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ;;@ ~lib/allocator/tlsf.ts:445:45 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:445:46 - (get_global $~lib/internal/allocator/AL_MASK) - (i32.const -1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:446:4 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:446:29 - (current_memory) - ) - ;;@ ~lib/allocator/tlsf.ts:447:4 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:447:22 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:447:28 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:447:29 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:447:30 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:447:31 - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:447:44 - (get_global $~lib/allocator/tlsf/Root.SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:447:57 - (i32.const 65535) - ) - ;;@ ~lib/allocator/tlsf.ts:447:67 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:447:68 - (i32.const 65535) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:447:80 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:448:4 - (if - ;;@ ~lib/allocator/tlsf.ts:448:8 - (if (result i32) - (tee_local $5 - (i32.gt_s - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:448:22 - (get_local $3) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:448:37 - (i32.lt_s - ;;@ ~lib/allocator/tlsf.ts:448:44 - (grow_memory - ;;@ ~lib/allocator/tlsf.ts:448:49 - (i32.sub - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:448:63 - (get_local $3) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:448:78 - (i32.const 0) - ) - (get_local $5) - ) - ;;@ ~lib/allocator/tlsf.ts:448:81 - (unreachable) - ) - ;;@ ~lib/allocator/tlsf.ts:449:4 - (set_global $~lib/allocator/tlsf/ROOT - ;;@ ~lib/allocator/tlsf.ts:449:11 - (tee_local $1 - ;;@ ~lib/allocator/tlsf.ts:449:18 - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:450:4 - (call $~lib/allocator/tlsf/Root#set:tailRef - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:450:19 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:451:4 - (i32.store - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:451:17 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:452:4 - (block $break|0 - ;;@ ~lib/allocator/tlsf.ts:452:9 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:452:25 - (i32.const 0) - ) - (loop $repeat|0 - (br_if $break|0 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:452:28 - (i32.lt_u - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:452:33 - (get_global $~lib/allocator/tlsf/FL_BITS) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:452:48 - (block - ;;@ ~lib/allocator/tlsf.ts:453:11 - (call $~lib/allocator/tlsf/Root#setSLMap - ;;@ ~lib/allocator/tlsf.ts:453:6 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:453:20 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:453:24 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:454:6 - (block $break|1 - ;;@ ~lib/allocator/tlsf.ts:454:11 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:454:25 - (i32.const 0) - ) - (loop $repeat|1 - (br_if $break|1 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:454:28 - (i32.lt_u - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:454:33 - (get_global $~lib/allocator/tlsf/SL_SIZE) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:454:48 - (call $~lib/allocator/tlsf/Root#setHead - ;;@ ~lib/allocator/tlsf.ts:455:8 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:455:21 - (get_local $5) - ;;@ ~lib/allocator/tlsf.ts:455:25 - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:455:29 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:454:42 - (set_local $6 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:454:44 - (get_local $6) - (i32.const 1) - ) - ) - (br $repeat|1) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:452:42 - (set_local $5 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:452:44 - (get_local $5) - (i32.const 1) - ) - ) - (br $repeat|0) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:458:9 - (drop - (call $~lib/allocator/tlsf/Root#addMemory - ;;@ ~lib/allocator/tlsf.ts:458:4 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:458:19 - (i32.and - (i32.add - ;;@ ~lib/allocator/tlsf.ts:458:20 - (i32.add - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:458:33 - (get_global $~lib/allocator/tlsf/Root.SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:458:45 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ;;@ ~lib/allocator/tlsf.ts:458:56 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:458:57 - (get_global $~lib/internal/allocator/AL_MASK) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:458:66 - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:458:73 - (current_memory) - ;;@ ~lib/allocator/tlsf.ts:458:83 - (i32.const 16) - ) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:462:2 - (set_local $7 - ;;@ ~lib/allocator/tlsf.ts:462:20 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:463:2 - (if - ;;@ ~lib/allocator/tlsf.ts:463:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:463:12 - (block - ;;@ ~lib/allocator/tlsf.ts:464:4 - (if - ;;@ ~lib/allocator/tlsf.ts:464:8 - (i32.gt_u - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:464:15 - (get_global $~lib/allocator/tlsf/Block.MAX_SIZE) - ) - ;;@ ~lib/allocator/tlsf.ts:464:31 - (unreachable) - ) - ;;@ ~lib/allocator/tlsf.ts:466:4 - (set_local $0 - ;;@ ~lib/allocator/tlsf.ts:466:11 - (select - (tee_local $4 - ;;@ ~lib/allocator/tlsf.ts:466:22 - (i32.and - (i32.add - ;;@ ~lib/allocator/tlsf.ts:466:23 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:466:30 - (get_global $~lib/internal/allocator/AL_MASK) - ) - ;;@ ~lib/allocator/tlsf.ts:466:41 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:466:42 - (get_global $~lib/internal/allocator/AL_MASK) - (i32.const -1) - ) - ) - ) - (tee_local $3 - ;;@ ~lib/allocator/tlsf.ts:466:51 - (get_global $~lib/allocator/tlsf/Block.MIN_SIZE) - ) - (i32.gt_u - (get_local $4) - (get_local $3) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:468:4 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:468:21 - (call $~lib/allocator/tlsf/Root#search - ;;@ ~lib/allocator/tlsf.ts:468:16 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:468:28 - (get_local $0) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:469:4 - (if - ;;@ ~lib/allocator/tlsf.ts:469:8 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:469:9 - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:469:16 - (block - ;;@ ~lib/allocator/tlsf.ts:472:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:472:31 - (current_memory) - ) - ;;@ ~lib/allocator/tlsf.ts:473:6 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:473:24 - (i32.shr_u - ;;@ ~lib/allocator/tlsf.ts:473:30 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:473:31 - (i32.add - ;;@ ~lib/allocator/tlsf.ts:473:32 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:473:39 - (i32.const 65535) - ) - ;;@ ~lib/allocator/tlsf.ts:473:49 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:473:50 - (i32.const 65535) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:473:62 - (i32.const 16) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:474:6 - (set_local $5 - ;;@ ~lib/allocator/tlsf.ts:474:24 - (select - (tee_local $5 - ;;@ ~lib/allocator/tlsf.ts:474:28 - (get_local $3) - ) - (tee_local $6 - ;;@ ~lib/allocator/tlsf.ts:474:41 - (get_local $2) - ) - (i32.gt_s - (get_local $5) - (get_local $6) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:475:6 - (if - ;;@ ~lib/allocator/tlsf.ts:475:10 - (i32.lt_s - ;;@ ~lib/allocator/tlsf.ts:475:17 - (grow_memory - ;;@ ~lib/allocator/tlsf.ts:475:22 - (get_local $5) - ) - ;;@ ~lib/allocator/tlsf.ts:475:37 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:475:40 - (if - ;;@ ~lib/allocator/tlsf.ts:476:12 - (i32.lt_s - ;;@ ~lib/allocator/tlsf.ts:476:19 - (grow_memory - ;;@ ~lib/allocator/tlsf.ts:476:24 - (get_local $2) - ) - ;;@ ~lib/allocator/tlsf.ts:476:39 - (i32.const 0) - ) - ;;@ ~lib/allocator/tlsf.ts:476:42 - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:480:6 - (set_local $6 - ;;@ ~lib/allocator/tlsf.ts:480:30 - (current_memory) - ) - ;;@ ~lib/allocator/tlsf.ts:481:11 - (drop - (call $~lib/allocator/tlsf/Root#addMemory - ;;@ ~lib/allocator/tlsf.ts:481:6 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:481:21 - (i32.shl - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:481:43 - (i32.const 16) - ) - ;;@ ~lib/allocator/tlsf.ts:481:47 - (i32.shl - (get_local $6) - ;;@ ~lib/allocator/tlsf.ts:481:68 - (i32.const 16) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:482:6 - (set_local $4 - ;;@ ~lib/allocator/tlsf.ts:482:14 - (if (result i32) - (i32.eqz - (tee_local $8 - ;;@ ~lib/allocator/tlsf.ts:482:26 - (call $~lib/allocator/tlsf/Root#search - ;;@ ~lib/allocator/tlsf.ts:482:21 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:482:33 - (get_local $0) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 482) - (i32.const 14) - ) - (unreachable) - ) - (get_local $8) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:485:4 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:485:11 - (i32.ge_u - (i32.and - ;;@ ~lib/allocator/tlsf.ts:485:12 - (i32.load - (get_local $4) - ) - ;;@ ~lib/allocator/tlsf.ts:485:25 - (i32.xor - ;;@ ~lib/allocator/tlsf.ts:485:26 - (get_global $~lib/allocator/tlsf/TAGS) - (i32.const -1) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:485:35 - (get_local $0) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 485) - (i32.const 4) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:486:4 - (set_local $7 - ;;@ ~lib/allocator/tlsf.ts:486:16 - (call $~lib/allocator/tlsf/Root#use - ;;@ ~lib/allocator/tlsf.ts:486:11 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:486:20 - (get_local $4) - ;;@ ~lib/allocator/tlsf.ts:486:34 - (get_local $0) - ) - ) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:489:9 - (get_local $7) + global.get $~lib/allocator/tlsf/ROOT + local.set $1 + local.get $1 + i32.eqz + if + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $2 + current_memory + local.set $3 + local.get $2 + global.get $~lib/allocator/tlsf/Root.SIZE + i32.add + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $4 + local.get $4 + local.get $3 + i32.gt_s + local.tee $5 + if (result i32) + local.get $4 + local.get $3 + i32.sub + grow_memory + i32.const 0 + i32.lt_s + else + local.get $5 + end + if + unreachable + end + local.get $2 + local.tee $1 + global.set $~lib/allocator/tlsf/ROOT + local.get $1 + i32.const 0 + call $~lib/allocator/tlsf/Root#set:tailRef + local.get $1 + i32.const 0 + i32.store + block $break|0 + i32.const 0 + local.set $5 + loop $repeat|0 + local.get $5 + global.get $~lib/allocator/tlsf/FL_BITS + i32.lt_u + i32.eqz + br_if $break|0 + block + local.get $1 + local.get $5 + i32.const 0 + call $~lib/allocator/tlsf/Root#setSLMap + block $break|1 + i32.const 0 + local.set $6 + loop $repeat|1 + local.get $6 + global.get $~lib/allocator/tlsf/SL_SIZE + i32.lt_u + i32.eqz + br_if $break|1 + local.get $1 + local.get $5 + local.get $6 + i32.const 0 + call $~lib/allocator/tlsf/Root#setHead + local.get $6 + i32.const 1 + i32.add + local.set $6 + br $repeat|1 + unreachable + end + unreachable + end + end + local.get $5 + i32.const 1 + i32.add + local.set $5 + br $repeat|0 + unreachable + end + unreachable + end + local.get $1 + local.get $2 + global.get $~lib/allocator/tlsf/Root.SIZE + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + current_memory + i32.const 16 + i32.shl + call $~lib/allocator/tlsf/Root#addMemory + drop + end + local.get $0 + global.get $~lib/allocator/tlsf/Block.MAX_SIZE + i32.gt_u + if + unreachable + end + local.get $0 + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.tee $4 + global.get $~lib/allocator/tlsf/Block.MIN_SIZE + local.tee $3 + local.get $4 + local.get $3 + i32.gt_u + select + local.set $0 + local.get $1 + local.get $0 + call $~lib/allocator/tlsf/Root#search + local.set $7 + local.get $7 + i32.eqz + if + current_memory + local.set $4 + local.get $0 + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $3 + local.get $4 + local.tee $2 + local.get $3 + local.tee $5 + local.get $2 + local.get $5 + i32.gt_s + select + local.set $2 + local.get $2 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + current_memory + local.set $5 + local.get $1 + local.get $4 + i32.const 16 + i32.shl + local.get $5 + i32.const 16 + i32.shl + call $~lib/allocator/tlsf/Root#addMemory + drop + local.get $1 + local.get $0 + call $~lib/allocator/tlsf/Root#search + local.tee $6 + i32.eqz + if (result i32) + i32.const 0 + i32.const 8 + i32.const 480 + i32.const 12 + call $~lib/env/abort + unreachable + else + local.get $6 + end + local.set $7 + end + local.get $7 + i32.load + global.get $~lib/allocator/tlsf/TAGS + i32.const -1 + i32.xor + i32.and + local.get $0 + i32.ge_u + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 483 + i32.const 2 + call $~lib/env/abort + unreachable + end + local.get $1 + local.get $7 + local.get $0 + call $~lib/allocator/tlsf/Root#use ) - (func $~lib/memory/memory.allocate (; 26 ;) (type $ii) (param $0 i32) (result i32) - ;;@ ~lib/memory.ts:37:4 - (return - ;;@ ~lib/memory.ts:37:45 - (call $~lib/allocator/tlsf/__memory_allocate - ;;@ ~lib/memory.ts:37:63 - (get_local $0) - ) - ) + (func $~lib/memory/memory.allocate (; 23 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + call $~lib/allocator/tlsf/__memory_allocate + return ) - (func $~lib/allocator/tlsf/__memory_free (; 27 ;) (type $iv) (param $0 i32) + (func $~lib/allocator/tlsf/__memory_free (; 24 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) - ;;@ ~lib/allocator/tlsf.ts:495:2 - (if - ;;@ ~lib/allocator/tlsf.ts:495:6 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:495:12 - (block - ;;@ ~lib/allocator/tlsf.ts:496:4 - (set_local $1 - ;;@ ~lib/allocator/tlsf.ts:496:15 - (get_global $~lib/allocator/tlsf/ROOT) - ) - ;;@ ~lib/allocator/tlsf.ts:497:4 - (if - ;;@ ~lib/allocator/tlsf.ts:497:8 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:497:14 - (block - ;;@ ~lib/allocator/tlsf.ts:498:6 - (set_local $2 - ;;@ ~lib/allocator/tlsf.ts:498:18 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:498:36 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:498:43 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:499:6 - (set_local $3 - ;;@ ~lib/allocator/tlsf.ts:499:22 - (i32.load - (get_local $2) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:500:6 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:500:13 - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:500:14 - (i32.and - ;;@ ~lib/allocator/tlsf.ts:500:15 - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:500:27 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 500) - (i32.const 6) - ) - (unreachable) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:501:6 - (i32.store - (get_local $2) - ;;@ ~lib/allocator/tlsf.ts:501:19 - (i32.or - (get_local $3) - ;;@ ~lib/allocator/tlsf.ts:501:31 - (get_global $~lib/allocator/tlsf/FREE) - ) - ) - ;;@ ~lib/allocator/tlsf.ts:502:11 - (call $~lib/allocator/tlsf/Root#insert - ;;@ ~lib/allocator/tlsf.ts:502:6 - (get_local $1) - ;;@ ~lib/allocator/tlsf.ts:502:18 - (i32.sub - ;;@ ~lib/allocator/tlsf.ts:502:36 - (get_local $0) - ;;@ ~lib/allocator/tlsf.ts:502:43 - (get_global $~lib/allocator/tlsf/Block.INFO) - ) - ) - ) - ) - ) - ) + local.get $0 + if + global.get $~lib/allocator/tlsf/ROOT + local.set $1 + local.get $1 + if + local.get $0 + global.get $~lib/allocator/tlsf/Block.INFO + i32.sub + local.set $2 + local.get $2 + i32.load + local.set $3 + local.get $3 + global.get $~lib/allocator/tlsf/FREE + i32.and + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 494 + i32.const 6 + call $~lib/env/abort + unreachable + end + local.get $2 + local.get $3 + global.get $~lib/allocator/tlsf/FREE + i32.or + i32.store + local.get $1 + local.get $0 + global.get $~lib/allocator/tlsf/Block.INFO + i32.sub + call $~lib/allocator/tlsf/Root#insert + end + end + ) + (func $~lib/memory/memory.free (; 25 ;) (type $i_) (param $0 i32) + local.get $0 + call $~lib/allocator/tlsf/__memory_free + return ) - (func $~lib/memory/memory.free (; 28 ;) (type $iv) (param $0 i32) - ;;@ ~lib/memory.ts:43:36 - (call $~lib/allocator/tlsf/__memory_free - ;;@ ~lib/memory.ts:43:50 - (get_local $0) - ) - ;;@ ~lib/memory.ts:43:56 - (return) + (func $~lib/allocator/tlsf/__memory_reset (; 26 ;) (type $_) + unreachable ) - (func $~lib/allocator/tlsf/__memory_reset (; 29 ;) (type $v) - ;;@ ~lib/allocator/tlsf.ts:509:2 - (unreachable) + (func $~lib/memory/memory.reset (; 27 ;) (type $_) + call $~lib/allocator/tlsf/__memory_reset + return ) - (func $~lib/memory/memory.reset (; 30 ;) (type $v) - ;;@ ~lib/memory.ts:49:37 - (call $~lib/allocator/tlsf/__memory_reset) - ;;@ ~lib/memory.ts:49:55 - (return) + (func $start (; 28 ;) (type $_) + call $start:assembly/index ) - (func $start (; 31 ;) (type $v) - ;;@ ~lib/allocator/tlsf.ts:122:0 - (if - (i32.eqz - ;;@ ~lib/allocator/tlsf.ts:122:7 - (i32.le_s - (i32.shl - ;;@ ~lib/allocator/tlsf.ts:122:8 - (i32.const 1) - ;;@ ~lib/allocator/tlsf.ts:122:13 - (get_global $~lib/allocator/tlsf/SL_BITS) - ) - ;;@ ~lib/allocator/tlsf.ts:122:25 - (i32.const 32) - ) - ) - (block - (call $~lib/env/abort - (i32.const 0) - (i32.const 8) - (i32.const 122) - (i32.const 0) - ) - (unreachable) - ) - ) + (func $null (; 29 ;) (type $_) ) ) diff --git a/tests/compiler.js b/tests/compiler.js index 7696824afc..a5aa1cf792 100644 --- a/tests/compiler.js +++ b/tests/compiler.js @@ -21,6 +21,12 @@ const config = { ], "type": "b" }, + "noDiff": { + "description": [ + "Disables output of detailed fixture differences." + ], + "type": "b" + }, "help": { "description": "Prints this message and exits.", "type": "b", @@ -128,13 +134,23 @@ tests.forEach(filename => { console.log("- " + colorsUtil.yellow("Created fixture")); } else { let expected = fs.readFileSync(path.join(basedir, basename + ".untouched.wat"), { encoding: "utf8" }).replace(/\r\n/g, "\n"); - let diffs = diff(basename + ".untouched.wat", expected, actual); - if (diffs !== null) { - console.log(diffs); - console.log("- " + colorsUtil.red("diff ERROR")); - failed = true; - } else - console.log("- " + colorsUtil.green("diff OK")); + if (args.noDiff) { + if (expected != actual) { + console.log("- " + colorsUtil.red("compare ERROR")); + failed = true; + } else { + console.log("- " + colorsUtil.green("compare OK")); + } + } else { + let diffs = diff(basename + ".untouched.wat", expected, actual); + if (diffs !== null) { + console.log(diffs); + console.log("- " + colorsUtil.red("diff ERROR")); + failed = true; + } else { + console.log("- " + colorsUtil.green("diff OK")); + } + } } console.log(); diff --git a/tests/compiler/abi.untouched.wat b/tests/compiler/abi.untouched.wat index bda647515e..9b07189ffd 100644 --- a/tests/compiler/abi.untouched.wat +++ b/tests/compiler/abi.untouched.wat @@ -9,34 +9,17 @@ (elem (i32.const 0) $null) (global $abi/condition (mut i32) (i32.const 0)) (global $abi/y (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 24)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 24)) (export "memory" (memory $0)) (export "table" (table $0)) (export "exported" (func $abi/exported)) (export "exportedExported" (func $abi/exportedExported)) (export "exportedInternal" (func $abi/exportedInternal)) (start $start) - (func $abi/exported (; 1 ;) (type $i) (result i32) - i32.const 128 - i32.const 24 - i32.shl - i32.const 24 - i32.shr_s - ) - (func $abi/exportedExported (; 2 ;) (type $i) (result i32) - call $abi/exported - ) - (func $abi/internal (; 3 ;) (type $i) (result i32) + (func $abi/internal (; 1 ;) (type $i) (result i32) i32.const 128 ) - (func $abi/exportedInternal (; 4 ;) (type $i) (result i32) - call $abi/internal - i32.const 24 - i32.shl - i32.const 24 - i32.shr_s - ) - (func $start (; 5 ;) (type $_) + (func $start:abi (; 2 ;) (type $_) (local $0 i32) (local $1 i32) call $abi/internal @@ -211,6 +194,26 @@ end end ) - (func $null (; 6 ;) (type $_) + (func $abi/exported (; 3 ;) (type $i) (result i32) + i32.const 128 + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + ) + (func $abi/exportedExported (; 4 ;) (type $i) (result i32) + call $abi/exported + ) + (func $abi/exportedInternal (; 5 ;) (type $i) (result i32) + call $abi/internal + i32.const 24 + i32.shl + i32.const 24 + i32.shr_s + ) + (func $start (; 6 ;) (type $_) + call $start:abi + ) + (func $null (; 7 ;) (type $_) ) ) diff --git a/tests/compiler/asc-constants.ts b/tests/compiler/asc-constants.ts index ed9764fb10..d940aef91f 100644 --- a/tests/compiler/asc-constants.ts +++ b/tests/compiler/asc-constants.ts @@ -1,5 +1,4 @@ ASC_TARGET; -ASC_NO_TREESHAKING; ASC_NO_ASSERT; ASC_MEMORY_BASE; ASC_OPTIMIZE_LEVEL; diff --git a/tests/compiler/asc-constants.untouched.wat b/tests/compiler/asc-constants.untouched.wat index 20c273ee78..0dcc88cf38 100644 --- a/tests/compiler/asc-constants.untouched.wat +++ b/tests/compiler/asc-constants.untouched.wat @@ -3,19 +3,18 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $ASC_TARGET i32 (i32.const 0)) - (global $ASC_NO_TREESHAKING i32 (i32.const 0)) - (global $ASC_NO_ASSERT i32 (i32.const 0)) - (global $ASC_MEMORY_BASE i32 (i32.const 0)) - (global $ASC_OPTIMIZE_LEVEL i32 (i32.const 0)) - (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) - (global $ASC_FEATURE_MUTABLE_GLOBAL i32 (i32.const 0)) - (global $ASC_FEATURE_SIGN_EXTENSION i32 (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/ASC_TARGET i32 (i32.const 0)) + (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) + (global $~lib/ASC_MEMORY_BASE i32 (i32.const 0)) + (global $~lib/ASC_OPTIMIZE_LEVEL i32 (i32.const 0)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) + (global $~lib/ASC_FEATURE_MUTABLE_GLOBAL i32 (i32.const 0)) + (global $~lib/ASC_FEATURE_SIGN_EXTENSION i32 (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:asc-constants (; 0 ;) (type $_) i32.const 1 drop i32.const 0 @@ -30,9 +29,10 @@ drop i32.const 0 drop - i32.const 0 - drop ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:asc-constants + ) + (func $null (; 2 ;) (type $_) ) ) diff --git a/tests/compiler/assert.untouched.wat b/tests/compiler/assert.untouched.wat index 143e0590b2..7d025fcba4 100644 --- a/tests/compiler/assert.untouched.wat +++ b/tests/compiler/assert.untouched.wat @@ -7,11 +7,11 @@ (data (i32.const 32) "\0c\00\00\00m\00u\00s\00t\00 \00b\00e\00 \00t\00r\00u\00e\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 60)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 60)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:assert (; 1 ;) (type $_) (local $0 i32) i32.const 1 i32.eqz @@ -107,6 +107,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:assert + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/binary.optimized.wat b/tests/compiler/binary.optimized.wat index 6f53f54766..b5943480c7 100644 --- a/tests/compiler/binary.optimized.wat +++ b/tests/compiler/binary.optimized.wat @@ -406,7 +406,7 @@ local.get $0 f64.mul ) - (func $start (; 4 ;) (type $_) + (func $start:binary (; 4 ;) (type $_) (local $0 i32) (local $1 i64) (local $2 f32) @@ -749,7 +749,10 @@ call $~lib/math/NativeMath.pow global.set $binary/F ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:binary + ) + (func $null (; 6 ;) (type $_) nop ) ) diff --git a/tests/compiler/binary.untouched.wat b/tests/compiler/binary.untouched.wat index 34633c44cb..0e0de93c4a 100644 --- a/tests/compiler/binary.untouched.wat +++ b/tests/compiler/binary.untouched.wat @@ -9,11 +9,10 @@ (elem (i32.const 0) $null) (global $binary/b (mut i32) (i32.const 0)) (global $binary/i (mut i32) (i32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) (global $binary/I (mut i64) (i64.const 0)) (global $binary/f (mut f32) (f32.const 0)) (global $binary/F (mut f64) (f64.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -2738,7 +2737,7 @@ local.get $2 f64.reinterpret_i64 ) - (func $start (; 6 ;) (type $_) + (func $start:binary (; 6 ;) (type $_) global.get $binary/i i32.const 1 i32.lt_s @@ -3346,6 +3345,9 @@ call $~lib/math/NativeMath.pow global.set $binary/F ) - (func $null (; 7 ;) (type $_) + (func $start (; 7 ;) (type $_) + call $start:binary + ) + (func $null (; 8 ;) (type $_) ) ) diff --git a/tests/compiler/bool.optimized.wat b/tests/compiler/bool.optimized.wat index 06eeafe9c6..dc7e3b7468 100644 --- a/tests/compiler/bool.optimized.wat +++ b/tests/compiler/bool.optimized.wat @@ -16,7 +16,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:bool (; 1 ;) (type $_) global.get $bool/i i32.const 0 i32.ne @@ -109,7 +109,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:bool + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/bool.untouched.wat b/tests/compiler/bool.untouched.wat index 8b47a099b0..be8a8245ac 100644 --- a/tests/compiler/bool.untouched.wat +++ b/tests/compiler/bool.untouched.wat @@ -13,11 +13,11 @@ (global $bool/f (mut f32) (f32.const 2)) (global $bool/F (mut f64) (f64.const 2)) (global $bool/uu (mut i32) (i32.const 2)) - (global $HEAP_BASE i32 (i32.const 28)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 28)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:bool (; 1 ;) (type $_) global.get $bool/i i32.const 0 i32.ne @@ -117,6 +117,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:bool + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/builtins.optimized.wat b/tests/compiler/builtins.optimized.wat index adaa2f02b4..8a61bc44ce 100644 --- a/tests/compiler/builtins.optimized.wat +++ b/tests/compiler/builtins.optimized.wat @@ -7,7 +7,7 @@ (data (i32.const 8) "\0b\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s") (data (i32.const 40) "\01\00\00\001") (table $0 2 funcref) - (elem (i32.const 0) $builtins/test $start~anonymous|1) + (elem (i32.const 0) $builtins/test $start:builtins~anonymous|1) (global $builtins/b (mut i32) (i32.const 0)) (global $builtins/i (mut i32) (i32.const 0)) (global $builtins/I (mut i64) (i64.const 0)) @@ -21,13 +21,10 @@ (export "table" (table $0)) (export "test" (func $builtins/test)) (start $start) - (func $start~anonymous|1 (; 1 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $start:builtins~anonymous|1 (; 1 ;) (type $ii_) (param $0 i32) (param $1 i32) nop ) - (func $builtins/test (; 2 ;) (type $_) - nop - ) - (func $start (; 3 ;) (type $_) + (func $start:builtins (; 2 ;) (type $_) i32.const 31 global.set $builtins/i i32.const 0 @@ -447,4 +444,10 @@ f64.const 1 f64.store ) + (func $builtins/test (; 3 ;) (type $_) + nop + ) + (func $start (; 4 ;) (type $_) + call $start:builtins + ) ) diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index ed90a3dcd9..ea5f4906b3 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -7,13 +7,11 @@ (data (i32.const 8) "\0b\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s\00") (data (i32.const 40) "\01\00\00\001\00") (table $0 2 funcref) - (elem (i32.const 0) $null $start~anonymous|1) + (elem (i32.const 0) $null $start:builtins~anonymous|1) (global $builtins/b (mut i32) (i32.const 0)) (global $builtins/i (mut i32) (i32.const 0)) (global $builtins/I (mut i64) (i64.const 0)) (global $builtins/f (mut f32) (f32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $Infinity f64 (f64.const inf)) (global $builtins/F (mut f64) (f64.const 0)) (global $builtins/constantOffset i32 (i32.const 8)) (global $builtins/u (mut i32) (i32.const 0)) @@ -50,18 +48,15 @@ (global $~lib/builtins/f64.MIN_SAFE_INTEGER f64 (f64.const -9007199254740991)) (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) - (global $HEAP_BASE i32 (i32.const 48)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 48)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $builtins/test)) (start $start) - (func $start~anonymous|1 (; 1 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $start:builtins~anonymous|1 (; 1 ;) (type $ii_) (param $0 i32) (param $1 i32) nop ) - (func $builtins/test (; 2 ;) (type $_) - nop - ) - (func $start (; 3 ;) (type $_) + (func $start:builtins (; 2 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i64) @@ -2179,6 +2174,12 @@ end drop ) - (func $null (; 4 ;) (type $_) + (func $builtins/test (; 3 ;) (type $_) + nop + ) + (func $start (; 4 ;) (type $_) + call $start:builtins + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/call-inferred.untouched.wat b/tests/compiler/call-inferred.untouched.wat index cd4fda5366..247b5d0f4b 100644 --- a/tests/compiler/call-inferred.untouched.wat +++ b/tests/compiler/call-inferred.untouched.wat @@ -9,7 +9,7 @@ (data (i32.const 8) "\10\00\00\00c\00a\00l\00l\00-\00i\00n\00f\00e\00r\00r\00e\00d\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 44)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 44)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -25,7 +25,7 @@ (func $call-inferred/bar (; 4 ;) (type $ff) (param $0 f32) (result f32) local.get $0 ) - (func $start (; 5 ;) (type $_) + (func $start:call-inferred (; 5 ;) (type $_) i32.const 42 call $call-inferred/foo i32.const 42 @@ -79,6 +79,9 @@ unreachable end ) - (func $null (; 6 ;) (type $_) + (func $start (; 6 ;) (type $_) + call $start:call-inferred + ) + (func $null (; 7 ;) (type $_) ) ) diff --git a/tests/compiler/call-optional.optimized.wat b/tests/compiler/call-optional.optimized.wat index f7cbc971aa..9a1c5a47c1 100644 --- a/tests/compiler/call-optional.optimized.wat +++ b/tests/compiler/call-optional.optimized.wat @@ -7,7 +7,7 @@ (data (i32.const 8) "\10\00\00\00c\00a\00l\00l\00-\00o\00p\00t\00i\00o\00n\00a\00l\00.\00t\00s") (table $0 2 funcref) (elem (i32.const 0) $null $call-optional/opt|trampoline) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $call-optional/optIndirect (mut i32) (i32.const 1)) (export "memory" (memory $0)) (export "table" (table $0)) @@ -17,7 +17,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -36,16 +36,16 @@ local.get $2 i32.add ) - (func $start (; 2 ;) (type $_) + (func $start:call-optional (; 2 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 1 - global.set $~argc + global.set $~lib/argc block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -72,7 +72,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 4 local.set $0 i32.const 0 @@ -81,7 +81,7 @@ block $1of22 block $0of23 block $outOfRange4 - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of23 $1of22 $2of21 $outOfRange4 @@ -110,7 +110,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 0 i32.const 0 @@ -125,7 +125,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 4 i32.const 0 @@ -142,7 +142,7 @@ unreachable end i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 4 i32.const 5 @@ -159,7 +159,10 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:call-optional + ) + (func $null (; 4 ;) (type $_) nop ) ) diff --git a/tests/compiler/call-optional.untouched.wat b/tests/compiler/call-optional.untouched.wat index 667d225ae5..f552f37122 100644 --- a/tests/compiler/call-optional.untouched.wat +++ b/tests/compiler/call-optional.untouched.wat @@ -7,9 +7,9 @@ (data (i32.const 8) "\10\00\00\00c\00a\00l\00l\00-\00o\00p\00t\00i\00o\00n\00a\00l\00.\00t\00s\00") (table $0 2 funcref) (elem (i32.const 0) $null $call-optional/opt|trampoline) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $call-optional/optIndirect (mut i32) (i32.const 1)) - (global $HEAP_BASE i32 (i32.const 44)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 44)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -25,7 +25,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -43,10 +43,10 @@ local.get $2 call $call-optional/opt ) - (func $start (; 3 ;) (type $_) + (func $start:call-optional (; 3 ;) (type $_) block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 0 i32.const 0 @@ -65,7 +65,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 4 i32.const 0 @@ -99,7 +99,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 0 i32.const 0 @@ -119,7 +119,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 4 i32.const 0 @@ -139,7 +139,7 @@ end block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 4 i32.const 5 @@ -158,6 +158,9 @@ unreachable end ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:call-optional + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/call-super.untouched.wat b/tests/compiler/call-super.untouched.wat index 02798dffe1..9f16a9ac45 100644 --- a/tests/compiler/call-super.untouched.wat +++ b/tests/compiler/call-super.untouched.wat @@ -7,17 +7,25 @@ (data (i32.const 8) "\0d\00\00\00c\00a\00l\00l\00-\00s\00u\00p\00e\00r\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -25,7 +33,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -42,9 +50,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -96,12 +104,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $call-super/A#constructor (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/A#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -129,7 +137,7 @@ end local.get $0 ) - (func $call-super/B#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/B#constructor (; 5 ;) (type $ii) (param $0 i32) (result i32) local.get $0 if (result i32) local.get $0 @@ -170,7 +178,7 @@ end local.get $0 ) - (func $call-super/test1 (; 5 ;) (type $_) + (func $call-super/test1 (; 6 ;) (type $_) (local $0 i32) i32.const 0 call $call-super/B#constructor @@ -202,7 +210,7 @@ unreachable end ) - (func $call-super/C#constructor (; 6 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/C#constructor (; 7 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -215,7 +223,7 @@ i32.store local.get $0 ) - (func $call-super/D#constructor (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/D#constructor (; 8 ;) (type $ii) (param $0 i32) (result i32) local.get $0 if (result i32) local.get $0 @@ -256,7 +264,7 @@ end local.get $0 ) - (func $call-super/test2 (; 8 ;) (type $_) + (func $call-super/test2 (; 9 ;) (type $_) (local $0 i32) i32.const 0 call $call-super/D#constructor @@ -288,7 +296,7 @@ unreachable end ) - (func $call-super/E#constructor (; 9 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/E#constructor (; 10 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -316,7 +324,7 @@ end local.get $0 ) - (func $call-super/F#constructor (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/F#constructor (; 11 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -332,7 +340,7 @@ i32.store offset=4 local.get $0 ) - (func $call-super/test3 (; 11 ;) (type $_) + (func $call-super/test3 (; 12 ;) (type $_) (local $0 i32) i32.const 0 call $call-super/F#constructor @@ -364,7 +372,7 @@ unreachable end ) - (func $call-super/G#constructor (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/G#constructor (; 13 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -377,7 +385,7 @@ i32.store local.get $0 ) - (func $call-super/H#constructor (; 13 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/H#constructor (; 14 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -393,7 +401,7 @@ i32.store offset=4 local.get $0 ) - (func $call-super/test4 (; 14 ;) (type $_) + (func $call-super/test4 (; 15 ;) (type $_) (local $0 i32) i32.const 0 call $call-super/H#constructor @@ -425,7 +433,7 @@ unreachable end ) - (func $call-super/I#constructor (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/I#constructor (; 16 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -438,7 +446,7 @@ i32.store local.get $0 ) - (func $call-super/J#constructor (; 16 ;) (type $ii) (param $0 i32) (result i32) + (func $call-super/J#constructor (; 17 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -454,7 +462,7 @@ i32.store offset=4 local.get $0 ) - (func $call-super/test5 (; 17 ;) (type $_) + (func $call-super/test5 (; 18 ;) (type $_) (local $0 i32) i32.const 0 call $call-super/J#constructor @@ -486,23 +494,17 @@ unreachable end ) - (func $start (; 18 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:call-super (; 19 ;) (type $_) + call $start:~lib/allocator/arena call $call-super/test1 call $call-super/test2 call $call-super/test3 call $call-super/test4 call $call-super/test5 ) - (func $null (; 19 ;) (type $_) + (func $start (; 20 ;) (type $_) + call $start:call-super + ) + (func $null (; 21 ;) (type $_) ) ) diff --git a/tests/compiler/class-extends.untouched.wat b/tests/compiler/class-extends.untouched.wat index 01d2539334..0a4451d5c9 100644 --- a/tests/compiler/class-extends.untouched.wat +++ b/tests/compiler/class-extends.untouched.wat @@ -4,7 +4,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $class-extends/test)) diff --git a/tests/compiler/class-overloading.untouched.wat b/tests/compiler/class-overloading.untouched.wat index 2f5a6a1882..92a33ee61a 100644 --- a/tests/compiler/class-overloading.untouched.wat +++ b/tests/compiler/class-overloading.untouched.wat @@ -4,7 +4,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $class-overloading/test)) @@ -16,10 +16,13 @@ local.get $0 call $class-overloading/Foo#baz ) - (func $start (; 2 ;) (type $_) + (func $start:class-overloading (; 2 ;) (type $_) i32.const 0 call $class-overloading/test ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:class-overloading + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/class-with-boolean-field.optimized.wat b/tests/compiler/class-with-boolean-field.optimized.wat deleted file mode 100644 index 66c4e1f21a..0000000000 --- a/tests/compiler/class-with-boolean-field.optimized.wat +++ /dev/null @@ -1,22 +0,0 @@ -(module - (type $i (func (result i32))) - (type $_ (func)) - (memory $0 0) - (table $0 1 funcref) - (elem (i32.const 0) $null) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "test" (func $class-with-boolean-field/test)) - (func $class-with-boolean-field/test (; 0 ;) (type $i) (result i32) - i32.const 0 - i32.const 1 - i32.store8 - i32.const 0 - i32.load8_u - i32.const 0 - i32.ne - ) - (func $null (; 1 ;) (type $_) - nop - ) -) diff --git a/tests/compiler/class-with-boolean-field.ts b/tests/compiler/class-with-boolean-field.ts deleted file mode 100644 index 57b7dbcda4..0000000000 --- a/tests/compiler/class-with-boolean-field.ts +++ /dev/null @@ -1,9 +0,0 @@ -class A { - boolValue: bool; -} - -export function test(): bool { - let a: A; - a.boolValue = true; - return a.boolValue; -} diff --git a/tests/compiler/class-with-boolean-field.untouched.wat b/tests/compiler/class-with-boolean-field.untouched.wat deleted file mode 100644 index ca516a5326..0000000000 --- a/tests/compiler/class-with-boolean-field.untouched.wat +++ /dev/null @@ -1,23 +0,0 @@ -(module - (type $i (func (result i32))) - (type $_ (func)) - (memory $0 0) - (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "test" (func $class-with-boolean-field/test)) - (func $class-with-boolean-field/test (; 0 ;) (type $i) (result i32) - (local $0 i32) - local.get $0 - i32.const 1 - i32.store8 - local.get $0 - i32.load8_u - i32.const 0 - i32.ne - ) - (func $null (; 1 ;) (type $_) - ) -) diff --git a/tests/compiler/class.optimized.wat b/tests/compiler/class.optimized.wat index f73adeb9e0..e958e77870 100644 --- a/tests/compiler/class.optimized.wat +++ b/tests/compiler/class.optimized.wat @@ -1,6 +1,6 @@ (module - (type $ii (func (param i32) (result i32))) (type $_ (func)) + (type $ii (func (param i32) (result i32))) (memory $0 1) (data (i32.const 8) "\08\00\00\00c\00l\00a\00s\00s\00.\00t\00s") (table $0 1 funcref) diff --git a/tests/compiler/class.untouched.wat b/tests/compiler/class.untouched.wat index c255e74275..0eed9dcb19 100644 --- a/tests/compiler/class.untouched.wat +++ b/tests/compiler/class.untouched.wat @@ -2,17 +2,17 @@ (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $fff (func (param f32 f32) (result f32))) + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ifff (func (param i32 f32 f32) (result f32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\08\00\00\00c\00l\00a\00s\00s\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $class/Animal.ONE (mut i32) (i32.const 1)) - (global $HEAP_BASE i32 (i32.const 28)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 28)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $class/test)) @@ -32,14 +32,38 @@ f32.convert_i32_s f32.add ) - (func $class/Animal#instanceAdd (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:class (; 3 ;) (type $_) + i32.const 4 + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $class/Animal.ONE + drop + i32.const 1 + i32.const 2 + call $class/Animal.add + drop + f32.const 1 + f32.const 2 + call $class/Animal.sub + drop + ) + (func $class/Animal#instanceAdd (; 4 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $1 local.get $2 i32.add global.get $class/Animal.ONE i32.add ) - (func $class/Animal#instanceSub (; 4 ;) (type $ifff) (param $0 i32) (param $1 f32) (param $2 f32) (result f32) + (func $class/Animal#instanceSub (; 5 ;) (type $ifff) (param $0 i32) (param $1 f32) (param $2 f32) (result f32) local.get $1 local.get $2 f32.sub @@ -47,7 +71,7 @@ f32.convert_i32_s f32.add ) - (func $class/test (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $class/test (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -92,30 +116,9 @@ local.set $2 local.get $2 ) - (func $start (; 6 ;) (type $_) - i32.const 4 - i32.const 4 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 8 - i32.const 13 - i32.const 0 - call $~lib/env/abort - unreachable - end - global.get $class/Animal.ONE - drop - i32.const 1 - i32.const 2 - call $class/Animal.add - drop - f32.const 1 - f32.const 2 - call $class/Animal.sub - drop + (func $start (; 7 ;) (type $_) + call $start:class ) - (func $null (; 7 ;) (type $_) + (func $null (; 8 ;) (type $_) ) ) diff --git a/tests/compiler/closure.untouched.wat b/tests/compiler/closure.untouched.wat index ec9d592b76..b39336cd4d 100644 --- a/tests/compiler/closure.untouched.wat +++ b/tests/compiler/closure.untouched.wat @@ -3,7 +3,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (func $null (; 0 ;) (type $_) diff --git a/tests/compiler/comma.optimized.wat b/tests/compiler/comma.optimized.wat index a1450d2224..c1b60c7771 100644 --- a/tests/compiler/comma.optimized.wat +++ b/tests/compiler/comma.optimized.wat @@ -11,7 +11,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:comma (; 1 ;) (type $_) (local $0 i32) global.get $comma/a local.tee $0 @@ -163,7 +163,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:comma + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/comma.untouched.wat b/tests/compiler/comma.untouched.wat index 0551cd35ae..d61b7756ca 100644 --- a/tests/compiler/comma.untouched.wat +++ b/tests/compiler/comma.untouched.wat @@ -8,11 +8,11 @@ (elem (i32.const 0) $null) (global $comma/a (mut i32) (i32.const 0)) (global $comma/b (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 28)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 28)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:comma (; 1 ;) (type $_) (local $0 i32) (local $1 i32) block @@ -204,6 +204,9 @@ drop end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:comma + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/std/constructor.optimized.wat b/tests/compiler/constructor.optimized.wat similarity index 55% rename from tests/compiler/std/constructor.optimized.wat rename to tests/compiler/constructor.optimized.wat index e8923b85c7..aa90bc5be4 100644 --- a/tests/compiler/std/constructor.optimized.wat +++ b/tests/compiler/constructor.optimized.wat @@ -1,23 +1,23 @@ (module - (type $ii (func (param i32) (result i32))) (type $_ (func)) + (type $ii (func (param i32) (result i32))) (type $FUNCSIG$i (func (result i32))) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $std/constructor/emptyCtor (mut i32) (i32.const 0)) - (global $std/constructor/emptyCtorWithFieldInit (mut i32) (i32.const 0)) - (global $std/constructor/emptyCtorWithFieldNoInit (mut i32) (i32.const 0)) - (global $std/constructor/none (mut i32) (i32.const 0)) - (global $std/constructor/justFieldInit (mut i32) (i32.const 0)) - (global $std/constructor/justFieldNoInit (mut i32) (i32.const 0)) - (global $std/constructor/ctorReturns (mut i32) (i32.const 0)) - (global $std/constructor/b (mut i32) (i32.const 1)) - (global $std/constructor/ctorConditionallyReturns (mut i32) (i32.const 0)) - (global $std/constructor/ctorAllocates (mut i32) (i32.const 0)) - (global $std/constructor/ctorConditionallyAllocates (mut i32) (i32.const 0)) + (global $constructor/emptyCtor (mut i32) (i32.const 0)) + (global $constructor/emptyCtorWithFieldInit (mut i32) (i32.const 0)) + (global $constructor/emptyCtorWithFieldNoInit (mut i32) (i32.const 0)) + (global $constructor/none (mut i32) (i32.const 0)) + (global $constructor/justFieldInit (mut i32) (i32.const 0)) + (global $constructor/justFieldNoInit (mut i32) (i32.const 0)) + (global $constructor/ctorReturns (mut i32) (i32.const 0)) + (global $constructor/b (mut i32) (i32.const 1)) + (global $constructor/ctorConditionallyReturns (mut i32) (i32.const 0)) + (global $constructor/ctorAllocates (mut i32) (i32.const 0)) + (global $constructor/ctorConditionallyAllocates (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -83,7 +83,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $std/constructor/EmptyCtorWithFieldInit#constructor (; 1 ;) (type $FUNCSIG$i) (result i32) + (func $constructor/EmptyCtorWithFieldInit#constructor (; 1 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) i32.const 4 call $~lib/allocator/arena/__memory_allocate @@ -92,7 +92,7 @@ i32.store local.get $0 ) - (func $std/constructor/EmptyCtorWithFieldNoInit#constructor (; 2 ;) (type $FUNCSIG$i) (result i32) + (func $constructor/EmptyCtorWithFieldNoInit#constructor (; 2 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) i32.const 4 call $~lib/allocator/arena/__memory_allocate @@ -101,7 +101,7 @@ i32.store local.get $0 ) - (func $start (; 3 ;) (type $_) + (func $start:constructor (; 3 ;) (type $_) (local $0 i32) i32.const 8 global.set $~lib/allocator/arena/startOffset @@ -109,37 +109,37 @@ global.set $~lib/allocator/arena/offset i32.const 0 call $~lib/allocator/arena/__memory_allocate - global.set $std/constructor/emptyCtor - call $std/constructor/EmptyCtorWithFieldInit#constructor - global.set $std/constructor/emptyCtorWithFieldInit - call $std/constructor/EmptyCtorWithFieldNoInit#constructor - global.set $std/constructor/emptyCtorWithFieldNoInit + global.set $constructor/emptyCtor + call $constructor/EmptyCtorWithFieldInit#constructor + global.set $constructor/emptyCtorWithFieldInit + call $constructor/EmptyCtorWithFieldNoInit#constructor + global.set $constructor/emptyCtorWithFieldNoInit i32.const 0 call $~lib/allocator/arena/__memory_allocate - global.set $std/constructor/none - call $std/constructor/EmptyCtorWithFieldInit#constructor - global.set $std/constructor/justFieldInit - call $std/constructor/EmptyCtorWithFieldNoInit#constructor - global.set $std/constructor/justFieldNoInit + global.set $constructor/none + call $constructor/EmptyCtorWithFieldInit#constructor + global.set $constructor/justFieldInit + call $constructor/EmptyCtorWithFieldNoInit#constructor + global.set $constructor/justFieldNoInit i32.const 0 call $~lib/allocator/arena/__memory_allocate - global.set $std/constructor/ctorReturns - block $__inlined_func$std/constructor/CtorConditionallyReturns#constructor (result i32) - global.get $std/constructor/b + global.set $constructor/ctorReturns + block $__inlined_func$constructor/CtorConditionallyReturns#constructor (result i32) + global.get $constructor/b if i32.const 0 call $~lib/allocator/arena/__memory_allocate - br $__inlined_func$std/constructor/CtorConditionallyReturns#constructor + br $__inlined_func$constructor/CtorConditionallyReturns#constructor end i32.const 0 call $~lib/allocator/arena/__memory_allocate end - global.set $std/constructor/ctorConditionallyReturns + global.set $constructor/ctorConditionallyReturns i32.const 0 call $~lib/allocator/arena/__memory_allocate - global.set $std/constructor/ctorAllocates + global.set $constructor/ctorAllocates block (result i32) - global.get $std/constructor/b + global.get $constructor/b if i32.const 0 call $~lib/allocator/arena/__memory_allocate @@ -154,9 +154,12 @@ local.set $0 end local.get $0 - global.set $std/constructor/ctorConditionallyAllocates + global.set $constructor/ctorConditionallyAllocates + ) + (func $start (; 4 ;) (type $_) + call $start:constructor ) - (func $null (; 4 ;) (type $_) + (func $null (; 5 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/constructor.ts b/tests/compiler/constructor.ts similarity index 100% rename from tests/compiler/std/constructor.ts rename to tests/compiler/constructor.ts diff --git a/tests/compiler/std/constructor.untouched.wat b/tests/compiler/constructor.untouched.wat similarity index 52% rename from tests/compiler/std/constructor.untouched.wat rename to tests/compiler/constructor.untouched.wat index 46a5d9675c..7a643d6097 100644 --- a/tests/compiler/std/constructor.untouched.wat +++ b/tests/compiler/constructor.untouched.wat @@ -1,31 +1,39 @@ (module - (type $ii (func (param i32) (result i32))) (type $_ (func)) + (type $ii (func (param i32) (result i32))) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $std/constructor/emptyCtor (mut i32) (i32.const 0)) - (global $std/constructor/emptyCtorWithFieldInit (mut i32) (i32.const 0)) - (global $std/constructor/emptyCtorWithFieldNoInit (mut i32) (i32.const 0)) - (global $std/constructor/none (mut i32) (i32.const 0)) - (global $std/constructor/justFieldInit (mut i32) (i32.const 0)) - (global $std/constructor/justFieldNoInit (mut i32) (i32.const 0)) - (global $std/constructor/ctorReturns (mut i32) (i32.const 0)) - (global $std/constructor/b (mut i32) (i32.const 1)) - (global $std/constructor/ctorConditionallyReturns (mut i32) (i32.const 0)) - (global $std/constructor/ctorAllocates (mut i32) (i32.const 0)) - (global $std/constructor/ctorConditionallyAllocates (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $constructor/emptyCtor (mut i32) (i32.const 0)) + (global $constructor/emptyCtorWithFieldInit (mut i32) (i32.const 0)) + (global $constructor/emptyCtorWithFieldNoInit (mut i32) (i32.const 0)) + (global $constructor/none (mut i32) (i32.const 0)) + (global $constructor/justFieldInit (mut i32) (i32.const 0)) + (global $constructor/justFieldNoInit (mut i32) (i32.const 0)) + (global $constructor/ctorReturns (mut i32) (i32.const 0)) + (global $constructor/b (mut i32) (i32.const 1)) + (global $constructor/ctorConditionallyReturns (mut i32) (i32.const 0)) + (global $constructor/ctorAllocates (mut i32) (i32.const 0)) + (global $constructor/ctorConditionallyAllocates (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -33,7 +41,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -50,9 +58,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -104,12 +112,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $std/constructor/EmptyCtor#constructor (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/EmptyCtor#constructor (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -119,7 +127,7 @@ end local.get $0 ) - (func $std/constructor/EmptyCtorWithFieldInit#constructor (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/EmptyCtorWithFieldInit#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -132,7 +140,7 @@ i32.store local.get $0 ) - (func $std/constructor/EmptyCtorWithFieldNoInit#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/EmptyCtorWithFieldNoInit#constructor (; 5 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -145,7 +153,7 @@ i32.store local.get $0 ) - (func $std/constructor/None#constructor (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/None#constructor (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -155,7 +163,7 @@ end local.get $0 ) - (func $std/constructor/JustFieldInit#constructor (; 6 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/JustFieldInit#constructor (; 7 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -168,7 +176,7 @@ i32.store local.get $0 ) - (func $std/constructor/JustFieldNoInit#constructor (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/JustFieldNoInit#constructor (; 8 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -181,7 +189,7 @@ i32.store local.get $0 ) - (func $std/constructor/CtorReturns#constructor (; 8 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/CtorReturns#constructor (; 9 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) block $~lib/memory/memory.allocate|inlined.0 (result i32) i32.const 0 @@ -191,9 +199,9 @@ br $~lib/memory/memory.allocate|inlined.0 end ) - (func $std/constructor/CtorConditionallyReturns#constructor (; 9 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/CtorConditionallyReturns#constructor (; 10 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $std/constructor/b + global.get $constructor/b if block $~lib/memory/memory.allocate|inlined.1 (result i32) i32.const 0 @@ -213,7 +221,7 @@ end local.get $0 ) - (func $std/constructor/CtorAllocates#constructor (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $constructor/CtorAllocates#constructor (; 11 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -227,8 +235,8 @@ drop local.get $0 ) - (func $std/constructor/CtorConditionallyAllocates#constructor (; 11 ;) (type $ii) (param $0 i32) (result i32) - global.get $std/constructor/b + (func $constructor/CtorConditionallyAllocates#constructor (; 12 ;) (type $ii) (param $0 i32) (result i32) + global.get $constructor/b if block (result i32) local.get $0 @@ -251,48 +259,42 @@ end local.get $0 ) - (func $start (; 12 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:constructor (; 13 ;) (type $_) + call $start:~lib/allocator/arena i32.const 0 - call $std/constructor/EmptyCtor#constructor - global.set $std/constructor/emptyCtor + call $constructor/EmptyCtor#constructor + global.set $constructor/emptyCtor i32.const 0 - call $std/constructor/EmptyCtorWithFieldInit#constructor - global.set $std/constructor/emptyCtorWithFieldInit + call $constructor/EmptyCtorWithFieldInit#constructor + global.set $constructor/emptyCtorWithFieldInit i32.const 0 - call $std/constructor/EmptyCtorWithFieldNoInit#constructor - global.set $std/constructor/emptyCtorWithFieldNoInit + call $constructor/EmptyCtorWithFieldNoInit#constructor + global.set $constructor/emptyCtorWithFieldNoInit i32.const 0 - call $std/constructor/None#constructor - global.set $std/constructor/none + call $constructor/None#constructor + global.set $constructor/none i32.const 0 - call $std/constructor/JustFieldInit#constructor - global.set $std/constructor/justFieldInit + call $constructor/JustFieldInit#constructor + global.set $constructor/justFieldInit i32.const 0 - call $std/constructor/JustFieldNoInit#constructor - global.set $std/constructor/justFieldNoInit + call $constructor/JustFieldNoInit#constructor + global.set $constructor/justFieldNoInit i32.const 0 - call $std/constructor/CtorReturns#constructor - global.set $std/constructor/ctorReturns + call $constructor/CtorReturns#constructor + global.set $constructor/ctorReturns i32.const 0 - call $std/constructor/CtorConditionallyReturns#constructor - global.set $std/constructor/ctorConditionallyReturns + call $constructor/CtorConditionallyReturns#constructor + global.set $constructor/ctorConditionallyReturns i32.const 0 - call $std/constructor/CtorAllocates#constructor - global.set $std/constructor/ctorAllocates + call $constructor/CtorAllocates#constructor + global.set $constructor/ctorAllocates i32.const 0 - call $std/constructor/CtorConditionallyAllocates#constructor - global.set $std/constructor/ctorConditionallyAllocates + call $constructor/CtorConditionallyAllocates#constructor + global.set $constructor/ctorConditionallyAllocates + ) + (func $start (; 14 ;) (type $_) + call $start:constructor ) - (func $null (; 13 ;) (type $_) + (func $null (; 15 ;) (type $_) ) ) diff --git a/tests/compiler/declare.optimized.wat b/tests/compiler/declare.optimized.wat index fcd15e50d5..aa13968b84 100644 --- a/tests/compiler/declare.optimized.wat +++ b/tests/compiler/declare.optimized.wat @@ -13,7 +13,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 3 ;) (type $_) + (func $start:declare (; 3 ;) (type $_) call $declare/externalFunction global.get $declare/externalConstant i32.const 1 @@ -39,7 +39,10 @@ unreachable end ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:declare + ) + (func $null (; 5 ;) (type $_) nop ) ) diff --git a/tests/compiler/declare.untouched.wat b/tests/compiler/declare.untouched.wat index b152bcab18..3b837d9d1a 100644 --- a/tests/compiler/declare.untouched.wat +++ b/tests/compiler/declare.untouched.wat @@ -10,11 +10,11 @@ (data (i32.const 8) "\n\00\00\00d\00e\00c\00l\00a\00r\00e\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 3 ;) (type $_) + (func $start:declare (; 3 ;) (type $_) call $declare/externalFunction global.get $declare/externalConstant i32.const 1 @@ -42,6 +42,9 @@ unreachable end ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:declare + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/do.optimized.wat b/tests/compiler/do.optimized.wat index 6f2d55aa44..4caddb8c1a 100644 --- a/tests/compiler/do.optimized.wat +++ b/tests/compiler/do.optimized.wat @@ -12,7 +12,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:do (; 1 ;) (type $_) (local $0 i32) loop $continue|0 global.get $do/n @@ -148,7 +148,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:do + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/do.untouched.wat b/tests/compiler/do.untouched.wat index d7200e948e..30b696afb1 100644 --- a/tests/compiler/do.untouched.wat +++ b/tests/compiler/do.untouched.wat @@ -9,11 +9,11 @@ (global $do/n (mut i32) (i32.const 10)) (global $do/m (mut i32) (i32.const 0)) (global $do/o (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 24)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 24)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:do (; 1 ;) (type $_) (local $0 i32) block $break|0 loop $continue|0 @@ -180,6 +180,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:do + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/empty.untouched.wat b/tests/compiler/empty.untouched.wat index ec9d592b76..b39336cd4d 100644 --- a/tests/compiler/empty.untouched.wat +++ b/tests/compiler/empty.untouched.wat @@ -3,7 +3,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (func $null (; 0 ;) (type $_) diff --git a/tests/compiler/enum.untouched.wat b/tests/compiler/enum.untouched.wat index 5e961a3f21..47134e6233 100644 --- a/tests/compiler/enum.untouched.wat +++ b/tests/compiler/enum.untouched.wat @@ -21,7 +21,7 @@ (global $enum/SelfReference.ZERO i32 (i32.const 0)) (global $enum/SelfReference.ONE i32 (i32.const 1)) (global $enum/enumType (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "Implicit.ZERO" (global $enum/Implicit.ZERO)) @@ -42,7 +42,7 @@ (func $enum/getZero (; 0 ;) (type $i) (result i32) i32.const 0 ) - (func $start (; 1 ;) (type $_) + (func $start:enum (; 1 ;) (type $_) call $enum/getZero global.set $enum/NonConstant.ZERO call $enum/getZero @@ -54,6 +54,9 @@ global.get $enum/NonConstant.ONE drop ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:enum + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/export.optimized.wat b/tests/compiler/export.optimized.wat index bc012a12cc..dd8613e436 100644 --- a/tests/compiler/export.optimized.wat +++ b/tests/compiler/export.optimized.wat @@ -3,7 +3,7 @@ (type $_ (func)) (memory $0 0) (table $0 1 funcref) - (elem (i32.const 0) $export/ns.two) + (elem (i32.const 0) $export/ns.one) (global $export/a i32 (i32.const 1)) (global $export/b i32 (i32.const 2)) (global $export/c i32 (i32.const 3)) @@ -15,7 +15,7 @@ (export "a" (global $export/a)) (export "b" (global $export/b)) (export "renamed_c" (global $export/c)) - (export "ns.two" (func $export/ns.two)) + (export "ns.two" (func $export/ns.one)) (func $export/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 @@ -31,7 +31,7 @@ local.get $1 i32.mul ) - (func $export/ns.two (; 3 ;) (type $_) + (func $export/ns.one (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/export.untouched.wat b/tests/compiler/export.untouched.wat index ceb0812377..3dcf132156 100644 --- a/tests/compiler/export.untouched.wat +++ b/tests/compiler/export.untouched.wat @@ -7,7 +7,7 @@ (global $export/a i32 (i32.const 1)) (global $export/b i32 (i32.const 2)) (global $export/c i32 (i32.const 3)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "add" (func $export/add)) @@ -32,9 +32,12 @@ local.get $1 i32.mul ) - (func $export/ns.two (; 3 ;) (type $_) + (func $export/ns.one (; 3 ;) (type $_) nop ) - (func $null (; 4 ;) (type $_) + (func $export/ns.two (; 4 ;) (type $_) + nop + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/exports.optimized.wat b/tests/compiler/exports.optimized.wat index b75b466166..c63bb4b2d1 100644 --- a/tests/compiler/exports.optimized.wat +++ b/tests/compiler/exports.optimized.wat @@ -1,10 +1,10 @@ (module + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $i (func (result i32))) (type $ii (func (param i32) (result i32))) (type $ii_ (func (param i32 i32))) (type $i_ (func (param i32))) - (type $_ (func)) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) @@ -17,33 +17,33 @@ (global $exports/Car.TIRES i32 (i32.const 4)) (global $exports/vehicles.Car.TIRES i32 (i32.const 4)) (global $exports/outer.inner.a i32 (i32.const 42)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "add" (func $exports/add)) - (export "_setargc" (func $~setargc)) + (export "_setargc" (func $~lib/setargc)) (export "subOpt" (func $exports/subOpt|trampoline)) (export "math.sub" (func $exports/subOpt)) (export "Animal.CAT" (global $exports/Animal.CAT)) (export "Animal.DOG" (global $exports/Animal.DOG)) (export "animals.Animal.CAT" (global $exports/animals.Animal.CAT)) (export "animals.Animal.DOG" (global $exports/animals.Animal.DOG)) - (export "Car.TIRES" (global $exports/Car.TIRES)) - (export "Car.getNumTires" (func $exports/Car.getNumTires)) - (export "Car#constructor" (func $exports/Car#constructor|trampoline)) (export "Car#get:doors" (func $exports/Car#get:numDoors)) (export "Car#set:doors" (func $exports/Car#set:numDoors)) + (export "Car#constructor" (func $exports/Car#constructor|trampoline)) (export "Car#get:numDoors" (func $exports/Car#get:numDoors)) (export "Car#set:numDoors" (func $exports/Car#set:numDoors)) (export "Car#openDoors" (func $exports/Car#openDoors)) - (export "vehicles.Car.TIRES" (global $exports/vehicles.Car.TIRES)) - (export "vehicles.Car.getNumTires" (func $exports/Car.getNumTires)) - (export "vehicles.Car#constructor" (func $exports/Car#constructor|trampoline)) + (export "Car.TIRES" (global $exports/Car.TIRES)) + (export "Car.getNumTires" (func $exports/Car.getNumTires)) (export "vehicles.Car#get:doors" (func $exports/Car#get:numDoors)) (export "vehicles.Car#set:doors" (func $exports/Car#set:numDoors)) + (export "vehicles.Car#constructor" (func $exports/Car#constructor|trampoline)) (export "vehicles.Car#get:numDoors" (func $exports/Car#get:numDoors)) (export "vehicles.Car#set:numDoors" (func $exports/Car#set:numDoors)) (export "vehicles.Car#openDoors" (func $exports/Car#openDoors)) + (export "vehicles.Car.TIRES" (global $exports/vehicles.Car.TIRES)) + (export "vehicles.Car.getNumTires" (func $exports/Car.getNumTires)) (export "outer.inner.a" (global $exports/outer.inner.a)) (start $start) (func $exports/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) @@ -146,7 +146,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -160,15 +160,15 @@ local.get $1 i32.sub ) - (func $~setargc (; 10 ;) (type $i_) (param $0 i32) + (func $~lib/setargc (; 10 ;) (type $i_) (param $0 i32) local.get $0 - global.set $~argc + global.set $~lib/argc ) (func $exports/Car#constructor|trampoline (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable diff --git a/tests/compiler/exports.untouched.wat b/tests/compiler/exports.untouched.wat index ddf5c5beee..b9f45d1e6c 100644 --- a/tests/compiler/exports.untouched.wat +++ b/tests/compiler/exports.untouched.wat @@ -1,17 +1,13 @@ (module + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $i (func (result i32))) (type $ii (func (param i32) (result i32))) (type $ii_ (func (param i32 i32))) (type $i_ (func (param i32))) - (type $_ (func)) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $exports/Animal.CAT i32 (i32.const 0)) @@ -21,55 +17,70 @@ (global $exports/Car.TIRES i32 (i32.const 4)) (global $exports/vehicles.Car.TIRES i32 (i32.const 4)) (global $exports/outer.inner.a i32 (i32.const 42)) - (global $HEAP_BASE i32 (i32.const 8)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) + (global $~lib/argc (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "add" (func $exports/add)) - (export "_setargc" (func $~setargc)) + (export "_setargc" (func $~lib/setargc)) (export "subOpt" (func $exports/subOpt|trampoline)) (export "math.sub" (func $exports/math.sub)) (export "Animal.CAT" (global $exports/Animal.CAT)) (export "Animal.DOG" (global $exports/Animal.DOG)) (export "animals.Animal.CAT" (global $exports/animals.Animal.CAT)) (export "animals.Animal.DOG" (global $exports/animals.Animal.DOG)) - (export "Car.TIRES" (global $exports/Car.TIRES)) - (export "Car.getNumTires" (func $exports/Car.getNumTires)) - (export "Car#constructor" (func $exports/Car#constructor|trampoline)) (export "Car#get:doors" (func $Car#get:doors)) (export "Car#set:doors" (func $Car#set:doors)) + (export "Car#constructor" (func $exports/Car#constructor|trampoline)) (export "Car#get:numDoors" (func $exports/Car#get:numDoors)) (export "Car#set:numDoors" (func $exports/Car#set:numDoors)) (export "Car#openDoors" (func $exports/Car#openDoors)) - (export "vehicles.Car.TIRES" (global $exports/vehicles.Car.TIRES)) - (export "vehicles.Car.getNumTires" (func $exports/vehicles.Car.getNumTires)) - (export "vehicles.Car#constructor" (func $exports/vehicles.Car#constructor|trampoline)) + (export "Car.TIRES" (global $exports/Car.TIRES)) + (export "Car.getNumTires" (func $exports/Car.getNumTires)) (export "vehicles.Car#get:doors" (func $vehicles.Car#get:doors)) (export "vehicles.Car#set:doors" (func $vehicles.Car#set:doors)) + (export "vehicles.Car#constructor" (func $exports/vehicles.Car#constructor|trampoline)) (export "vehicles.Car#get:numDoors" (func $exports/vehicles.Car#get:numDoors)) (export "vehicles.Car#set:numDoors" (func $exports/vehicles.Car#set:numDoors)) (export "vehicles.Car#openDoors" (func $exports/vehicles.Car#openDoors)) + (export "vehicles.Car.TIRES" (global $exports/vehicles.Car.TIRES)) + (export "vehicles.Car.getNumTires" (func $exports/vehicles.Car.getNumTires)) (export "outer.inner.a" (global $exports/outer.inner.a)) (start $start) - (func $exports/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $start:exports (; 1 ;) (type $_) + call $start:~lib/allocator/arena + ) + (func $exports/add (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $exports/subOpt (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/subOpt (; 3 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.sub ) - (func $exports/math.sub (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/math.sub (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.sub ) - (func $exports/Car.getNumTires (; 3 ;) (type $i) (result i32) + (func $exports/Car.getNumTires (; 5 ;) (type $i) (result i32) global.get $exports/Car.TIRES ) - (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -77,7 +88,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -94,9 +105,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -148,12 +159,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 7 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $exports/Car#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/Car#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -171,22 +182,22 @@ i32.store local.get $0 ) - (func $exports/Car#get:numDoors (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $exports/Car#get:numDoors (; 9 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load ) - (func $exports/Car#set:numDoors (; 8 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $exports/Car#set:numDoors (; 10 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 i32.store ) - (func $exports/Car#openDoors (; 9 ;) (type $i_) (param $0 i32) + (func $exports/Car#openDoors (; 11 ;) (type $i_) (param $0 i32) nop ) - (func $exports/vehicles.Car.getNumTires (; 10 ;) (type $i) (result i32) + (func $exports/vehicles.Car.getNumTires (; 12 ;) (type $i) (result i32) global.get $exports/vehicles.Car.TIRES ) - (func $exports/vehicles.Car#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/vehicles.Car#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -204,37 +215,28 @@ i32.store local.get $0 ) - (func $exports/vehicles.Car#get:numDoors (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $exports/vehicles.Car#get:numDoors (; 14 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load ) - (func $exports/vehicles.Car#set:numDoors (; 13 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $exports/vehicles.Car#set:numDoors (; 15 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 i32.store ) - (func $exports/vehicles.Car#openDoors (; 14 ;) (type $i_) (param $0 i32) + (func $exports/vehicles.Car#openDoors (; 16 ;) (type $i_) (param $0 i32) nop ) - (func $start (; 15 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start (; 17 ;) (type $_) + call $start:exports ) - (func $null (; 16 ;) (type $_) + (func $null (; 18 ;) (type $_) ) - (func $exports/subOpt|trampoline (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/subOpt|trampoline (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -248,15 +250,24 @@ local.get $1 call $exports/subOpt ) - (func $~setargc (; 18 ;) (type $i_) (param $0 i32) + (func $~lib/setargc (; 20 ;) (type $i_) (param $0 i32) + local.get $0 + global.set $~lib/argc + ) + (func $Car#get:doors (; 21 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.load + ) + (func $Car#set:doors (; 22 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 - global.set $~argc + local.get $1 + i32.store ) - (func $exports/Car#constructor|trampoline (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/Car#constructor|trampoline (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -268,20 +279,20 @@ local.get $1 call $exports/Car#constructor ) - (func $Car#get:doors (; 20 ;) (type $ii) (param $0 i32) (result i32) + (func $vehicles.Car#get:doors (; 24 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load ) - (func $Car#set:doors (; 21 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $vehicles.Car#set:doors (; 25 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 i32.store ) - (func $exports/vehicles.Car#constructor|trampoline (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/vehicles.Car#constructor|trampoline (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -293,13 +304,4 @@ local.get $1 call $exports/vehicles.Car#constructor ) - (func $vehicles.Car#get:doors (; 23 ;) (type $ii) (param $0 i32) (result i32) - local.get $0 - i32.load - ) - (func $vehicles.Car#set:doors (; 24 ;) (type $ii_) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - i32.store - ) ) diff --git a/tests/compiler/external.optimized.wat b/tests/compiler/external.optimized.wat index 1f7a59ad03..b8084aae84 100644 --- a/tests/compiler/external.optimized.wat +++ b/tests/compiler/external.optimized.wat @@ -10,8 +10,8 @@ (elem (i32.const 0) $null) (export "memory" (memory $0)) (export "table" (table $0)) - (export "foo.bar" (func $external/foo.bar)) (export "foo" (func $external/foo)) + (export "foo.bar" (func $external/foo.bar)) (export "two" (func $external/two)) (export "three" (func $external/three)) (export "var_" (global $external/var_)) diff --git a/tests/compiler/external.untouched.wat b/tests/compiler/external.untouched.wat index df5cb183d3..ef5dffafad 100644 --- a/tests/compiler/external.untouched.wat +++ b/tests/compiler/external.untouched.wat @@ -8,11 +8,11 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) - (export "foo.bar" (func $external/foo.bar)) (export "foo" (func $external/foo)) + (export "foo.bar" (func $external/foo.bar)) (export "two" (func $external/two)) (export "three" (func $external/three)) (export "var_" (global $external/var_)) diff --git a/tests/compiler/for.optimized.wat b/tests/compiler/for.optimized.wat index a7ec998cba..d2037ac1e4 100644 --- a/tests/compiler/for.optimized.wat +++ b/tests/compiler/for.optimized.wat @@ -10,7 +10,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:for (; 1 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -158,7 +158,10 @@ end end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:for + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/for.untouched.wat b/tests/compiler/for.untouched.wat index 27236209b5..b82d129026 100644 --- a/tests/compiler/for.untouched.wat +++ b/tests/compiler/for.untouched.wat @@ -7,11 +7,11 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $for/i (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 24)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 24)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:for (; 1 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -215,6 +215,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:for + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/function-expression.optimized.wat b/tests/compiler/function-expression.optimized.wat index 5ca87683ea..c29402f3e0 100644 --- a/tests/compiler/function-expression.optimized.wat +++ b/tests/compiler/function-expression.optimized.wat @@ -7,27 +7,27 @@ (memory $0 1) (data (i32.const 8) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s") (table $0 5 funcref) - (elem (i32.const 0) $start~someName|3 $start~anonymous|1 $start~anonymous|1 $start~someName|3 $start~anonymous|4) + (elem (i32.const 0) $start:function-expression~someName|3 $start:function-expression~anonymous|1 $start:function-expression~anonymous|1 $start:function-expression~someName|3 $start:function-expression~anonymous|4) (global $function-expression/f1 (mut i32) (i32.const 1)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $function-expression/f2 (mut i32) (i32.const 2)) (global $function-expression/f3 (mut i32) (i32.const 3)) (global $function-expression/f4 (mut i32) (i32.const 4)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start~anonymous|1 (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:function-expression~anonymous|1 (; 1 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $start~someName|3 (; 2 ;) (type $_) + (func $start:function-expression~someName|3 (; 2 ;) (type $_) nop ) - (func $start~anonymous|4 (; 3 ;) (type $i) (result i32) + (func $start:function-expression~anonymous|4 (; 3 ;) (type $i) (result i32) i32.const 1 ) - (func $start (; 4 ;) (type $_) + (func $start:function-expression (; 4 ;) (type $_) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1 global.get $function-expression/f1 call_indirect (type $ii) @@ -42,7 +42,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 2 global.get $function-expression/f2 call_indirect (type $ii) @@ -57,11 +57,11 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $function-expression/f3 call_indirect (type $_) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $function-expression/f4 call_indirect (type $i) i32.const 1 @@ -75,4 +75,7 @@ unreachable end ) + (func $start (; 5 ;) (type $_) + call $start:function-expression + ) ) diff --git a/tests/compiler/function-expression.untouched.wat b/tests/compiler/function-expression.untouched.wat index 7b1dab43ce..e442877a89 100644 --- a/tests/compiler/function-expression.untouched.wat +++ b/tests/compiler/function-expression.untouched.wat @@ -7,32 +7,32 @@ (memory $0 1) (data (i32.const 8) "\16\00\00\00f\00u\00n\00c\00t\00i\00o\00n\00-\00e\00x\00p\00r\00e\00s\00s\00i\00o\00n\00.\00t\00s\00") (table $0 5 funcref) - (elem (i32.const 0) $null $start~anonymous|1 $start~anonymous|2 $start~someName|3 $start~anonymous|4) + (elem (i32.const 0) $null $start:function-expression~anonymous|1 $start:function-expression~anonymous|2 $start:function-expression~someName|3 $start:function-expression~anonymous|4) (global $function-expression/f1 (mut i32) (i32.const 1)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $function-expression/f2 (mut i32) (i32.const 2)) (global $function-expression/f3 (mut i32) (i32.const 3)) (global $function-expression/f4 (mut i32) (i32.const 4)) - (global $HEAP_BASE i32 (i32.const 56)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 56)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start~anonymous|1 (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:function-expression~anonymous|1 (; 1 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $start~anonymous|2 (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $start:function-expression~anonymous|2 (; 2 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $start~someName|3 (; 3 ;) (type $_) + (func $start:function-expression~someName|3 (; 3 ;) (type $_) nop ) - (func $start~anonymous|4 (; 4 ;) (type $i) (result i32) + (func $start:function-expression~anonymous|4 (; 4 ;) (type $i) (result i32) i32.const 1 ) - (func $start (; 5 ;) (type $_) + (func $start:function-expression (; 5 ;) (type $_) block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1 global.get $function-expression/f1 call_indirect (type $ii) @@ -50,7 +50,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 2 global.get $function-expression/f2 call_indirect (type $ii) @@ -68,13 +68,13 @@ end block i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $function-expression/f3 call_indirect (type $_) end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $function-expression/f4 call_indirect (type $i) end @@ -90,6 +90,9 @@ unreachable end ) - (func $null (; 6 ;) (type $_) + (func $start (; 6 ;) (type $_) + call $start:function-expression + ) + (func $null (; 7 ;) (type $_) ) ) diff --git a/tests/compiler/function-types.optimized.wat b/tests/compiler/function-types.optimized.wat index 45bd2aa832..27b777e3e1 100644 --- a/tests/compiler/function-types.optimized.wat +++ b/tests/compiler/function-types.optimized.wat @@ -10,7 +10,7 @@ (table $0 5 funcref) (elem (i32.const 0) $null $function-types/makeAdder~anonymous|1 $function-types/makeAdder~anonymous|2 $function-types/makeAdder~anonymous|3 $function-types/makeAdder~anonymous|1) (global $function-types/i32Adder (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $function-types/i64Adder (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) @@ -30,12 +30,12 @@ local.get $1 f64.add ) - (func $start (; 4 ;) (type $_) + (func $start:function-types (; 4 ;) (type $_) (local $0 i32) i32.const 1 global.set $function-types/i32Adder i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 1 i32.const 2 global.get $function-types/i32Adder @@ -53,7 +53,7 @@ i32.const 2 global.set $function-types/i64Adder i32.const 2 - global.set $~argc + global.set $~lib/argc i64.const 10 i64.const 20 global.get $function-types/i64Adder @@ -69,7 +69,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc f64.const 1.5 f64.const 2.5 i32.const 3 @@ -85,7 +85,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 2 i32.const 3 global.get $function-types/i32Adder @@ -101,7 +101,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 3 i32.const 4 i32.const 1 @@ -117,7 +117,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 4 i32.const 5 i32.const 4 @@ -133,11 +133,11 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 2 i32.sub br_table $0of1 $1of1 $outOfRange @@ -148,7 +148,7 @@ local.set $0 end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 1 i32.const 2 local.get $0 @@ -164,7 +164,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 1 i32.const 2 i32.const 1 @@ -180,7 +180,10 @@ unreachable end ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:function-types + ) + (func $null (; 6 ;) (type $_) nop ) ) diff --git a/tests/compiler/function-types.untouched.wat b/tests/compiler/function-types.untouched.wat index 31af343924..54f4977aa4 100644 --- a/tests/compiler/function-types.untouched.wat +++ b/tests/compiler/function-types.untouched.wat @@ -12,9 +12,9 @@ (table $0 5 funcref) (elem (i32.const 0) $null $function-types/makeAdder~anonymous|1 $function-types/makeAdder~anonymous|2 $function-types/makeAdder~anonymous|3 $function-types/addI32) (global $function-types/i32Adder (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $function-types/i64Adder (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 48)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 48)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -44,7 +44,7 @@ ) (func $function-types/doAddWithFn (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $1 local.get $2 @@ -52,7 +52,7 @@ ) (func $function-types/doAdd (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $1 call $function-types/makeAdder @@ -65,7 +65,7 @@ ) (func $function-types/makeAndAdd (; 10 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $1 local.get $2 @@ -75,7 +75,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 2 i32.sub br_table $0of1 $1of1 $outOfRange @@ -90,13 +90,12 @@ local.get $2 call $function-types/makeAndAdd ) - (func $start (; 12 ;) (type $_) - nop + (func $start:function-types (; 12 ;) (type $_) call $function-types/makeAdder global.set $function-types/i32Adder block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 1 i32.const 2 global.get $function-types/i32Adder @@ -117,7 +116,7 @@ global.set $function-types/i64Adder block (result i64) i32.const 2 - global.set $~argc + global.set $~lib/argc i64.const 10 i64.const 20 global.get $function-types/i64Adder @@ -136,7 +135,7 @@ end block (result f64) i32.const 2 - global.set $~argc + global.set $~lib/argc f64.const 1.5 f64.const 2.5 call $function-types/makeAdder @@ -199,7 +198,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc i32.const 1 i32.const 2 i32.const 0 @@ -232,6 +231,9 @@ unreachable end ) - (func $null (; 13 ;) (type $_) + (func $start (; 13 ;) (type $_) + call $start:function-types + ) + (func $null (; 14 ;) (type $_) ) ) diff --git a/tests/compiler/function.untouched.wat b/tests/compiler/function.untouched.wat index 633dbb7a07..c219b23e12 100644 --- a/tests/compiler/function.untouched.wat +++ b/tests/compiler/function.untouched.wat @@ -17,7 +17,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -75,7 +75,7 @@ local.get $1 f64.add ) - (func $start (; 15 ;) (type $_) + (func $start:function (; 15 ;) (type $_) call $function/v call $function/i drop @@ -119,6 +119,9 @@ call $function/FFF drop ) - (func $null (; 16 ;) (type $_) + (func $start (; 16 ;) (type $_) + call $start:function + ) + (func $null (; 17 ;) (type $_) ) ) diff --git a/tests/compiler/getter-call.optimized.wat b/tests/compiler/getter-call.optimized.wat index 97791c2e3b..63bd3806bb 100644 --- a/tests/compiler/getter-call.optimized.wat +++ b/tests/compiler/getter-call.optimized.wat @@ -1,13 +1,13 @@ (module + (type $_ (func)) (type $i (func (result i32))) (type $ii (func (param i32) (result i32))) - (type $_ (func)) (memory $0 0) (table $0 2 funcref) (elem (i32.const 0) $null $getter-call/C#get:x~anonymous|1) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $getter-call/test)) @@ -82,7 +82,7 @@ call $~lib/allocator/arena/__memory_allocate drop i32.const 0 - global.set $~argc + global.set $~lib/argc i32.const 1 call_indirect (type $i) ) diff --git a/tests/compiler/getter-call.untouched.wat b/tests/compiler/getter-call.untouched.wat index d565826130..cc54959f4c 100644 --- a/tests/compiler/getter-call.untouched.wat +++ b/tests/compiler/getter-call.untouched.wat @@ -1,23 +1,34 @@ (module + (type $_ (func)) (type $i (func (result i32))) (type $ii (func (param i32) (result i32))) - (type $_ (func)) (memory $0 0) (table $0 2 funcref) (elem (i32.const 0) $null $getter-call/C#get:x~anonymous|1) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/argc (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $getter-call/test)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $start:getter-call (; 1 ;) (type $_) + call $start:~lib/allocator/arena + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -25,7 +36,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -42,9 +53,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -96,12 +107,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $getter-call/C#constructor (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $getter-call/C#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -111,35 +122,26 @@ end local.get $0 ) - (func $getter-call/C#get:x~anonymous|1 (; 3 ;) (type $i) (result i32) + (func $getter-call/C#get:x~anonymous|1 (; 5 ;) (type $i) (result i32) i32.const 42 ) - (func $getter-call/C#get:x (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $getter-call/C#get:x (; 6 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 ) - (func $getter-call/test (; 5 ;) (type $i) (result i32) + (func $getter-call/test (; 7 ;) (type $i) (result i32) (local $0 i32) i32.const 0 call $getter-call/C#constructor local.set $0 i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 call $getter-call/C#get:x call_indirect (type $i) ) - (func $start (; 6 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start (; 8 ;) (type $_) + call $start:getter-call ) - (func $null (; 7 ;) (type $_) + (func $null (; 9 ;) (type $_) ) ) diff --git a/tests/compiler/getter-setter.optimized.wat b/tests/compiler/getter-setter.optimized.wat index 03a728ae0b..56193ae7d2 100644 --- a/tests/compiler/getter-setter.optimized.wat +++ b/tests/compiler/getter-setter.optimized.wat @@ -10,7 +10,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:getter-setter (; 1 ;) (type $_) global.get $getter-setter/Foo._bar if i32.const 0 @@ -47,7 +47,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:getter-setter + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/getter-setter.untouched.wat b/tests/compiler/getter-setter.untouched.wat index 3dcc82144a..a176d505bb 100644 --- a/tests/compiler/getter-setter.untouched.wat +++ b/tests/compiler/getter-setter.untouched.wat @@ -9,19 +9,19 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $getter-setter/Foo._bar (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 44)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 44)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $getter-setter/Foo.get:bar (; 1 ;) (type $i) (result i32) + (func $getter-setter/Foo.bar.get:bar (; 1 ;) (type $i) (result i32) global.get $getter-setter/Foo._bar ) - (func $getter-setter/Foo.set:bar (; 2 ;) (type $i_) (param $0 i32) + (func $getter-setter/Foo.bar.set:bar (; 2 ;) (type $i_) (param $0 i32) local.get $0 global.set $getter-setter/Foo._bar ) - (func $start (; 3 ;) (type $_) - call $getter-setter/Foo.get:bar + (func $start:getter-setter (; 3 ;) (type $_) + call $getter-setter/Foo.bar.get:bar i32.const 0 i32.eq i32.eqz @@ -34,8 +34,8 @@ unreachable end i32.const 1 - call $getter-setter/Foo.set:bar - call $getter-setter/Foo.get:bar + call $getter-setter/Foo.bar.set:bar + call $getter-setter/Foo.bar.get:bar i32.const 1 i32.eq i32.eqz @@ -49,8 +49,8 @@ end block (result i32) i32.const 2 - call $getter-setter/Foo.set:bar - call $getter-setter/Foo.get:bar + call $getter-setter/Foo.bar.set:bar + call $getter-setter/Foo.bar.get:bar end i32.const 2 i32.eq @@ -64,6 +64,9 @@ unreachable end ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:getter-setter + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/i64-polyfill.untouched.wat b/tests/compiler/i64-polyfill.untouched.wat index c8dfd7c018..8cfbf31735 100644 --- a/tests/compiler/i64-polyfill.untouched.wat +++ b/tests/compiler/i64-polyfill.untouched.wat @@ -8,9 +8,7 @@ (elem (i32.const 0) $null) (global $../../examples/i64-polyfill/assembly/i64/lo (mut i32) (i32.const 0)) (global $../../examples/i64-polyfill/assembly/i64/hi (mut i32) (i32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $Infinity f64 (f64.const inf)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "getHi" (func $../../examples/i64-polyfill/assembly/i64/getHi)) diff --git a/tests/compiler/if.untouched.wat b/tests/compiler/if.untouched.wat index 46df3e869b..5ba6a3b80a 100644 --- a/tests/compiler/if.untouched.wat +++ b/tests/compiler/if.untouched.wat @@ -7,7 +7,7 @@ (data (i32.const 8) "\05\00\00\00i\00f\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 24)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 24)) (export "memory" (memory $0)) (export "table" (table $0)) (export "ifThenElse" (func $if/ifThenElse)) @@ -47,23 +47,7 @@ unreachable unreachable ) - (func $if/ifAlwaysReturns (; 4 ;) (type $ii) (param $0 i32) (result i32) - local.get $0 - if - i32.const 1 - return - else - i32.const 0 - i32.const 8 - i32.const 37 - i32.const 4 - call $~lib/env/abort - unreachable - end - unreachable - unreachable - ) - (func $start (; 5 ;) (type $_) + (func $start:if (; 4 ;) (type $_) i32.const 0 call $if/ifThenElse i32.const 0 @@ -143,6 +127,25 @@ unreachable end ) - (func $null (; 6 ;) (type $_) + (func $if/ifAlwaysReturns (; 5 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + if + i32.const 1 + return + else + i32.const 0 + i32.const 8 + i32.const 37 + i32.const 4 + call $~lib/env/abort + unreachable + end + unreachable + unreachable + ) + (func $start (; 6 ;) (type $_) + call $start:if + ) + (func $null (; 7 ;) (type $_) ) ) diff --git a/tests/compiler/import.untouched.wat b/tests/compiler/import.untouched.wat index 19e80f7dc6..04e6d9b8f3 100644 --- a/tests/compiler/import.untouched.wat +++ b/tests/compiler/import.untouched.wat @@ -7,7 +7,7 @@ (global $export/a i32 (i32.const 1)) (global $export/b i32 (i32.const 2)) (global $export/c i32 (i32.const 3)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -29,7 +29,7 @@ (func $export/ns.two (; 3 ;) (type $_) nop ) - (func $start (; 4 ;) (type $_) + (func $start:import (; 4 ;) (type $_) global.get $export/a global.get $export/b call $export/add @@ -57,6 +57,9 @@ drop call $export/ns.two ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:import + ) + (func $null (; 6 ;) (type $_) ) ) diff --git a/tests/compiler/infer-type.optimized.wat b/tests/compiler/infer-type.optimized.wat index 30e6981b8c..572489f488 100644 --- a/tests/compiler/infer-type.optimized.wat +++ b/tests/compiler/infer-type.optimized.wat @@ -11,7 +11,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:infer-type (; 0 ;) (type $_) (local $0 i32) i32.const 0 global.set $infer-type/ri @@ -34,7 +34,10 @@ end end ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:infer-type + ) + (func $null (; 2 ;) (type $_) nop ) ) diff --git a/tests/compiler/infer-type.untouched.wat b/tests/compiler/infer-type.untouched.wat index 563a5b60cb..1a95b58840 100644 --- a/tests/compiler/infer-type.untouched.wat +++ b/tests/compiler/infer-type.untouched.wat @@ -19,7 +19,7 @@ (global $infer-type/rF (mut f64) (f64.const 0)) (global $infer-type/inferi (mut i32) (i32.const -2147483648)) (global $infer-type/inferu (mut i32) (i32.const 2147483647)) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -55,7 +55,7 @@ (func $infer-type/refF (; 5 ;) (type $F) (result f64) f64.const 0 ) - (func $start (; 6 ;) (type $_) + (func $start:infer-type (; 6 ;) (type $_) (local $0 i32) (local $1 i32) global.get $infer-type/i @@ -126,6 +126,9 @@ unreachable end ) - (func $null (; 7 ;) (type $_) + (func $start (; 7 ;) (type $_) + call $start:infer-type + ) + (func $null (; 8 ;) (type $_) ) ) diff --git a/tests/compiler/inlining-recursive.untouched.wat b/tests/compiler/inlining-recursive.untouched.wat index 0b9bee8036..c94f687d2b 100644 --- a/tests/compiler/inlining-recursive.untouched.wat +++ b/tests/compiler/inlining-recursive.untouched.wat @@ -3,7 +3,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "foo" (func $inlining-recursive/foo)) diff --git a/tests/compiler/inlining.optimized.wat b/tests/compiler/inlining.optimized.wat index 6dc979efc5..1031cb1ba5 100644 --- a/tests/compiler/inlining.optimized.wat +++ b/tests/compiler/inlining.optimized.wat @@ -8,7 +8,7 @@ (data (i32.const 8) "\0b\00\00\00i\00n\00l\00i\00n\00i\00n\00g\00.\00t\00s") (table $0 2 funcref) (elem (i32.const 0) $null $inlining/func_fe~anonymous|1) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (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)) (export "memory" (memory $0)) @@ -23,7 +23,7 @@ ) (func $inlining/test_funcs (; 3 ;) (type $_) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 2 i32.const 1 call_indirect (type $ii) diff --git a/tests/compiler/inlining.untouched.wat b/tests/compiler/inlining.untouched.wat index 9bc15782db..a570ce7b00 100644 --- a/tests/compiler/inlining.untouched.wat +++ b/tests/compiler/inlining.untouched.wat @@ -9,14 +9,10 @@ (table $0 2 funcref) (elem (i32.const 0) $null $inlining/func_fe~anonymous|1) (global $inlining/constantGlobal i32 (i32.const 1)) - (global $~argc (mut i32) (i32.const 0)) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) + (global $~lib/argc (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 $HEAP_BASE i32 (i32.const 36)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 36)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $inlining/test)) @@ -222,7 +218,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 2 block $inlining/func_fe|inlined.0 (result i32) i32.const 1 @@ -283,7 +279,19 @@ unreachable end ) - (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 4 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -291,7 +299,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -308,9 +316,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -362,12 +370,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $inlining/test_ctor (; 6 ;) (type $_) + (func $inlining/test_ctor (; 7 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -475,7 +483,7 @@ unreachable end ) - (func $start (; 7 ;) (type $_) + (func $start:inlining (; 8 ;) (type $_) call $inlining/test i32.const 3 i32.eq @@ -489,18 +497,12 @@ unreachable end call $inlining/test_funcs - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena call $inlining/test_ctor ) - (func $null (; 8 ;) (type $_) + (func $start (; 9 ;) (type $_) + call $start:inlining + ) + (func $null (; 10 ;) (type $_) ) ) diff --git a/tests/compiler/instanceof.optimized.wat b/tests/compiler/instanceof.optimized.wat index f2ad8e5488..69798ebe4b 100644 --- a/tests/compiler/instanceof.optimized.wat +++ b/tests/compiler/instanceof.optimized.wat @@ -10,7 +10,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:instanceof (; 1 ;) (type $_) global.get $instanceof/an if i32.const 0 @@ -33,7 +33,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:instanceof + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/instanceof.untouched.wat b/tests/compiler/instanceof.untouched.wat index 386503d727..65d8c99ce8 100644 --- a/tests/compiler/instanceof.untouched.wat +++ b/tests/compiler/instanceof.untouched.wat @@ -13,7 +13,7 @@ (global $instanceof/i (mut i32) (i32.const 0)) (global $instanceof/f (mut f32) (f32.const 0)) (global $instanceof/an (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -29,7 +29,7 @@ i32.const 0 return ) - (func $start (; 4 ;) (type $_) + (func $start:instanceof (; 4 ;) (type $_) i32.const 1 i32.eqz if @@ -284,6 +284,9 @@ unreachable end ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:instanceof + ) + (func $null (; 6 ;) (type $_) ) ) diff --git a/tests/compiler/limits.untouched.wat b/tests/compiler/limits.untouched.wat index 93aaf43835..50c10b71d7 100644 --- a/tests/compiler/limits.untouched.wat +++ b/tests/compiler/limits.untouched.wat @@ -29,11 +29,11 @@ (global $~lib/builtins/f32.MAX_SAFE_INTEGER f32 (f32.const 16777215)) (global $~lib/builtins/f64.MIN_SAFE_INTEGER f64 (f64.const -9007199254740991)) (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:limits (; 0 ;) (type $_) global.get $~lib/builtins/i8.MIN_VALUE drop global.get $~lib/builtins/i8.MAX_VALUE @@ -87,6 +87,9 @@ global.get $~lib/builtins/f64.MAX_SAFE_INTEGER drop ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:limits + ) + (func $null (; 2 ;) (type $_) ) ) diff --git a/tests/compiler/literals.untouched.wat b/tests/compiler/literals.untouched.wat index 6744d5dce6..c7fb5abbff 100644 --- a/tests/compiler/literals.untouched.wat +++ b/tests/compiler/literals.untouched.wat @@ -3,11 +3,11 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:literals (; 0 ;) (type $_) i32.const 0 drop i32.const 1 @@ -97,6 +97,9 @@ i32.const 0 drop ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:literals + ) + (func $null (; 2 ;) (type $_) ) ) diff --git a/tests/compiler/logical.optimized.wat b/tests/compiler/logical.optimized.wat index cd10c2abcf..20c8524e1b 100644 --- a/tests/compiler/logical.optimized.wat +++ b/tests/compiler/logical.optimized.wat @@ -13,7 +13,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:logical (; 1 ;) (type $_) i32.const 2 global.set $logical/i global.get $logical/i @@ -119,7 +119,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:logical + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/logical.untouched.wat b/tests/compiler/logical.untouched.wat index 8fb3732a99..7fc806aeb3 100644 --- a/tests/compiler/logical.untouched.wat +++ b/tests/compiler/logical.untouched.wat @@ -10,11 +10,11 @@ (global $logical/I (mut i64) (i64.const 0)) (global $logical/f (mut f32) (f32.const 0)) (global $logical/F (mut f64) (f64.const 0)) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:logical (; 1 ;) (type $_) (local $0 i32) (local $1 f64) i32.const 0 @@ -244,6 +244,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:logical + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/main.optimized.wat b/tests/compiler/main.optimized.wat index 03e6ad5729..ca58e65184 100644 --- a/tests/compiler/main.optimized.wat +++ b/tests/compiler/main.optimized.wat @@ -1,22 +1,22 @@ (module - (type $iii (func (param i32 i32) (result i32))) (type $_ (func)) + (type $iii (func (param i32 i32) (result i32))) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) (global $main/code (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $main/main)) (func $main/main (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - global.get $~started + global.get $~lib/started i32.eqz if i32.const 1 global.set $main/code i32.const 1 - global.set $~started + global.set $~lib/started end global.get $main/code ) diff --git a/tests/compiler/main.ts b/tests/compiler/main.ts index 2ed96b1d36..391e22b94c 100644 --- a/tests/compiler/main.ts +++ b/tests/compiler/main.ts @@ -1,6 +1,7 @@ var code = 0; code = 1; +@start export function main(argc: i32, argv: usize): i32 { return code; } diff --git a/tests/compiler/main.untouched.wat b/tests/compiler/main.untouched.wat index 7c955f06df..c0173d5377 100644 --- a/tests/compiler/main.untouched.wat +++ b/tests/compiler/main.untouched.wat @@ -1,29 +1,32 @@ (module - (type $iii (func (param i32 i32) (result i32))) (type $_ (func)) + (type $iii (func (param i32 i32) (result i32))) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) (global $main/code (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $main/main)) - (func $main/main (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - global.get $~started + (func $start:main (; 0 ;) (type $_) + i32.const 1 + global.set $main/code + ) + (func $main/main (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + global.get $~lib/started i32.eqz if call $start i32.const 1 - global.set $~started + global.set $~lib/started end global.get $main/code ) - (func $start (; 1 ;) (type $_) - i32.const 1 - global.set $main/code + (func $start (; 2 ;) (type $_) + call $start:main ) - (func $null (; 2 ;) (type $_) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/mandelbrot.untouched.wat b/tests/compiler/mandelbrot.untouched.wat index ecd032f7c0..4444163b28 100644 --- a/tests/compiler/mandelbrot.untouched.wat +++ b/tests/compiler/mandelbrot.untouched.wat @@ -7,7 +7,7 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $../../examples/mandelbrot/assembly/index/NUM_COLORS i32 (i32.const 2048)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "computeLine" (func $../../examples/mandelbrot/assembly/index/computeLine)) diff --git a/tests/compiler/many-locals.untouched.wat b/tests/compiler/many-locals.untouched.wat index d5382e2c9a..bdd48e606e 100644 --- a/tests/compiler/many-locals.untouched.wat +++ b/tests/compiler/many-locals.untouched.wat @@ -7,7 +7,7 @@ (data (i32.const 8) "\0e\00\00\00m\00a\00n\00y\00-\00l\00o\00c\00a\00l\00s\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (export "testI32" (func $many-locals/testI32)) @@ -791,7 +791,7 @@ i32.const 24 i32.shr_s ) - (func $start (; 3 ;) (type $_) + (func $start:many-locals (; 3 ;) (type $_) i32.const 42 call $many-locals/testI32 i32.const 42 @@ -819,6 +819,9 @@ unreachable end ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:many-locals + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/memcpy.optimized.wat b/tests/compiler/memcpy.optimized.wat index 700e45b60f..5611df70d4 100644 --- a/tests/compiler/memcpy.optimized.wat +++ b/tests/compiler/memcpy.optimized.wat @@ -914,7 +914,7 @@ end local.get $6 ) - (func $start (; 2 ;) (type $_) + (func $start:memcpy (; 2 ;) (type $_) i32.const 8 i64.const 1229782938247303441 i64.store @@ -1090,7 +1090,10 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:memcpy + ) + (func $null (; 4 ;) (type $_) nop ) ) diff --git a/tests/compiler/memcpy.untouched.wat b/tests/compiler/memcpy.untouched.wat index 9e8ac41296..0e3339a077 100644 --- a/tests/compiler/memcpy.untouched.wat +++ b/tests/compiler/memcpy.untouched.wat @@ -9,7 +9,7 @@ (elem (i32.const 0) $null) (global $memcpy/base i32 (i32.const 8)) (global $memcpy/dest (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (export "memcpy" (func $memcpy/memcpy)) @@ -1208,7 +1208,7 @@ end local.get $3 ) - (func $start (; 2 ;) (type $_) + (func $start:memcpy (; 2 ;) (type $_) global.get $memcpy/base i64.const 1229782938247303441 i64.store @@ -1428,6 +1428,9 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:memcpy + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/memmove.optimized.wat b/tests/compiler/memmove.optimized.wat index 26c1f9f23c..b082dbb216 100644 --- a/tests/compiler/memmove.optimized.wat +++ b/tests/compiler/memmove.optimized.wat @@ -193,7 +193,7 @@ end local.get $3 ) - (func $start (; 2 ;) (type $_) + (func $start:memmove (; 2 ;) (type $_) i32.const 8 i64.const 1229782938247303441 i64.store @@ -369,7 +369,10 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:memmove + ) + (func $null (; 4 ;) (type $_) nop ) ) diff --git a/tests/compiler/memmove.untouched.wat b/tests/compiler/memmove.untouched.wat index c809a25c02..6b4cdbf942 100644 --- a/tests/compiler/memmove.untouched.wat +++ b/tests/compiler/memmove.untouched.wat @@ -9,7 +9,7 @@ (elem (i32.const 0) $null) (global $memmove/base i32 (i32.const 8)) (global $memmove/dest (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -225,7 +225,7 @@ end local.get $3 ) - (func $start (; 2 ;) (type $_) + (func $start:memmove (; 2 ;) (type $_) global.get $memmove/base i64.const 1229782938247303441 i64.store @@ -445,6 +445,9 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:memmove + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/memset.optimized.wat b/tests/compiler/memset.optimized.wat index 4160ffeccf..63320dce25 100644 --- a/tests/compiler/memset.optimized.wat +++ b/tests/compiler/memset.optimized.wat @@ -242,7 +242,7 @@ end local.get $3 ) - (func $start (; 2 ;) (type $_) + (func $start:memset (; 2 ;) (type $_) i32.const 32 global.set $memset/dest global.get $memset/dest @@ -338,7 +338,10 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:memset + ) + (func $null (; 4 ;) (type $_) nop ) ) diff --git a/tests/compiler/memset.untouched.wat b/tests/compiler/memset.untouched.wat index 9fc7a658b2..bb36ffcebf 100644 --- a/tests/compiler/memset.untouched.wat +++ b/tests/compiler/memset.untouched.wat @@ -8,7 +8,7 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $memset/dest (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -276,8 +276,8 @@ end local.get $3 ) - (func $start (; 2 ;) (type $_) - global.get $HEAP_BASE + (func $start:memset (; 2 ;) (type $_) + global.get $~lib/memory/HEAP_BASE global.set $memset/dest global.get $memset/dest i32.const 1 @@ -378,6 +378,9 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:memset + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/merge.optimized.wat b/tests/compiler/merge.optimized.wat new file mode 100644 index 0000000000..c89468dc8e --- /dev/null +++ b/tests/compiler/merge.optimized.wat @@ -0,0 +1,11 @@ +(module + (type $_ (func)) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $start) + (export "memory" (memory $0)) + (export "table" (table $0)) + (func $start (; 0 ;) (type $_) + nop + ) +) diff --git a/tests/compiler/merge.ts b/tests/compiler/merge.ts new file mode 100644 index 0000000000..cf81d91ad7 --- /dev/null +++ b/tests/compiler/merge.ts @@ -0,0 +1,71 @@ +// variable can be shadowed by a type +const globalType: i32 = 2; +type globalType = bool; +globalType; +var globalType_test: globalType; + +type typeGlobal = bool; +const typeGlobal: i32 = 3; +var typeGlobal_test: typeGlobal; +typeGlobal; + +// namespace can be shadowed by a type +namespace namespaceType { export function test(): void {} } +type namespaceType = i32; +namespaceType.test(); +var namespaceType_test: namespaceType; + +type typeNamespace = i32; +namespace typeNamespace { export function test(): void {} } +var typeNamespace_test: typeNamespace; +typeNamespace.test(); + +// function can be shadowed by a type +function functionType(): void {} +type functionType = i32; +functionType(); +var functionType_test: functionType; + +type typeFunction = i32; +function typeFunction(): void {} +var typeFunction_test: typeFunction; +typeFunction(); + +// class can join with namespace +class classNamespace { static test1(): void {} } +namespace classNamespace { export function test2(): void {} } +classNamespace.test1(); +classNamespace.test2(); + +namespace namespaceClass { export function test1(): void {} } // TS2434, but possible in AS +class namespaceClass { static test2(): void {} } +namespaceClass.test1(); +namespaceClass.test2(); + +// function can join with namespace +function functionNamespace(): void {} +namespace functionNamespace { export function test(): void {} } +functionNamespace(); +functionNamespace.test(); + +namespace namespaceFunction { export function test(): void {} } // TS2434, but possible in AS +function namespaceFunction(): void {} +namespaceFunction.test(); +namespaceFunction(); + +// enum can join with namespace +enum enumNamespace { val = 1 } +namespace enumNamespace { export function test(): void {} } +enumNamespace.val; +enumNamespace.test(); + +namespace namespaceEnum { export function test(): void {} } +enum namespaceEnum { val = 2 } +namespaceEnum.test(); +namespaceEnum.val; + +// namespace can join with namespace +namespace namespaceNamespace { export function test1(): void {} } +namespace namespaceNamespace { export function test2(): void {} } +namespaceNamespace.test1(); +namespaceNamespace.test2(); diff --git a/tests/compiler/merge.untouched.wat b/tests/compiler/merge.untouched.wat new file mode 100644 index 0000000000..8d6d0a5a86 --- /dev/null +++ b/tests/compiler/merge.untouched.wat @@ -0,0 +1,99 @@ +(module + (type $_ (func)) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $merge/globalType i32 (i32.const 2)) + (global $merge/globalType_test (mut i32) (i32.const 0)) + (global $merge/typeGlobal i32 (i32.const 3)) + (global $merge/typeGlobal_test (mut i32) (i32.const 0)) + (global $merge/namespaceType_test (mut i32) (i32.const 0)) + (global $merge/typeNamespace_test (mut i32) (i32.const 0)) + (global $merge/functionType_test (mut i32) (i32.const 0)) + (global $merge/typeFunction_test (mut i32) (i32.const 0)) + (global $merge/enumNamespace.val (mut i32) (i32.const 1)) + (global $merge/namespaceEnum.val (mut i32) (i32.const 2)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (start $start) + (func $merge/namespaceType.test (; 0 ;) (type $_) + nop + ) + (func $merge/typeNamespace.test (; 1 ;) (type $_) + nop + ) + (func $merge/functionType (; 2 ;) (type $_) + nop + ) + (func $merge/typeFunction (; 3 ;) (type $_) + nop + ) + (func $merge/classNamespace.test1 (; 4 ;) (type $_) + nop + ) + (func $merge/classNamespace.test2 (; 5 ;) (type $_) + nop + ) + (func $merge/namespaceClass.test1 (; 6 ;) (type $_) + nop + ) + (func $merge/namespaceClass.test2 (; 7 ;) (type $_) + nop + ) + (func $merge/functionNamespace (; 8 ;) (type $_) + nop + ) + (func $merge/functionNamespace.test (; 9 ;) (type $_) + nop + ) + (func $merge/namespaceFunction.test (; 10 ;) (type $_) + nop + ) + (func $merge/namespaceFunction (; 11 ;) (type $_) + nop + ) + (func $merge/enumNamespace.test (; 12 ;) (type $_) + nop + ) + (func $merge/namespaceEnum.test (; 13 ;) (type $_) + nop + ) + (func $merge/namespaceNamespace.test1 (; 14 ;) (type $_) + nop + ) + (func $merge/namespaceNamespace.test2 (; 15 ;) (type $_) + nop + ) + (func $start:merge (; 16 ;) (type $_) + global.get $merge/globalType + drop + global.get $merge/typeGlobal + drop + call $merge/namespaceType.test + call $merge/typeNamespace.test + call $merge/functionType + call $merge/typeFunction + call $merge/classNamespace.test1 + call $merge/classNamespace.test2 + call $merge/namespaceClass.test1 + call $merge/namespaceClass.test2 + call $merge/functionNamespace + call $merge/functionNamespace.test + call $merge/namespaceFunction.test + call $merge/namespaceFunction + global.get $merge/enumNamespace.val + drop + call $merge/enumNamespace.test + call $merge/namespaceEnum.test + global.get $merge/namespaceEnum.val + drop + call $merge/namespaceNamespace.test1 + call $merge/namespaceNamespace.test2 + ) + (func $start (; 17 ;) (type $_) + call $start:merge + ) + (func $null (; 18 ;) (type $_) + ) +) diff --git a/tests/compiler/named-export-default.untouched.wat b/tests/compiler/named-export-default.untouched.wat index 8b69d8d22d..bec1e0d72b 100644 --- a/tests/compiler/named-export-default.untouched.wat +++ b/tests/compiler/named-export-default.untouched.wat @@ -4,7 +4,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "default" (func $named-export-default/get3)) diff --git a/tests/compiler/named-import-default.untouched.wat b/tests/compiler/named-import-default.untouched.wat index d4deb6e85d..6d60ab2f57 100644 --- a/tests/compiler/named-import-default.untouched.wat +++ b/tests/compiler/named-import-default.untouched.wat @@ -4,7 +4,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "getValue" (func $named-import-default/getValue)) diff --git a/tests/compiler/namespace.ts b/tests/compiler/namespace.ts index 755c999eac..e23c100a9a 100644 --- a/tests/compiler/namespace.ts +++ b/tests/compiler/namespace.ts @@ -2,13 +2,15 @@ namespace Outer { export namespace Inner { export var aVar: i32 = 0; export function aFunc(): i32 { return aVar; } - export const enum anEnum { ONE = 1, TWO = 2 } + export enum anEnum { ONE = 1, TWO = 2 } + export const enum aConstEnum { ONE = 1, TWO = 2 } } } Outer.Inner.aVar; Outer.Inner.aFunc(); Outer.Inner.anEnum.ONE; +Outer.Inner.aConstEnum.TWO; const enum Joined { // FIXME: tsc doesn't accept this when 'const'? THREE = 3 diff --git a/tests/compiler/namespace.untouched.wat b/tests/compiler/namespace.untouched.wat index 186af60c6f..99195c5d4b 100644 --- a/tests/compiler/namespace.untouched.wat +++ b/tests/compiler/namespace.untouched.wat @@ -5,10 +5,9 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $namespace/Outer.Inner.aVar (mut i32) (i32.const 0)) - (global $namespace/Outer.Inner.anEnum.ONE i32 (i32.const 1)) - (global $namespace/Outer.Inner.anEnum.TWO i32 (i32.const 2)) - (global $namespace/Joined.THREE i32 (i32.const 3)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $namespace/Outer.Inner.anEnum.ONE (mut i32) (i32.const 1)) + (global $namespace/Outer.Inner.anEnum.TWO (mut i32) (i32.const 2)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -16,18 +15,23 @@ global.get $namespace/Outer.Inner.aVar ) (func $namespace/Joined.anotherFunc (; 1 ;) (type $i) (result i32) - global.get $namespace/Joined.THREE + i32.const 3 ) - (func $start (; 2 ;) (type $_) + (func $start:namespace (; 2 ;) (type $_) global.get $namespace/Outer.Inner.aVar drop call $namespace/Outer.Inner.aFunc drop global.get $namespace/Outer.Inner.anEnum.ONE drop + i32.const 2 + drop call $namespace/Joined.anotherFunc drop ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:namespace + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/new-without-allocator.untouched.wat b/tests/compiler/new-without-allocator.untouched.wat index 41add11112..ebd7f84268 100644 --- a/tests/compiler/new-without-allocator.untouched.wat +++ b/tests/compiler/new-without-allocator.untouched.wat @@ -5,7 +5,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "test" (func $new-without-allocator/test)) diff --git a/tests/compiler/nonNullAssertion.optimized.wat b/tests/compiler/nonNullAssertion.optimized.wat index 22e9d79502..204641d4dd 100644 --- a/tests/compiler/nonNullAssertion.optimized.wat +++ b/tests/compiler/nonNullAssertion.optimized.wat @@ -1,13 +1,13 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $i (func (result i32))) - (type $_ (func)) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "testVar" (func $nonNullAssertion/testVar)) @@ -65,13 +65,13 @@ ) (func $nonNullAssertion/testFn (; 4 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 call_indirect (type $i) ) (func $nonNullAssertion/testObjFn (; 5 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load offset=4 call_indirect (type $i) diff --git a/tests/compiler/nonNullAssertion.untouched.wat b/tests/compiler/nonNullAssertion.untouched.wat index 8110ba4edf..7c98068e64 100644 --- a/tests/compiler/nonNullAssertion.untouched.wat +++ b/tests/compiler/nonNullAssertion.untouched.wat @@ -1,20 +1,15 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iii (func (param i32 i32) (result i32))) (type $i (func (result i32))) - (type $_ (func)) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~argc (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/argc (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "testVar" (func $nonNullAssertion/testVar)) @@ -30,18 +25,33 @@ (export "testObjFn" (func $nonNullAssertion/testObjFn)) (export "testObjRet" (func $nonNullAssertion/testObjRet)) (start $start) - (func $nonNullAssertion/testVar (; 0 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $start:nonNullAssertion (; 1 ;) (type $_) + call $start:~lib/allocator/arena + ) + (func $nonNullAssertion/testVar (; 2 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $nonNullAssertion/testObj (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testObj (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load ) - (func $nonNullAssertion/testProp (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testProp (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load ) - (func $~lib/array/Array#__get (; 3 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -74,12 +84,12 @@ unreachable end ) - (func $nonNullAssertion/testArr (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testArr (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 call $~lib/array/Array#__get ) - (func $~lib/array/Array#__get (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -112,70 +122,61 @@ unreachable end ) - (func $nonNullAssertion/testElem (; 6 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testElem (; 8 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 call $~lib/array/Array#__get ) - (func $nonNullAssertion/testAll (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testAll (; 9 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 call $~lib/array/Array#__get i32.load ) - (func $nonNullAssertion/testAll2 (; 8 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testAll2 (; 10 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 call $~lib/array/Array#__get i32.load ) - (func $nonNullAssertion/testFn (; 9 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testFn (; 11 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 call_indirect (type $i) ) - (func $nonNullAssertion/testFn2 (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testFn2 (; 12 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 local.set $1 i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $1 call_indirect (type $i) ) - (func $nonNullAssertion/testRet (; 11 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testRet (; 13 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 call_indirect (type $i) ) - (func $nonNullAssertion/testObjFn (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testObjFn (; 14 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load offset=4 call_indirect (type $i) ) - (func $nonNullAssertion/testObjRet (; 13 ;) (type $ii) (param $0 i32) (result i32) + (func $nonNullAssertion/testObjRet (; 15 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load offset=4 call_indirect (type $i) ) - (func $start (; 14 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start (; 16 ;) (type $_) + call $start:nonNullAssertion ) - (func $null (; 15 ;) (type $_) + (func $null (; 17 ;) (type $_) ) ) diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index 3e69dfb3d2..040f77881d 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii_ (func (param i32 i32 i32))) @@ -7,7 +8,6 @@ (type $iFi (func (param i32 f64) (result i32))) (type $iIiIiIii (func (param i32 i64 i32 i64 i32 i64 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32))) - (type $_ (func)) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) @@ -2661,7 +2661,7 @@ end local.get $1 ) - (func $start (; 15 ;) (type $_) + (func $start:number (; 15 ;) (type $_) (local $0 i32) i32.const 2192 global.set $~lib/allocator/arena/startOffset @@ -2827,7 +2827,10 @@ unreachable end ) - (func $null (; 16 ;) (type $_) + (func $start (; 16 ;) (type $_) + call $start:number + ) + (func $null (; 17 ;) (type $_) nop ) ) diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index f3c182c0f2..8e30c2c015 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii_ (func (param i32 i32 i32))) @@ -11,7 +12,6 @@ (type $iiiii_ (func (param i32 i32 i32 i32 i32))) (type $i_ (func (param i32))) (type $fi (func (param f32) (result i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\01\00\00\000\00") @@ -41,44 +41,10 @@ (data (i32.const 2176) "\05\00\00\00f\00a\00l\00s\00e\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $number/a (mut i32) (i32.const 1)) - (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/string/CharCode.PLUS i32 (i32.const 43)) - (global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45)) - (global $~lib/internal/string/CharCode.DOT i32 (i32.const 46)) - (global $~lib/internal/string/CharCode._0 i32 (i32.const 48)) - (global $~lib/internal/string/CharCode._1 i32 (i32.const 49)) - (global $~lib/internal/string/CharCode._2 i32 (i32.const 50)) - (global $~lib/internal/string/CharCode._3 i32 (i32.const 51)) - (global $~lib/internal/string/CharCode._4 i32 (i32.const 52)) - (global $~lib/internal/string/CharCode._5 i32 (i32.const 53)) - (global $~lib/internal/string/CharCode._6 i32 (i32.const 54)) - (global $~lib/internal/string/CharCode._7 i32 (i32.const 55)) - (global $~lib/internal/string/CharCode._8 i32 (i32.const 56)) - (global $~lib/internal/string/CharCode._9 i32 (i32.const 57)) - (global $~lib/internal/string/CharCode.A i32 (i32.const 65)) - (global $~lib/internal/string/CharCode.B i32 (i32.const 66)) - (global $~lib/internal/string/CharCode.E i32 (i32.const 69)) - (global $~lib/internal/string/CharCode.N i32 (i32.const 78)) - (global $~lib/internal/string/CharCode.O i32 (i32.const 79)) - (global $~lib/internal/string/CharCode.X i32 (i32.const 88)) - (global $~lib/internal/string/CharCode.Z i32 (i32.const 90)) - (global $~lib/internal/string/CharCode.a i32 (i32.const 97)) - (global $~lib/internal/string/CharCode.b i32 (i32.const 98)) - (global $~lib/internal/string/CharCode.e i32 (i32.const 101)) - (global $~lib/internal/string/CharCode.n i32 (i32.const 110)) - (global $~lib/internal/string/CharCode.o i32 (i32.const 111)) - (global $~lib/internal/string/CharCode.x i32 (i32.const 120)) - (global $~lib/internal/string/CharCode.z i32 (i32.const 122)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/internal/number/MAX_DOUBLE_LENGTH i32 (i32.const 28)) (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) @@ -86,21 +52,31 @@ (global $~lib/internal/number/_K (mut i32) (i32.const 0)) (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) (global $~lib/number/F32.NaN f32 (f32.const nan:0x400000)) (global $~lib/builtins/f32.MIN_SAFE_INTEGER f32 (f32.const -16777215)) (global $~lib/builtins/f32.MAX_SAFE_INTEGER f32 (f32.const 16777215)) - (global $Infinity f64 (f64.const inf)) (global $~lib/builtins/f32.EPSILON f32 (f32.const 1.1920928955078125e-07)) (global $~lib/number/F64.NaN f64 (f64.const nan:0x8000000000000)) (global $~lib/builtins/f64.MIN_SAFE_INTEGER f64 (f64.const -9007199254740991)) (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) - (global $HEAP_BASE i32 (i32.const 2192)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 2192)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/internal/number/decimalCount32 (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/internal/number/decimalCount32 (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 100000 @@ -169,7 +145,7 @@ unreachable unreachable ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -177,7 +153,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -194,9 +170,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -248,7 +224,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/string/allocateUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/string/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -257,7 +233,7 @@ local.tee $1 if (result i32) local.get $0 - global.get $~lib/internal/string/MAX_LENGTH + i32.const 536870910 i32.le_s else local.get $1 @@ -272,7 +248,7 @@ unreachable end block $~lib/memory/memory.allocate|inlined.0 (result i32) - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 local.get $0 i32.const 1 i32.shl @@ -288,7 +264,7 @@ i32.store local.get $2 ) - (func $~lib/internal/number/utoa32_lut (; 4 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/number/utoa32_lut (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -463,7 +439,7 @@ i32.const 1 i32.sub local.set $2 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $1 i32.add local.set $7 @@ -476,7 +452,7 @@ i32.store16 offset=4 end ) - (func $~lib/internal/number/itoa32 (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa32 (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -523,21 +499,21 @@ local.get $1 if local.get $3 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $3 ) - (func $~lib/internal/number/itoa (; 6 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa (; 7 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/internal/number/itoa32 return ) - (func $~lib/number/I32#toString (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/number/I32#toString (; 8 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/internal/number/itoa ) - (func $~lib/internal/string/compareUnsafe (; 8 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/internal/string/compareUnsafe (; 9 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -590,7 +566,7 @@ end local.get $5 ) - (func $~lib/string/String.__eq (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -634,19 +610,19 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $~lib/builtins/isFinite (; 10 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/builtins/isFinite (; 11 ;) (type $Fi) (param $0 f64) (result i32) local.get $0 local.get $0 f64.sub f64.const 0 f64.eq ) - (func $~lib/builtins/isNaN (; 11 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/builtins/isNaN (; 12 ;) (type $Fi) (param $0 f64) (result i32) local.get $0 local.get $0 f64.ne ) - (func $~lib/internal/number/genDigits (; 12 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) + (func $~lib/internal/number/genDigits (; 13 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) (local $7 i32) (local $8 i64) (local $9 i64) @@ -930,7 +906,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $17 i32.const 65535 i32.and @@ -1102,7 +1078,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $19 i32.wrap_i64 i32.const 65535 @@ -1239,7 +1215,7 @@ end local.get $15 ) - (func $~lib/internal/memory/memcpy (; 13 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 14 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2440,7 +2416,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 14 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 15 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -2667,7 +2643,7 @@ end end ) - (func $~lib/internal/number/prettify (; 15 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/prettify (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2685,8 +2661,8 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT - global.get $~lib/internal/string/CharCode._0 + i32.const 46 + i32.const 48 i32.const 16 i32.shl i32.or @@ -2726,7 +2702,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $4 i32.const 1 @@ -2742,8 +2718,8 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT - global.get $~lib/internal/string/CharCode._0 + i32.const 46 + i32.const 48 i32.const 16 i32.shl i32.or @@ -2771,15 +2747,15 @@ i32.shl i32.add local.set $4 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $4 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 2 i32.add local.set $5 local.get $4 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 i32.const 0 @@ -2798,7 +2774,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=4 local.get $1 i32.const 1 @@ -2821,9 +2797,9 @@ local.get $3 i32.sub local.set $4 - block $memory.copy|inlined.1 + block $~lib/memory/memory.copy|inlined.1 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.get $4 i32.const 1 @@ -2831,7 +2807,7 @@ i32.add local.set $7 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $1 @@ -2844,8 +2820,8 @@ call $~lib/internal/memory/memmove end local.get $0 - global.get $~lib/internal/string/CharCode._0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 48 + i32.const 46 i32.const 16 i32.shl i32.or @@ -2864,7 +2840,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $5 i32.const 1 @@ -2885,7 +2861,7 @@ i32.eq if local.get $0 - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.store16 offset=6 block $~lib/internal/number/genExponent|inlined.0 (result i32) local.get $0 @@ -2925,8 +2901,8 @@ call $~lib/internal/number/utoa32_lut end local.get $4 - global.get $~lib/internal/string/CharCode.MINUS - global.get $~lib/internal/string/CharCode.PLUS + i32.const 45 + i32.const 43 local.get $6 select i32.store16 offset=4 @@ -2942,15 +2918,15 @@ i32.const 1 i32.shl local.set $7 - block $memory.copy|inlined.2 + block $~lib/memory/memory.copy|inlined.2 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 4 i32.add local.set $6 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 2 i32.add @@ -2965,12 +2941,12 @@ call $~lib/internal/memory/memmove end local.get $0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=6 local.get $0 local.get $7 i32.add - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.store16 offset=6 local.get $1 block $~lib/internal/number/genExponent|inlined.1 (result i32) @@ -3013,8 +2989,8 @@ call $~lib/internal/number/utoa32_lut end local.get $4 - global.get $~lib/internal/string/CharCode.MINUS - global.get $~lib/internal/string/CharCode.PLUS + i32.const 45 + i32.const 43 local.get $6 select i32.store16 offset=4 @@ -3036,7 +3012,7 @@ unreachable unreachable ) - (func $~lib/internal/number/dtoa_core (; 16 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/internal/number/dtoa_core (; 17 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 i32) (local $3 f64) (local $4 i32) @@ -3077,7 +3053,7 @@ f64.neg local.set $1 local.get $0 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end block $~lib/internal/number/grisu2|inlined.0 (result i32) @@ -3513,7 +3489,7 @@ local.get $2 i32.add ) - (func $~lib/internal/string/copyUnsafe (; 17 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + (func $~lib/internal/string/copyUnsafe (; 18 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -3522,7 +3498,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $5 local.get $2 @@ -3530,7 +3506,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $4 @@ -3542,7 +3518,7 @@ local.get $7 call $~lib/internal/memory/memmove ) - (func $~lib/string/String#substring (; 18 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#substring (; 19 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3652,10 +3628,10 @@ call $~lib/internal/string/copyUnsafe local.get $10 ) - (func $~lib/allocator/arena/__memory_free (; 19 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 20 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/internal/number/dtoa (; 20 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/internal/number/dtoa (; 21 ;) (type $Fi) (param $0 f64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3721,11 +3697,11 @@ end local.get $3 ) - (func $~lib/number/F64#toString (; 21 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/number/F64#toString (; 22 ;) (type $Fi) (param $0 f64) (result i32) local.get $0 call $~lib/internal/number/dtoa ) - (func $~lib/number/Bool#toString (; 22 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/number/Bool#toString (; 23 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 i32.ne @@ -3735,7 +3711,7 @@ i32.const 2176 end ) - (func $~lib/number/F32.isSafeInteger (; 23 ;) (type $fi) (param $0 f32) (result i32) + (func $~lib/number/F32.isSafeInteger (; 24 ;) (type $fi) (param $0 f32) (result i32) (local $1 i32) local.get $0 f32.abs @@ -3751,7 +3727,7 @@ local.get $1 end ) - (func $~lib/number/F32.isInteger (; 24 ;) (type $fi) (param $0 f32) (result i32) + (func $~lib/number/F32.isInteger (; 25 ;) (type $fi) (param $0 f32) (result i32) (local $1 f32) (local $2 i32) block $~lib/builtins/isFinite|inlined.0 (result i32) @@ -3775,7 +3751,7 @@ local.get $2 end ) - (func $~lib/number/F64.isSafeInteger (; 25 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/number/F64.isSafeInteger (; 26 ;) (type $Fi) (param $0 f64) (result i32) (local $1 i32) local.get $0 f64.abs @@ -3791,7 +3767,7 @@ local.get $1 end ) - (func $~lib/number/F64.isInteger (; 26 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/number/F64.isInteger (; 27 ;) (type $Fi) (param $0 f64) (result i32) (local $1 f64) (local $2 i32) block $~lib/builtins/isFinite|inlined.0 (result i32) @@ -3815,20 +3791,11 @@ local.get $2 end ) - (func $start (; 27 ;) (type $_) + (func $start:number (; 28 ;) (type $_) (local $0 i32) (local $1 f32) (local $2 f64) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena global.get $number/a call $~lib/number/I32#toString i32.const 592 @@ -4609,6 +4576,9 @@ unreachable end ) - (func $null (; 28 ;) (type $_) + (func $start (; 29 ;) (type $_) + call $start:number + ) + (func $null (; 30 ;) (type $_) ) ) diff --git a/tests/compiler/object-literal.optimized.wat b/tests/compiler/object-literal.optimized.wat index 705fa667ef..3fec9e1e7c 100644 --- a/tests/compiler/object-literal.optimized.wat +++ b/tests/compiler/object-literal.optimized.wat @@ -1,8 +1,8 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $i_ (func (param i32))) (type $iiii_ (func (param i32 i32 i32 i32))) - (type $_ (func)) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) @@ -174,7 +174,7 @@ unreachable end ) - (func $start (; 5 ;) (type $_) + (func $start:object-literal (; 5 ;) (type $_) (local $0 i32) i32.const 80 global.set $~lib/allocator/arena/startOffset @@ -225,7 +225,10 @@ unreachable end ) - (func $null (; 6 ;) (type $_) + (func $start (; 6 ;) (type $_) + call $start:object-literal + ) + (func $null (; 7 ;) (type $_) nop ) ) diff --git a/tests/compiler/object-literal.untouched.wat b/tests/compiler/object-literal.untouched.wat index 0f75ef4e15..5eb7396d40 100644 --- a/tests/compiler/object-literal.untouched.wat +++ b/tests/compiler/object-literal.untouched.wat @@ -1,28 +1,35 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $i_ (func (param i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\0b\00\00\00h\00e\00l\00l\00o\00 \00w\00o\00r\00l\00d\00") (data (i32.const 40) "\11\00\00\00o\00b\00j\00e\00c\00t\00-\00l\00i\00t\00e\00r\00a\00l\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $HEAP_BASE i32 (i32.const 80)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 80)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -30,7 +37,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -47,9 +54,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -101,12 +108,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/string/compareUnsafe (; 3 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/internal/string/compareUnsafe (; 4 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -159,7 +166,7 @@ end local.get $5 ) - (func $~lib/string/String.__eq (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -203,7 +210,7 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $object-literal/bar (; 5 ;) (type $i_) (param $0 i32) + (func $object-literal/bar (; 6 ;) (type $i_) (param $0 i32) local.get $0 i32.load i32.const 1 @@ -231,7 +238,7 @@ unreachable end ) - (func $object-literal/bar2 (; 6 ;) (type $i_) (param $0 i32) + (func $object-literal/bar2 (; 7 ;) (type $i_) (param $0 i32) local.get $0 i32.load i32.const 2 @@ -246,7 +253,7 @@ unreachable end ) - (func $object-literal/Foo2#test (; 7 ;) (type $i_) (param $0 i32) + (func $object-literal/Foo2#test (; 8 ;) (type $i_) (param $0 i32) local.get $0 i32.load i32.const 3 @@ -261,20 +268,11 @@ unreachable end ) - (func $start (; 8 ;) (type $_) + (func $start:object-literal (; 9 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena block (result i32) i32.const 8 call $~lib/memory/memory.allocate @@ -309,6 +307,9 @@ end call $object-literal/Foo2#test ) - (func $null (; 9 ;) (type $_) + (func $start (; 10 ;) (type $_) + call $start:object-literal + ) + (func $null (; 11 ;) (type $_) ) ) diff --git a/tests/compiler/optional-typeparameters.untouched.wat b/tests/compiler/optional-typeparameters.untouched.wat index 06367c42fb..166327adb1 100644 --- a/tests/compiler/optional-typeparameters.untouched.wat +++ b/tests/compiler/optional-typeparameters.untouched.wat @@ -1,20 +1,16 @@ (module (type $ii (func (param i32) (result i32))) + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $iFFF (func (param i32 f64 f64) (result f64))) - (type $_ (func)) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $optional-typeparameters/tConcrete (mut i32) (i32.const 0)) (global $optional-typeparameters/tDerived (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -24,7 +20,19 @@ (func $optional-typeparameters/testDerived (; 1 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 2 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -32,7 +40,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -49,9 +57,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -103,12 +111,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $optional-typeparameters/TestConcrete#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $optional-typeparameters/TestConcrete#constructor (; 5 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -118,12 +126,12 @@ end local.get $0 ) - (func $optional-typeparameters/TestConcrete#test (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $optional-typeparameters/TestConcrete#test (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $1 local.get $2 i32.add ) - (func $optional-typeparameters/TestDerived#constructor (; 6 ;) (type $ii) (param $0 i32) (result i32) + (func $optional-typeparameters/TestDerived#constructor (; 7 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -133,28 +141,19 @@ end local.get $0 ) - (func $optional-typeparameters/TestDerived#test (; 7 ;) (type $iFFF) (param $0 i32) (param $1 f64) (param $2 f64) (result f64) + (func $optional-typeparameters/TestDerived#test (; 8 ;) (type $iFFF) (param $0 i32) (param $1 f64) (param $2 f64) (result f64) local.get $1 local.get $2 f64.add ) - (func $start (; 8 ;) (type $_) + (func $start:optional-typeparameters (; 9 ;) (type $_) i32.const 1 call $optional-typeparameters/testConcrete drop i32.const 2 call $optional-typeparameters/testDerived drop - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena i32.const 0 call $optional-typeparameters/TestConcrete#constructor global.set $optional-typeparameters/tConcrete @@ -172,6 +171,9 @@ call $optional-typeparameters/TestDerived#test drop ) - (func $null (; 9 ;) (type $_) + (func $start (; 10 ;) (type $_) + call $start:optional-typeparameters + ) + (func $null (; 11 ;) (type $_) ) ) diff --git a/tests/compiler/overflow.untouched.wat b/tests/compiler/overflow.untouched.wat index f84f73a12f..1ed84eb038 100644 --- a/tests/compiler/overflow.untouched.wat +++ b/tests/compiler/overflow.untouched.wat @@ -6,11 +6,11 @@ (data (i32.const 8) "\0b\00\00\00o\00v\00e\00r\00f\00l\00o\00w\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 36)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 36)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:overflow (; 1 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -755,6 +755,9 @@ end end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:overflow + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/portable-conversions.optimized.wat b/tests/compiler/portable-conversions.optimized.wat index dced50883c..9d34a015b3 100644 --- a/tests/compiler/portable-conversions.optimized.wat +++ b/tests/compiler/portable-conversions.optimized.wat @@ -13,7 +13,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:portable-conversions (; 1 ;) (type $_) global.get $portable-conversions/i i32.const 255 i32.and @@ -614,7 +614,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:portable-conversions + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/portable-conversions.untouched.wat b/tests/compiler/portable-conversions.untouched.wat index 28a6bb053b..a1bde8faf1 100644 --- a/tests/compiler/portable-conversions.untouched.wat +++ b/tests/compiler/portable-conversions.untouched.wat @@ -10,11 +10,11 @@ (global $portable-conversions/I (mut i64) (i64.const 1)) (global $portable-conversions/f (mut f32) (f32.const 1)) (global $portable-conversions/F (mut f64) (f64.const 1)) - (global $HEAP_BASE i32 (i32.const 60)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 60)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:portable-conversions (; 1 ;) (type $_) global.get $portable-conversions/i i32.const 24 i32.shl @@ -636,6 +636,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:portable-conversions + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/recursive.untouched.wat b/tests/compiler/recursive.untouched.wat index 59754b6e2e..2baf4ce473 100644 --- a/tests/compiler/recursive.untouched.wat +++ b/tests/compiler/recursive.untouched.wat @@ -4,7 +4,7 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "fib" (func $recursive/fib)) diff --git a/tests/compiler/reexport.optimized.wat b/tests/compiler/reexport.optimized.wat index 7461086215..c1ed53f1a8 100644 --- a/tests/compiler/reexport.optimized.wat +++ b/tests/compiler/reexport.optimized.wat @@ -3,7 +3,7 @@ (type $_ (func)) (memory $0 0) (table $0 1 funcref) - (elem (i32.const 0) $export/ns.two) + (elem (i32.const 0) $export/ns.one) (global $export/a i32 (i32.const 1)) (global $export/b i32 (i32.const 2)) (global $export/c i32 (i32.const 3)) @@ -19,23 +19,23 @@ (export "rerenamed_c" (global $export/c)) (export "renamed_add" (func $export/add)) (export "rerenamed_sub" (func $export/mul)) - (export "renamed_ns.two" (func $export/ns.two)) + (export "renamed_ns.two" (func $export/ns.one)) (func $export/add (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $export/sub (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $export/mul (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 - i32.sub + i32.mul ) - (func $export/mul (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $export/sub (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 - i32.mul + i32.sub ) - (func $export/ns.two (; 3 ;) (type $_) + (func $export/ns.one (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/reexport.untouched.wat b/tests/compiler/reexport.untouched.wat index 0c0412b813..90bf2f1865 100644 --- a/tests/compiler/reexport.untouched.wat +++ b/tests/compiler/reexport.untouched.wat @@ -7,7 +7,7 @@ (global $export/a i32 (i32.const 1)) (global $export/b i32 (i32.const 2)) (global $export/c i32 (i32.const 3)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "add" (func $export/add)) @@ -27,20 +27,12 @@ local.get $1 i32.add ) - (func $export/sub (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - local.get $1 - i32.sub - ) - (func $export/mul (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $export/mul (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.mul ) - (func $export/ns.two (; 3 ;) (type $_) - nop - ) - (func $start (; 4 ;) (type $_) + (func $start:reexport (; 2 ;) (type $_) i32.const 1 i32.const 2 call $export/add @@ -50,6 +42,20 @@ i32.add drop ) - (func $null (; 5 ;) (type $_) + (func $export/sub (; 3 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + local.get $0 + local.get $1 + i32.sub + ) + (func $export/ns.one (; 4 ;) (type $_) + nop + ) + (func $export/ns.two (; 5 ;) (type $_) + nop + ) + (func $start (; 6 ;) (type $_) + call $start:reexport + ) + (func $null (; 7 ;) (type $_) ) ) diff --git a/tests/compiler/rereexport.untouched.wat b/tests/compiler/rereexport.untouched.wat index 2bb09a0316..6e7dd98130 100644 --- a/tests/compiler/rereexport.untouched.wat +++ b/tests/compiler/rereexport.untouched.wat @@ -7,7 +7,7 @@ (global $export/a i32 (i32.const 1)) (global $export/b i32 (i32.const 2)) (global $export/c i32 (i32.const 3)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "a" (global $export/a)) @@ -25,7 +25,7 @@ local.get $1 i32.mul ) - (func $start (; 2 ;) (type $_) + (func $start:reexport (; 2 ;) (type $_) i32.const 1 i32.const 2 call $export/add @@ -35,6 +35,12 @@ i32.add drop ) - (func $null (; 3 ;) (type $_) + (func $start:rereexport (; 3 ;) (type $_) + call $start:reexport + ) + (func $start (; 4 ;) (type $_) + call $start:rereexport + ) + (func $null (; 5 ;) (type $_) ) ) diff --git a/tests/compiler/resolve-nested.optimized.wat b/tests/compiler/resolve-nested.optimized.wat new file mode 100644 index 0000000000..f16c09d70e --- /dev/null +++ b/tests/compiler/resolve-nested.optimized.wat @@ -0,0 +1,26 @@ +(module + (type $iiiiii_ (func (param i32 i32 i32 i32 i32 i32))) + (type $iiiii_ (func (param i32 i32 i32 i32 i32))) + (type $iii_ (func (param i32 i32 i32))) + (type $_ (func)) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "Outer.Inner.evenInner" (func $resolve-nested/Outer.Inner.evenInner)) + (export "Outer.inner" (func $resolve-nested/Outer.inner)) + (export "outer" (func $resolve-nested/outer)) + (func $resolve-nested/Outer.Inner.evenInner (; 0 ;) (type $iiiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) + nop + ) + (func $resolve-nested/Outer.inner (; 1 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + nop + ) + (func $resolve-nested/outer (; 2 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + nop + ) + (func $null (; 3 ;) (type $_) + nop + ) +) diff --git a/tests/compiler/resolve-nested.ts b/tests/compiler/resolve-nested.ts new file mode 100644 index 0000000000..a2fa919378 --- /dev/null +++ b/tests/compiler/resolve-nested.ts @@ -0,0 +1,41 @@ +class OuterClass {} +export namespace Outer { + export class InnerClass {} + export namespace Inner { + export class EvenInnerClass {} + var a: OuterClass; + var b: InnerClass; + var c: EvenInnerClass; + var d: Outer.InnerClass; + var e: Outer.Inner.EvenInnerClass; + var f: Inner.EvenInnerClass; + export function evenInner( + a: OuterClass, + b: InnerClass, + c: EvenInnerClass, + d: Outer.InnerClass, + e: Outer.Inner.EvenInnerClass, + f: Inner.EvenInnerClass + ): void {} + } + var a: OuterClass; + var b: InnerClass; + var c: Inner.EvenInnerClass; + var d: Outer.InnerClass; + var e: Outer.Inner.EvenInnerClass; + export function inner( + a: OuterClass, + b: InnerClass, + c: Inner.EvenInnerClass, + d: Outer.InnerClass, + e: Outer.Inner.EvenInnerClass + ): void {} +} +var a: OuterClass; +var b: Outer.InnerClass; +var c: Outer.Inner.EvenInnerClass; +export function outer( + a: OuterClass, + b: Outer.InnerClass, + c: Outer.Inner.EvenInnerClass +): void {} diff --git a/tests/compiler/resolve-nested.untouched.wat b/tests/compiler/resolve-nested.untouched.wat new file mode 100644 index 0000000000..ae821ca5ae --- /dev/null +++ b/tests/compiler/resolve-nested.untouched.wat @@ -0,0 +1,40 @@ +(module + (type $iiiiii_ (func (param i32 i32 i32 i32 i32 i32))) + (type $iiiii_ (func (param i32 i32 i32 i32 i32))) + (type $iii_ (func (param i32 i32 i32))) + (type $_ (func)) + (memory $0 0) + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $resolve-nested/Outer.Inner.a (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.Inner.b (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.Inner.c (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.Inner.d (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.Inner.e (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.Inner.f (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.a (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.b (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.c (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.d (mut i32) (i32.const 0)) + (global $resolve-nested/Outer.e (mut i32) (i32.const 0)) + (global $resolve-nested/a (mut i32) (i32.const 0)) + (global $resolve-nested/b (mut i32) (i32.const 0)) + (global $resolve-nested/c (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "Outer.Inner.evenInner" (func $resolve-nested/Outer.Inner.evenInner)) + (export "Outer.inner" (func $resolve-nested/Outer.inner)) + (export "outer" (func $resolve-nested/outer)) + (func $resolve-nested/Outer.Inner.evenInner (; 0 ;) (type $iiiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) + nop + ) + (func $resolve-nested/Outer.inner (; 1 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + nop + ) + (func $resolve-nested/outer (; 2 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + nop + ) + (func $null (; 3 ;) (type $_) + ) +) diff --git a/tests/compiler/retain-i32.optimized.wat b/tests/compiler/retain-i32.optimized.wat index c18d16fd2e..bde1dac3ed 100644 --- a/tests/compiler/retain-i32.optimized.wat +++ b/tests/compiler/retain-i32.optimized.wat @@ -11,7 +11,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:retain-i32 (; 1 ;) (type $_) (local $0 i32) i32.const -128 local.set $0 @@ -258,7 +258,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:retain-i32 + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/retain-i32.untouched.wat b/tests/compiler/retain-i32.untouched.wat index 21a1e58137..ca1f62575a 100644 --- a/tests/compiler/retain-i32.untouched.wat +++ b/tests/compiler/retain-i32.untouched.wat @@ -18,7 +18,7 @@ (global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1)) (global $retain-i32/si (mut i32) (i32.const 0)) (global $retain-i32/ui (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -332,7 +332,7 @@ unreachable end ) - (func $start (; 2 ;) (type $_) + (func $start:retain-i32 (; 2 ;) (type $_) (local $0 i32) i32.const 0 global.get $~lib/builtins/i8.MAX_VALUE @@ -792,6 +792,9 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:retain-i32 + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/scoped.optimized.wat b/tests/compiler/scoped.optimized.wat index 143143302d..46c090eae8 100644 --- a/tests/compiler/scoped.optimized.wat +++ b/tests/compiler/scoped.optimized.wat @@ -6,7 +6,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:scoped (; 0 ;) (type $_) (local $0 i32) loop $repeat|0 local.get $0 @@ -35,7 +35,10 @@ end end ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:scoped + ) + (func $null (; 2 ;) (type $_) nop ) ) diff --git a/tests/compiler/scoped.untouched.wat b/tests/compiler/scoped.untouched.wat index 3d5a1b9eaf..b3337ff143 100644 --- a/tests/compiler/scoped.untouched.wat +++ b/tests/compiler/scoped.untouched.wat @@ -7,7 +7,7 @@ (global $scoped/aGlobal (mut i32) (i32.const 1)) (global $scoped/aConstant i32 (i32.const 3)) (global $scoped/aStartFunctionLocal (mut i32) (i32.const 2)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -18,7 +18,7 @@ local.get $0 local.set $1 ) - (func $start (; 1 ;) (type $_) + (func $start:scoped (; 1 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i64) @@ -71,6 +71,9 @@ i32.const 42 call $scoped/fn ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:scoped + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/static-this.untouched.wat b/tests/compiler/static-this.untouched.wat index 76568fb392..73ae644017 100644 --- a/tests/compiler/static-this.untouched.wat +++ b/tests/compiler/static-this.untouched.wat @@ -8,14 +8,14 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $static-this/Foo.bar (mut i32) (i32.const 42)) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) (func $static-this/Foo.getBar (; 1 ;) (type $i) (result i32) global.get $static-this/Foo.bar ) - (func $start (; 2 ;) (type $_) + (func $start:static-this (; 2 ;) (type $_) call $static-this/Foo.getBar i32.const 42 i32.eq @@ -29,6 +29,9 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:static-this + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/std/allocator_arena.optimized.wat b/tests/compiler/std/allocator_arena.optimized.wat index 0fcecb6882..e4c650dc23 100644 --- a/tests/compiler/std/allocator_arena.optimized.wat +++ b/tests/compiler/std/allocator_arena.optimized.wat @@ -1,7 +1,7 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii_ (func (param i32 i32 i32))) - (type $_ (func)) (type $FUNCSIG$i (func (result i32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vii (func (param i32 i32))) @@ -1412,7 +1412,7 @@ i32.const 0 end ) - (func $start (; 6 ;) (type $_) + (func $start:std/allocator_arena (; 6 ;) (type $_) i32.const 56 global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset @@ -1524,7 +1524,10 @@ unreachable end ) - (func $null (; 7 ;) (type $_) + (func $start (; 7 ;) (type $_) + call $start:std/allocator_arena + ) + (func $null (; 8 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/allocator_arena.untouched.wat b/tests/compiler/std/allocator_arena.untouched.wat index 41f0c596a3..4fc19a1bd0 100644 --- a/tests/compiler/std/allocator_arena.untouched.wat +++ b/tests/compiler/std/allocator_arena.untouched.wat @@ -1,30 +1,38 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii_ (func (param i32 i32 i32))) (type $iiii (func (param i32 i32 i32) (result i32))) (type $i_ (func (param i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\16\00\00\00s\00t\00d\00/\00a\00l\00l\00o\00c\00a\00t\00o\00r\00_\00a\00r\00e\00n\00a\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/allocator_arena/size i32 (i32.const 42)) (global $std/allocator_arena/ptr1 (mut i32) (i32.const 0)) (global $std/allocator_arena/ptr2 (mut i32) (i32.const 0)) (global $std/allocator_arena/i (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 56)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 56)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -32,7 +40,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -49,9 +57,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -103,7 +111,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/memory/memset (; 2 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 3 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -357,7 +365,7 @@ end end ) - (func $~lib/internal/memory/memcpy (; 3 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 4 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1558,7 +1566,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 4 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -1785,7 +1793,7 @@ end end ) - (func $~lib/internal/memory/memcmp (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/memory/memcmp (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $0 local.get $1 @@ -1839,27 +1847,18 @@ i32.const 0 end ) - (func $~lib/allocator/arena/__memory_free (; 6 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 7 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/allocator/arena/__memory_reset (; 7 ;) (type $_) + (func $~lib/allocator/arena/__memory_reset (; 8 ;) (type $_) global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset ) - (func $start (; 8 ;) (type $_) + (func $start:std/allocator_arena (; 9 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena block $~lib/memory/memory.allocate|inlined.0 (result i32) global.get $std/allocator_arena/size local.set $0 @@ -1888,7 +1887,7 @@ call $~lib/env/abort unreachable end - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 global.get $std/allocator_arena/ptr1 local.set $0 i32.const 18 @@ -1933,7 +1932,7 @@ end unreachable end - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 global.get $std/allocator_arena/ptr2 local.set $2 global.get $std/allocator_arena/ptr1 @@ -2028,7 +2027,7 @@ end global.set $std/allocator_arena/ptr1 global.get $std/allocator_arena/ptr1 - global.get $HEAP_BASE + global.get $~lib/memory/HEAP_BASE i32.const 7 i32.add i32.const 7 @@ -2046,6 +2045,9 @@ unreachable end ) - (func $null (; 9 ;) (type $_) + (func $start (; 10 ;) (type $_) + call $start:std/allocator_arena + ) + (func $null (; 11 ;) (type $_) ) ) diff --git a/tests/compiler/std/array-access.untouched.wat b/tests/compiler/std/array-access.untouched.wat index 81f4a0c2b2..b7b3b714da 100644 --- a/tests/compiler/std/array-access.untouched.wat +++ b/tests/compiler/std/array-access.untouched.wat @@ -12,12 +12,7 @@ (data (i32.const 48) "\04\00\00\00n\00u\00l\00l\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $HEAP_BASE i32 (i32.const 60)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 60)) (export "memory" (memory $0)) (export "table" (table $0)) (export "i32ArrayArrayElementAccess" (func $std/array-access/i32ArrayArrayElementAccess)) diff --git a/tests/compiler/std/array-literal.optimized.wat b/tests/compiler/std/array-literal.optimized.wat index fa45c3a8e0..c6529c96c3 100644 --- a/tests/compiler/std/array-literal.optimized.wat +++ b/tests/compiler/std/array-literal.optimized.wat @@ -1,7 +1,7 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) - (type $_ (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$i (func (result i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) @@ -391,7 +391,7 @@ call $~lib/internal/memory/memset local.get $0 ) - (func $start (; 6 ;) (type $_) + (func $start:std/array-literal (; 6 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 232 @@ -895,7 +895,10 @@ unreachable end ) - (func $null (; 7 ;) (type $_) + (func $start (; 7 ;) (type $_) + call $start:std/array-literal + ) + (func $null (; 8 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/array-literal.untouched.wat b/tests/compiler/std/array-literal.untouched.wat index ea58225d14..65351d735e 100644 --- a/tests/compiler/std/array-literal.untouched.wat +++ b/tests/compiler/std/array-literal.untouched.wat @@ -1,9 +1,9 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\03\00\00\00\00\00\00\00\00\01\02\00\00\00\00\00") @@ -17,27 +17,33 @@ (data (i32.const 168) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/array-literal/staticArrayI8 i32 (i32.const 24)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) (global $std/array-literal/staticArrayI32 i32 (i32.const 112)) (global $std/array-literal/emptyArrayI32 (mut i32) (i32.const 128)) (global $std/array-literal/i (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) (global $std/array-literal/dynamicArrayI8 (mut i32) (i32.const 0)) (global $std/array-literal/dynamicArrayI32 (mut i32) (i32.const 0)) (global $std/array-literal/dynamicArrayRef (mut i32) (i32.const 0)) (global $std/array-literal/dynamicArrayRefWithCtor (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 228)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 228)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/array/Array#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/array/Array#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -70,7 +76,7 @@ unreachable end ) - (func $~lib/array/Array#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 3 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -103,11 +109,11 @@ unreachable end ) - (func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 4 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -115,7 +121,7 @@ i32.sub i32.shl ) - (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -123,7 +129,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -140,9 +146,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -194,11 +200,11 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -223,12 +229,12 @@ i32.store local.get $1 ) - (func $~lib/memory/memory.allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 7 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/memory/memset (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 8 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -482,7 +488,7 @@ end end ) - (func $~lib/array/Array#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -527,9 +533,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -543,7 +549,7 @@ end local.get $0 ) - (func $~lib/array/Array#__unchecked_set (; 9 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__unchecked_set (; 10 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -567,7 +573,7 @@ local.get $5 i32.store8 offset=8 ) - (func $~lib/array/Array#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -612,9 +618,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.1 + block $~lib/memory/memory.fill|inlined.1 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -628,7 +634,7 @@ end local.get $0 ) - (func $~lib/array/Array#__unchecked_set (; 11 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__unchecked_set (; 12 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -652,7 +658,7 @@ local.get $5 i32.store offset=8 ) - (func $std/array-literal/Ref#constructor (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array-literal/Ref#constructor (; 13 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -662,7 +668,7 @@ end local.get $0 ) - (func $~lib/array/Array#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -707,9 +713,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.2 + block $~lib/memory/memory.fill|inlined.2 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -723,7 +729,7 @@ end local.get $0 ) - (func $~lib/array/Array#__unchecked_set (; 14 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__unchecked_set (; 15 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -747,7 +753,7 @@ local.get $5 i32.store offset=8 ) - (func $std/array-literal/RefWithCtor#constructor (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array-literal/RefWithCtor#constructor (; 16 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -757,7 +763,7 @@ end local.get $0 ) - (func $~lib/array/Array#constructor (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -802,9 +808,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.3 + block $~lib/memory/memory.fill|inlined.3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -818,7 +824,7 @@ end local.get $0 ) - (func $~lib/array/Array#__unchecked_set (; 17 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__unchecked_set (; 18 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -842,22 +848,13 @@ local.get $5 i32.store offset=8 ) - (func $start (; 18 ;) (type $_) + (func $start:std/array-literal (; 19 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena block $~lib/array/Array#get:length|inlined.0 (result i32) global.get $std/array-literal/staticArrayI8 local.set $0 @@ -1282,6 +1279,9 @@ unreachable end ) - (func $null (; 19 ;) (type $_) + (func $start (; 20 ;) (type $_) + call $start:std/array-literal + ) + (func $null (; 21 ;) (type $_) ) ) diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 09100d36d7..6cccb13df9 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) @@ -20,7 +21,6 @@ (type $Ii (func (param i64) (result i32))) (type $iIi_ (func (param i32 i64 i32))) (type $iiIi (func (param i32 i32 i64) (result i32))) - (type $_ (func)) (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) @@ -339,19 +339,13 @@ (data (i32.const 8408) "\04\00\00\00\00\00\00\00\d0 ") (data (i32.const 8424) "\d8 \00\00\01") (table $0 56 funcref) - (elem (i32.const 0) $null $start~anonymous|1 $start~anonymous|2 $start~anonymous|3 $start~anonymous|4 $start~anonymous|3 $start~anonymous|6 $start~anonymous|7 $start~anonymous|8 $start~anonymous|9 $start~anonymous|10 $start~anonymous|11 $start~anonymous|12 $start~anonymous|13 $start~anonymous|14 $start~anonymous|15 $start~anonymous|16 $start~anonymous|17 $start~anonymous|18 $start~anonymous|17 $start~anonymous|20 $start~anonymous|21 $start~anonymous|22 $start~anonymous|23 $start~anonymous|24 $start~anonymous|25 $start~anonymous|26 $start~anonymous|27 $start~anonymous|28 $start~anonymous|29 $start~anonymous|30 $start~anonymous|30 $start~anonymous|32 $start~anonymous|33 $start~anonymous|34 $start~anonymous|30 $start~anonymous|36 $start~anonymous|30 $start~anonymous|30 $start~anonymous|32 $start~anonymous|33 $start~anonymous|34 $start~anonymous|30 $start~anonymous|36 $~lib/internal/sort/COMPARATOR~anonymous|44 $~lib/internal/sort/COMPARATOR~anonymous|45 $~lib/internal/sort/COMPARATOR~anonymous|46 $~lib/internal/sort/COMPARATOR~anonymous|47 $~lib/internal/sort/COMPARATOR~anonymous|46 $~lib/internal/sort/COMPARATOR~anonymous|46 $start~anonymous|50 $~lib/internal/sort/COMPARATOR~anonymous|46 $start~anonymous|50 $start~anonymous|53 $start~anonymous|54 $~lib/internal/sort/COMPARATOR~anonymous|55) + (elem (i32.const 0) $null $start:std/array~anonymous|1 $start:std/array~anonymous|2 $start:std/array~anonymous|3 $start:std/array~anonymous|4 $start:std/array~anonymous|3 $start:std/array~anonymous|6 $start:std/array~anonymous|7 $start:std/array~anonymous|8 $start:std/array~anonymous|9 $start:std/array~anonymous|10 $start:std/array~anonymous|11 $start:std/array~anonymous|12 $start:std/array~anonymous|13 $start:std/array~anonymous|14 $start:std/array~anonymous|15 $start:std/array~anonymous|16 $start:std/array~anonymous|17 $start:std/array~anonymous|18 $start:std/array~anonymous|17 $start:std/array~anonymous|20 $start:std/array~anonymous|21 $start:std/array~anonymous|22 $start:std/array~anonymous|23 $start:std/array~anonymous|24 $start:std/array~anonymous|25 $start:std/array~anonymous|26 $start:std/array~anonymous|27 $start:std/array~anonymous|28 $start:std/array~anonymous|29 $start:std/array~anonymous|30 $start:std/array~anonymous|30 $start:std/array~anonymous|32 $start:std/array~anonymous|33 $start:std/array~anonymous|34 $start:std/array~anonymous|30 $start:std/array~anonymous|36 $start:std/array~anonymous|30 $start:std/array~anonymous|30 $start:std/array~anonymous|32 $start:std/array~anonymous|33 $start:std/array~anonymous|34 $start:std/array~anonymous|30 $start:std/array~anonymous|36 $~lib/internal/sort/COMPARATOR~anonymous|44 $~lib/internal/sort/COMPARATOR~anonymous|45 $~lib/internal/sort/COMPARATOR~anonymous|46 $~lib/internal/sort/COMPARATOR~anonymous|47 $~lib/internal/sort/COMPARATOR~anonymous|46 $~lib/internal/sort/COMPARATOR~anonymous|46 $start:std/array~anonymous|50 $~lib/internal/sort/COMPARATOR~anonymous|46 $start:std/array~anonymous|50 $start:std/array~anonymous|53 $start:std/array~anonymous|54 $~lib/internal/sort/COMPARATOR~anonymous|55) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/number/_K (mut i32) (i32.const 0)) - (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) - (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) - (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (global $std/array/arr (mut i32) (i32.const 0)) (global $std/array/Null (mut i32) (i32.const 0)) (global $std/array/arr8 (mut i32) (i32.const 232)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/array/arr32 (mut i32) (i32.const 392)) (global $std/array/i (mut i32) (i32.const 0)) (global $std/array/other (mut i32) (i32.const 0)) @@ -391,6 +385,12 @@ (global $std/array/randomStringsActual (mut i32) (i32.const 3976)) (global $std/array/randomStringsExpected (mut i32) (i32.const 4048)) (global $std/array/randomStrings400 (mut i32) (i32.const 0)) + (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) + (global $~lib/internal/number/_K (mut i32) (i32.const 0)) + (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (global $std/array/refArr (mut i32) (i32.const 0)) (global $std/array/subarr32 (mut i32) (i32.const 8256)) (global $std/array/subarr8 (mut i32) (i32.const 8352)) @@ -962,7 +962,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -1144,7 +1144,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -2653,7 +2653,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 2 i32.sub br_table $0of1 $1of1 $outOfRange @@ -3009,7 +3009,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -3070,7 +3070,7 @@ local.get $2 i32.store offset=8 ) - (func $start~anonymous|1 (; 28 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|1 (; 28 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.eqz ) @@ -3095,7 +3095,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load local.get $3 @@ -3123,17 +3123,17 @@ end i32.const -1 ) - (func $start~anonymous|2 (; 30 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|2 (; 30 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 1 i32.eq ) - (func $start~anonymous|3 (; 31 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|3 (; 31 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 100 i32.eq ) - (func $start~anonymous|4 (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|4 (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -3142,7 +3142,7 @@ i32.const 100 i32.eq ) - (func $start~anonymous|6 (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|6 (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -3150,7 +3150,7 @@ i32.const 100 i32.eq ) - (func $start~anonymous|7 (; 34 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|7 (; 34 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.ge_s @@ -3176,7 +3176,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load local.get $3 @@ -3204,12 +3204,12 @@ end i32.const 1 ) - (func $start~anonymous|8 (; 36 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|8 (; 36 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.le_s ) - (func $start~anonymous|9 (; 37 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|9 (; 37 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -3218,12 +3218,12 @@ i32.const 10 i32.lt_s ) - (func $start~anonymous|10 (; 38 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|10 (; 38 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 10 i32.lt_s ) - (func $start~anonymous|11 (; 39 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|11 (; 39 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -3231,7 +3231,7 @@ i32.const 3 i32.lt_s ) - (func $start~anonymous|12 (; 40 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|12 (; 40 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 3 i32.ge_s @@ -3257,7 +3257,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load local.get $3 @@ -3285,12 +3285,12 @@ end i32.const 0 ) - (func $start~anonymous|13 (; 42 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|13 (; 42 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const -1 i32.le_s ) - (func $start~anonymous|14 (; 43 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|14 (; 43 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -3299,12 +3299,12 @@ i32.const 10 i32.gt_s ) - (func $start~anonymous|15 (; 44 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|15 (; 44 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 10 i32.gt_s ) - (func $start~anonymous|16 (; 45 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|16 (; 45 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -3312,7 +3312,7 @@ i32.const 3 i32.gt_s ) - (func $start~anonymous|17 (; 46 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|17 (; 46 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) global.get $std/array/i local.get $0 i32.add @@ -3339,7 +3339,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.load local.get $3 @@ -3362,7 +3362,7 @@ unreachable end ) - (func $start~anonymous|18 (; 48 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|18 (; 48 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -3372,7 +3372,7 @@ i32.add global.set $std/array/i ) - (func $start~anonymous|20 (; 49 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|20 (; 49 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) local.get $2 call $~lib/array/Array#pop drop @@ -3381,7 +3381,7 @@ i32.add global.set $std/array/i ) - (func $start~anonymous|21 (; 50 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|21 (; 50 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $1 i32.eqz @@ -3480,7 +3480,7 @@ end end ) - (func $start~anonymous|22 (; 51 ;) (type $iiif) (param $0 i32) (param $1 i32) (param $2 i32) (result f32) + (func $start:std/array~anonymous|22 (; 51 ;) (type $iiif) (param $0 i32) (param $1 i32) (param $2 i32) (result f32) local.get $0 f32.convert_i32_s ) @@ -3510,7 +3510,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 local.tee $2 i32.const 2 @@ -3537,7 +3537,7 @@ end local.get $4 ) - (func $start~anonymous|23 (; 53 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|23 (; 53 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -3575,7 +3575,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $3 local.tee $2 @@ -3603,14 +3603,14 @@ end local.get $5 ) - (func $start~anonymous|24 (; 55 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|24 (; 55 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) global.get $std/array/i local.get $0 i32.add global.set $std/array/i local.get $0 ) - (func $start~anonymous|25 (; 56 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|25 (; 56 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -3620,7 +3620,7 @@ global.set $std/array/i local.get $0 ) - (func $start~anonymous|26 (; 57 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|26 (; 57 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.ge_s @@ -3659,7 +3659,7 @@ i32.load offset=8 local.set $2 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $3 local.get $0 @@ -3680,7 +3680,7 @@ end local.get $4 ) - (func $start~anonymous|27 (; 59 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|27 (; 59 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -3693,7 +3693,7 @@ i32.const 2 i32.ge_s ) - (func $start~anonymous|28 (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|28 (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) global.get $std/array/i local.get $0 i32.add @@ -3702,7 +3702,7 @@ i32.const 2 i32.ge_s ) - (func $start~anonymous|29 (; 61 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|29 (; 61 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -3714,7 +3714,7 @@ i32.const 2 i32.ge_s ) - (func $start~anonymous|30 (; 62 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|30 (; 62 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add @@ -3744,7 +3744,7 @@ i32.ge_s br_if $break|0 i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $0 i32.load @@ -3767,7 +3767,7 @@ end local.get $3 ) - (func $start~anonymous|32 (; 64 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|32 (; 64 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.const 2 @@ -3775,7 +3775,7 @@ local.get $0 select ) - (func $start~anonymous|33 (; 65 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|33 (; 65 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.const 100 @@ -3783,7 +3783,7 @@ local.get $0 select ) - (func $start~anonymous|34 (; 66 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|34 (; 66 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 i32.const 1 call $~lib/array/Array#push @@ -3792,7 +3792,7 @@ local.get $1 i32.add ) - (func $start~anonymous|36 (; 67 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|36 (; 67 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 call $~lib/array/Array#pop drop @@ -3814,7 +3814,7 @@ i32.lt_s br_if $break|0 i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $0 i32.load @@ -3876,7 +3876,7 @@ if i32.const 0 i32.const 2896 - i32.const 972 + i32.const 968 i32.const 4 call $~lib/env/abort unreachable @@ -3971,7 +3971,7 @@ f32.load offset=8 local.set $6 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $6 local.get $2 @@ -4092,7 +4092,7 @@ f32.load offset=8 local.set $5 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $5 local.get $2 @@ -4209,7 +4209,7 @@ f32.load offset=8 local.set $6 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $6 local.get $2 @@ -4314,7 +4314,7 @@ f32.load offset=8 local.set $5 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $4 local.get $5 local.get $1 @@ -4544,7 +4544,7 @@ f64.load offset=8 local.set $6 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $6 local.get $2 @@ -4665,7 +4665,7 @@ f64.load offset=8 local.set $5 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $5 local.get $2 @@ -4782,7 +4782,7 @@ f64.load offset=8 local.set $6 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $6 local.get $2 @@ -4887,7 +4887,7 @@ f64.load offset=8 local.set $5 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $4 local.get $5 local.get $1 @@ -5117,7 +5117,7 @@ i32.load offset=8 local.set $6 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $6 local.get $2 @@ -5238,7 +5238,7 @@ i32.load offset=8 local.set $3 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $3 local.get $2 @@ -5355,7 +5355,7 @@ i32.load offset=8 local.set $3 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $3 local.get $2 @@ -5458,7 +5458,7 @@ i32.load offset=8 local.set $4 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $4 local.get $1 @@ -5552,7 +5552,7 @@ if i32.const 0 i32.const 2896 - i32.const 981 + i32.const 977 i32.const 24 call $~lib/env/abort unreachable @@ -5637,7 +5637,7 @@ i32.lt_s if i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 1 i32.sub @@ -5717,7 +5717,7 @@ i32.const 48 call $std/array/assertSorted ) - (func $start~anonymous|50 (; 92 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|50 (; 92 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.sub @@ -5775,7 +5775,7 @@ end local.get $1 ) - (func $start~anonymous|53 (; 94 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|53 (; 94 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -5845,7 +5845,7 @@ i32.load offset=8 local.set $4 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $4 local.get $1 @@ -5926,7 +5926,7 @@ end local.get $0 ) - (func $start~anonymous|54 (; 98 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|54 (; 98 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load local.get $1 @@ -6038,7 +6038,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -10043,7 +10043,7 @@ end local.get $1 ) - (func $start (; 147 ;) (type $_) + (func $start:std/array (; 147 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 8432 @@ -10102,7 +10102,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr8 i32.const 0 i32.const 0 @@ -10139,7 +10139,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr8 i32.const 2 i32.const -2 @@ -10195,7 +10195,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr32 i32.const 0 i32.const 0 @@ -10234,7 +10234,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr32 i32.const 2 i32.const -2 @@ -11048,7 +11048,7 @@ i32.const 664 global.set $std/array/cwArr i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 0 i32.const 3 @@ -11068,7 +11068,7 @@ i32.const 744 global.set $std/array/cwArr i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 1 i32.const 3 @@ -11088,7 +11088,7 @@ i32.const 824 global.set $std/array/cwArr i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 1 i32.const 2 @@ -11108,7 +11108,7 @@ i32.const 904 global.set $std/array/cwArr i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 2 i32.const 2 @@ -11185,7 +11185,7 @@ i32.const 1224 global.set $std/array/cwArr i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 0 i32.const -2 @@ -11262,7 +11262,7 @@ i32.const 1544 global.set $std/array/cwArr i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const -4 i32.const -3 @@ -12382,7 +12382,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const 0 call $~lib/array/Array#splice|trampoline @@ -12414,7 +12414,7 @@ i32.const 1720 global.set $std/array/sarr i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const 2 call $~lib/array/Array#splice|trampoline @@ -12508,7 +12508,7 @@ i32.const 2032 global.set $std/array/sarr i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const -1 call $~lib/array/Array#splice|trampoline @@ -12540,7 +12540,7 @@ i32.const 2136 global.set $std/array/sarr i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const -2 call $~lib/array/Array#splice|trampoline @@ -13901,7 +13901,7 @@ i64.reinterpret_f64 call $~lib/math/NativeMath.seedRandom i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/f32ArrayTyped local.set $0 i32.const 0 @@ -13909,7 +13909,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -13933,7 +13933,7 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/f64ArrayTyped local.set $0 i32.const 0 @@ -13941,7 +13941,7 @@ block $1of155 block $0of156 block $outOfRange57 - global.get $~argc + global.get $~lib/argc br_table $0of156 $1of155 $outOfRange57 end unreachable @@ -13965,7 +13965,7 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/i32ArrayTyped local.set $0 i32.const 0 @@ -13973,7 +13973,7 @@ block $1of158 block $0of159 block $outOfRange60 - global.get $~argc + global.get $~lib/argc br_table $0of159 $1of158 $outOfRange60 end unreachable @@ -13999,7 +13999,7 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/u32ArrayTyped local.set $0 i32.const 0 @@ -14007,7 +14007,7 @@ block $1of161 block $0of162 block $outOfRange63 - global.get $~argc + global.get $~lib/argc br_table $0of162 $1of161 $outOfRange63 end unreachable @@ -14185,7 +14185,7 @@ i32.const 54 call $std/array/assertSorted> i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/randomStringsActual call $std/array/assertSorted|trampoline global.get $std/array/randomStringsActual @@ -14203,7 +14203,7 @@ call $std/array/createRandomStringArray global.set $std/array/randomStrings400 i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/randomStrings400 call $std/array/assertSorted|trampoline call $~lib/array/Array#join @@ -14498,7 +14498,10 @@ unreachable end ) - (func $null (; 148 ;) (type $_) + (func $start (; 148 ;) (type $_) + call $start:std/array + ) + (func $null (; 149 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index 644f3bff85..95fe4b488b 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) @@ -25,7 +26,6 @@ (type $Ii (func (param i64) (result i32))) (type $iIi_ (func (param i32 i64 i32))) (type $iiIi (func (param i32 i32 i64) (result i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "Math" "random" (func $~lib/bindings/Math/random (result f64))) (memory $0 1) @@ -334,34 +334,16 @@ (data (i32.const 8408) "\04\00\00\00\00\00\00\00\d0 \00\00\00\00\00\00") (data (i32.const 8424) "\d8 \00\00\01\00\00\00") (table $0 56 funcref) - (elem (i32.const 0) $null $start~anonymous|1 $start~anonymous|2 $start~anonymous|3 $start~anonymous|4 $start~anonymous|5 $start~anonymous|6 $start~anonymous|7 $start~anonymous|8 $start~anonymous|9 $start~anonymous|10 $start~anonymous|11 $start~anonymous|12 $start~anonymous|13 $start~anonymous|14 $start~anonymous|15 $start~anonymous|16 $start~anonymous|17 $start~anonymous|18 $start~anonymous|19 $start~anonymous|20 $start~anonymous|21 $start~anonymous|22 $start~anonymous|23 $start~anonymous|24 $start~anonymous|25 $start~anonymous|26 $start~anonymous|27 $start~anonymous|28 $start~anonymous|29 $start~anonymous|30 $start~anonymous|31 $start~anonymous|32 $start~anonymous|33 $start~anonymous|34 $start~anonymous|35 $start~anonymous|36 $start~anonymous|37 $start~anonymous|38 $start~anonymous|39 $start~anonymous|40 $start~anonymous|41 $start~anonymous|42 $start~anonymous|43 $~lib/internal/sort/COMPARATOR~anonymous|44 $~lib/internal/sort/COMPARATOR~anonymous|45 $~lib/internal/sort/COMPARATOR~anonymous|46 $~lib/internal/sort/COMPARATOR~anonymous|47 $~lib/internal/sort/COMPARATOR~anonymous|48 $start~anonymous|49 $start~anonymous|50 $start~anonymous|51 $start~anonymous|52 $start~anonymous|53 $start~anonymous|54 $~lib/internal/sort/COMPARATOR~anonymous|55) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) + (elem (i32.const 0) $null $start:std/array~anonymous|1 $start:std/array~anonymous|2 $start:std/array~anonymous|3 $start:std/array~anonymous|4 $start:std/array~anonymous|5 $start:std/array~anonymous|6 $start:std/array~anonymous|7 $start:std/array~anonymous|8 $start:std/array~anonymous|9 $start:std/array~anonymous|10 $start:std/array~anonymous|11 $start:std/array~anonymous|12 $start:std/array~anonymous|13 $start:std/array~anonymous|14 $start:std/array~anonymous|15 $start:std/array~anonymous|16 $start:std/array~anonymous|17 $start:std/array~anonymous|18 $start:std/array~anonymous|19 $start:std/array~anonymous|20 $start:std/array~anonymous|21 $start:std/array~anonymous|22 $start:std/array~anonymous|23 $start:std/array~anonymous|24 $start:std/array~anonymous|25 $start:std/array~anonymous|26 $start:std/array~anonymous|27 $start:std/array~anonymous|28 $start:std/array~anonymous|29 $start:std/array~anonymous|30 $start:std/array~anonymous|31 $start:std/array~anonymous|32 $start:std/array~anonymous|33 $start:std/array~anonymous|34 $start:std/array~anonymous|35 $start:std/array~anonymous|36 $start:std/array~anonymous|37 $start:std/array~anonymous|38 $start:std/array~anonymous|39 $start:std/array~anonymous|40 $start:std/array~anonymous|41 $start:std/array~anonymous|42 $start:std/array~anonymous|43 $~lib/internal/sort/COMPARATOR~anonymous|44 $~lib/internal/sort/COMPARATOR~anonymous|45 $~lib/internal/sort/COMPARATOR~anonymous|46 $~lib/internal/sort/COMPARATOR~anonymous|47 $~lib/internal/sort/COMPARATOR~anonymous|48 $start:std/array~anonymous|49 $start:std/array~anonymous|50 $start:std/array~anonymous|51 $start:std/array~anonymous|52 $start:std/array~anonymous|53 $start:std/array~anonymous|54 $~lib/internal/sort/COMPARATOR~anonymous|55) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) - (global $~lib/internal/number/MAX_DOUBLE_LENGTH i32 (i32.const 28)) - (global $~lib/internal/number/_K (mut i32) (i32.const 0)) - (global $~lib/internal/number/_frc (mut i64) (i64.const 0)) - (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) - (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) - (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $Infinity f64 (f64.const inf)) (global $std/array/arr (mut i32) (i32.const 0)) (global $std/array/num (mut i32) (i32.const 1)) (global $std/array/Null (mut i32) (i32.const 0)) (global $std/array/str (mut i32) (i32.const 104)) (global $std/array/arr8 (mut i32) (i32.const 232)) (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/array/arr32 (mut i32) (i32.const 392)) (global $std/array/i (mut i32) (i32.const 0)) (global $std/array/other (mut i32) (i32.const 0)) @@ -402,50 +384,42 @@ (global $std/array/randomStringsActual (mut i32) (i32.const 3976)) (global $std/array/randomStringsExpected (mut i32) (i32.const 4048)) (global $std/array/randomStrings400 (mut i32) (i32.const 0)) - (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) - (global $~lib/internal/string/CharCode.PLUS i32 (i32.const 43)) - (global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45)) - (global $~lib/internal/string/CharCode.DOT i32 (i32.const 46)) - (global $~lib/internal/string/CharCode._0 i32 (i32.const 48)) - (global $~lib/internal/string/CharCode._1 i32 (i32.const 49)) - (global $~lib/internal/string/CharCode._2 i32 (i32.const 50)) - (global $~lib/internal/string/CharCode._3 i32 (i32.const 51)) - (global $~lib/internal/string/CharCode._4 i32 (i32.const 52)) - (global $~lib/internal/string/CharCode._5 i32 (i32.const 53)) - (global $~lib/internal/string/CharCode._6 i32 (i32.const 54)) - (global $~lib/internal/string/CharCode._7 i32 (i32.const 55)) - (global $~lib/internal/string/CharCode._8 i32 (i32.const 56)) - (global $~lib/internal/string/CharCode._9 i32 (i32.const 57)) - (global $~lib/internal/string/CharCode.A i32 (i32.const 65)) - (global $~lib/internal/string/CharCode.B i32 (i32.const 66)) - (global $~lib/internal/string/CharCode.E i32 (i32.const 69)) - (global $~lib/internal/string/CharCode.N i32 (i32.const 78)) - (global $~lib/internal/string/CharCode.O i32 (i32.const 79)) - (global $~lib/internal/string/CharCode.X i32 (i32.const 88)) - (global $~lib/internal/string/CharCode.Z i32 (i32.const 90)) - (global $~lib/internal/string/CharCode.a i32 (i32.const 97)) - (global $~lib/internal/string/CharCode.b i32 (i32.const 98)) - (global $~lib/internal/string/CharCode.e i32 (i32.const 101)) - (global $~lib/internal/string/CharCode.n i32 (i32.const 110)) - (global $~lib/internal/string/CharCode.o i32 (i32.const 111)) - (global $~lib/internal/string/CharCode.x i32 (i32.const 120)) - (global $~lib/internal/string/CharCode.z i32 (i32.const 122)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/builtins/i32.MIN_VALUE i32 (i32.const -2147483648)) + (global $~lib/internal/number/MAX_DOUBLE_LENGTH i32 (i32.const 28)) + (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) + (global $~lib/internal/number/_K (mut i32) (i32.const 0)) + (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (global $std/array/refArr (mut i32) (i32.const 0)) (global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1)) (global $~lib/builtins/i64.MAX_VALUE i64 (i64.const 9223372036854775807)) (global $std/array/subarr32 (mut i32) (i32.const 8256)) (global $std/array/subarr8 (mut i32) (i32.const 8352)) (global $std/array/subarrU32 (mut i32) (i32.const 8424)) - (global $HEAP_BASE i32 (i32.const 8432)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8432)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/internal/arraybuffer/computeSize (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 2 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -453,7 +427,7 @@ i32.sub i32.shl ) - (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -461,7 +435,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -478,9 +452,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -532,11 +506,11 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -561,12 +535,12 @@ i32.store local.get $1 ) - (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/memory/memset (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -820,7 +794,7 @@ end end ) - (func $~lib/array/Array#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -865,9 +839,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -881,7 +855,7 @@ end local.get $0 ) - (func $~lib/array/Array.isArray | null> (; 8 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array.isArray | null> (; 9 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 if (result i32) local.get $0 @@ -891,7 +865,7 @@ i32.const 1 end ) - (func $~lib/array/Array.isArray> (; 9 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array.isArray> (; 10 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 if (result i32) local.get $0 @@ -901,7 +875,7 @@ i32.const 1 end ) - (func $std/array/P#constructor (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/P#constructor (; 11 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -911,7 +885,7 @@ end local.get $0 ) - (func $~lib/array/Array.isArray

(; 11 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array.isArray

(; 12 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 if (result i32) local.get $0 @@ -921,7 +895,7 @@ i32.const 0 end ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -945,9 +919,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.1 + block $~lib/memory/memory.fill|inlined.1 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -988,7 +962,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint8Array#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#constructor (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -1002,7 +976,7 @@ local.set $0 local.get $0 ) - (func $~lib/array/Array.isArray (; 14 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array.isArray (; 15 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 if (result i32) local.get $0 @@ -1012,7 +986,7 @@ i32.const 0 end ) - (func $~lib/array/Array.isArray (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array.isArray (; 16 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 if (result i32) local.get $0 @@ -1022,7 +996,7 @@ i32.const 0 end ) - (func $~lib/array/Array.isArray (; 16 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array.isArray (; 17 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 if (result i32) local.get $0 @@ -1032,7 +1006,7 @@ i32.const 0 end ) - (func $~lib/array/Array#fill (; 17 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/array/Array#fill (; 18 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1101,7 +1075,7 @@ local.get $4 local.get $2 i32.add - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $1 @@ -1117,7 +1091,7 @@ end local.get $0 ) - (func $~lib/array/Array#__get (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1150,7 +1124,7 @@ unreachable end ) - (func $std/array/isArraysEqual (; 19 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/array/isArraysEqual (; 20 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $2 i32.eqz @@ -1217,12 +1191,12 @@ end i32.const 1 ) - (func $~lib/array/Array#fill|trampoline (; 20 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/array/Array#fill|trampoline (; 21 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -1241,7 +1215,7 @@ local.get $3 call $~lib/array/Array#fill ) - (func $~lib/array/Array#fill (; 21 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/array/Array#fill (; 22 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1341,7 +1315,7 @@ end local.get $0 ) - (func $~lib/array/Array#__get (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1374,7 +1348,7 @@ unreachable end ) - (func $std/array/isArraysEqual (; 23 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/array/isArraysEqual (; 24 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $2 i32.eqz @@ -1437,12 +1411,12 @@ end i32.const 1 ) - (func $~lib/array/Array#fill|trampoline (; 24 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/array/Array#fill|trampoline (; 25 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -1461,7 +1435,7 @@ local.get $3 call $~lib/array/Array#fill ) - (func $std/array/internalCapacity (; 25 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/internalCapacity (; 26 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.load @@ -1471,7 +1445,7 @@ i32.const 2 i32.shr_s ) - (func $~lib/internal/memory/memcpy (; 26 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 27 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2672,7 +2646,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 27 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 28 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -2899,10 +2873,10 @@ end end ) - (func $~lib/allocator/arena/__memory_free (; 28 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 29 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 29 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/arraybuffer/reallocateUnsafe (; 30 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2916,7 +2890,7 @@ i32.gt_s if local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_s i32.eqz if @@ -2930,7 +2904,7 @@ local.get $1 local.get $2 call $~lib/internal/arraybuffer/computeSize - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.sub i32.le_s if @@ -2941,13 +2915,13 @@ local.get $1 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $5 local.get $2 @@ -2967,9 +2941,9 @@ local.get $3 local.set $0 end - block $memory.fill|inlined.3 + block $~lib/memory/memory.fill|inlined.3 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $2 i32.add @@ -3009,7 +2983,7 @@ end local.get $0 ) - (func $~lib/array/Array#push (; 30 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#push (; 31 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3082,7 +3056,7 @@ end local.get $5 ) - (func $~lib/array/Array#__get (; 31 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 32 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3115,7 +3089,7 @@ unreachable end ) - (func $~lib/array/Array#pop (; 32 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array#pop (; 33 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3161,7 +3135,7 @@ i32.store offset=4 local.get $5 ) - (func $~lib/array/Array#concat (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#concat (; 34 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3192,12 +3166,12 @@ if local.get $5 i32.load - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $0 i32.load - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $7 local.get $2 @@ -3213,7 +3187,7 @@ if local.get $5 i32.load - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $2 i32.const 2 @@ -3222,7 +3196,7 @@ local.set $8 local.get $1 i32.load - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $7 local.get $3 @@ -3236,7 +3210,7 @@ end local.get $5 ) - (func $~lib/array/Array#copyWithin (; 34 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/array/Array#copyWithin (; 35 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -3435,7 +3409,7 @@ end else local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $8 i32.const 2 @@ -3443,7 +3417,7 @@ i32.add local.set $13 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $9 i32.const 2 @@ -3461,11 +3435,11 @@ end local.get $0 ) - (func $~lib/array/Array#copyWithin|trampoline (; 35 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/array/Array#copyWithin|trampoline (; 36 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 2 i32.sub br_table $0of1 $1of1 $outOfRange @@ -3481,7 +3455,7 @@ local.get $3 call $~lib/array/Array#copyWithin ) - (func $std/array/isArraysEqual (; 36 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/array/isArraysEqual (; 37 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $2 i32.eqz @@ -3544,7 +3518,7 @@ end i32.const 1 ) - (func $~lib/array/Array#unshift (; 37 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#unshift (; 38 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3598,15 +3572,15 @@ local.get $2 i32.store end - block $memory.copy|inlined.4 + block $~lib/memory/memory.copy|inlined.4 local.get $2 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 4 i32.add local.set $6 local.get $2 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $7 local.get $3 @@ -3644,7 +3618,7 @@ i32.store offset=4 local.get $5 ) - (func $~lib/array/Array#shift (; 38 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array#shift (; 39 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3691,13 +3665,13 @@ i32.const 1 i32.sub local.set $7 - block $memory.copy|inlined.5 + block $~lib/memory/memory.copy|inlined.5 local.get $2 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $5 local.get $2 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 4 i32.add @@ -3735,7 +3709,7 @@ i32.store offset=4 local.get $6 ) - (func $~lib/array/Array#reverse (; 39 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/array/Array#reverse (; 40 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3853,7 +3827,7 @@ end local.get $0 ) - (func $~lib/array/Array#indexOf (; 40 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#indexOf (; 41 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3936,7 +3910,7 @@ end i32.const -1 ) - (func $~lib/array/Array#splice (; 41 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#splice (; 42 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3999,17 +3973,17 @@ call $~lib/array/Array#constructor local.set $7 local.get $6 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $1 i32.const 2 i32.shl i32.add local.set $8 - block $memory.copy|inlined.6 + block $~lib/memory/memory.copy|inlined.6 local.get $7 i32.load - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 local.get $8 @@ -4034,7 +4008,7 @@ local.get $8 local.set $9 local.get $6 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $10 i32.const 2 @@ -4059,11 +4033,11 @@ i32.store offset=4 local.get $7 ) - (func $~lib/array/Array#splice|trampoline (; 42 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#splice|trampoline (; 43 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -4078,7 +4052,7 @@ local.get $2 call $~lib/array/Array#splice ) - (func $~lib/array/Array#__set (; 43 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__set (; 44 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4145,12 +4119,12 @@ i32.store offset=8 end ) - (func $start~anonymous|1 (; 44 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|1 (; 45 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.eq ) - (func $~lib/array/Array#findIndex (; 45 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#findIndex (; 46 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4180,7 +4154,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i32) local.get $0 i32.load @@ -4220,17 +4194,17 @@ end i32.const -1 ) - (func $start~anonymous|2 (; 46 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|2 (; 47 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 1 i32.eq ) - (func $start~anonymous|3 (; 47 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|3 (; 48 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 100 i32.eq ) - (func $start~anonymous|4 (; 48 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|4 (; 49 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -4239,12 +4213,12 @@ i32.const 100 i32.eq ) - (func $start~anonymous|5 (; 49 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|5 (; 50 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 100 i32.eq ) - (func $start~anonymous|6 (; 50 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|6 (; 51 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -4252,12 +4226,12 @@ i32.const 100 i32.eq ) - (func $start~anonymous|7 (; 51 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|7 (; 52 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.ge_s ) - (func $~lib/array/Array#every (; 52 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#every (; 53 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4287,7 +4261,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.11 (result i32) local.get $0 i32.load @@ -4328,12 +4302,12 @@ end i32.const 1 ) - (func $start~anonymous|8 (; 53 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|8 (; 54 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.le_s ) - (func $start~anonymous|9 (; 54 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|9 (; 55 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -4342,12 +4316,12 @@ i32.const 10 i32.lt_s ) - (func $start~anonymous|10 (; 55 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|10 (; 56 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 10 i32.lt_s ) - (func $start~anonymous|11 (; 56 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|11 (; 57 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -4355,12 +4329,12 @@ i32.const 3 i32.lt_s ) - (func $start~anonymous|12 (; 57 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|12 (; 58 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 3 i32.ge_s ) - (func $~lib/array/Array#some (; 58 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#some (; 59 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4390,7 +4364,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.13 (result i32) local.get $0 i32.load @@ -4430,12 +4404,12 @@ end i32.const 0 ) - (func $start~anonymous|13 (; 59 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|13 (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const -1 i32.le_s ) - (func $start~anonymous|14 (; 60 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|14 (; 61 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -4444,12 +4418,12 @@ i32.const 10 i32.gt_s ) - (func $start~anonymous|15 (; 61 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|15 (; 62 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 10 i32.gt_s ) - (func $start~anonymous|16 (; 62 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|16 (; 63 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -4457,13 +4431,13 @@ i32.const 3 i32.gt_s ) - (func $start~anonymous|17 (; 63 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|17 (; 64 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) global.get $std/array/i local.get $0 i32.add global.set $std/array/i ) - (func $~lib/array/Array#forEach (; 64 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/array/Array#forEach (; 65 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4493,7 +4467,7 @@ br_if $break|0 block i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.14 (result i32) local.get $0 i32.load @@ -4526,7 +4500,7 @@ unreachable end ) - (func $start~anonymous|18 (; 65 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|18 (; 66 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -4536,13 +4510,13 @@ i32.add global.set $std/array/i ) - (func $start~anonymous|19 (; 66 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|19 (; 67 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) global.get $std/array/i local.get $0 i32.add global.set $std/array/i ) - (func $start~anonymous|20 (; 67 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|20 (; 68 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) local.get $2 call $~lib/array/Array#pop drop @@ -4551,7 +4525,7 @@ i32.add global.set $std/array/i ) - (func $start~anonymous|21 (; 68 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $start:std/array~anonymous|21 (; 69 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $1 i32.const 0 @@ -4666,11 +4640,11 @@ end end ) - (func $start~anonymous|22 (; 69 ;) (type $iiif) (param $0 i32) (param $1 i32) (param $2 i32) (result f32) + (func $start:std/array~anonymous|22 (; 70 ;) (type $iiif) (param $0 i32) (param $1 i32) (param $2 i32) (result f32) local.get $0 f32.convert_i32_s ) - (func $~lib/array/Array#constructor (; 70 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 71 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4715,9 +4689,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.4 + block $~lib/memory/memory.fill|inlined.4 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -4731,7 +4705,7 @@ end local.get $0 ) - (func $~lib/array/Array#map (; 71 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#map (; 72 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4776,7 +4750,7 @@ local.set $7 block (result f32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.15 (result i32) local.get $0 i32.load @@ -4823,7 +4797,7 @@ end local.get $3 ) - (func $~lib/array/Array#__get (; 72 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__get (; 73 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4856,7 +4830,7 @@ unreachable end ) - (func $start~anonymous|23 (; 73 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|23 (; 74 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -4867,7 +4841,7 @@ global.set $std/array/i local.get $0 ) - (func $~lib/array/Array#map (; 74 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#map (; 75 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4911,7 +4885,7 @@ local.set $7 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.16 (result i32) local.get $0 i32.load @@ -4958,14 +4932,14 @@ end local.get $3 ) - (func $start~anonymous|24 (; 75 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|24 (; 76 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) global.get $std/array/i local.get $0 i32.add global.set $std/array/i local.get $0 ) - (func $start~anonymous|25 (; 76 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|25 (; 77 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -4975,12 +4949,12 @@ global.set $std/array/i local.get $0 ) - (func $start~anonymous|26 (; 77 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|26 (; 78 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.ge_s ) - (func $~lib/array/Array#filter (; 78 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#filter (; 79 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5034,7 +5008,7 @@ local.set $7 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $3 local.get $0 @@ -5061,7 +5035,7 @@ end local.get $2 ) - (func $start~anonymous|27 (; 79 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|27 (; 80 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 i32.const 100 call $~lib/array/Array#push @@ -5074,7 +5048,7 @@ i32.const 2 i32.ge_s ) - (func $start~anonymous|28 (; 80 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|28 (; 81 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) global.get $std/array/i local.get $0 i32.add @@ -5083,7 +5057,7 @@ i32.const 2 i32.ge_s ) - (func $start~anonymous|29 (; 81 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $start:std/array~anonymous|29 (; 82 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $2 call $~lib/array/Array#pop drop @@ -5095,12 +5069,12 @@ i32.const 2 i32.ge_s ) - (func $start~anonymous|30 (; 82 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|30 (; 83 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/array/Array#reduce (; 83 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#reduce (; 84 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5133,7 +5107,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 block $~lib/internal/arraybuffer/LOAD|inlined.18 (result i32) local.get $0 @@ -5169,12 +5143,12 @@ end local.get $3 ) - (func $start~anonymous|31 (; 84 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|31 (; 85 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $start~anonymous|32 (; 85 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|32 (; 86 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 i32.const 0 i32.ne @@ -5186,7 +5160,7 @@ i32.gt_s end ) - (func $~lib/array/Array#reduce (; 86 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#reduce (; 87 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5219,7 +5193,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 block $~lib/internal/arraybuffer/LOAD|inlined.19 (result i32) local.get $0 @@ -5255,7 +5229,7 @@ end local.get $3 ) - (func $start~anonymous|33 (; 87 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|33 (; 88 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 i32.const 0 i32.ne @@ -5267,7 +5241,7 @@ i32.gt_s end ) - (func $start~anonymous|34 (; 88 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|34 (; 89 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 i32.const 1 call $~lib/array/Array#push @@ -5276,12 +5250,12 @@ local.get $1 i32.add ) - (func $start~anonymous|35 (; 89 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|35 (; 90 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $start~anonymous|36 (; 90 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|36 (; 91 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 call $~lib/array/Array#pop drop @@ -5289,12 +5263,12 @@ local.get $1 i32.add ) - (func $start~anonymous|37 (; 91 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|37 (; 92 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/array/Array#reduceRight (; 92 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#reduceRight (; 93 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5316,7 +5290,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 block $~lib/internal/arraybuffer/LOAD|inlined.20 (result i32) local.get $0 @@ -5352,12 +5326,12 @@ end local.get $3 ) - (func $start~anonymous|38 (; 93 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|38 (; 94 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $start~anonymous|39 (; 94 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|39 (; 95 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 i32.const 0 i32.ne @@ -5369,7 +5343,7 @@ i32.gt_s end ) - (func $~lib/array/Array#reduceRight (; 95 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/array/Array#reduceRight (; 96 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5391,7 +5365,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 block $~lib/internal/arraybuffer/LOAD|inlined.21 (result i32) local.get $0 @@ -5427,7 +5401,7 @@ end local.get $3 ) - (func $start~anonymous|40 (; 96 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|40 (; 97 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 i32.const 0 i32.ne @@ -5439,7 +5413,7 @@ i32.gt_s end ) - (func $start~anonymous|41 (; 97 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|41 (; 98 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 i32.const 1 call $~lib/array/Array#push @@ -5448,12 +5422,12 @@ local.get $1 i32.add ) - (func $start~anonymous|42 (; 98 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|42 (; 99 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $start~anonymous|43 (; 99 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $start:std/array~anonymous|43 (; 100 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 call $~lib/array/Array#pop drop @@ -5461,7 +5435,7 @@ local.get $1 i32.add ) - (func $~lib/math/murmurHash3 (; 100 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/murmurHash3 (; 101 ;) (type $II) (param $0 i64) (result i64) local.get $0 local.get $0 i64.const 33 @@ -5490,7 +5464,7 @@ local.set $0 local.get $0 ) - (func $~lib/math/splitMix32 (; 101 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/splitMix32 (; 102 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 1831565813 i32.add @@ -5525,13 +5499,13 @@ i32.shr_u i32.xor ) - (func $~lib/math/NativeMath.seedRandom (; 102 ;) (type $I_) (param $0 i64) + (func $~lib/math/NativeMath.seedRandom (; 103 ;) (type $I_) (param $0 i64) local.get $0 i64.eqz if i32.const 0 i32.const 2896 - i32.const 972 + i32.const 968 i32.const 4 call $~lib/env/abort unreachable @@ -5554,7 +5528,7 @@ call $~lib/math/splitMix32 global.set $~lib/math/random_state1_32 ) - (func $~lib/internal/sort/insertionSort (; 103 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort (; 104 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -5620,7 +5594,7 @@ local.set $10 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $8 local.get $10 local.get $3 @@ -5695,7 +5669,7 @@ unreachable end ) - (func $~lib/internal/sort/weakHeapSort (; 104 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/weakHeapSort (; 105 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -5724,7 +5698,7 @@ br $~lib/memory/memory.allocate|inlined.1 end local.set $6 - block $memory.fill|inlined.5 + block $~lib/memory/memory.fill|inlined.5 local.get $6 local.set $5 i32.const 0 @@ -5821,7 +5795,7 @@ local.set $13 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $12 local.get $13 local.get $3 @@ -6058,7 +6032,7 @@ local.set $12 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $13 local.get $12 local.get $3 @@ -6225,7 +6199,7 @@ f32.store offset=8 end ) - (func $~lib/array/Array#sort (; 105 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort (; 106 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6298,7 +6272,7 @@ local.set $8 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $8 local.get $1 @@ -6377,7 +6351,7 @@ end local.get $0 ) - (func $~lib/internal/sort/COMPARATOR~anonymous|44 (; 106 ;) (type $ffi) (param $0 f32) (param $1 f32) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|44 (; 107 ;) (type $ffi) (param $0 f32) (param $1 f32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -6410,11 +6384,11 @@ i32.lt_s i32.sub ) - (func $~lib/array/Array#sort|trampoline (; 107 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort|trampoline (; 108 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -6429,12 +6403,12 @@ local.get $1 call $~lib/array/Array#sort ) - (func $~lib/builtins/isNaN (; 108 ;) (type $fi) (param $0 f32) (result i32) + (func $~lib/builtins/isNaN (; 109 ;) (type $fi) (param $0 f32) (result i32) local.get $0 local.get $0 f32.ne ) - (func $std/array/isArraysEqual (; 109 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/array/isArraysEqual (; 110 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $2 i32.eqz @@ -6513,7 +6487,7 @@ end i32.const 1 ) - (func $~lib/internal/sort/insertionSort (; 110 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort (; 111 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -6579,7 +6553,7 @@ local.set $10 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $8 local.get $10 local.get $3 @@ -6654,7 +6628,7 @@ unreachable end ) - (func $~lib/internal/sort/weakHeapSort (; 111 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/weakHeapSort (; 112 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -6683,7 +6657,7 @@ br $~lib/memory/memory.allocate|inlined.2 end local.set $6 - block $memory.fill|inlined.6 + block $~lib/memory/memory.fill|inlined.6 local.get $6 local.set $5 i32.const 0 @@ -6780,7 +6754,7 @@ local.set $13 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $12 local.get $13 local.get $3 @@ -7017,7 +6991,7 @@ local.set $12 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $13 local.get $12 local.get $3 @@ -7184,7 +7158,7 @@ f64.store offset=8 end ) - (func $~lib/array/Array#sort (; 112 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort (; 113 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7257,7 +7231,7 @@ local.set $8 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $8 local.get $1 @@ -7336,7 +7310,7 @@ end local.get $0 ) - (func $~lib/internal/sort/COMPARATOR~anonymous|45 (; 113 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|45 (; 114 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32) (local $2 i64) (local $3 i64) local.get $0 @@ -7369,11 +7343,11 @@ i64.lt_s i32.sub ) - (func $~lib/array/Array#sort|trampoline (; 114 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort|trampoline (; 115 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -7388,7 +7362,7 @@ local.get $1 call $~lib/array/Array#sort ) - (func $~lib/array/Array#__get (; 115 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__get (; 116 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7421,12 +7395,12 @@ unreachable end ) - (func $~lib/builtins/isNaN (; 116 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/builtins/isNaN (; 117 ;) (type $Fi) (param $0 f64) (result i32) local.get $0 local.get $0 f64.ne ) - (func $std/array/isArraysEqual (; 117 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/array/isArraysEqual (; 118 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $2 i32.eqz @@ -7505,7 +7479,7 @@ end i32.const 1 ) - (func $~lib/internal/sort/insertionSort (; 118 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort (; 119 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -7571,7 +7545,7 @@ local.set $9 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $9 local.get $3 @@ -7646,7 +7620,7 @@ unreachable end ) - (func $~lib/internal/sort/weakHeapSort (; 119 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/weakHeapSort (; 120 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -7675,7 +7649,7 @@ br $~lib/memory/memory.allocate|inlined.3 end local.set $6 - block $memory.fill|inlined.7 + block $~lib/memory/memory.fill|inlined.7 local.get $6 local.set $5 i32.const 0 @@ -7772,7 +7746,7 @@ local.set $12 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $11 local.get $12 local.get $3 @@ -8009,7 +7983,7 @@ local.set $10 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $10 local.get $3 @@ -8176,7 +8150,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#sort (; 120 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort (; 121 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8248,7 +8222,7 @@ local.set $7 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $1 @@ -8327,16 +8301,16 @@ end local.get $0 ) - (func $~lib/internal/sort/COMPARATOR~anonymous|46 (; 121 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|46 (; 122 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.sub ) - (func $~lib/array/Array#sort|trampoline (; 122 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort|trampoline (; 123 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -8351,7 +8325,7 @@ local.get $1 call $~lib/array/Array#sort ) - (func $~lib/internal/sort/insertionSort (; 123 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort (; 124 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -8417,7 +8391,7 @@ local.set $9 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $9 local.get $3 @@ -8492,7 +8466,7 @@ unreachable end ) - (func $~lib/internal/sort/weakHeapSort (; 124 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/weakHeapSort (; 125 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -8521,7 +8495,7 @@ br $~lib/memory/memory.allocate|inlined.4 end local.set $6 - block $memory.fill|inlined.8 + block $~lib/memory/memory.fill|inlined.8 local.get $6 local.set $5 i32.const 0 @@ -8618,7 +8592,7 @@ local.set $12 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $11 local.get $12 local.get $3 @@ -8855,7 +8829,7 @@ local.set $10 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $5 local.get $10 local.get $3 @@ -9022,7 +8996,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#sort (; 125 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort (; 126 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9094,7 +9068,7 @@ local.set $7 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $1 @@ -9173,7 +9147,7 @@ end local.get $0 ) - (func $~lib/internal/sort/COMPARATOR~anonymous|47 (; 126 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|47 (; 127 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.gt_u @@ -9182,11 +9156,11 @@ i32.lt_u i32.sub ) - (func $~lib/array/Array#sort|trampoline (; 127 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort|trampoline (; 128 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -9201,7 +9175,7 @@ local.get $1 call $~lib/array/Array#sort ) - (func $std/array/createReverseOrderedArray (; 128 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/createReverseOrderedArray (; 129 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -9247,7 +9221,7 @@ end local.get $1 ) - (func $~lib/math/NativeMath.random (; 129 ;) (type $F) (result f64) + (func $~lib/math/NativeMath.random (; 130 ;) (type $F) (result f64) (local $0 i64) (local $1 i64) (local $2 i64) @@ -9256,7 +9230,7 @@ if i32.const 0 i32.const 2896 - i32.const 981 + i32.const 977 i32.const 24 call $~lib/env/abort unreachable @@ -9304,7 +9278,7 @@ f64.const 1 f64.sub ) - (func $std/array/createRandomOrderedArray (; 130 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/createRandomOrderedArray (; 131 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -9350,12 +9324,12 @@ end local.get $1 ) - (func $~lib/internal/sort/COMPARATOR~anonymous|48 (; 131 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|48 (; 132 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.sub ) - (func $std/array/isSorted (; 132 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/array/isSorted (; 133 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) block $break|0 @@ -9378,7 +9352,7 @@ br_if $break|0 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $2 i32.const 1 @@ -9407,7 +9381,7 @@ end i32.const 1 ) - (func $std/array/assertSorted (; 133 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $std/array/assertSorted (; 134 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 call $~lib/array/Array#sort @@ -9423,7 +9397,7 @@ unreachable end ) - (func $std/array/assertSortedDefault (; 134 ;) (type $i_) (param $0 i32) + (func $std/array/assertSortedDefault (; 135 ;) (type $i_) (param $0 i32) local.get $0 block $~lib/internal/sort/COMPARATOR|inlined.1 (result i32) i32.const 48 @@ -9431,27 +9405,27 @@ end call $std/array/assertSorted ) - (func $start~anonymous|49 (; 135 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|49 (; 136 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.sub ) - (func $start~anonymous|50 (; 136 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|50 (; 137 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.sub ) - (func $start~anonymous|51 (; 137 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|51 (; 138 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 i32.sub ) - (func $start~anonymous|52 (; 138 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|52 (; 139 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $1 local.get $0 i32.sub ) - (func $~lib/array/Array>#constructor (; 139 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#constructor (; 140 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9496,9 +9470,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.9 + block $~lib/memory/memory.fill|inlined.9 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -9512,7 +9486,7 @@ end local.get $0 ) - (func $~lib/array/Array>#__set (; 140 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array>#__set (; 141 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -9579,7 +9553,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array>#__get (; 141 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#__get (; 142 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9612,7 +9586,7 @@ unreachable end ) - (func $std/array/createReverseOrderedNestedArray (; 142 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/createReverseOrderedNestedArray (; 143 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -9668,7 +9642,7 @@ end local.get $1 ) - (func $start~anonymous|53 (; 143 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|53 (; 144 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.const 0 call $~lib/array/Array#__get @@ -9677,7 +9651,7 @@ call $~lib/array/Array#__get i32.sub ) - (func $~lib/internal/sort/insertionSort> (; 144 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort> (; 145 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -9743,7 +9717,7 @@ local.set $9 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $9 local.get $3 @@ -9818,7 +9792,7 @@ unreachable end ) - (func $~lib/array/Array>#sort (; 145 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#sort (; 146 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9890,7 +9864,7 @@ local.set $7 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $1 @@ -9958,7 +9932,7 @@ end local.get $0 ) - (func $std/array/isSorted> (; 146 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/array/isSorted> (; 147 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) block $break|0 @@ -9981,7 +9955,7 @@ br_if $break|0 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $2 i32.const 1 @@ -10010,7 +9984,7 @@ end i32.const 1 ) - (func $std/array/assertSorted> (; 147 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $std/array/assertSorted> (; 148 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 call $~lib/array/Array>#sort @@ -10026,7 +10000,7 @@ unreachable end ) - (func $~lib/array/Array>#constructor (; 148 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#constructor (; 149 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10071,9 +10045,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.10 + block $~lib/memory/memory.fill|inlined.10 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -10087,7 +10061,7 @@ end local.get $0 ) - (func $std/array/Proxy#constructor (; 149 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/array/Proxy#constructor (; 150 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -10100,7 +10074,7 @@ i32.store local.get $0 ) - (func $~lib/array/Array>#__set (; 150 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array>#__set (; 151 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -10167,7 +10141,7 @@ i32.store offset=8 end ) - (func $std/array/createReverseOrderedElementsArray (; 151 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/createReverseOrderedElementsArray (; 152 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -10215,14 +10189,14 @@ end local.get $1 ) - (func $start~anonymous|54 (; 152 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:std/array~anonymous|54 (; 153 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.load local.get $1 i32.load i32.sub ) - (func $~lib/internal/sort/insertionSort> (; 153 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort> (; 154 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -10288,7 +10262,7 @@ local.set $9 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $9 local.get $3 @@ -10363,7 +10337,7 @@ unreachable end ) - (func $~lib/array/Array>#sort (; 154 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#sort (; 155 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10435,7 +10409,7 @@ local.set $7 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $1 @@ -10503,7 +10477,7 @@ end local.get $0 ) - (func $~lib/array/Array>#__get (; 155 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#__get (; 156 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10536,7 +10510,7 @@ unreachable end ) - (func $std/array/isSorted> (; 156 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/array/isSorted> (; 157 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) block $break|0 @@ -10559,7 +10533,7 @@ br_if $break|0 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $2 i32.const 1 @@ -10588,7 +10562,7 @@ end i32.const 1 ) - (func $std/array/assertSorted> (; 157 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $std/array/assertSorted> (; 158 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 call $~lib/array/Array>#sort @@ -10604,7 +10578,7 @@ unreachable end ) - (func $~lib/internal/sort/insertionSort (; 158 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort (; 159 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -10670,7 +10644,7 @@ local.set $9 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $9 local.get $3 @@ -10745,7 +10719,7 @@ unreachable end ) - (func $~lib/array/Array#sort (; 159 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#sort (; 160 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10817,7 +10791,7 @@ local.set $7 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $1 @@ -10885,7 +10859,7 @@ end local.get $0 ) - (func $~lib/array/Array#__get (; 160 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 161 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10918,7 +10892,7 @@ unreachable end ) - (func $std/array/isSorted (; 161 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/array/isSorted (; 162 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) block $break|0 @@ -10941,7 +10915,7 @@ br_if $break|0 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $2 i32.const 1 @@ -10970,7 +10944,7 @@ end i32.const 1 ) - (func $std/array/assertSorted (; 162 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $std/array/assertSorted (; 163 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 call $~lib/array/Array#sort @@ -10986,7 +10960,7 @@ unreachable end ) - (func $~lib/internal/string/compareUnsafe (; 163 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/internal/string/compareUnsafe (; 164 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -11039,7 +11013,7 @@ end local.get $5 ) - (func $~lib/internal/sort/COMPARATOR~anonymous|55 (; 164 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|55 (; 165 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11112,11 +11086,11 @@ select call $~lib/internal/string/compareUnsafe ) - (func $std/array/assertSorted|trampoline (; 165 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $std/array/assertSorted|trampoline (; 166 ;) (type $ii_) (param $0 i32) (param $1 i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -11133,7 +11107,7 @@ local.get $1 call $std/array/assertSorted ) - (func $~lib/string/String.__eq (; 166 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 167 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -11177,13 +11151,13 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $~lib/string/String.__ne (; 167 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__ne (; 168 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 call $~lib/string/String.__eq i32.eqz ) - (func $std/array/isArraysEqual (; 168 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/array/isArraysEqual (; 169 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) local.get $2 i32.eqz @@ -11246,7 +11220,7 @@ end i32.const 1 ) - (func $~lib/array/Array#constructor (; 169 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 170 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11291,9 +11265,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.11 + block $~lib/memory/memory.fill|inlined.11 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -11307,7 +11281,7 @@ end local.get $0 ) - (func $~lib/internal/string/allocateUnsafe (; 170 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/string/allocateUnsafe (; 171 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -11316,7 +11290,7 @@ local.tee $1 if (result i32) local.get $0 - global.get $~lib/internal/string/MAX_LENGTH + i32.const 536870910 i32.le_s else local.get $1 @@ -11331,7 +11305,7 @@ unreachable end block $~lib/memory/memory.allocate|inlined.5 (result i32) - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 local.get $0 i32.const 1 i32.shl @@ -11347,7 +11321,7 @@ i32.store local.get $2 ) - (func $~lib/string/String#charAt (; 171 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#charAt (; 172 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.const 0 @@ -11382,7 +11356,7 @@ i32.store16 offset=4 local.get $2 ) - (func $~lib/internal/string/copyUnsafe (; 172 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + (func $~lib/internal/string/copyUnsafe (; 173 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -11391,7 +11365,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $5 local.get $2 @@ -11399,7 +11373,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $4 @@ -11411,7 +11385,7 @@ local.get $7 call $~lib/internal/memory/memmove ) - (func $~lib/string/String#concat (; 173 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#concat (; 174 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11469,7 +11443,7 @@ call $~lib/internal/string/copyUnsafe local.get $5 ) - (func $~lib/string/String.__concat (; 174 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__concat (; 175 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -11480,7 +11454,7 @@ local.get $1 call $~lib/string/String#concat ) - (func $std/array/createRandomString (; 175 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/createRandomString (; 176 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 f64) @@ -11522,7 +11496,7 @@ end local.get $1 ) - (func $~lib/array/Array#__set (; 176 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__set (; 177 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -11589,7 +11563,7 @@ i32.store offset=8 end ) - (func $std/array/createRandomStringArray (; 177 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/createRandomStringArray (; 178 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -11630,7 +11604,7 @@ end local.get $1 ) - (func $~lib/string/String#substring (; 178 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#substring (; 179 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -11740,7 +11714,7 @@ call $~lib/internal/string/copyUnsafe local.get $10 ) - (func $~lib/array/Array#join (; 179 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 180 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11967,7 +11941,7 @@ local.get $14 return ) - (func $~lib/internal/number/decimalCount32 (; 180 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/decimalCount32 (; 181 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 100000 @@ -12036,7 +12010,7 @@ unreachable unreachable ) - (func $~lib/internal/number/utoa32_lut (; 181 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/number/utoa32_lut (; 182 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -12211,7 +12185,7 @@ i32.const 1 i32.sub local.set $2 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $1 i32.add local.set $7 @@ -12224,7 +12198,7 @@ i32.store16 offset=4 end ) - (func $~lib/internal/number/itoa32 (; 182 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa32 (; 183 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -12271,17 +12245,17 @@ local.get $1 if local.get $3 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $3 ) - (func $~lib/internal/number/itoa (; 183 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa (; 184 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/internal/number/itoa32 return ) - (func $~lib/internal/number/itoa_stream (; 184 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/itoa_stream (; 185 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -12297,7 +12271,7 @@ i32.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -12335,12 +12309,12 @@ local.get $4 if local.get $0 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $3 ) - (func $~lib/array/Array#join (; 185 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 186 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12530,7 +12504,7 @@ local.get $13 return ) - (func $~lib/internal/number/utoa32 (; 186 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/utoa32 (; 187 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -12562,12 +12536,12 @@ end local.get $2 ) - (func $~lib/internal/number/itoa (; 187 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa (; 188 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/internal/number/utoa32 return ) - (func $~lib/internal/number/itoa_stream (; 188 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/itoa_stream (; 189 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -12582,7 +12556,7 @@ i32.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -12606,7 +12580,7 @@ end local.get $3 ) - (func $~lib/array/Array#join (; 189 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 190 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12796,14 +12770,14 @@ local.get $13 return ) - (func $~lib/builtins/isFinite (; 190 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/builtins/isFinite (; 191 ;) (type $Fi) (param $0 f64) (result i32) local.get $0 local.get $0 f64.sub f64.const 0 f64.eq ) - (func $~lib/internal/number/genDigits (; 191 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) + (func $~lib/internal/number/genDigits (; 192 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) (local $7 i32) (local $8 i64) (local $9 i64) @@ -13087,7 +13061,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $17 i32.const 65535 i32.and @@ -13259,7 +13233,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $19 i32.wrap_i64 i32.const 65535 @@ -13396,7 +13370,7 @@ end local.get $15 ) - (func $~lib/internal/number/prettify (; 192 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/prettify (; 193 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -13414,8 +13388,8 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT - global.get $~lib/internal/string/CharCode._0 + i32.const 46 + i32.const 48 i32.const 16 i32.shl i32.or @@ -13455,7 +13429,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $4 i32.const 1 @@ -13471,8 +13445,8 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT - global.get $~lib/internal/string/CharCode._0 + i32.const 46 + i32.const 48 i32.const 16 i32.shl i32.or @@ -13500,15 +13474,15 @@ i32.shl i32.add local.set $4 - block $memory.copy|inlined.9 + block $~lib/memory/memory.copy|inlined.9 local.get $4 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 2 i32.add local.set $5 local.get $4 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 i32.const 0 @@ -13527,7 +13501,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=4 local.get $1 i32.const 1 @@ -13550,9 +13524,9 @@ local.get $3 i32.sub local.set $4 - block $memory.copy|inlined.10 + block $~lib/memory/memory.copy|inlined.10 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.get $4 i32.const 1 @@ -13560,7 +13534,7 @@ i32.add local.set $7 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $1 @@ -13573,8 +13547,8 @@ call $~lib/internal/memory/memmove end local.get $0 - global.get $~lib/internal/string/CharCode._0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 48 + i32.const 46 i32.const 16 i32.shl i32.or @@ -13593,7 +13567,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $5 i32.const 1 @@ -13614,7 +13588,7 @@ i32.eq if local.get $0 - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.store16 offset=6 block $~lib/internal/number/genExponent|inlined.0 (result i32) local.get $0 @@ -13654,8 +13628,8 @@ call $~lib/internal/number/utoa32_lut end local.get $4 - global.get $~lib/internal/string/CharCode.MINUS - global.get $~lib/internal/string/CharCode.PLUS + i32.const 45 + i32.const 43 local.get $6 select i32.store16 offset=4 @@ -13671,15 +13645,15 @@ i32.const 1 i32.shl local.set $7 - block $memory.copy|inlined.11 + block $~lib/memory/memory.copy|inlined.11 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 4 i32.add local.set $6 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 2 i32.add @@ -13694,12 +13668,12 @@ call $~lib/internal/memory/memmove end local.get $0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=6 local.get $0 local.get $7 i32.add - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.store16 offset=6 local.get $1 block $~lib/internal/number/genExponent|inlined.1 (result i32) @@ -13742,8 +13716,8 @@ call $~lib/internal/number/utoa32_lut end local.get $4 - global.get $~lib/internal/string/CharCode.MINUS - global.get $~lib/internal/string/CharCode.PLUS + i32.const 45 + i32.const 43 local.get $6 select i32.store16 offset=4 @@ -13765,7 +13739,7 @@ unreachable unreachable ) - (func $~lib/internal/number/dtoa_core (; 193 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/internal/number/dtoa_core (; 194 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 i32) (local $3 f64) (local $4 i32) @@ -13806,7 +13780,7 @@ f64.neg local.set $1 local.get $0 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end block $~lib/internal/number/grisu2|inlined.0 (result i32) @@ -14242,7 +14216,7 @@ local.get $2 i32.add ) - (func $~lib/internal/number/dtoa (; 194 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/internal/number/dtoa (; 195 ;) (type $Fi) (param $0 f64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -14308,7 +14282,7 @@ end local.get $3 ) - (func $~lib/internal/number/dtoa_stream (; 195 ;) (type $iiFi) (param $0 i32) (param $1 i32) (param $2 f64) (result i32) + (func $~lib/internal/number/dtoa_stream (; 196 ;) (type $iiFi) (param $0 i32) (param $1 i32) (param $2 f64) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -14326,13 +14300,13 @@ f64.eq if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=6 local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=8 i32.const 3 return @@ -14345,13 +14319,13 @@ call $~lib/builtins/isNaN if local.get $0 - global.get $~lib/internal/string/CharCode.N + i32.const 78 i32.store16 offset=4 local.get $0 - global.get $~lib/internal/string/CharCode.a + i32.const 97 i32.store16 offset=6 local.get $0 - global.get $~lib/internal/string/CharCode.N + i32.const 78 i32.store16 offset=8 i32.const 3 return @@ -14369,13 +14343,13 @@ local.get $3 select local.set $5 - block $memory.copy|inlined.12 + block $~lib/memory/memory.copy|inlined.12 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $5 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $7 local.get $4 @@ -14397,7 +14371,7 @@ local.get $2 call $~lib/internal/number/dtoa_core ) - (func $~lib/array/Array#join (; 196 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 197 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 f64) @@ -14587,7 +14561,7 @@ local.get $13 return ) - (func $~lib/array/Array#join (; 197 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 198 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -14799,7 +14773,7 @@ local.get $9 return ) - (func $std/array/Ref#constructor (; 198 ;) (type $ii) (param $0 i32) (result i32) + (func $std/array/Ref#constructor (; 199 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -14809,7 +14783,7 @@ end local.get $0 ) - (func $~lib/array/Array#constructor (; 199 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#constructor (; 200 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -14854,9 +14828,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.12 + block $~lib/memory/memory.fill|inlined.12 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -14870,7 +14844,7 @@ end local.get $0 ) - (func $~lib/array/Array#__unchecked_set (; 200 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__unchecked_set (; 201 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -14894,7 +14868,7 @@ local.get $5 i32.store offset=8 ) - (func $~lib/array/Array#join (; 201 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 202 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -15078,7 +15052,7 @@ local.get $11 return ) - (func $~lib/internal/number/itoa (; 202 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa (; 203 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -15087,7 +15061,7 @@ call $~lib/internal/number/itoa32 return ) - (func $~lib/internal/number/itoa_stream (; 203 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/itoa_stream (; 204 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -15107,7 +15081,7 @@ i32.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -15157,12 +15131,12 @@ local.get $4 if local.get $0 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $3 ) - (func $~lib/array/Array#join (; 204 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 205 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -15352,14 +15326,14 @@ local.get $13 return ) - (func $~lib/internal/number/itoa (; 205 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa (; 206 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 65535 i32.and call $~lib/internal/number/utoa32 return ) - (func $~lib/internal/number/itoa_stream (; 206 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/itoa_stream (; 207 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -15376,7 +15350,7 @@ i32.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -15404,7 +15378,7 @@ end local.get $3 ) - (func $~lib/array/Array#join (; 207 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 208 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -15594,7 +15568,7 @@ local.get $13 return ) - (func $~lib/internal/number/decimalCount64 (; 208 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/decimalCount64 (; 209 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) local.get $0 i64.const 1000000000000000 @@ -15663,7 +15637,7 @@ unreachable unreachable ) - (func $~lib/internal/number/utoa64_lut (; 209 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) + (func $~lib/internal/number/utoa64_lut (; 210 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) (local $3 i32) (local $4 i64) (local $5 i32) @@ -15836,7 +15810,7 @@ local.get $2 call $~lib/internal/number/utoa32_lut ) - (func $~lib/internal/number/utoa64 (; 210 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/utoa64 (; 211 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -15898,12 +15872,12 @@ end local.get $1 ) - (func $~lib/internal/number/itoa (; 211 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/itoa (; 212 ;) (type $Ii) (param $0 i64) (result i32) local.get $0 call $~lib/internal/number/utoa64 return ) - (func $~lib/internal/number/itoa_stream (; 212 ;) (type $iiIi) (param $0 i32) (param $1 i32) (param $2 i64) (result i32) + (func $~lib/internal/number/itoa_stream (; 213 ;) (type $iiIi) (param $0 i32) (param $1 i32) (param $2 i64) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -15920,7 +15894,7 @@ i64.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -15969,7 +15943,7 @@ end local.get $3 ) - (func $~lib/array/Array#join (; 213 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 214 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i64) @@ -16159,7 +16133,7 @@ local.get $13 return ) - (func $~lib/internal/number/itoa64 (; 214 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/itoa64 (; 215 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -16238,17 +16212,17 @@ local.get $1 if local.get $2 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $2 ) - (func $~lib/internal/number/itoa (; 215 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/itoa (; 216 ;) (type $Ii) (param $0 i64) (result i32) local.get $0 call $~lib/internal/number/itoa64 return ) - (func $~lib/internal/number/itoa_stream (; 216 ;) (type $iiIi) (param $0 i32) (param $1 i32) (param $2 i64) (result i32) + (func $~lib/internal/number/itoa_stream (; 217 ;) (type $iiIi) (param $0 i32) (param $1 i32) (param $2 i64) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -16266,7 +16240,7 @@ i64.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -16331,12 +16305,12 @@ local.get $4 if local.get $0 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $3 ) - (func $~lib/array/Array#join (; 217 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 218 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i64) @@ -16526,7 +16500,7 @@ local.get $13 return ) - (func $~lib/array/Array>#join (; 218 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#join (; 219 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -16673,14 +16647,14 @@ local.get $3 return ) - (func $~lib/internal/number/itoa (; 219 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa (; 220 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 255 i32.and call $~lib/internal/number/utoa32 return ) - (func $~lib/internal/number/itoa_stream (; 220 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/itoa_stream (; 221 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -16697,7 +16671,7 @@ i32.eqz if local.get $0 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 i32.const 1 return @@ -16725,7 +16699,7 @@ end local.get $3 ) - (func $~lib/array/Array#join (; 221 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#join (; 222 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -16915,7 +16889,7 @@ local.get $13 return ) - (func $~lib/array/Array>#join (; 222 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#join (; 223 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -17062,7 +17036,7 @@ local.get $3 return ) - (func $~lib/array/Array>#join (; 223 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>#join (; 224 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -17209,7 +17183,7 @@ local.get $3 return ) - (func $~lib/array/Array>>#join (; 224 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array>>#join (; 225 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -17356,21 +17330,12 @@ local.get $3 return ) - (func $start (; 225 ;) (type $_) + (func $start:std/array (; 226 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena i32.const 0 i32.const 0 call $~lib/array/Array#constructor @@ -17477,7 +17442,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr8 i32.const 0 i32.const 0 @@ -17519,7 +17484,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr8 i32.const 2 i32.const -2 @@ -17580,7 +17545,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr32 i32.const 0 i32.const 0 @@ -17622,7 +17587,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/arr32 i32.const 2 i32.const -2 @@ -18328,7 +18293,7 @@ global.set $std/array/cwArr block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 0 i32.const 3 @@ -18351,7 +18316,7 @@ global.set $std/array/cwArr block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 1 i32.const 3 @@ -18374,7 +18339,7 @@ global.set $std/array/cwArr block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 1 i32.const 2 @@ -18397,7 +18362,7 @@ global.set $std/array/cwArr block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 2 i32.const 2 @@ -18477,7 +18442,7 @@ global.set $std/array/cwArr block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const 0 i32.const -2 @@ -18557,7 +18522,7 @@ global.set $std/array/cwArr block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/array/cwArr i32.const -4 i32.const -3 @@ -19566,7 +19531,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const 0 i32.const 0 @@ -19601,7 +19566,7 @@ global.set $std/array/sarr block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const 2 i32.const 0 @@ -19698,7 +19663,7 @@ global.set $std/array/sarr block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const -1 i32.const 0 @@ -19733,7 +19698,7 @@ global.set $std/array/sarr block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/sarr i32.const -2 i32.const 0 @@ -21236,7 +21201,7 @@ call $~lib/math/NativeMath.seedRandom block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/f32ArrayTyped i32.const 0 call $~lib/array/Array#sort|trampoline @@ -21257,7 +21222,7 @@ end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/f64ArrayTyped i32.const 0 call $~lib/array/Array#sort|trampoline @@ -21278,7 +21243,7 @@ end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/i32ArrayTyped i32.const 0 call $~lib/array/Array#sort|trampoline @@ -21299,7 +21264,7 @@ end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/array/u32ArrayTyped i32.const 0 call $~lib/array/Array#sort|trampoline @@ -21474,7 +21439,7 @@ call $std/array/assertSorted> block i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/randomStringsActual i32.const 0 call $std/array/assertSorted|trampoline @@ -21497,7 +21462,7 @@ global.set $std/array/randomStrings400 block i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/array/randomStrings400 i32.const 0 call $std/array/assertSorted|trampoline @@ -21857,6 +21822,9 @@ unreachable end ) - (func $null (; 226 ;) (type $_) + (func $start (; 227 ;) (type $_) + call $start:std/array + ) + (func $null (; 228 ;) (type $_) ) ) diff --git a/tests/compiler/std/arraybuffer.optimized.wat b/tests/compiler/std/arraybuffer.optimized.wat index c8c82b8845..67e77e99d1 100644 --- a/tests/compiler/std/arraybuffer.optimized.wat +++ b/tests/compiler/std/arraybuffer.optimized.wat @@ -1,11 +1,11 @@ (module + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iiiii (func (param i32 i32 i32 i32) (result i32))) - (type $_ (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32))) @@ -23,7 +23,7 @@ (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/arraybuffer/buffer (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/arraybuffer/sliced (mut i32) (i32.const 0)) (global $std/arraybuffer/arr8 (mut i32) (i32.const 0)) (export "memory" (memory $0)) @@ -1511,7 +1511,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of2 $1of2 $2of2 $outOfRange end unreachable @@ -1694,7 +1694,7 @@ block $2of2 block $1of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $1of2 $1of2 $2of2 $outOfRange @@ -1710,7 +1710,7 @@ local.get $1 call $~lib/dataview/DataView#constructor ) - (func $start (; 12 ;) (type $_) + (func $start:std/arraybuffer (; 12 ;) (type $_) (local $0 i32) i32.const 288 global.set $~lib/allocator/arena/startOffset @@ -1738,7 +1738,7 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const 0 call $~lib/arraybuffer/ArrayBuffer#slice|trampoline @@ -1778,7 +1778,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const 1 call $~lib/arraybuffer/ArrayBuffer#slice|trampoline @@ -1796,7 +1796,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const -1 call $~lib/arraybuffer/ArrayBuffer#slice|trampoline @@ -1882,7 +1882,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const 42 call $~lib/arraybuffer/ArrayBuffer#slice|trampoline @@ -1946,7 +1946,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc block $__inlined_func$~lib/arraybuffer/ArrayBuffer.isView6 (result i32) i32.const 0 global.get $std/arraybuffer/arr8 @@ -1967,7 +1967,10 @@ unreachable end ) - (func $null (; 13 ;) (type $_) + (func $start (; 13 ;) (type $_) + call $start:std/arraybuffer + ) + (func $null (; 14 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/arraybuffer.untouched.wat b/tests/compiler/std/arraybuffer.untouched.wat index cbefd3bdb1..5429c26bb0 100644 --- a/tests/compiler/std/arraybuffer.untouched.wat +++ b/tests/compiler/std/arraybuffer.untouched.wat @@ -1,11 +1,11 @@ (module + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iiiii (func (param i32 i32 i32 i32) (result i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\13\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") @@ -17,28 +17,34 @@ (data (i32.const 248) "\10\00\00\00~\00l\00i\00b\00/\00d\00a\00t\00a\00v\00i\00e\00w\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) (global $std/arraybuffer/buffer (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/arraybuffer/sliced (mut i32) (i32.const 0)) (global $std/arraybuffer/arr8 (mut i32) (i32.const 0)) (global $~lib/builtins/i32.MIN_VALUE i32 (i32.const -2147483648)) - (global $HEAP_BASE i32 (i32.const 284)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 284)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/internal/arraybuffer/computeSize (; 2 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -46,7 +52,7 @@ i32.sub i32.shl ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -54,7 +60,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -71,9 +77,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -125,11 +131,11 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -154,7 +160,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 4 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -408,13 +414,13 @@ end end ) - (func $~lib/arraybuffer/ArrayBuffer#constructor (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#constructor (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -433,7 +439,7 @@ i32.eqz if local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -447,7 +453,7 @@ end local.get $3 ) - (func $~lib/internal/memory/memcpy (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1648,7 +1654,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 8 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -1875,7 +1881,7 @@ end end ) - (func $~lib/arraybuffer/ArrayBuffer#slice (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#slice (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1951,13 +1957,13 @@ local.get $6 call $~lib/internal/arraybuffer/allocateUnsafe local.set $7 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $7 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $1 i32.add @@ -1971,12 +1977,12 @@ end local.get $7 ) - (func $~lib/arraybuffer/ArrayBuffer#slice|trampoline (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#slice|trampoline (; 10 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of2 $1of2 $2of2 $outOfRange end unreachable @@ -1984,7 +1990,7 @@ i32.const 0 local.set $1 end - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 local.set $2 end local.get $0 @@ -1992,7 +1998,7 @@ local.get $2 call $~lib/arraybuffer/ArrayBuffer#slice ) - (func $~lib/arraybuffer/ArrayBuffer.isView> (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer.isView> (; 11 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 i32.eq @@ -2002,7 +2008,7 @@ end i32.const 0 ) - (func $~lib/arraybuffer/ArrayBuffer.isView (; 11 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer.isView (; 12 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 i32.eq @@ -2012,7 +2018,7 @@ end i32.const 0 ) - (func $~lib/arraybuffer/ArrayBuffer.isView (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer.isView (; 13 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 i32.eq @@ -2023,7 +2029,7 @@ i32.const 1 return ) - (func $~lib/arraybuffer/ArrayBuffer.isView (; 13 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer.isView (; 14 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 i32.eq @@ -2034,7 +2040,7 @@ i32.const 1 return ) - (func $~lib/arraybuffer/ArrayBuffer.isView (; 14 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer.isView (; 15 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 0 i32.eq @@ -2045,12 +2051,12 @@ i32.const 1 return ) - (func $~lib/memory/memory.allocate (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 16 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2074,9 +2080,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.1 + block $~lib/memory/memory.fill|inlined.1 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -2117,7 +2123,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint8Array#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#constructor (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -2131,7 +2137,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2155,9 +2161,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.2 + block $~lib/memory/memory.fill|inlined.2 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -2198,7 +2204,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Int32Array#constructor (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int32Array#constructor (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -2212,7 +2218,7 @@ local.set $0 local.get $0 ) - (func $~lib/dataview/DataView#constructor (; 20 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/dataview/DataView#constructor (; 21 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 global.get $~lib/builtins/i32.MIN_VALUE i32.eq @@ -2224,7 +2230,7 @@ local.set $3 end local.get $2 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -2235,7 +2241,7 @@ unreachable end local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -2277,12 +2283,12 @@ i32.store offset=8 local.get $0 ) - (func $~lib/dataview/DataView#constructor|trampoline (; 21 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/dataview/DataView#constructor|trampoline (; 22 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -2301,18 +2307,9 @@ local.get $3 call $~lib/dataview/DataView#constructor ) - (func $start (; 22 ;) (type $_) + (func $start:std/arraybuffer (; 23 ;) (type $_) (local $0 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena i32.const 0 i32.const 8 i32.const 0 @@ -2333,7 +2330,7 @@ end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const 0 i32.const 0 @@ -2357,14 +2354,14 @@ global.get $std/arraybuffer/sliced local.set $0 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add end block $~lib/arraybuffer/ArrayBuffer#get:data|inlined.1 (result i32) global.get $std/arraybuffer/buffer local.set $0 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add end i32.ne @@ -2391,7 +2388,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const 1 i32.const 0 @@ -2413,7 +2410,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const -1 i32.const 0 @@ -2507,7 +2504,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/arraybuffer/buffer i32.const 42 i32.const 0 @@ -2641,7 +2638,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 0 global.get $std/arraybuffer/arr8 i32.load @@ -2660,6 +2657,9 @@ unreachable end ) - (func $null (; 23 ;) (type $_) + (func $start (; 24 ;) (type $_) + call $start:std/arraybuffer + ) + (func $null (; 25 ;) (type $_) ) ) diff --git a/tests/compiler/std/dataview.optimized.wat b/tests/compiler/std/dataview.optimized.wat index c30f1b7920..cf6bc42ee4 100644 --- a/tests/compiler/std/dataview.optimized.wat +++ b/tests/compiler/std/dataview.optimized.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) @@ -6,7 +7,6 @@ (type $iiif (func (param i32 i32 i32) (result f32))) (type $II (func (param i64) (result i64))) (type $iiii (func (param i32 i32 i32) (result i32))) - (type $_ (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (type $FUNCSIG$dii (func (param i32 i32) (result f64))) @@ -1096,7 +1096,7 @@ local.get $1 i32.store16 offset=8 ) - (func $start (; 23 ;) (type $_) + (func $start:std/dataview (; 23 ;) (type $_) (local $0 i32) i32.const 216 global.set $~lib/allocator/arena/startOffset @@ -2625,7 +2625,10 @@ unreachable end ) - (func $null (; 24 ;) (type $_) + (func $start (; 24 ;) (type $_) + call $start:std/dataview + ) + (func $null (; 25 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/dataview.untouched.wat b/tests/compiler/std/dataview.untouched.wat index 6dc7ace494..dcfaff5e63 100644 --- a/tests/compiler/std/dataview.untouched.wat +++ b/tests/compiler/std/dataview.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $ii (func (param i32) (result i32))) @@ -12,7 +13,6 @@ (type $iifi_ (func (param i32 i32 f32 i32))) (type $iiFi_ (func (param i32 i32 f64 i32))) (type $iiIi_ (func (param i32 i32 i64 i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\1b\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00t\00y\00p\00e\00d\00a\00r\00r\00a\00y\00.\00t\00s\00") @@ -21,26 +21,32 @@ (data (i32.const 176) "\0f\00\00\00s\00t\00d\00/\00d\00a\00t\00a\00v\00i\00e\00w\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) (global $std/dataview/array (mut i32) (i32.const 0)) (global $~lib/builtins/i32.MIN_VALUE i32 (i32.const -2147483648)) (global $std/dataview/view (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 212)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 212)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/internal/arraybuffer/computeSize (; 2 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -48,7 +54,7 @@ i32.sub i32.shl ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -56,7 +62,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -73,9 +79,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -127,11 +133,11 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -156,7 +162,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 4 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -410,12 +416,12 @@ end end ) - (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -439,9 +445,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -482,7 +488,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint8Array#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -496,7 +502,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#__set (; 8 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 9 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -537,7 +543,7 @@ i32.store8 offset=8 end ) - (func $~lib/dataview/DataView#constructor (; 9 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/dataview/DataView#constructor (; 10 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $3 global.get $~lib/builtins/i32.MIN_VALUE i32.eq @@ -549,7 +555,7 @@ local.set $3 end local.get $2 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -560,7 +566,7 @@ unreachable end local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -602,7 +608,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/polyfills/bswap (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/polyfills/bswap (; 11 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const -16711936 i32.and @@ -616,7 +622,7 @@ i32.or return ) - (func $~lib/dataview/DataView#getFloat32 (; 11 ;) (type $iiif) (param $0 i32) (param $1 i32) (param $2 i32) (result f32) + (func $~lib/dataview/DataView#getFloat32 (; 12 ;) (type $iiif) (param $0 i32) (param $1 i32) (param $2 i32) (result f32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -630,7 +636,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -676,7 +682,7 @@ f32.reinterpret_i32 end ) - (func $~lib/polyfills/bswap (; 12 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/polyfills/bswap (; 13 ;) (type $II) (param $0 i64) (result i64) (local $1 i64) (local $2 i64) (local $3 i64) @@ -715,7 +721,7 @@ i64.rotr return ) - (func $~lib/dataview/DataView#getFloat64 (; 13 ;) (type $iiiF) (param $0 i32) (param $1 i32) (param $2 i32) (result f64) + (func $~lib/dataview/DataView#getFloat64 (; 14 ;) (type $iiiF) (param $0 i32) (param $1 i32) (param $2 i32) (result f64) (local $3 i32) (local $4 i32) (local $5 i32) @@ -729,7 +735,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -775,7 +781,7 @@ f64.reinterpret_i64 end ) - (func $~lib/dataview/DataView#getInt8 (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/dataview/DataView#getInt8 (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -789,7 +795,7 @@ i32.load offset=8 local.set $4 local.get $2 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $5 if (result i32) @@ -819,7 +825,7 @@ i32.add i32.load8_s offset=8 ) - (func $~lib/polyfills/bswap (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/polyfills/bswap (; 16 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 8 i32.shl @@ -835,7 +841,7 @@ i32.or return ) - (func $~lib/dataview/DataView#getInt16 (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/dataview/DataView#getInt16 (; 17 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -850,7 +856,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -890,7 +896,7 @@ call $~lib/polyfills/bswap end ) - (func $~lib/polyfills/bswap (; 17 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/polyfills/bswap (; 18 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const -16711936 i32.and @@ -904,7 +910,7 @@ i32.or return ) - (func $~lib/dataview/DataView#getInt32 (; 18 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/dataview/DataView#getInt32 (; 19 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -919,7 +925,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -959,7 +965,7 @@ call $~lib/polyfills/bswap end ) - (func $~lib/polyfills/bswap (; 19 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/polyfills/bswap (; 20 ;) (type $II) (param $0 i64) (result i64) (local $1 i64) (local $2 i64) (local $3 i64) @@ -998,7 +1004,7 @@ i64.rotr return ) - (func $~lib/dataview/DataView#getInt64 (; 20 ;) (type $iiiI) (param $0 i32) (param $1 i32) (param $2 i32) (result i64) + (func $~lib/dataview/DataView#getInt64 (; 21 ;) (type $iiiI) (param $0 i32) (param $1 i32) (param $2 i32) (result i64) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1013,7 +1019,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -1053,7 +1059,7 @@ call $~lib/polyfills/bswap end ) - (func $~lib/dataview/DataView#getUint8 (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/dataview/DataView#getUint8 (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1067,7 +1073,7 @@ i32.load offset=8 local.set $4 local.get $2 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $5 if (result i32) @@ -1097,7 +1103,7 @@ i32.add i32.load8_u offset=8 ) - (func $~lib/polyfills/bswap (; 22 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/polyfills/bswap (; 23 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 8 i32.shl @@ -1111,7 +1117,7 @@ i32.or return ) - (func $~lib/dataview/DataView#getUint16 (; 23 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/dataview/DataView#getUint16 (; 24 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1126,7 +1132,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -1166,7 +1172,7 @@ call $~lib/polyfills/bswap end ) - (func $~lib/dataview/DataView#getUint32 (; 24 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/dataview/DataView#getUint32 (; 25 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1181,7 +1187,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -1221,7 +1227,7 @@ call $~lib/polyfills/bswap end ) - (func $~lib/dataview/DataView#getUint64 (; 25 ;) (type $iiiI) (param $0 i32) (param $1 i32) (param $2 i32) (result i64) + (func $~lib/dataview/DataView#getUint64 (; 26 ;) (type $iiiI) (param $0 i32) (param $1 i32) (param $2 i32) (result i64) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1236,7 +1242,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -1276,7 +1282,7 @@ call $~lib/polyfills/bswap end ) - (func $~lib/dataview/DataView#setFloat32 (; 26 ;) (type $iifi_) (param $0 i32) (param $1 i32) (param $2 f32) (param $3 i32) + (func $~lib/dataview/DataView#setFloat32 (; 27 ;) (type $iifi_) (param $0 i32) (param $1 i32) (param $2 f32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1290,7 +1296,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1338,7 +1344,7 @@ i32.store offset=8 end ) - (func $~lib/dataview/DataView#setFloat64 (; 27 ;) (type $iiFi_) (param $0 i32) (param $1 i32) (param $2 f64) (param $3 i32) + (func $~lib/dataview/DataView#setFloat64 (; 28 ;) (type $iiFi_) (param $0 i32) (param $1 i32) (param $2 f64) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1352,7 +1358,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1400,7 +1406,7 @@ i64.store offset=8 end ) - (func $~lib/dataview/DataView#setInt8 (; 28 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/dataview/DataView#setInt8 (; 29 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1414,7 +1420,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -1445,7 +1451,7 @@ local.get $2 i32.store8 offset=8 ) - (func $~lib/dataview/DataView#setInt16 (; 29 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/dataview/DataView#setInt16 (; 30 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1459,7 +1465,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1498,7 +1504,7 @@ end i32.store16 offset=8 ) - (func $~lib/dataview/DataView#setInt32 (; 30 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/dataview/DataView#setInt32 (; 31 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1512,7 +1518,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1551,7 +1557,7 @@ end i32.store offset=8 ) - (func $~lib/dataview/DataView#setInt64 (; 31 ;) (type $iiIi_) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i32) + (func $~lib/dataview/DataView#setInt64 (; 32 ;) (type $iiIi_) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1565,7 +1571,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1604,7 +1610,7 @@ end i64.store offset=8 ) - (func $~lib/dataview/DataView#setUint8 (; 32 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/dataview/DataView#setUint8 (; 33 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1618,7 +1624,7 @@ i32.load offset=8 local.set $5 local.get $3 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $6 if (result i32) @@ -1649,7 +1655,7 @@ local.get $2 i32.store8 offset=8 ) - (func $~lib/dataview/DataView#setUint16 (; 33 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/dataview/DataView#setUint16 (; 34 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1663,7 +1669,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1702,7 +1708,7 @@ end i32.store16 offset=8 ) - (func $~lib/dataview/DataView#setUint32 (; 34 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/dataview/DataView#setUint32 (; 35 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1716,7 +1722,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1755,7 +1761,7 @@ end i32.store offset=8 ) - (func $~lib/dataview/DataView#setUint64 (; 35 ;) (type $iiIi_) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i32) + (func $~lib/dataview/DataView#setUint64 (; 36 ;) (type $iiIi_) (param $0 i32) (param $1 i32) (param $2 i64) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -1769,7 +1775,7 @@ i32.load offset=8 local.set $6 local.get $4 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u local.tee $7 if (result i32) @@ -1808,17 +1814,8 @@ end i64.store offset=8 ) - (func $start (; 36 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:std/dataview (; 37 ;) (type $_) + call $start:~lib/allocator/arena i32.const 0 i32.const 8 call $~lib/typedarray/Uint8Array#constructor @@ -3501,6 +3498,9 @@ unreachable end ) - (func $null (; 37 ;) (type $_) + (func $start (; 38 ;) (type $_) + call $start:std/dataview + ) + (func $null (; 39 ;) (type $_) ) ) diff --git a/tests/compiler/std/date.optimized.wat b/tests/compiler/std/date.optimized.wat index 8f6fb870b3..f350be2673 100644 --- a/tests/compiler/std/date.optimized.wat +++ b/tests/compiler/std/date.optimized.wat @@ -1,9 +1,9 @@ (module + (type $_ (func)) (type $iiiiiiFF (func (param i32 i32 i32 i32 i32 i32 f64) (result f64))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $F (func (result f64))) (type $ii (func (param i32) (result i32))) - (type $_ (func)) (import "Date" "UTC" (func $~lib/bindings/Date/UTC (param i32 i32 i32 i32 i32 i32 f64) (result f64))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "Date" "now" (func $~lib/bindings/Date/now (result f64))) @@ -80,7 +80,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $start (; 4 ;) (type $_) + (func $start:std/date (; 4 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 40 @@ -202,7 +202,10 @@ unreachable end ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:std/date + ) + (func $null (; 6 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/date.untouched.wat b/tests/compiler/std/date.untouched.wat index 8f6616c803..050e135355 100644 --- a/tests/compiler/std/date.untouched.wat +++ b/tests/compiler/std/date.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iiiiiiFF (func (param i32 i32 i32 i32 i32 i32 f64) (result f64))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $F (func (result f64))) @@ -6,7 +7,6 @@ (type $ii (func (param i32) (result i32))) (type $iI (func (param i32) (result i64))) (type $iII (func (param i32 i64) (result i64))) - (type $_ (func)) (import "Date" "UTC" (func $~lib/bindings/Date/UTC (param i32 i32 i32 i32 i32 i32 f64) (result f64))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "Date" "now" (func $~lib/bindings/Date/now (result f64))) @@ -14,19 +14,27 @@ (data (i32.const 8) "\0b\00\00\00s\00t\00d\00/\00d\00a\00t\00e\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/date/creationTime (mut i64) (i64.const 0)) (global $std/date/date (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 36)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 36)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 3 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -34,7 +42,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -51,9 +59,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -105,12 +113,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/date/Date#constructor (; 5 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/date/Date#constructor (; 6 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) block (result i32) local.get $0 i32.eqz @@ -128,17 +136,17 @@ i64.store local.get $0 ) - (func $~lib/date/Date#getTime (; 6 ;) (type $iI) (param $0 i32) (result i64) + (func $~lib/date/Date#getTime (; 7 ;) (type $iI) (param $0 i32) (result i64) local.get $0 i64.load ) - (func $~lib/date/Date#setTime (; 7 ;) (type $iII) (param $0 i32) (param $1 i64) (result i64) + (func $~lib/date/Date#setTime (; 8 ;) (type $iII) (param $0 i32) (param $1 i64) (result i64) local.get $0 local.get $1 i64.store local.get $1 ) - (func $start (; 8 ;) (type $_) + (func $start:std/date (; 9 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -146,16 +154,7 @@ (local $4 i32) (local $5 i32) (local $6 i64) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena block $~lib/date/Date.UTC|inlined.0 (result i64) i32.const 1970 local.set $0 @@ -323,6 +322,9 @@ unreachable end ) - (func $null (; 9 ;) (type $_) + (func $start (; 10 ;) (type $_) + call $start:std/date + ) + (func $null (; 11 ;) (type $_) ) ) diff --git a/tests/compiler/std/gc-array.optimized.wat b/tests/compiler/std/gc-array.optimized.wat index b11a1bfbca..99153eb4f7 100644 --- a/tests/compiler/std/gc-array.optimized.wat +++ b/tests/compiler/std/gc-array.optimized.wat @@ -1,8 +1,8 @@ (module + (type $_ (func)) (type $i_ (func (param i32))) (type $ii (func (param i32) (result i32))) (type $ii_ (func (param i32 i32))) - (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $iiii_ (func (param i32 i32 i32 i32))) @@ -24,8 +24,8 @@ (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) (global $std/gc-array/arr (mut i32) (i32.const 48)) - (global $~argc (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/gc-array/main)) @@ -292,7 +292,7 @@ i32.or i32.store i32.const 1 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 16 i32.add @@ -1913,23 +1913,11 @@ local.get $2 call $~lib/collector/itcm/__gc_link ) - (func $std/gc-array/main (; 18 ;) (type $i) (result i32) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - i32.const 0 - ) - (func $start (; 19 ;) (type $_) + (func $start:std/gc-array (; 18 ;) (type $_) i32.const 184 global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset - i32.const 0 - global.set $~lib/collector/itcm/state call $~lib/collector/itcm/__gc_collect global.get $std/gc-array/arr i32.const 0 @@ -1953,6 +1941,16 @@ call $~lib/array/Array#__set call $~lib/collector/itcm/__gc_collect ) + (func $std/gc-array/main (; 19 ;) (type $i) (result i32) + global.get $~lib/started + i32.eqz + if + call $start:std/gc-array + i32.const 1 + global.set $~lib/started + end + i32.const 0 + ) (func $null (; 20 ;) (type $_) nop ) diff --git a/tests/compiler/std/gc-array.ts b/tests/compiler/std/gc-array.ts index 6be1ed84b7..f42c59d20c 100644 --- a/tests/compiler/std/gc-array.ts +++ b/tests/compiler/std/gc-array.ts @@ -20,4 +20,5 @@ arr[0] = {}; gc.collect(); // should collect the old one +@start export function main(): i32 { return 0; } diff --git a/tests/compiler/std/gc-array.untouched.wat b/tests/compiler/std/gc-array.untouched.wat index c13743f836..13bc1749c0 100644 --- a/tests/compiler/std/gc-array.untouched.wat +++ b/tests/compiler/std/gc-array.untouched.wat @@ -1,8 +1,8 @@ (module + (type $_ (func)) (type $i_ (func (param i32))) (type $ii (func (param i32) (result i32))) (type $ii_ (func (param i32 i32))) - (type $_ (func)) (type $iii (func (param i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $iiii_ (func (param i32 i32 i32 i32))) @@ -15,33 +15,33 @@ (data (i32.const 104) "\00\00\00\00\00\00\00\00\05\00\00\00\00\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (table $0 7 funcref) (elem (i32.const 0) $null $~lib/arraybuffer/ArrayBuffer~gc $~lib/array/Array~gc $~lib/collector/itcm/__gc_mark $std/gc-array/Foo~gc $~lib/string/String~gc $~lib/internal/arraybuffer/__gc) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/TRACE i32 (i32.const 0)) - (global $~lib/collector/itcm/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/collector/itcm/State.INIT i32 (i32.const 0)) - (global $~lib/collector/itcm/State.IDLE i32 (i32.const 1)) - (global $~lib/collector/itcm/State.MARK i32 (i32.const 2)) - (global $~lib/collector/itcm/State.SWEEP i32 (i32.const 3)) (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) (global $std/gc-array/arr (mut i32) (i32.const 48)) - (global $~argc (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $~started (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 180)) + (global $~lib/argc (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 180)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/gc-array/main)) - (func $~lib/arraybuffer/ArrayBuffer~gc (; 1 ;) (type $i_) (param $0 i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/arraybuffer/ArrayBuffer~gc (; 2 ;) (type $i_) (param $0 i32) local.get $0 i32.eqz if @@ -50,13 +50,13 @@ local.get $0 call $~lib/collector/itcm/__gc_mark ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/collector/itcm/ManagedObject#get:color (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load i32.const 3 i32.and ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/collector/itcm/ManagedObject#get:next (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load i32.const 3 @@ -64,7 +64,7 @@ i32.xor i32.and ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 4 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObject#set:next (; 5 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 local.get $0 @@ -74,7 +74,7 @@ i32.or i32.store ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 5 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObject#unlink (; 6 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -90,7 +90,7 @@ local.get $1 call $~lib/collector/itcm/ManagedObject#set:next ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 6 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObjectList#push (; 7 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) local.get $0 i32.load offset=4 @@ -108,7 +108,7 @@ local.get $1 i32.store offset=4 ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObject#makeGray (; 8 ;) (type $i_) (param $0 i32) local.get $0 global.get $~lib/collector/itcm/iter i32.eq @@ -133,7 +133,7 @@ i32.or i32.store ) - (func $~lib/collector/itcm/__gc_mark (; 8 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/__gc_mark (; 9 ;) (type $i_) (param $0 i32) (local $1 i32) local.get $0 if @@ -141,7 +141,7 @@ local.get $0 local.set $1 local.get $1 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.sub end local.set $1 @@ -155,7 +155,7 @@ end end ) - (func $~lib/array/Array~gc (; 9 ;) (type $i_) (param $0 i32) + (func $~lib/array/Array~gc (; 10 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -193,7 +193,7 @@ end end ) - (func $~lib/allocator/arena/__memory_allocate (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 11 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -201,7 +201,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -218,9 +218,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -272,7 +272,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 11 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObjectList#clear (; 12 ;) (type $i_) (param $0 i32) local.get $0 local.get $0 i32.store @@ -280,7 +280,7 @@ local.get $0 i32.store offset=4 ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 12 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObject#set:color (; 13 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $0 i32.load @@ -292,10 +292,10 @@ i32.or i32.store ) - (func $~lib/allocator/arena/__memory_free (; 13 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 14 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/collector/itcm/step (; 14 ;) (type $_) + (func $~lib/collector/itcm/step (; 15 ;) (type $_) (local $0 i32) (local $1 i32) block $break|0 @@ -306,26 +306,26 @@ global.get $~lib/collector/itcm/state local.set $1 local.get $1 - global.get $~lib/collector/itcm/State.INIT + i32.const 0 i32.eq br_if $case0|0 local.get $1 - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.eq br_if $case1|0 local.get $1 - global.get $~lib/collector/itcm/State.MARK + i32.const 2 i32.eq br_if $case2|0 local.get $1 - global.get $~lib/collector/itcm/State.SWEEP + i32.const 3 i32.eq br_if $case3|0 br $break|0 end block block $~lib/memory/memory.allocate|inlined.0 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.set $1 local.get $1 call $~lib/allocator/arena/__memory_allocate @@ -338,7 +338,7 @@ global.get $~lib/collector/itcm/fromSpace call $~lib/collector/itcm/ManagedObjectList#clear block $~lib/memory/memory.allocate|inlined.1 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.set $1 local.get $1 call $~lib/allocator/arena/__memory_allocate @@ -352,14 +352,14 @@ call $~lib/collector/itcm/ManagedObjectList#clear global.get $~lib/collector/itcm/toSpace global.set $~lib/collector/itcm/iter - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 global.set $~lib/collector/itcm/state end end block i32.const 3 call $~iterateRoots - global.get $~lib/collector/itcm/State.MARK + i32.const 2 global.set $~lib/collector/itcm/state br $break|0 unreachable @@ -381,12 +381,12 @@ i32.eqz call $~lib/collector/itcm/ManagedObject#set:color i32.const 1 - global.set $~argc + global.set $~lib/argc block $~lib/collector/itcm/objToRef|inlined.0 (result i32) local.get $0 local.set $1 local.get $1 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.add end local.get $0 @@ -414,7 +414,7 @@ local.get $1 call $~lib/collector/itcm/ManagedObject#get:next global.set $~lib/collector/itcm/iter - global.get $~lib/collector/itcm/State.SWEEP + i32.const 3 global.set $~lib/collector/itcm/state end end @@ -434,7 +434,7 @@ call $~lib/collector/itcm/ManagedObject#get:next global.set $~lib/collector/itcm/iter local.get $0 - global.get $HEAP_BASE + global.get $~lib/memory/HEAP_BASE i32.ge_u if block $~lib/memory/memory.free|inlined.0 @@ -448,7 +448,7 @@ else global.get $~lib/collector/itcm/toSpace call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 global.set $~lib/collector/itcm/state end br $break|0 @@ -457,7 +457,7 @@ unreachable end ) - (func $~lib/collector/itcm/__gc_collect (; 15 ;) (type $_) + (func $~lib/collector/itcm/__gc_collect (; 16 ;) (type $_) (local $0 i32) block $break|0 block $case1|0 @@ -465,11 +465,11 @@ global.get $~lib/collector/itcm/state local.set $0 local.get $0 - global.get $~lib/collector/itcm/State.INIT + i32.const 0 i32.eq br_if $case0|0 local.get $0 - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.eq br_if $case1|0 br $break|0 @@ -480,7 +480,7 @@ block $break|1 loop $continue|1 global.get $~lib/collector/itcm/state - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.ne if call $~lib/collector/itcm/step @@ -489,16 +489,16 @@ end end ) - (func $~lib/gc/gc.collect (; 16 ;) (type $_) + (func $~lib/gc/gc.collect (; 17 ;) (type $_) call $~lib/collector/itcm/__gc_collect return ) - (func $~lib/collector/itcm/__gc_allocate (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/collector/itcm/__gc_allocate (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 1073741824 + i32.const 16 i32.sub i32.gt_u if @@ -506,7 +506,7 @@ end call $~lib/collector/itcm/step block $~lib/memory/memory.allocate|inlined.2 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.get $0 i32.add local.set $2 @@ -528,11 +528,11 @@ local.get $3 local.set $2 local.get $2 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.add end ) - (func $std/gc-array/Foo~gc (; 18 ;) (type $i_) (param $0 i32) + (func $std/gc-array/Foo~gc (; 19 ;) (type $i_) (param $0 i32) local.get $0 i32.eqz if @@ -541,7 +541,7 @@ local.get $0 call $~lib/collector/itcm/__gc_mark ) - (func $~lib/string/String~gc (; 19 ;) (type $i_) (param $0 i32) + (func $~lib/string/String~gc (; 20 ;) (type $i_) (param $0 i32) local.get $0 i32.eqz if @@ -550,11 +550,11 @@ local.get $0 call $~lib/collector/itcm/__gc_mark ) - (func $~lib/internal/arraybuffer/computeSize (; 20 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 21 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -562,13 +562,13 @@ i32.sub i32.shl ) - (func $~lib/internal/arraybuffer/__gc (; 21 ;) (type $i_) (param $0 i32) + (func $~lib/internal/arraybuffer/__gc (; 22 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 22 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 23 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -589,7 +589,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memcpy (; 23 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 24 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1790,7 +1790,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 24 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 25 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -2017,7 +2017,7 @@ end end ) - (func $~lib/internal/memory/memset (; 25 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 26 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -2271,7 +2271,7 @@ end end ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/arraybuffer/reallocateUnsafe (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2285,7 +2285,7 @@ i32.gt_s if local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_s i32.eqz if @@ -2299,7 +2299,7 @@ local.get $1 local.get $2 call $~lib/internal/arraybuffer/computeSize - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.sub i32.le_s if @@ -2310,13 +2310,13 @@ local.get $1 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $5 local.get $2 @@ -2329,9 +2329,9 @@ local.get $3 local.set $0 end - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $2 i32.add @@ -2371,14 +2371,14 @@ end local.get $0 ) - (func $~lib/collector/itcm/__gc_link (; 27 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/__gc_link (; 28 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) block $~lib/collector/itcm/refToObj|inlined.1 (result i32) local.get $0 local.set $2 local.get $2 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.sub end local.set $3 @@ -2393,7 +2393,7 @@ local.get $1 local.set $2 local.get $2 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.sub end call $~lib/collector/itcm/ManagedObject#get:color @@ -2407,7 +2407,7 @@ call $~lib/collector/itcm/ManagedObject#makeGray end ) - (func $~lib/array/Array#__set (; 28 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__set (; 29 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2477,32 +2477,11 @@ local.get $2 call $~lib/collector/itcm/__gc_link ) - (func $std/gc-array/main (; 29 ;) (type $i) (result i32) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - i32.const 0 - ) - (func $start (; 30 ;) (type $_) + (func $start:std/gc-array (; 30 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - global.get $~lib/collector/itcm/State.INIT - global.set $~lib/collector/itcm/state + call $start:~lib/allocator/arena call $~lib/gc/gc.collect global.get $std/gc-array/arr i32.const 0 @@ -2538,9 +2517,22 @@ call $~lib/array/Array#__set call $~lib/gc/gc.collect ) - (func $null (; 31 ;) (type $_) + (func $std/gc-array/main (; 31 ;) (type $i) (result i32) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + i32.const 0 + ) + (func $start (; 32 ;) (type $_) + call $start:std/gc-array + ) + (func $null (; 33 ;) (type $_) ) - (func $~iterateRoots (; 32 ;) (type $i_) (param $0 i32) + (func $~iterateRoots (; 34 ;) (type $i_) (param $0 i32) global.get $std/gc-array/arr local.get $0 call_indirect (type $i_) diff --git a/tests/compiler/std/gc-basics.optimized.wat b/tests/compiler/std/gc-basics.optimized.wat index 8b7dc2d66d..3eb8e55d2e 100644 --- a/tests/compiler/std/gc-basics.optimized.wat +++ b/tests/compiler/std/gc-basics.optimized.wat @@ -1,6 +1,6 @@ (module - (type $i_ (func (param i32))) (type $_ (func)) + (type $i_ (func (param i32))) (type $ii (func (param i32) (result i32))) (type $ii_ (func (param i32 i32))) (type $iiii_ (func (param i32 i32 i32 i32))) @@ -18,10 +18,10 @@ (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/gc-basics/obj (mut i32) (i32.const 0)) (global $std/gc-basics/obj2 (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/gc-basics/main)) @@ -252,7 +252,7 @@ i32.or i32.store i32.const 1 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 16 i32.add @@ -374,17 +374,7 @@ end end ) - (func $std/gc-basics/main (; 10 ;) (type $i) (result i32) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - i32.const 0 - ) - (func $start (; 11 ;) (type $_) + (func $start:std/gc-basics (; 10 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -393,8 +383,6 @@ global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset - i32.const 0 - global.set $~lib/collector/itcm/state call $~lib/collector/itcm/__gc_allocate global.set $std/gc-basics/obj global.get $std/gc-basics/obj @@ -479,6 +467,16 @@ global.set $std/gc-basics/obj call $~lib/collector/itcm/__gc_collect ) + (func $std/gc-basics/main (; 11 ;) (type $i) (result i32) + global.get $~lib/started + i32.eqz + if + call $start:std/gc-basics + i32.const 1 + global.set $~lib/started + end + i32.const 0 + ) (func $null (; 12 ;) (type $_) nop ) diff --git a/tests/compiler/std/gc-basics.ts b/tests/compiler/std/gc-basics.ts index b4ddfa8658..fc79941f51 100644 --- a/tests/compiler/std/gc-basics.ts +++ b/tests/compiler/std/gc-basics.ts @@ -31,4 +31,5 @@ gc.collect(); // should free 'obj' because it isn't referenced anymore (see trac var obj2: MyObject; // should also iterate globals defined late +@start export function main(): i32 { return 0; } diff --git a/tests/compiler/std/gc-basics.untouched.wat b/tests/compiler/std/gc-basics.untouched.wat index 20946a8654..9366a8f38e 100644 --- a/tests/compiler/std/gc-basics.untouched.wat +++ b/tests/compiler/std/gc-basics.untouched.wat @@ -1,7 +1,7 @@ (module + (type $_ (func)) (type $i_ (func (param i32))) (type $iii (func (param i32 i32) (result i32))) - (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $ii_ (func (param i32 i32))) (type $iiii_ (func (param i32 i32 i32 i32))) @@ -11,35 +11,37 @@ (data (i32.const 8) "\00\00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s\00") (table $0 4 funcref) (elem (i32.const 0) $null $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark $~lib/string/String~gc) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/TRACE i32 (i32.const 0)) - (global $~lib/collector/itcm/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/collector/itcm/State.INIT i32 (i32.const 0)) - (global $~lib/collector/itcm/State.IDLE i32 (i32.const 1)) - (global $~lib/collector/itcm/State.MARK i32 (i32.const 2)) - (global $~lib/collector/itcm/State.SWEEP i32 (i32.const 3)) (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/gc-basics/obj (mut i32) (i32.const 0)) (global $std/gc-basics/obj2 (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 60)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 60)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/gc-basics/main)) - (func $std/gc-basics/MyObject_visit (; 1 ;) (type $i_) (param $0 i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $std/gc-basics/MyObject_visit (; 2 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -47,7 +49,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -64,9 +66,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -118,7 +120,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 3 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObjectList#clear (; 4 ;) (type $i_) (param $0 i32) local.get $0 local.get $0 i32.store @@ -126,13 +128,13 @@ local.get $0 i32.store offset=4 ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/collector/itcm/ManagedObject#get:color (; 5 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load i32.const 3 i32.and ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/collector/itcm/ManagedObject#get:next (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load i32.const 3 @@ -140,7 +142,7 @@ i32.xor i32.and ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 6 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObject#set:next (; 7 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 local.get $0 @@ -150,7 +152,7 @@ i32.or i32.store ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObject#unlink (; 8 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -166,7 +168,7 @@ local.get $1 call $~lib/collector/itcm/ManagedObject#set:next ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 8 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObjectList#push (; 9 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) local.get $0 i32.load offset=4 @@ -184,7 +186,7 @@ local.get $1 i32.store offset=4 ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 9 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObject#makeGray (; 10 ;) (type $i_) (param $0 i32) local.get $0 global.get $~lib/collector/itcm/iter i32.eq @@ -209,7 +211,7 @@ i32.or i32.store ) - (func $~lib/collector/itcm/__gc_mark (; 10 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/__gc_mark (; 11 ;) (type $i_) (param $0 i32) (local $1 i32) local.get $0 if @@ -217,7 +219,7 @@ local.get $0 local.set $1 local.get $1 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.sub end local.set $1 @@ -231,7 +233,7 @@ end end ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 11 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObject#set:color (; 12 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $0 i32.load @@ -243,10 +245,10 @@ i32.or i32.store ) - (func $~lib/allocator/arena/__memory_free (; 12 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 13 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/collector/itcm/step (; 13 ;) (type $_) + (func $~lib/collector/itcm/step (; 14 ;) (type $_) (local $0 i32) (local $1 i32) block $break|0 @@ -257,26 +259,26 @@ global.get $~lib/collector/itcm/state local.set $1 local.get $1 - global.get $~lib/collector/itcm/State.INIT + i32.const 0 i32.eq br_if $case0|0 local.get $1 - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.eq br_if $case1|0 local.get $1 - global.get $~lib/collector/itcm/State.MARK + i32.const 2 i32.eq br_if $case2|0 local.get $1 - global.get $~lib/collector/itcm/State.SWEEP + i32.const 3 i32.eq br_if $case3|0 br $break|0 end block block $~lib/memory/memory.allocate|inlined.0 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.set $1 local.get $1 call $~lib/allocator/arena/__memory_allocate @@ -289,7 +291,7 @@ global.get $~lib/collector/itcm/fromSpace call $~lib/collector/itcm/ManagedObjectList#clear block $~lib/memory/memory.allocate|inlined.1 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.set $1 local.get $1 call $~lib/allocator/arena/__memory_allocate @@ -303,14 +305,14 @@ call $~lib/collector/itcm/ManagedObjectList#clear global.get $~lib/collector/itcm/toSpace global.set $~lib/collector/itcm/iter - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 global.set $~lib/collector/itcm/state end end block i32.const 2 call $~iterateRoots - global.get $~lib/collector/itcm/State.MARK + i32.const 2 global.set $~lib/collector/itcm/state br $break|0 unreachable @@ -332,12 +334,12 @@ i32.eqz call $~lib/collector/itcm/ManagedObject#set:color i32.const 1 - global.set $~argc + global.set $~lib/argc block $~lib/collector/itcm/objToRef|inlined.0 (result i32) local.get $0 local.set $1 local.get $1 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.add end local.get $0 @@ -365,7 +367,7 @@ local.get $1 call $~lib/collector/itcm/ManagedObject#get:next global.set $~lib/collector/itcm/iter - global.get $~lib/collector/itcm/State.SWEEP + i32.const 3 global.set $~lib/collector/itcm/state end end @@ -385,7 +387,7 @@ call $~lib/collector/itcm/ManagedObject#get:next global.set $~lib/collector/itcm/iter local.get $0 - global.get $HEAP_BASE + global.get $~lib/memory/HEAP_BASE i32.ge_u if block $~lib/memory/memory.free|inlined.0 @@ -399,7 +401,7 @@ else global.get $~lib/collector/itcm/toSpace call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 global.set $~lib/collector/itcm/state end br $break|0 @@ -408,12 +410,12 @@ unreachable end ) - (func $~lib/collector/itcm/__gc_allocate (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/collector/itcm/__gc_allocate (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 1073741824 + i32.const 16 i32.sub i32.gt_u if @@ -421,7 +423,7 @@ end call $~lib/collector/itcm/step block $~lib/memory/memory.allocate|inlined.2 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.get $0 i32.add local.set $2 @@ -443,11 +445,11 @@ local.get $3 local.set $2 local.get $2 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.add end ) - (func $~lib/string/String~gc (; 15 ;) (type $i_) (param $0 i32) + (func $~lib/string/String~gc (; 16 ;) (type $i_) (param $0 i32) local.get $0 i32.eqz if @@ -456,7 +458,7 @@ local.get $0 call $~lib/collector/itcm/__gc_mark ) - (func $~lib/collector/itcm/__gc_collect (; 16 ;) (type $_) + (func $~lib/collector/itcm/__gc_collect (; 17 ;) (type $_) (local $0 i32) block $break|0 block $case1|0 @@ -464,11 +466,11 @@ global.get $~lib/collector/itcm/state local.set $0 local.get $0 - global.get $~lib/collector/itcm/State.INIT + i32.const 0 i32.eq br_if $case0|0 local.get $0 - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.eq br_if $case1|0 br $break|0 @@ -479,7 +481,7 @@ block $break|1 loop $continue|1 global.get $~lib/collector/itcm/state - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.ne if call $~lib/collector/itcm/step @@ -488,39 +490,18 @@ end end ) - (func $~lib/gc/gc.collect (; 17 ;) (type $_) + (func $~lib/gc/gc.collect (; 18 ;) (type $_) call $~lib/collector/itcm/__gc_collect return ) - (func $std/gc-basics/main (; 18 ;) (type $i) (result i32) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - i32.const 0 - ) - (func $start (; 19 ;) (type $_) + (func $start:std/gc-basics (; 19 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - global.get $~lib/collector/itcm/State.INIT - global.set $~lib/collector/itcm/state + call $start:~lib/allocator/arena i32.const 4 i32.const 1 call $~lib/collector/itcm/__gc_allocate @@ -622,9 +603,22 @@ global.set $std/gc-basics/obj call $~lib/gc/gc.collect ) - (func $null (; 20 ;) (type $_) + (func $std/gc-basics/main (; 20 ;) (type $i) (result i32) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + i32.const 0 + ) + (func $start (; 21 ;) (type $_) + call $start:std/gc-basics + ) + (func $null (; 22 ;) (type $_) ) - (func $~iterateRoots (; 21 ;) (type $i_) (param $0 i32) + (func $~iterateRoots (; 23 ;) (type $i_) (param $0 i32) global.get $std/gc-basics/obj local.get $0 call_indirect (type $i_) diff --git a/tests/compiler/std/gc-integration.optimized.wat b/tests/compiler/std/gc-integration.optimized.wat index b1cea52e67..3608527868 100644 --- a/tests/compiler/std/gc-integration.optimized.wat +++ b/tests/compiler/std/gc-integration.optimized.wat @@ -6,7 +6,7 @@ (memory $0 1) (data (i32.const 8) "\15\00\00\00s\00t\00d\00/\00g\00c\00-\00i\00n\00t\00e\00g\00r\00a\00t\00i\00o\00n\00.\00t\00s") (table $0 2 funcref) - (elem (i32.const 0) $null $start~anonymous|1) + (elem (i32.const 0) $null $start:std/gc-integration~anonymous|1) (global $std/gc-integration/B.d (mut i32) (i32.const 16)) (global $std/gc-integration/a_ref (mut i32) (i32.const 24)) (global $std/gc-integration/b_ref (mut i32) (i32.const 32)) @@ -14,7 +14,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start~anonymous|1 (; 1 ;) (type $i_) (param $0 i32) + (func $start:std/gc-integration~anonymous|1 (; 1 ;) (type $i_) (param $0 i32) global.get $std/gc-integration/i i32.const 1 i32.add @@ -33,7 +33,7 @@ unreachable end ) - (func $start (; 2 ;) (type $_) + (func $start:std/gc-integration (; 2 ;) (type $_) i32.const 8 i32.const 1 call_indirect (type $i_) @@ -58,7 +58,10 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:std/gc-integration + ) + (func $null (; 4 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/gc-integration.untouched.wat b/tests/compiler/std/gc-integration.untouched.wat index e719b79f1a..b2bb4459bb 100644 --- a/tests/compiler/std/gc-integration.untouched.wat +++ b/tests/compiler/std/gc-integration.untouched.wat @@ -6,18 +6,18 @@ (memory $0 1) (data (i32.const 8) "\15\00\00\00s\00t\00d\00/\00g\00c\00-\00i\00n\00t\00e\00g\00r\00a\00t\00i\00o\00n\00.\00t\00s\00") (table $0 2 funcref) - (elem (i32.const 0) $null $start~anonymous|1) + (elem (i32.const 0) $null $start:std/gc-integration~anonymous|1) (global $std/gc-integration/B.c i32 (i32.const 8)) (global $std/gc-integration/B.d (mut i32) (i32.const 16)) (global $std/gc-integration/no_ref (mut i32) (i32.const 64)) (global $std/gc-integration/a_ref (mut i32) (i32.const 24)) (global $std/gc-integration/b_ref (mut i32) (i32.const 32)) (global $std/gc-integration/i (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 56)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 56)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start~anonymous|1 (; 1 ;) (type $i_) (param $0 i32) + (func $start:std/gc-integration~anonymous|1 (; 1 ;) (type $i_) (param $0 i32) local.get $0 block (result i32) global.get $std/gc-integration/i @@ -39,7 +39,7 @@ unreachable end ) - (func $start (; 2 ;) (type $_) + (func $start:std/gc-integration (; 2 ;) (type $_) global.get $std/gc-integration/B.c drop global.get $std/gc-integration/B.d @@ -59,9 +59,12 @@ unreachable end ) - (func $null (; 3 ;) (type $_) + (func $start (; 3 ;) (type $_) + call $start:std/gc-integration ) - (func $~iterateRoots (; 4 ;) (type $i_) (param $0 i32) + (func $null (; 4 ;) (type $_) + ) + (func $~iterateRoots (; 5 ;) (type $i_) (param $0 i32) global.get $std/gc-integration/B.c local.get $0 call_indirect (type $i_) diff --git a/tests/compiler/std/gc-object.optimized.wat b/tests/compiler/std/gc-object.optimized.wat index 5f72257d84..4edf91c5dc 100644 --- a/tests/compiler/std/gc-object.optimized.wat +++ b/tests/compiler/std/gc-object.optimized.wat @@ -1,6 +1,6 @@ (module - (type $iii (func (param i32 i32) (result i32))) (type $_ (func)) + (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) (type $i_ (func (param i32))) (type $ii_ (func (param i32 i32))) @@ -15,9 +15,9 @@ (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/gc-object/obj (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/gc-object/main)) @@ -242,7 +242,7 @@ i32.or i32.store i32.const 1 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 16 i32.add @@ -406,23 +406,12 @@ end end ) - (func $std/gc-object/main (; 10 ;) (type $_) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - ) - (func $start (; 11 ;) (type $_) + (func $start:std/gc-object (; 10 ;) (type $_) (local $0 i32) i32.const 8 global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset - i32.const 0 - global.set $~lib/collector/itcm/state call $std/gc-object/Custom#constructor global.set $std/gc-object/obj call $~lib/collector/itcm/__gc_collect @@ -435,6 +424,15 @@ global.set $std/gc-object/obj call $~lib/collector/itcm/__gc_collect ) + (func $std/gc-object/main (; 11 ;) (type $_) + global.get $~lib/started + i32.eqz + if + call $start:std/gc-object + i32.const 1 + global.set $~lib/started + end + ) (func $null (; 12 ;) (type $_) nop ) diff --git a/tests/compiler/std/gc-object.ts b/tests/compiler/std/gc-object.ts index 4d04737b55..9a96a6a1c7 100644 --- a/tests/compiler/std/gc-object.ts +++ b/tests/compiler/std/gc-object.ts @@ -21,4 +21,5 @@ obj = null; gc.collect(); +@start export function main(): void {} diff --git a/tests/compiler/std/gc-object.untouched.wat b/tests/compiler/std/gc-object.untouched.wat index ee4265f51e..b6abdd5404 100644 --- a/tests/compiler/std/gc-object.untouched.wat +++ b/tests/compiler/std/gc-object.untouched.wat @@ -1,37 +1,39 @@ (module - (type $iii (func (param i32 i32) (result i32))) (type $_ (func)) + (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) (type $i_ (func (param i32))) (type $ii_ (func (param i32 i32))) (memory $0 0) (table $0 4 funcref) (elem (i32.const 0) $null $~lib/collector/itcm/__gc_mark $std/gc-object/Base~gc $std/gc-object/Custom~gc) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/TRACE i32 (i32.const 0)) - (global $~lib/collector/itcm/HEADER_SIZE i32 (i32.const 16)) - (global $~lib/collector/itcm/State.INIT i32 (i32.const 0)) - (global $~lib/collector/itcm/State.IDLE i32 (i32.const 1)) - (global $~lib/collector/itcm/State.MARK i32 (i32.const 2)) - (global $~lib/collector/itcm/State.SWEEP i32 (i32.const 3)) (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/gc-object/obj (mut i32) (i32.const 0)) - (global $~started (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/gc-object/main)) - (func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -39,7 +41,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -56,9 +58,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -110,7 +112,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 1 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObjectList#clear (; 2 ;) (type $i_) (param $0 i32) local.get $0 local.get $0 i32.store @@ -118,13 +120,13 @@ local.get $0 i32.store offset=4 ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/collector/itcm/ManagedObject#get:color (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load i32.const 3 i32.and ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/collector/itcm/ManagedObject#get:next (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load i32.const 3 @@ -132,7 +134,7 @@ i32.xor i32.and ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 4 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObject#set:next (; 5 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $1 local.get $0 @@ -142,7 +144,7 @@ i32.or i32.store ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 5 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObject#unlink (; 6 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) local.get $0 @@ -158,7 +160,7 @@ local.get $1 call $~lib/collector/itcm/ManagedObject#set:next ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 6 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObjectList#push (; 7 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) local.get $0 i32.load offset=4 @@ -176,7 +178,7 @@ local.get $1 i32.store offset=4 ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/ManagedObject#makeGray (; 8 ;) (type $i_) (param $0 i32) local.get $0 global.get $~lib/collector/itcm/iter i32.eq @@ -201,7 +203,7 @@ i32.or i32.store ) - (func $~lib/collector/itcm/__gc_mark (; 8 ;) (type $i_) (param $0 i32) + (func $~lib/collector/itcm/__gc_mark (; 9 ;) (type $i_) (param $0 i32) (local $1 i32) local.get $0 if @@ -209,7 +211,7 @@ local.get $0 local.set $1 local.get $1 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.sub end local.set $1 @@ -223,7 +225,7 @@ end end ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 9 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/collector/itcm/ManagedObject#set:color (; 10 ;) (type $ii_) (param $0 i32) (param $1 i32) local.get $0 local.get $0 i32.load @@ -235,10 +237,10 @@ i32.or i32.store ) - (func $~lib/allocator/arena/__memory_free (; 10 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 11 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/collector/itcm/step (; 11 ;) (type $_) + (func $~lib/collector/itcm/step (; 12 ;) (type $_) (local $0 i32) (local $1 i32) block $break|0 @@ -249,26 +251,26 @@ global.get $~lib/collector/itcm/state local.set $1 local.get $1 - global.get $~lib/collector/itcm/State.INIT + i32.const 0 i32.eq br_if $case0|0 local.get $1 - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.eq br_if $case1|0 local.get $1 - global.get $~lib/collector/itcm/State.MARK + i32.const 2 i32.eq br_if $case2|0 local.get $1 - global.get $~lib/collector/itcm/State.SWEEP + i32.const 3 i32.eq br_if $case3|0 br $break|0 end block block $~lib/memory/memory.allocate|inlined.0 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.set $1 local.get $1 call $~lib/allocator/arena/__memory_allocate @@ -281,7 +283,7 @@ global.get $~lib/collector/itcm/fromSpace call $~lib/collector/itcm/ManagedObjectList#clear block $~lib/memory/memory.allocate|inlined.1 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.set $1 local.get $1 call $~lib/allocator/arena/__memory_allocate @@ -295,14 +297,14 @@ call $~lib/collector/itcm/ManagedObjectList#clear global.get $~lib/collector/itcm/toSpace global.set $~lib/collector/itcm/iter - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 global.set $~lib/collector/itcm/state end end block i32.const 1 call $~iterateRoots - global.get $~lib/collector/itcm/State.MARK + i32.const 2 global.set $~lib/collector/itcm/state br $break|0 unreachable @@ -324,12 +326,12 @@ i32.eqz call $~lib/collector/itcm/ManagedObject#set:color i32.const 1 - global.set $~argc + global.set $~lib/argc block $~lib/collector/itcm/objToRef|inlined.0 (result i32) local.get $0 local.set $1 local.get $1 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.add end local.get $0 @@ -357,7 +359,7 @@ local.get $1 call $~lib/collector/itcm/ManagedObject#get:next global.set $~lib/collector/itcm/iter - global.get $~lib/collector/itcm/State.SWEEP + i32.const 3 global.set $~lib/collector/itcm/state end end @@ -377,7 +379,7 @@ call $~lib/collector/itcm/ManagedObject#get:next global.set $~lib/collector/itcm/iter local.get $0 - global.get $HEAP_BASE + global.get $~lib/memory/HEAP_BASE i32.ge_u if block $~lib/memory/memory.free|inlined.0 @@ -391,7 +393,7 @@ else global.get $~lib/collector/itcm/toSpace call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 global.set $~lib/collector/itcm/state end br $break|0 @@ -400,12 +402,12 @@ unreachable end ) - (func $~lib/collector/itcm/__gc_allocate (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/collector/itcm/__gc_allocate (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 1073741824 + i32.const 16 i32.sub i32.gt_u if @@ -413,7 +415,7 @@ end call $~lib/collector/itcm/step block $~lib/memory/memory.allocate|inlined.2 (result i32) - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 local.get $0 i32.add local.set $2 @@ -435,11 +437,11 @@ local.get $3 local.set $2 local.get $2 - global.get $~lib/collector/itcm/HEADER_SIZE + i32.const 16 i32.add end ) - (func $std/gc-object/Base~gc (; 13 ;) (type $i_) (param $0 i32) + (func $std/gc-object/Base~gc (; 14 ;) (type $i_) (param $0 i32) local.get $0 i32.eqz if @@ -448,7 +450,7 @@ local.get $0 call $~lib/collector/itcm/__gc_mark ) - (func $std/gc-object/Base#constructor (; 14 ;) (type $ii) (param $0 i32) (result i32) + (func $std/gc-object/Base#constructor (; 15 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -459,7 +461,7 @@ end local.get $0 ) - (func $std/gc-object/Custom~gc (; 15 ;) (type $i_) (param $0 i32) + (func $std/gc-object/Custom~gc (; 16 ;) (type $i_) (param $0 i32) local.get $0 i32.eqz if @@ -475,7 +477,7 @@ i32.load offset=4 call $~lib/collector/itcm/__gc_mark ) - (func $std/gc-object/Custom#constructor (; 16 ;) (type $ii) (param $0 i32) (result i32) + (func $std/gc-object/Custom#constructor (; 17 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.eqz if @@ -495,7 +497,7 @@ i32.store offset=4 local.get $0 ) - (func $~lib/collector/itcm/__gc_collect (; 17 ;) (type $_) + (func $~lib/collector/itcm/__gc_collect (; 18 ;) (type $_) (local $0 i32) block $break|0 block $case1|0 @@ -503,11 +505,11 @@ global.get $~lib/collector/itcm/state local.set $0 local.get $0 - global.get $~lib/collector/itcm/State.INIT + i32.const 0 i32.eq br_if $case0|0 local.get $0 - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.eq br_if $case1|0 br $break|0 @@ -518,7 +520,7 @@ block $break|1 loop $continue|1 global.get $~lib/collector/itcm/state - global.get $~lib/collector/itcm/State.IDLE + i32.const 1 i32.ne if call $~lib/collector/itcm/step @@ -527,32 +529,12 @@ end end ) - (func $~lib/gc/gc.collect (; 18 ;) (type $_) + (func $~lib/gc/gc.collect (; 19 ;) (type $_) call $~lib/collector/itcm/__gc_collect return ) - (func $std/gc-object/main (; 19 ;) (type $_) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - ) - (func $start (; 20 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - global.get $~lib/collector/itcm/State.INIT - global.set $~lib/collector/itcm/state + (func $start:std/gc-object (; 20 ;) (type $_) + call $start:~lib/allocator/arena i32.const 0 call $std/gc-object/Custom#constructor global.set $std/gc-object/obj @@ -565,9 +547,21 @@ global.set $std/gc-object/obj call $~lib/gc/gc.collect ) - (func $null (; 21 ;) (type $_) + (func $std/gc-object/main (; 21 ;) (type $_) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 22 ;) (type $_) + call $start:std/gc-object + ) + (func $null (; 23 ;) (type $_) ) - (func $~iterateRoots (; 22 ;) (type $i_) (param $0 i32) + (func $~iterateRoots (; 24 ;) (type $i_) (param $0 i32) global.get $std/gc-object/obj local.get $0 call_indirect (type $i_) diff --git a/tests/compiler/std/hash.optimized.wat b/tests/compiler/std/hash.optimized.wat index 8371323497..c01ffbf6e5 100644 --- a/tests/compiler/std/hash.optimized.wat +++ b/tests/compiler/std/hash.optimized.wat @@ -143,7 +143,7 @@ i32.const 16777619 i32.mul ) - (func $start (; 3 ;) (type $_) + (func $start:std/hash (; 3 ;) (type $_) i32.const 0 call $~lib/internal/hash/hashStr drop @@ -196,7 +196,10 @@ call $~lib/internal/hash/hash64 drop ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:std/hash + ) + (func $null (; 5 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/hash.untouched.wat b/tests/compiler/std/hash.untouched.wat index 4cbdaf767b..04d74228d8 100644 --- a/tests/compiler/std/hash.untouched.wat +++ b/tests/compiler/std/hash.untouched.wat @@ -9,19 +9,7 @@ (data (i32.const 32) "\03\00\00\00a\00b\00c\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) - (global $~lib/internal/hash/FNV_OFFSET i32 (i32.const -2128831035)) - (global $~lib/internal/hash/FNV_PRIME i32 (i32.const 16777619)) - (global $Infinity f64 (f64.const inf)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $HEAP_BASE i32 (i32.const 44)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 44)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -29,7 +17,7 @@ (local $1 i32) (local $2 i32) (local $3 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 block $break|0 block @@ -53,7 +41,7 @@ i32.add i32.load8_u offset=4 i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $2 @@ -72,14 +60,14 @@ ) (func $~lib/internal/hash/hash32 (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 local.get $1 local.get $0 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -89,7 +77,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -99,7 +87,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -107,7 +95,7 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -124,14 +112,14 @@ i64.shr_u i32.wrap_i64 local.set $2 - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $3 local.get $3 local.get $1 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -141,7 +129,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -151,7 +139,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -159,7 +147,7 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -167,7 +155,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -177,7 +165,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -187,7 +175,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -195,12 +183,12 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 ) - (func $start (; 4 ;) (type $_) + (func $start:std/hash (; 4 ;) (type $_) (local $0 i32) (local $1 f32) (local $2 f64) @@ -370,6 +358,9 @@ call $std/hash/check drop ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:std/hash + ) + (func $null (; 6 ;) (type $_) ) ) diff --git a/tests/compiler/std/libm.untouched.wat b/tests/compiler/std/libm.untouched.wat index 33ca5308d1..3c0dc866b4 100644 --- a/tests/compiler/std/libm.untouched.wat +++ b/tests/compiler/std/libm.untouched.wat @@ -24,9 +24,8 @@ (global $std/libm/SQRT1_2 f64 (f64.const 0.7071067811865476)) (global $~lib/math/NativeMath.SQRT2 f64 (f64.const 1.4142135623730951)) (global $std/libm/SQRT2 f64 (f64.const 1.4142135623730951)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "E" (global $std/libm/E)) diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index 343bddaa3d..ee31265a42 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -24,26 +24,25 @@ (data (i32.const 120) "\n\00\00\00s\00t\00d\00/\00m\00a\00p\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/map/INITIAL_CAPACITY i32 (i32.const 4)) - (global $~lib/map/BUCKET_SIZE i32 (i32.const 4)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $~lib/internal/hash/FNV_OFFSET i32 (i32.const -2128831035)) - (global $~lib/internal/hash/FNV_PRIME i32 (i32.const 16777619)) - (global $~lib/map/EMPTY i32 (i32.const 1)) - (global $~lib/map/FREE_FACTOR f64 (f64.const 0.75)) - (global $~lib/map/FILL_FACTOR f64 (f64.const 2.6666666666666665)) - (global $HEAP_BASE i32 (i32.const 144)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 144)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -51,7 +50,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -68,9 +67,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -122,16 +121,16 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 4 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -139,11 +138,11 @@ i32.sub i32.shl ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -168,7 +167,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -422,13 +421,13 @@ end end ) - (func $~lib/arraybuffer/ArrayBuffer#constructor (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#constructor (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -447,7 +446,7 @@ i32.eqz if local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -461,7 +460,7 @@ end local.get $3 ) - (func $~lib/map/Map#clear (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 8 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -469,7 +468,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -480,7 +479,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -489,7 +488,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 8 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 9 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -521,14 +520,14 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/internal/hash/hash8 (; 9 ;) (type $ii) (param $0 i32) (result i32) - global.get $~lib/internal/hash/FNV_OFFSET + (func $~lib/internal/hash/hash8 (; 10 ;) (type $ii) (param $0 i32) (result i32) + i32.const -2128831035 local.get $0 i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul ) - (func $~lib/map/Map#find (; 10 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -537,7 +536,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -549,7 +548,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -571,7 +570,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -583,7 +582,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -602,7 +601,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 12 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 13 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -620,14 +619,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -642,7 +641,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -655,7 +654,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -669,7 +668,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -696,7 +695,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -742,7 +741,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 13 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 14 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -782,7 +781,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -803,7 +802,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -839,7 +838,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -852,7 +851,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -878,11 +877,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 16 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#delete (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -911,7 +910,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -928,7 +927,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -945,7 +944,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -959,7 +958,7 @@ end i32.const 1 ) - (func $std/map/test (; 17 ;) (type $_) + (func $std/map/test (; 18 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -1343,7 +1342,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 18 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 19 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -1351,7 +1350,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -1362,7 +1361,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1371,7 +1370,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 19 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 20 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -1403,7 +1402,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#find (; 20 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -1412,7 +1411,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -1424,7 +1423,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -1444,7 +1443,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -1456,7 +1455,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -1473,7 +1472,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 22 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 23 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1491,14 +1490,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -1513,7 +1512,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -1526,7 +1525,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -1540,7 +1539,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -1567,7 +1566,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -1613,7 +1612,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 23 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 24 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1651,7 +1650,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -1672,7 +1671,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -1708,7 +1707,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -1721,7 +1720,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 24 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -1745,11 +1744,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 25 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 26 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#delete (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1776,7 +1775,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -1793,7 +1792,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -1810,7 +1809,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -1824,7 +1823,7 @@ end i32.const 1 ) - (func $std/map/test (; 27 ;) (type $_) + (func $std/map/test (; 28 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -2194,7 +2193,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 28 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 29 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -2202,7 +2201,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -2213,7 +2212,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -2222,7 +2221,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 29 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 30 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -2254,16 +2253,16 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/internal/hash/hash16 (; 30 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/hash16 (; 31 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 local.get $1 local.get $0 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -2271,12 +2270,12 @@ i32.const 8 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 ) - (func $~lib/map/Map#find (; 31 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -2285,7 +2284,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -2297,7 +2296,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -2319,7 +2318,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -2331,7 +2330,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 32 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -2350,7 +2349,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 33 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 34 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2368,14 +2367,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -2390,7 +2389,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -2403,7 +2402,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -2417,7 +2416,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -2444,7 +2443,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -2490,7 +2489,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 34 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 35 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2530,7 +2529,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -2551,7 +2550,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -2587,7 +2586,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -2600,7 +2599,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 35 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 36 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -2626,11 +2625,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 36 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 37 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 37 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#delete (; 38 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2659,7 +2658,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -2676,7 +2675,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -2693,7 +2692,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -2707,7 +2706,7 @@ end i32.const 1 ) - (func $std/map/test (; 38 ;) (type $_) + (func $std/map/test (; 39 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -3091,7 +3090,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 39 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 40 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -3099,7 +3098,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -3110,7 +3109,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -3119,7 +3118,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 40 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 41 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -3151,7 +3150,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#find (; 41 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 42 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -3160,7 +3159,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -3172,7 +3171,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -3192,7 +3191,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -3204,7 +3203,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 42 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 43 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -3221,7 +3220,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 43 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 44 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3239,14 +3238,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -3261,7 +3260,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -3274,7 +3273,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -3288,7 +3287,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -3315,7 +3314,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -3361,7 +3360,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 44 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 45 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3399,7 +3398,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -3420,7 +3419,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -3456,7 +3455,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -3469,7 +3468,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 45 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 46 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -3493,11 +3492,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 46 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 47 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#delete (; 48 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3524,7 +3523,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -3541,7 +3540,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -3558,7 +3557,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -3572,7 +3571,7 @@ end i32.const 1 ) - (func $std/map/test (; 48 ;) (type $_) + (func $std/map/test (; 49 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -3942,7 +3941,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 49 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 50 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -3950,7 +3949,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -3961,7 +3960,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -3970,7 +3969,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 50 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 51 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -4002,16 +4001,16 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/internal/hash/hash32 (; 51 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/hash32 (; 52 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 local.get $1 local.get $0 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -4021,7 +4020,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -4031,7 +4030,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -4039,12 +4038,12 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 ) - (func $~lib/map/Map#find (; 52 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 53 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -4053,7 +4052,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -4065,7 +4064,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -4083,7 +4082,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -4095,7 +4094,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 53 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 54 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -4110,7 +4109,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 54 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 55 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4128,14 +4127,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -4150,7 +4149,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -4163,7 +4162,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -4177,7 +4176,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -4204,7 +4203,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -4250,7 +4249,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 55 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 56 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4286,7 +4285,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -4307,7 +4306,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -4343,7 +4342,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -4356,7 +4355,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 56 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 57 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -4378,11 +4377,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 57 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 58 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 58 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#delete (; 59 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4407,7 +4406,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -4424,7 +4423,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -4441,7 +4440,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -4455,7 +4454,7 @@ end i32.const 1 ) - (func $std/map/test (; 59 ;) (type $_) + (func $std/map/test (; 60 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4811,7 +4810,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 60 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 61 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -4819,7 +4818,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -4830,7 +4829,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4839,7 +4838,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 61 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 62 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -4871,7 +4870,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#find (; 62 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 63 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -4880,7 +4879,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -4892,7 +4891,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -4910,7 +4909,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -4922,7 +4921,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 63 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 64 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -4937,7 +4936,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 64 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 65 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4955,14 +4954,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -4977,7 +4976,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -4990,7 +4989,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -5004,7 +5003,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -5031,7 +5030,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -5077,7 +5076,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 65 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 66 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5113,7 +5112,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -5134,7 +5133,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -5170,7 +5169,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -5183,7 +5182,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 66 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 67 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -5205,11 +5204,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 67 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 68 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 68 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#delete (; 69 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5234,7 +5233,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -5251,7 +5250,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -5268,7 +5267,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -5282,7 +5281,7 @@ end i32.const 1 ) - (func $std/map/test (; 69 ;) (type $_) + (func $std/map/test (; 70 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -5638,7 +5637,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 70 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 71 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -5646,7 +5645,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -5657,7 +5656,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -5666,7 +5665,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 71 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 72 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -5698,7 +5697,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/internal/hash/hash64 (; 72 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/hash/hash64 (; 73 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -5710,14 +5709,14 @@ i64.shr_u i32.wrap_i64 local.set $2 - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $3 local.get $3 local.get $1 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5727,7 +5726,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5737,7 +5736,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5745,7 +5744,7 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5753,7 +5752,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5763,7 +5762,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5773,7 +5772,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5781,12 +5780,12 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 ) - (func $~lib/map/Map#find (; 73 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 74 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -5795,7 +5794,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -5807,7 +5806,7 @@ block local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -5825,7 +5824,7 @@ end local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -5837,7 +5836,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 74 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/map/Map#has (; 75 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) local.get $0 local.get $1 @@ -5852,7 +5851,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 75 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 76 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5871,14 +5870,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -5893,7 +5892,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -5906,7 +5905,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -5920,7 +5919,7 @@ local.set $9 local.get $9 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -5947,7 +5946,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -5993,7 +5992,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 76 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) + (func $~lib/map/Map#set (; 77 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) (local $3 i64) (local $4 i32) (local $5 i32) @@ -6030,7 +6029,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -6051,7 +6050,7 @@ i32.load offset=8 local.set $6 local.get $6 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -6087,7 +6086,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $7 @@ -6100,7 +6099,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 77 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/map/Map#get (; 78 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) (local $3 i32) local.get $0 @@ -6122,11 +6121,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 78 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 79 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 79 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/map/Map#delete (; 80 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) (local $3 i32) (local $4 i32) @@ -6152,7 +6151,7 @@ local.get $3 local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=12 local.get $0 @@ -6169,7 +6168,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -6186,7 +6185,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -6200,7 +6199,7 @@ end i32.const 1 ) - (func $std/map/test (; 80 ;) (type $_) + (func $std/map/test (; 81 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -6563,7 +6562,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 81 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 82 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -6571,7 +6570,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -6582,7 +6581,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -6591,7 +6590,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 82 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 83 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -6623,7 +6622,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#find (; 83 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 84 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -6632,7 +6631,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -6644,7 +6643,7 @@ block local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -6662,7 +6661,7 @@ end local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -6674,7 +6673,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 84 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/map/Map#has (; 85 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) local.get $0 local.get $1 @@ -6689,7 +6688,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 85 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 86 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6708,14 +6707,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -6730,7 +6729,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -6743,7 +6742,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -6757,7 +6756,7 @@ local.set $9 local.get $9 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -6784,7 +6783,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -6830,7 +6829,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 86 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) + (func $~lib/map/Map#set (; 87 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) (local $3 i64) (local $4 i32) (local $5 i32) @@ -6867,7 +6866,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -6888,7 +6887,7 @@ i32.load offset=8 local.set $6 local.get $6 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -6924,7 +6923,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $7 @@ -6937,7 +6936,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 87 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/map/Map#get (; 88 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) (local $3 i32) local.get $0 @@ -6959,11 +6958,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 88 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 89 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 89 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/map/Map#delete (; 90 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) (local $3 i32) (local $4 i32) @@ -6989,7 +6988,7 @@ local.get $3 local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=12 local.get $0 @@ -7006,7 +7005,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -7023,7 +7022,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -7037,7 +7036,7 @@ end i32.const 1 ) - (func $std/map/test (; 90 ;) (type $_) + (func $std/map/test (; 91 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -7400,7 +7399,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 91 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 92 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -7408,7 +7407,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -7419,7 +7418,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -7428,7 +7427,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 92 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 93 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -7460,7 +7459,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#find (; 93 ;) (type $ifii) (param $0 i32) (param $1 f32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 94 ;) (type $ifii) (param $0 i32) (param $1 f32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -7469,7 +7468,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -7481,7 +7480,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -7499,7 +7498,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -7511,7 +7510,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 94 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) + (func $~lib/map/Map#has (; 95 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) (local $2 f32) local.get $0 local.get $1 @@ -7527,7 +7526,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 95 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 96 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7546,14 +7545,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -7568,7 +7567,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -7581,7 +7580,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -7595,7 +7594,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -7623,7 +7622,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -7669,7 +7668,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 96 ;) (type $ifi_) (param $0 i32) (param $1 f32) (param $2 i32) + (func $~lib/map/Map#set (; 97 ;) (type $ifi_) (param $0 i32) (param $1 f32) (param $2 i32) (local $3 f32) (local $4 i32) (local $5 i32) @@ -7707,7 +7706,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -7728,7 +7727,7 @@ i32.load offset=8 local.set $6 local.get $6 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -7764,7 +7763,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $7 @@ -7777,7 +7776,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 97 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) + (func $~lib/map/Map#get (; 98 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) (local $2 f32) (local $3 i32) local.get $0 @@ -7800,11 +7799,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 98 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 99 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 99 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) + (func $~lib/map/Map#delete (; 100 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) (local $2 f32) (local $3 i32) (local $4 i32) @@ -7831,7 +7830,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -7848,7 +7847,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -7865,7 +7864,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -7879,7 +7878,7 @@ end i32.const 1 ) - (func $std/map/test (; 100 ;) (type $_) + (func $std/map/test (; 101 ;) (type $_) (local $0 i32) (local $1 f32) i32.const 0 @@ -8242,7 +8241,7 @@ unreachable end ) - (func $~lib/map/Map#clear (; 101 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 102 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -8250,7 +8249,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -8261,7 +8260,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -8270,7 +8269,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 102 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 103 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -8302,7 +8301,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#find (; 103 ;) (type $iFii) (param $0 i32) (param $1 f64) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 104 ;) (type $iFii) (param $0 i32) (param $1 f64) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -8311,7 +8310,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -8323,7 +8322,7 @@ block local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -8341,7 +8340,7 @@ end local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -8353,7 +8352,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 104 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/map/Map#has (; 105 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 f64) local.get $0 local.get $1 @@ -8369,7 +8368,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#rehash (; 105 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 106 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8388,14 +8387,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -8410,7 +8409,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -8423,7 +8422,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -8437,7 +8436,7 @@ local.set $9 local.get $9 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -8465,7 +8464,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -8511,7 +8510,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 106 ;) (type $iFi_) (param $0 i32) (param $1 f64) (param $2 i32) + (func $~lib/map/Map#set (; 107 ;) (type $iFi_) (param $0 i32) (param $1 f64) (param $2 i32) (local $3 f64) (local $4 i32) (local $5 i32) @@ -8549,7 +8548,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -8570,7 +8569,7 @@ i32.load offset=8 local.set $6 local.get $6 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -8606,7 +8605,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $7 @@ -8619,7 +8618,7 @@ i32.store offset=8 end ) - (func $~lib/map/Map#get (; 107 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/map/Map#get (; 108 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 f64) (local $3 i32) local.get $0 @@ -8642,11 +8641,11 @@ unreachable end ) - (func $~lib/map/Map#get:size (; 108 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#get:size (; 109 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/map/Map#delete (; 109 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/map/Map#delete (; 110 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 f64) (local $3 i32) (local $4 i32) @@ -8673,7 +8672,7 @@ local.get $3 local.get $3 i32.load offset=12 - global.get $~lib/map/EMPTY + i32.const 1 i32.or i32.store offset=12 local.get $0 @@ -8690,7 +8689,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -8707,7 +8706,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -8721,7 +8720,7 @@ end i32.const 1 ) - (func $std/map/test (; 110 ;) (type $_) + (func $std/map/test (; 111 ;) (type $_) (local $0 i32) (local $1 f64) i32.const 0 @@ -9084,17 +9083,8 @@ unreachable end ) - (func $start (; 111 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:std/map (; 112 ;) (type $_) + call $start:~lib/allocator/arena call $std/map/test call $std/map/test call $std/map/test @@ -9106,6 +9096,9 @@ call $std/map/test call $std/map/test ) - (func $null (; 112 ;) (type $_) + (func $start (; 113 ;) (type $_) + call $start:std/map + ) + (func $null (; 114 ;) (type $_) ) ) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 82f4e659f7..b0fb306a6c 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -8001,7 +8001,7 @@ if i32.const 0 i32.const 40 - i32.const 972 + i32.const 968 i32.const 4 call $~lib/env/abort unreachable @@ -8067,7 +8067,7 @@ if i32.const 0 i32.const 40 - i32.const 981 + i32.const 977 i32.const 24 call $~lib/env/abort unreachable @@ -8114,7 +8114,7 @@ if i32.const 0 i32.const 40 - i32.const 2051 + i32.const 2044 i32.const 24 call $~lib/env/abort unreachable @@ -9510,7 +9510,7 @@ end local.get $2 ) - (func $start (; 149 ;) (type $_) + (func $start:std/math (; 149 ;) (type $_) (local $0 f64) (local $1 f32) (local $2 i32) @@ -38637,7 +38637,10 @@ unreachable end ) - (func $null (; 150 ;) (type $_) + (func $start (; 150 ;) (type $_) + call $start:std/math + ) + (func $null (; 151 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 9a41b37b41..cdffcb64f6 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -73,7 +73,6 @@ (global $std/math/OVERFLOW i32 (i32.const 16)) (global $~lib/math/NativeMath.E f64 (f64.const 2.718281828459045)) (global $~lib/math/NativeMathf.E f32 (f32.const 2.7182817459106445)) - (global $Infinity f64 (f64.const inf)) (global $~lib/math/NativeMath.LN2 f64 (f64.const 0.6931471805599453)) (global $~lib/math/NativeMath.LN10 f64 (f64.const 2.302585092994046)) (global $~lib/math/NativeMath.LOG2E f64 (f64.const 1.4426950408889634)) @@ -86,18 +85,17 @@ (global $~lib/math/NativeMathf.PI f32 (f32.const 3.1415927410125732)) (global $~lib/math/NativeMathf.SQRT1_2 f32 (f32.const 0.7071067690849304)) (global $~lib/math/NativeMathf.SQRT2 f32 (f32.const 1.4142135381698608)) - (global $NaN f64 (f64.const nan:0x8000000000000)) (global $~lib/builtins/f64.MIN_VALUE f64 (f64.const 5e-324)) (global $~lib/math/random_seeded (mut i32) (i32.const 0)) (global $~lib/math/random_state0_64 (mut i64) (i64.const 0)) (global $~lib/math/random_state1_64 (mut i64) (i64.const 0)) (global $~lib/math/random_state0_32 (mut i32) (i32.const 0)) (global $~lib/math/random_state1_32 (mut i32) (i32.const 0)) - (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/builtins/f64.MAX_VALUE f64 (f64.const 1797693134862315708145274e284)) (global $~lib/builtins/f32.MAX_VALUE f32 (f32.const 3402823466385288598117041e14)) (global $~lib/builtins/f32.MIN_VALUE f32 (f32.const 1.401298464324817e-45)) - (global $HEAP_BASE i32 (i32.const 68)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 68)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -9774,7 +9772,7 @@ if i32.const 0 i32.const 40 - i32.const 972 + i32.const 968 i32.const 4 call $~lib/env/abort unreachable @@ -9806,7 +9804,7 @@ if i32.const 0 i32.const 40 - i32.const 981 + i32.const 977 i32.const 24 call $~lib/env/abort unreachable @@ -9863,7 +9861,7 @@ if i32.const 0 i32.const 40 - i32.const 2051 + i32.const 2044 i32.const 24 call $~lib/env/abort unreachable @@ -11581,7 +11579,7 @@ local.get $3 end ) - (func $start (; 157 ;) (type $_) + (func $start:std/math (; 157 ;) (type $_) (local $0 i32) (local $1 f64) (local $2 i32) @@ -42988,6 +42986,9 @@ unreachable end ) - (func $null (; 158 ;) (type $_) + (func $start (; 158 ;) (type $_) + call $start:std/math + ) + (func $null (; 159 ;) (type $_) ) ) diff --git a/tests/compiler/std/mod.optimized.wat b/tests/compiler/std/mod.optimized.wat index 33f61f3eb8..3eaf5edf11 100644 --- a/tests/compiler/std/mod.optimized.wat +++ b/tests/compiler/std/mod.optimized.wat @@ -1,6 +1,6 @@ (module - (type $FFF (func (param f64 f64) (result f64))) (type $FFFi (func (param f64 f64 f64) (result i32))) + (type $FFF (func (param f64 f64) (result f64))) (type $FFi (func (param f64 f64) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $fffi (func (param f32 f32 f32) (result i32))) @@ -500,7 +500,7 @@ local.get $2 call $std/mod/check ) - (func $start (; 8 ;) (type $_) + (func $start:std/mod (; 8 ;) (type $_) f64.const 3 f64.const 2 f64.const 1 @@ -2257,7 +2257,10 @@ unreachable end ) - (func $null (; 9 ;) (type $_) + (func $start (; 9 ;) (type $_) + call $start:std/mod + ) + (func $null (; 10 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/mod.untouched.wat b/tests/compiler/std/mod.untouched.wat index ef3cca6493..1a85de2c78 100644 --- a/tests/compiler/std/mod.untouched.wat +++ b/tests/compiler/std/mod.untouched.wat @@ -1,6 +1,6 @@ (module - (type $FFF (func (param f64 f64) (result f64))) (type $FFFi (func (param f64 f64 f64) (result i32))) + (type $FFF (func (param f64 f64) (result f64))) (type $FFi (func (param f64 f64) (result i32))) (type $Fi (func (param f64) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) @@ -16,9 +16,7 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $std/mod/js i32 (i32.const 1)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $Infinity f64 (f64.const inf)) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (export "mod" (func $std/mod/mod)) @@ -631,7 +629,7 @@ local.get $2 call $std/mod/check ) - (func $start (; 10 ;) (type $_) + (func $start:std/mod (; 10 ;) (type $_) f64.const 3 f64.const 2 f64.const 1 @@ -2416,6 +2414,9 @@ unreachable end ) - (func $null (; 11 ;) (type $_) + (func $start (; 11 ;) (type $_) + call $start:std/mod + ) + (func $null (; 12 ;) (type $_) ) ) diff --git a/tests/compiler/std/new.optimized.wat b/tests/compiler/std/new.optimized.wat index 004d14d12a..37bda0390a 100644 --- a/tests/compiler/std/new.optimized.wat +++ b/tests/compiler/std/new.optimized.wat @@ -1,6 +1,6 @@ (module - (type $ii (func (param i32) (result i32))) (type $_ (func)) + (type $ii (func (param i32) (result i32))) (type $FUNCSIG$i (func (result i32))) (memory $0 0) (table $0 1 funcref) diff --git a/tests/compiler/std/new.untouched.wat b/tests/compiler/std/new.untouched.wat index ec57adca1a..3aca3ead4f 100644 --- a/tests/compiler/std/new.untouched.wat +++ b/tests/compiler/std/new.untouched.wat @@ -1,22 +1,31 @@ (module + (type $_ (func)) (type $ifi (func (param i32 f32) (result i32))) (type $ii (func (param i32) (result i32))) - (type $_ (func)) (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $std/new/AClass.aStaticField (mut i32) (i32.const 0)) (global $std/new/aClass (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 0 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -24,7 +33,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -41,9 +50,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -95,12 +104,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $std/new/AClass#constructor (; 2 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) + (func $std/new/AClass#constructor (; 3 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) local.get $0 block (result i32) local.get $0 @@ -127,22 +136,16 @@ f32.store offset=4 local.get $0 ) - (func $start (; 3 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:std/new (; 4 ;) (type $_) + call $start:~lib/allocator/arena i32.const 0 f32.const 3 call $std/new/AClass#constructor global.set $std/new/aClass ) - (func $null (; 4 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:std/new + ) + (func $null (; 6 ;) (type $_) ) ) diff --git a/tests/compiler/std/operator-overloading.optimized.wat b/tests/compiler/std/operator-overloading.optimized.wat index b43ab1a38c..70b4e9590b 100644 --- a/tests/compiler/std/operator-overloading.optimized.wat +++ b/tests/compiler/std/operator-overloading.optimized.wat @@ -1,10 +1,10 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iii (func (param i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $FFF (func (param f64 f64) (result f64))) (type $FiF (func (param f64 i32) (result f64))) - (type $_ (func)) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) @@ -1202,7 +1202,7 @@ i32.trunc_f64_s call $std/operator-overloading/Tester#constructor ) - (func $start (; 6 ;) (type $_) + (func $start:std/operator-overloading (; 6 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -2457,7 +2457,10 @@ unreachable end ) - (func $null (; 7 ;) (type $_) + (func $start (; 7 ;) (type $_) + call $start:std/operator-overloading + ) + (func $null (; 8 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/operator-overloading.untouched.wat b/tests/compiler/std/operator-overloading.untouched.wat index 0bd52e43ea..27888cdaf8 100644 --- a/tests/compiler/std/operator-overloading.untouched.wat +++ b/tests/compiler/std/operator-overloading.untouched.wat @@ -1,20 +1,16 @@ (module + (type $_ (func)) (type $iiii (func (param i32 i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) (type $iii (func (param i32 i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $FFF (func (param f64 f64) (result f64))) (type $FiF (func (param f64 i32) (result f64))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\1b\00\00\00s\00t\00d\00/\00o\00p\00e\00r\00a\00t\00o\00r\00-\00o\00v\00e\00r\00l\00o\00a\00d\00i\00n\00g\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/operator-overloading/a1 (mut i32) (i32.const 0)) @@ -34,7 +30,6 @@ (global $std/operator-overloading/f (mut i32) (i32.const 0)) (global $std/operator-overloading/p1 (mut i32) (i32.const 0)) (global $std/operator-overloading/p2 (mut i32) (i32.const 0)) - (global $NaN f64 (f64.const nan:0x8000000000000)) (global $std/operator-overloading/p (mut i32) (i32.const 0)) (global $std/operator-overloading/n1 (mut i32) (i32.const 0)) (global $std/operator-overloading/n2 (mut i32) (i32.const 0)) @@ -85,11 +80,23 @@ (global $std/operator-overloading/aii1 (mut i32) (i32.const 0)) (global $std/operator-overloading/aii2 (mut i32) (i32.const 0)) (global $std/operator-overloading/aii (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 68)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 68)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -97,7 +104,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -114,9 +121,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -168,12 +175,12 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $std/operator-overloading/Tester#constructor (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/operator-overloading/Tester#constructor (; 4 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.eqz if @@ -189,7 +196,7 @@ i32.store offset=4 local.get $0 ) - (func $std/operator-overloading/Tester.add (; 4 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.add (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -203,7 +210,7 @@ i32.add call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.sub (; 5 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.sub (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -217,7 +224,7 @@ i32.sub call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.mul (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.mul (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -231,7 +238,7 @@ i32.mul call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.div (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.div (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -245,7 +252,7 @@ i32.div_s call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.mod (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.mod (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -259,7 +266,7 @@ i32.rem_s call $std/operator-overloading/Tester#constructor ) - (func $~lib/math/NativeMath.scalbn (; 9 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/NativeMath.scalbn (; 10 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) (local $4 i32) @@ -350,7 +357,7 @@ f64.reinterpret_i64 f64.mul ) - (func $~lib/math/NativeMath.pow (; 10 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.pow (; 11 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -1438,7 +1445,7 @@ local.get $16 f64.mul ) - (func $std/operator-overloading/Tester.pow (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.pow (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1458,7 +1465,7 @@ i32.trunc_f64_s call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.and (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.and (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1472,7 +1479,7 @@ i32.and call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.or (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.or (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1486,7 +1493,7 @@ i32.or call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.xor (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.xor (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1500,7 +1507,7 @@ i32.xor call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.equals (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.equals (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.load @@ -1518,7 +1525,7 @@ local.get $2 end ) - (func $std/operator-overloading/Tester.notEquals (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.notEquals (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.load @@ -1536,7 +1543,7 @@ local.get $2 end ) - (func $std/operator-overloading/Tester.greater (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.greater (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.load @@ -1554,7 +1561,7 @@ local.get $2 end ) - (func $std/operator-overloading/Tester.greaterEquals (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.greaterEquals (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.load @@ -1572,7 +1579,7 @@ local.get $2 end ) - (func $std/operator-overloading/Tester.less (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.less (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.load @@ -1590,7 +1597,7 @@ local.get $2 end ) - (func $std/operator-overloading/Tester.lessEquals (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.lessEquals (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 i32.load @@ -1608,7 +1615,7 @@ local.get $2 end ) - (func $std/operator-overloading/Tester.shr (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.shr (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1620,7 +1627,7 @@ i32.shr_s call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.shu (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.shu (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1632,7 +1639,7 @@ i32.shr_u call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.shl (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/operator-overloading/Tester.shl (; 24 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1644,7 +1651,7 @@ i32.shl call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.pos (; 24 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester.pos (; 25 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1652,7 +1659,7 @@ i32.load offset=4 call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.neg (; 25 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester.neg (; 26 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 i32.const 0 local.get $0 @@ -1664,7 +1671,7 @@ i32.sub call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.not (; 26 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester.not (; 27 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1676,7 +1683,7 @@ i32.xor call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester.excl (; 27 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester.excl (; 28 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.load @@ -1690,7 +1697,7 @@ local.get $1 end ) - (func $std/operator-overloading/Tester#inc (; 28 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester#inc (; 29 ;) (type $ii) (param $0 i32) (result i32) local.get $0 local.get $0 i32.load @@ -1705,7 +1712,7 @@ i32.store offset=4 local.get $0 ) - (func $std/operator-overloading/Tester#dec (; 29 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester#dec (; 30 ;) (type $ii) (param $0 i32) (result i32) local.get $0 local.get $0 i32.load @@ -1720,7 +1727,7 @@ i32.store offset=4 local.get $0 ) - (func $std/operator-overloading/Tester#postInc (; 30 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester#postInc (; 31 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1732,7 +1739,7 @@ i32.add call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/Tester#postDec (; 31 ;) (type $ii) (param $0 i32) (result i32) + (func $std/operator-overloading/Tester#postDec (; 32 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 local.get $0 i32.load @@ -1744,7 +1751,7 @@ i32.sub call $std/operator-overloading/Tester#constructor ) - (func $std/operator-overloading/TesterInlineStatic#constructor (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/operator-overloading/TesterInlineStatic#constructor (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.eqz if @@ -1760,7 +1767,7 @@ i32.store offset=4 local.get $0 ) - (func $std/operator-overloading/TesterInlineInstance#constructor (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/operator-overloading/TesterInlineInstance#constructor (; 34 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.eqz if @@ -1776,19 +1783,10 @@ i32.store offset=4 local.get $0 ) - (func $start (; 34 ;) (type $_) + (func $start:std/operator-overloading (; 35 ;) (type $_) (local $0 i32) (local $1 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena i32.const 0 i32.const 1 i32.const 2 @@ -2837,6 +2835,9 @@ unreachable end ) - (func $null (; 35 ;) (type $_) + (func $start (; 36 ;) (type $_) + call $start:std/operator-overloading + ) + (func $null (; 37 ;) (type $_) ) ) diff --git a/tests/compiler/std/pointer.optimized.wat b/tests/compiler/std/pointer.optimized.wat index 8108e8d2a3..63915d38fd 100644 --- a/tests/compiler/std/pointer.optimized.wat +++ b/tests/compiler/std/pointer.optimized.wat @@ -1159,7 +1159,7 @@ end end ) - (func $start (; 4 ;) (type $_) + (func $start:std/pointer (; 4 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 8 @@ -1548,7 +1548,10 @@ unreachable end ) - (func $null (; 5 ;) (type $_) + (func $start (; 5 ;) (type $_) + call $start:std/pointer + ) + (func $null (; 6 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/pointer.untouched.wat b/tests/compiler/std/pointer.untouched.wat index c2cf8ca36c..79d919f98a 100644 --- a/tests/compiler/std/pointer.untouched.wat +++ b/tests/compiler/std/pointer.untouched.wat @@ -16,7 +16,7 @@ (global $std/pointer/sub (mut i32) (i32.const 0)) (global $std/pointer/nextOne (mut i32) (i32.const 0)) (global $std/pointer/buf (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 40)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 40)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -1747,7 +1747,7 @@ local.get $1 f32.store ) - (func $start (; 7 ;) (type $_) + (func $start:std/pointer (; 7 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 f32) @@ -2350,6 +2350,9 @@ unreachable end ) - (func $null (; 8 ;) (type $_) + (func $start (; 8 ;) (type $_) + call $start:std/pointer + ) + (func $null (; 9 ;) (type $_) ) ) diff --git a/tests/compiler/std/polyfills.untouched.wat b/tests/compiler/std/polyfills.untouched.wat index 7824746d04..5b633a2135 100644 --- a/tests/compiler/std/polyfills.untouched.wat +++ b/tests/compiler/std/polyfills.untouched.wat @@ -8,7 +8,7 @@ (data (i32.const 8) "\10\00\00\00s\00t\00d\00/\00p\00o\00l\00y\00f\00i\00l\00l\00s\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 44)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 44)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -184,7 +184,7 @@ i32.or return ) - (func $start (; 11 ;) (type $_) + (func $start:std/polyfills (; 11 ;) (type $_) (local $0 i32) i32.const 170 call $~lib/polyfills/bswap @@ -507,6 +507,9 @@ unreachable end ) - (func $null (; 12 ;) (type $_) + (func $start (; 12 ;) (type $_) + call $start:std/polyfills + ) + (func $null (; 13 ;) (type $_) ) ) diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index 99180a8515..69764182de 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -26,26 +26,25 @@ (data (i32.const 120) "\n\00\00\00s\00t\00d\00/\00s\00e\00t\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/set/INITIAL_CAPACITY i32 (i32.const 4)) - (global $~lib/set/BUCKET_SIZE i32 (i32.const 4)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $~lib/internal/hash/FNV_OFFSET i32 (i32.const -2128831035)) - (global $~lib/internal/hash/FNV_PRIME i32 (i32.const 16777619)) - (global $~lib/set/EMPTY i32 (i32.const 1)) - (global $~lib/set/FREE_FACTOR f64 (f64.const 0.75)) - (global $~lib/set/FILL_FACTOR f64 (f64.const 2.6666666666666665)) - (global $HEAP_BASE i32 (i32.const 144)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 144)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -53,7 +52,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -70,9 +69,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -124,16 +123,16 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 4 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -141,11 +140,11 @@ i32.sub i32.shl ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -170,7 +169,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -424,13 +423,13 @@ end end ) - (func $~lib/arraybuffer/ArrayBuffer#constructor (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#constructor (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -449,7 +448,7 @@ i32.eqz if local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -463,7 +462,7 @@ end local.get $3 ) - (func $~lib/set/Set#clear (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 8 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -471,7 +470,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -482,7 +481,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -491,7 +490,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 8 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 9 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -523,14 +522,14 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/hash8 (; 9 ;) (type $ii) (param $0 i32) (result i32) - global.get $~lib/internal/hash/FNV_OFFSET + (func $~lib/internal/hash/hash8 (; 10 ;) (type $ii) (param $0 i32) (result i32) + i32.const -2128831035 local.get $0 i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul ) - (func $~lib/internal/hash/HASH (; 10 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/HASH (; 11 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -539,7 +538,7 @@ call $~lib/internal/hash/hash8 return ) - (func $~lib/set/Set#find (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 12 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -548,7 +547,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -560,7 +559,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -582,7 +581,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -594,7 +593,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#has (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 local.get $1 @@ -603,7 +602,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 13 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 14 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -621,14 +620,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -643,7 +642,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -656,7 +655,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -670,7 +669,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -693,7 +692,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -739,7 +738,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 14 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#add (; 15 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -767,7 +766,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -788,7 +787,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -821,7 +820,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -834,11 +833,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 15 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 16 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#delete (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -867,7 +866,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -884,7 +883,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -901,7 +900,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -915,7 +914,7 @@ end i32.const 1 ) - (func $std/set/test (; 17 ;) (type $_) + (func $std/set/test (; 18 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -1198,7 +1197,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 18 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 19 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -1206,7 +1205,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -1217,7 +1216,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1226,7 +1225,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 19 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 20 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -1258,14 +1257,14 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/HASH (; 20 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/HASH (; 21 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 255 i32.and call $~lib/internal/hash/hash8 return ) - (func $~lib/set/Set#find (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 22 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -1274,7 +1273,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -1286,7 +1285,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -1306,7 +1305,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -1318,7 +1317,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#has (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 local.get $1 @@ -1327,7 +1326,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 23 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 24 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1345,14 +1344,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -1367,7 +1366,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -1380,7 +1379,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -1394,7 +1393,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -1417,7 +1416,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -1463,7 +1462,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 24 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#add (; 25 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1491,7 +1490,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -1512,7 +1511,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -1545,7 +1544,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -1558,11 +1557,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 25 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 26 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#delete (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1589,7 +1588,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -1606,7 +1605,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -1623,7 +1622,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -1637,7 +1636,7 @@ end i32.const 1 ) - (func $std/set/test (; 27 ;) (type $_) + (func $std/set/test (; 28 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -1920,7 +1919,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 28 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 29 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -1928,7 +1927,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -1939,7 +1938,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -1948,7 +1947,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 29 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 30 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -1980,16 +1979,16 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/hash16 (; 30 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/hash16 (; 31 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 local.get $1 local.get $0 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -1997,12 +1996,12 @@ i32.const 8 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 ) - (func $~lib/internal/hash/HASH (; 31 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/HASH (; 32 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -2011,7 +2010,7 @@ call $~lib/internal/hash/hash16 return ) - (func $~lib/set/Set#find (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -2020,7 +2019,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -2032,7 +2031,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -2054,7 +2053,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -2066,7 +2065,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#has (; 34 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 local.get $1 @@ -2075,7 +2074,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 34 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 35 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2093,14 +2092,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -2115,7 +2114,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -2128,7 +2127,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -2142,7 +2141,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -2165,7 +2164,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -2211,7 +2210,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 35 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#add (; 36 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2239,7 +2238,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -2260,7 +2259,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -2293,7 +2292,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -2306,11 +2305,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 36 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 37 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 37 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#delete (; 38 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2339,7 +2338,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -2356,7 +2355,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -2373,7 +2372,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -2387,7 +2386,7 @@ end i32.const 1 ) - (func $std/set/test (; 38 ;) (type $_) + (func $std/set/test (; 39 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -2670,7 +2669,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 39 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 40 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -2678,7 +2677,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -2689,7 +2688,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -2698,7 +2697,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 40 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 41 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -2730,14 +2729,14 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/HASH (; 41 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/HASH (; 42 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 65535 i32.and call $~lib/internal/hash/hash16 return ) - (func $~lib/set/Set#find (; 42 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 43 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -2746,7 +2745,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -2758,7 +2757,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -2778,7 +2777,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -2790,7 +2789,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 43 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#has (; 44 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 local.get $1 @@ -2799,7 +2798,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 44 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 45 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2817,14 +2816,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -2839,7 +2838,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -2852,7 +2851,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -2866,7 +2865,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -2889,7 +2888,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -2935,7 +2934,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 45 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#add (; 46 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2963,7 +2962,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -2984,7 +2983,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -3017,7 +3016,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -3030,11 +3029,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 46 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 47 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#delete (; 48 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3061,7 +3060,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -3078,7 +3077,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -3095,7 +3094,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -3109,7 +3108,7 @@ end i32.const 1 ) - (func $std/set/test (; 48 ;) (type $_) + (func $std/set/test (; 49 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -3392,7 +3391,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 49 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 50 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -3400,7 +3399,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -3411,7 +3410,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -3420,7 +3419,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 50 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 51 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -3452,16 +3451,16 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/hash32 (; 51 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/hash32 (; 52 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 local.get $1 local.get $0 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -3471,7 +3470,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -3481,7 +3480,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -3489,17 +3488,17 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 ) - (func $~lib/internal/hash/HASH (; 52 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/HASH (; 53 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/internal/hash/hash32 return ) - (func $~lib/set/Set#find (; 53 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 54 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -3508,7 +3507,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -3520,7 +3519,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -3538,7 +3537,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -3550,7 +3549,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 54 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#has (; 55 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 local.get $1 @@ -3559,7 +3558,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 55 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 56 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3577,14 +3576,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -3599,7 +3598,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -3612,7 +3611,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -3626,7 +3625,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -3649,7 +3648,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -3695,7 +3694,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 56 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#add (; 57 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3723,7 +3722,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -3744,7 +3743,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -3777,7 +3776,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -3790,11 +3789,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 57 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 58 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 58 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#delete (; 59 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3819,7 +3818,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -3836,7 +3835,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -3853,7 +3852,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -3867,7 +3866,7 @@ end i32.const 1 ) - (func $std/set/test (; 59 ;) (type $_) + (func $std/set/test (; 60 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4150,7 +4149,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 60 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 61 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -4158,7 +4157,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -4169,7 +4168,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4178,7 +4177,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 61 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 62 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -4210,12 +4209,12 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/HASH (; 62 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/HASH (; 63 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/internal/hash/hash32 return ) - (func $~lib/set/Set#find (; 63 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 64 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -4224,7 +4223,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -4236,7 +4235,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -4254,7 +4253,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -4266,7 +4265,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 64 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#has (; 65 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 local.get $1 @@ -4275,7 +4274,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 65 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 66 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4293,14 +4292,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -4315,7 +4314,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -4328,7 +4327,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -4342,7 +4341,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -4365,7 +4364,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -4411,7 +4410,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 66 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#add (; 67 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4439,7 +4438,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -4460,7 +4459,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -4493,7 +4492,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -4506,11 +4505,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 67 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 68 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 68 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/set/Set#delete (; 69 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -4535,7 +4534,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -4552,7 +4551,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $2 local.get $0 i32.load offset=20 @@ -4569,7 +4568,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -4583,7 +4582,7 @@ end i32.const 1 ) - (func $std/set/test (; 69 ;) (type $_) + (func $std/set/test (; 70 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4866,7 +4865,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 70 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 71 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -4874,7 +4873,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -4885,7 +4884,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -4894,7 +4893,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 71 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 72 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -4926,7 +4925,7 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/hash64 (; 72 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/hash/hash64 (; 73 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -4938,14 +4937,14 @@ i64.shr_u i32.wrap_i64 local.set $2 - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $3 local.get $3 local.get $1 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -4955,7 +4954,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -4965,7 +4964,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -4973,7 +4972,7 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -4981,7 +4980,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -4991,7 +4990,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5001,7 +5000,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 @@ -5009,17 +5008,17 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $3 local.get $3 ) - (func $~lib/internal/hash/HASH (; 73 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/hash/HASH (; 74 ;) (type $Ii) (param $0 i64) (result i32) local.get $0 call $~lib/internal/hash/hash64 return ) - (func $~lib/set/Set#find (; 74 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 75 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -5028,7 +5027,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -5040,7 +5039,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -5058,7 +5057,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -5070,7 +5069,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 75 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/set/Set#has (; 76 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) local.get $0 local.get $1 local.get $1 @@ -5079,7 +5078,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 76 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 77 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5098,14 +5097,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -5120,7 +5119,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -5133,7 +5132,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -5147,7 +5146,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -5170,7 +5169,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -5216,7 +5215,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 77 ;) (type $iI_) (param $0 i32) (param $1 i64) + (func $~lib/set/Set#add (; 78 ;) (type $iI_) (param $0 i32) (param $1 i64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5244,7 +5243,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -5265,7 +5264,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -5298,7 +5297,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -5311,11 +5310,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 78 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 79 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 79 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/set/Set#delete (; 80 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) (local $3 i32) (local $4 i32) @@ -5341,7 +5340,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -5358,7 +5357,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -5375,7 +5374,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -5389,7 +5388,7 @@ end i32.const 1 ) - (func $std/set/test (; 80 ;) (type $_) + (func $std/set/test (; 81 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -5672,7 +5671,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 81 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 82 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -5680,7 +5679,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -5691,7 +5690,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -5700,7 +5699,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 82 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 83 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -5732,12 +5731,12 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/HASH (; 83 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/hash/HASH (; 84 ;) (type $Ii) (param $0 i64) (result i32) local.get $0 call $~lib/internal/hash/hash64 return ) - (func $~lib/set/Set#find (; 84 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 85 ;) (type $iIii) (param $0 i32) (param $1 i64) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -5746,7 +5745,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -5758,7 +5757,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -5776,7 +5775,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -5788,7 +5787,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 85 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/set/Set#has (; 86 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) local.get $0 local.get $1 local.get $1 @@ -5797,7 +5796,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 86 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 87 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5816,14 +5815,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -5838,7 +5837,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -5851,7 +5850,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -5865,7 +5864,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -5888,7 +5887,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -5934,7 +5933,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 87 ;) (type $iI_) (param $0 i32) (param $1 i64) + (func $~lib/set/Set#add (; 88 ;) (type $iI_) (param $0 i32) (param $1 i64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5962,7 +5961,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -5983,7 +5982,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -6016,7 +6015,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -6029,11 +6028,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 88 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 89 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 89 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) + (func $~lib/set/Set#delete (; 90 ;) (type $iIi) (param $0 i32) (param $1 i64) (result i32) (local $2 i64) (local $3 i32) (local $4 i32) @@ -6059,7 +6058,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -6076,7 +6075,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -6093,7 +6092,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -6107,7 +6106,7 @@ end i32.const 1 ) - (func $std/set/test (; 90 ;) (type $_) + (func $std/set/test (; 91 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -6390,7 +6389,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 91 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 92 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -6398,7 +6397,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -6409,7 +6408,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -6418,7 +6417,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 92 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 93 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -6450,13 +6449,13 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/HASH (; 93 ;) (type $fi) (param $0 f32) (result i32) + (func $~lib/internal/hash/HASH (; 94 ;) (type $fi) (param $0 f32) (result i32) local.get $0 i32.reinterpret_f32 call $~lib/internal/hash/hash32 return ) - (func $~lib/set/Set#find (; 94 ;) (type $ifii) (param $0 i32) (param $1 f32) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 95 ;) (type $ifii) (param $0 i32) (param $1 f32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -6465,7 +6464,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -6477,7 +6476,7 @@ block local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -6495,7 +6494,7 @@ end local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -6507,7 +6506,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 95 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) + (func $~lib/set/Set#has (; 96 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) local.get $0 local.get $1 local.get $1 @@ -6516,7 +6515,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 96 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 97 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6535,14 +6534,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -6557,7 +6556,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -6570,7 +6569,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -6584,7 +6583,7 @@ local.set $9 local.get $9 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -6608,7 +6607,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -6654,7 +6653,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 97 ;) (type $if_) (param $0 i32) (param $1 f32) + (func $~lib/set/Set#add (; 98 ;) (type $if_) (param $0 i32) (param $1 f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6682,7 +6681,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -6703,7 +6702,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -6736,7 +6735,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -6749,11 +6748,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 98 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 99 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 99 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) + (func $~lib/set/Set#delete (; 100 ;) (type $ifi) (param $0 i32) (param $1 f32) (result i32) (local $2 f32) (local $3 i32) (local $4 i32) @@ -6780,7 +6779,7 @@ local.get $3 local.get $3 i32.load offset=4 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=4 local.get $0 @@ -6797,7 +6796,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -6814,7 +6813,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -6828,7 +6827,7 @@ end i32.const 1 ) - (func $std/set/test (; 100 ;) (type $_) + (func $std/set/test (; 101 ;) (type $_) (local $0 i32) (local $1 f32) i32.const 0 @@ -7111,7 +7110,7 @@ unreachable end ) - (func $~lib/set/Set#clear (; 101 ;) (type $i_) (param $0 i32) + (func $~lib/set/Set#clear (; 102 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -7119,7 +7118,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -7130,7 +7129,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -7139,7 +7138,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/set/Set#constructor (; 102 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#constructor (; 103 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -7171,13 +7170,13 @@ call $~lib/set/Set#clear local.get $0 ) - (func $~lib/internal/hash/HASH (; 103 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/internal/hash/HASH (; 104 ;) (type $Fi) (param $0 f64) (result i32) local.get $0 i64.reinterpret_f64 call $~lib/internal/hash/hash64 return ) - (func $~lib/set/Set#find (; 104 ;) (type $iFii) (param $0 i32) (param $1 f64) (param $2 i32) (result i32) + (func $~lib/set/Set#find (; 105 ;) (type $iFii) (param $0 i32) (param $1 f64) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -7186,7 +7185,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -7198,7 +7197,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -7216,7 +7215,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -7228,7 +7227,7 @@ end i32.const 0 ) - (func $~lib/set/Set#has (; 105 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/set/Set#has (; 106 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) local.get $0 local.get $1 local.get $1 @@ -7237,7 +7236,7 @@ i32.const 0 i32.ne ) - (func $~lib/set/Set#rehash (; 106 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/set/Set#rehash (; 107 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7256,14 +7255,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/set/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -7278,7 +7277,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -7291,7 +7290,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -7305,7 +7304,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.and i32.eqz if @@ -7329,7 +7328,7 @@ local.set $12 local.get $3 local.get $12 - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $13 @@ -7375,7 +7374,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/set/Set#add (; 107 ;) (type $iF_) (param $0 i32) (param $1 f64) + (func $~lib/set/Set#add (; 108 ;) (type $iF_) (param $0 i32) (param $1 f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7403,7 +7402,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -7424,7 +7423,7 @@ i32.load offset=8 local.set $4 local.get $4 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -7457,7 +7456,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/set/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $5 @@ -7470,11 +7469,11 @@ i32.store offset=8 end ) - (func $~lib/set/Set#get:size (; 108 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/set/Set#get:size (; 109 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.load offset=20 ) - (func $~lib/set/Set#delete (; 109 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/set/Set#delete (; 110 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 f64) (local $3 i32) (local $4 i32) @@ -7501,7 +7500,7 @@ local.get $3 local.get $3 i32.load offset=8 - global.get $~lib/set/EMPTY + i32.const 1 i32.or i32.store offset=8 local.get $0 @@ -7518,7 +7517,7 @@ local.get $4 i32.const 1 i32.add - global.get $~lib/set/INITIAL_CAPACITY + i32.const 4 local.tee $5 local.get $0 i32.load offset=20 @@ -7535,7 +7534,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/set/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -7549,7 +7548,7 @@ end i32.const 1 ) - (func $std/set/test (; 110 ;) (type $_) + (func $std/set/test (; 111 ;) (type $_) (local $0 i32) (local $1 f64) i32.const 0 @@ -7832,17 +7831,8 @@ unreachable end ) - (func $start (; 111 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:std/set (; 112 ;) (type $_) + call $start:~lib/allocator/arena call $std/set/test call $std/set/test call $std/set/test @@ -7854,6 +7844,9 @@ call $std/set/test call $std/set/test ) - (func $null (; 112 ;) (type $_) + (func $start (; 113 ;) (type $_) + call $start:std/set + ) + (func $null (; 114 ;) (type $_) ) ) diff --git a/tests/compiler/std/static-array.optimized.wat b/tests/compiler/std/static-array.optimized.wat index 867cc68373..5872bbca9f 100644 --- a/tests/compiler/std/static-array.optimized.wat +++ b/tests/compiler/std/static-array.optimized.wat @@ -1,9 +1,9 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $ii (func (param i32) (result i32))) - (type $_ (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$v (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) @@ -1613,7 +1613,7 @@ f64.const 2.25 f64.store offset=8 ) - (func $start (; 11 ;) (type $_) + (func $start:std/static-array (; 11 ;) (type $_) (local $0 i32) i32.const 280 global.set $~lib/allocator/arena/startOffset @@ -1968,7 +1968,10 @@ unreachable end ) - (func $null (; 12 ;) (type $_) + (func $start (; 12 ;) (type $_) + call $start:std/static-array + ) + (func $null (; 13 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index e708488cbd..0701b53787 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) @@ -10,7 +11,6 @@ (type $iif_ (func (param i32 i32 f32))) (type $iiF (func (param i32 i32) (result f64))) (type $iiF_ (func (param i32 i32 f64))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\08\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00") @@ -26,23 +26,29 @@ (data (i32.const 216) "\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/static-array/i i32 (i32.const 24)) (global $std/static-array/I i32 (i32.const 64)) (global $std/static-array/f i32 (i32.const 88)) (global $std/static-array/F i32 (i32.const 128)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $HEAP_BASE i32 (i32.const 276)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 276)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/array/Array#__get (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/array/Array#__get (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -75,11 +81,11 @@ unreachable end ) - (func $~lib/internal/arraybuffer/computeSize (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 3 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -87,7 +93,7 @@ i32.sub i32.shl ) - (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -95,7 +101,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -112,9 +118,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -166,11 +172,11 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -195,7 +201,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memcpy (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1396,7 +1402,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -1623,10 +1629,10 @@ end end ) - (func $~lib/allocator/arena/__memory_free (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 8 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/internal/memory/memset (; 8 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 9 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -1880,7 +1886,7 @@ end end ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/arraybuffer/reallocateUnsafe (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1894,7 +1900,7 @@ i32.gt_s if local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_s i32.eqz if @@ -1908,7 +1914,7 @@ local.get $1 local.get $2 call $~lib/internal/arraybuffer/computeSize - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.sub i32.le_s if @@ -1919,13 +1925,13 @@ local.get $1 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $5 local.get $2 @@ -1945,9 +1951,9 @@ local.get $3 local.set $0 end - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $2 i32.add @@ -1987,7 +1993,7 @@ end local.get $0 ) - (func $~lib/array/Array#__set (; 10 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/array/Array#__set (; 11 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2054,7 +2060,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#__get (; 11 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64) + (func $~lib/array/Array#__get (; 12 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2087,7 +2093,7 @@ unreachable end ) - (func $~lib/array/Array#__set (; 12 ;) (type $iiI_) (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/array/Array#__set (; 13 ;) (type $iiI_) (param $0 i32) (param $1 i32) (param $2 i64) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2154,7 +2160,7 @@ i64.store offset=8 end ) - (func $~lib/array/Array#__get (; 13 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) + (func $~lib/array/Array#__get (; 14 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2187,7 +2193,7 @@ unreachable end ) - (func $~lib/array/Array#__set (; 14 ;) (type $iif_) (param $0 i32) (param $1 i32) (param $2 f32) + (func $~lib/array/Array#__set (; 15 ;) (type $iif_) (param $0 i32) (param $1 i32) (param $2 f32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2254,7 +2260,7 @@ f32.store offset=8 end ) - (func $~lib/array/Array#__get (; 15 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/array/Array#__get (; 16 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2287,7 +2293,7 @@ unreachable end ) - (func $~lib/array/Array#__set (; 16 ;) (type $iiF_) (param $0 i32) (param $1 i32) (param $2 f64) + (func $~lib/array/Array#__set (; 17 ;) (type $iiF_) (param $0 i32) (param $1 i32) (param $2 f64) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2354,18 +2360,9 @@ f64.store offset=8 end ) - (func $start (; 17 ;) (type $_) + (func $start:std/static-array (; 18 ;) (type $_) (local $0 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena block $~lib/array/Array#get:length|inlined.0 (result i32) global.get $std/static-array/i local.set $0 @@ -2619,6 +2616,9 @@ unreachable end ) - (func $null (; 18 ;) (type $_) + (func $start (; 19 ;) (type $_) + call $start:std/static-array + ) + (func $null (; 20 ;) (type $_) ) ) diff --git a/tests/compiler/std/string-utf8.optimized.wat b/tests/compiler/std/string-utf8.optimized.wat index 53d961d725..ed7e6cc544 100644 --- a/tests/compiler/std/string-utf8.optimized.wat +++ b/tests/compiler/std/string-utf8.optimized.wat @@ -1,9 +1,9 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) - (type $_ (func)) (type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) @@ -1837,7 +1837,7 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $start (; 10 ;) (type $_) + (func $start:std/string-utf8 (; 10 ;) (type $_) i32.const 192 global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset @@ -2082,7 +2082,10 @@ unreachable end ) - (func $null (; 11 ;) (type $_) + (func $start (; 11 ;) (type $_) + call $start:std/string-utf8 + ) + (func $null (; 12 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/string-utf8.untouched.wat b/tests/compiler/std/string-utf8.untouched.wat index 3c58bed1f1..c66caa9aea 100644 --- a/tests/compiler/std/string-utf8.untouched.wat +++ b/tests/compiler/std/string-utf8.untouched.wat @@ -1,11 +1,11 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $i_ (func (param i32))) (type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\06\00\00\00\01\d87\dch\00i\00R\d8b\df") @@ -19,22 +19,28 @@ (data (i32.const 184) "\01\00\00\00\00\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/string-utf8/str (mut i32) (i32.const 8)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) (global $std/string-utf8/len (mut i32) (i32.const 0)) (global $std/string-utf8/ptr (mut i32) (i32.const 0)) - (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) - (global $HEAP_BASE i32 (i32.const 192)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 192)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/string/String#get:lengthUTF8 (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/string/String#get:lengthUTF8 (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -147,7 +153,7 @@ end local.get $1 ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -155,7 +161,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -172,9 +178,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -226,7 +232,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/string/String#toUTF8 (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/string/String#toUTF8 (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -448,7 +454,7 @@ i32.store8 local.get $2 ) - (func $~lib/internal/string/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/string/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -457,7 +463,7 @@ local.tee $1 if (result i32) local.get $0 - global.get $~lib/internal/string/MAX_LENGTH + i32.const 536870910 i32.le_s else local.get $1 @@ -472,7 +478,7 @@ unreachable end block $~lib/memory/memory.allocate|inlined.2 (result i32) - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 local.get $0 i32.const 1 i32.shl @@ -488,7 +494,7 @@ i32.store local.get $2 ) - (func $~lib/internal/memory/memcpy (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1689,7 +1695,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -1916,10 +1922,10 @@ end end ) - (func $~lib/allocator/arena/__memory_free (; 7 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 8 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/string/String.fromUTF8 (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.fromUTF8 (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2224,9 +2230,9 @@ i32.shr_u call $~lib/internal/string/allocateUnsafe local.set $7 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $7 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $3 local.get $4 @@ -2247,7 +2253,7 @@ end local.get $7 ) - (func $~lib/internal/string/compareUnsafe (; 9 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/internal/string/compareUnsafe (; 10 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -2300,7 +2306,7 @@ end local.get $5 ) - (func $~lib/string/String.__eq (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -2344,18 +2350,9 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $start (; 11 ;) (type $_) + (func $start:std/string-utf8 (; 12 ;) (type $_) (local $0 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena global.get $std/string-utf8/str call $~lib/string/String#get:lengthUTF8 global.set $std/string-utf8/len @@ -2617,6 +2614,9 @@ br $~lib/memory/memory.free|inlined.1 end ) - (func $null (; 12 ;) (type $_) + (func $start (; 13 ;) (type $_) + call $start:std/string-utf8 + ) + (func $null (; 14 ;) (type $_) ) ) diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 34b0940446..40e96fb57d 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -1,11 +1,11 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $iiiii_ (func (param i32 i32 i32 i32 i32))) - (type $i (func (result i32))) (type $iiF (func (param i32 i32) (result f64))) (type $iF (func (param i32) (result f64))) (type $Ii (func (param i64) (result i32))) @@ -13,7 +13,7 @@ (type $Fi (func (param f64) (result i32))) (type $iFi (func (param i32 f64) (result i32))) (type $iIiIiIii (func (param i32 i64 i32 i64 i32 i64 i32) (result i32))) - (type $_ (func)) + (type $i (func (result i32))) (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) @@ -182,19 +182,19 @@ (elem (i32.const 0) $null) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/number/_K (mut i32) (i32.const 0)) - (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) - (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) - (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (global $std/string/str (mut i32) (i32.const 8)) (global $std/string/nullStr (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/string/c (mut i32) (i32.const 0)) (global $std/string/a (mut i32) (i32.const 0)) (global $std/string/b (mut i32) (i32.const 0)) (global $std/string/sa (mut i32) (i32.const 0)) + (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) + (global $~lib/internal/number/_K (mut i32) (i32.const 0)) + (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "getString" (func $std/string/getString)) @@ -2036,7 +2036,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -2149,7 +2149,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -2245,7 +2245,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -2260,10 +2260,7 @@ local.get $2 call $~lib/string/String#lastIndexOf ) - (func $std/string/getString (; 21 ;) (type $i) (result i32) - global.get $std/string/str - ) - (func $~lib/internal/string/parse (; 22 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/internal/string/parse (; 21 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2515,12 +2512,12 @@ local.get $5 f64.mul ) - (func $~lib/string/parseInt (; 23 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) + (func $~lib/string/parseInt (; 22 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) local.get $0 i32.const 0 call $~lib/internal/string/parse ) - (func $~lib/string/parseFloat (; 24 ;) (type $iF) (param $0 i32) (result f64) + (func $~lib/string/parseFloat (; 23 ;) (type $iF) (param $0 i32) (result f64) (local $1 i32) (local $2 i32) (local $3 i32) @@ -2629,7 +2626,7 @@ if i32.const 0 i32.const 80 - i32.const 643 + i32.const 645 i32.const 10 call $~lib/env/abort unreachable @@ -2688,7 +2685,7 @@ local.get $4 f64.mul ) - (func $~lib/string/String#concat (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#concat (; 24 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2735,7 +2732,7 @@ call $~lib/internal/string/copyUnsafe local.get $2 ) - (func $~lib/string/String.__concat (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__concat (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.const 200 local.get $0 @@ -2743,13 +2740,13 @@ local.get $1 call $~lib/string/String#concat ) - (func $~lib/string/String.__ne (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__ne (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 local.get $1 call $~lib/string/String.__eq i32.eqz ) - (func $~lib/string/String.__gt (; 28 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__gt (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -2804,7 +2801,7 @@ i32.const 0 i32.gt_s ) - (func $~lib/string/String.__gte (; 29 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__gte (; 28 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -2859,7 +2856,7 @@ i32.const 0 i32.ge_s ) - (func $~lib/string/String.__lt (; 30 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__lt (; 29 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -2914,7 +2911,7 @@ i32.const 0 i32.lt_s ) - (func $~lib/string/String.__lte (; 31 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/string/String.__lte (; 30 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -2961,7 +2958,7 @@ i32.const 0 i32.le_s ) - (func $~lib/string/String#repeat (; 32 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#repeat (; 31 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -3031,7 +3028,7 @@ call $~lib/internal/string/repeatUnsafe local.get $2 ) - (func $~lib/string/String#slice (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#slice (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -3100,12 +3097,12 @@ call $~lib/internal/string/copyUnsafe local.get $1 ) - (func $~lib/string/String#slice|trampoline (; 34 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#slice|trampoline (; 33 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -3120,7 +3117,7 @@ local.get $2 call $~lib/string/String#slice ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 35 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 34 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 1073741816 @@ -3147,7 +3144,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 36 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/internal/memory/memset (; 35 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) local.get $1 i32.eqz @@ -3366,7 +3363,7 @@ end end ) - (func $~lib/array/Array#constructor (; 37 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/array/Array#constructor (; 36 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3408,7 +3405,7 @@ call $~lib/internal/memory/memset local.get $1 ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 38 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/arraybuffer/reallocateUnsafe (; 37 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $1 @@ -3490,7 +3487,7 @@ end local.get $0 ) - (func $~lib/array/Array#push (; 39 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#push (; 38 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3541,7 +3538,7 @@ i32.store offset=8 local.get $3 ) - (func $~lib/string/String#split (; 40 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#split (; 39 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3758,13 +3755,13 @@ drop local.get $3 ) - (func $~lib/string/String#split|trampoline (; 41 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#split|trampoline (; 40 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of2 $1of2 $2of2 $outOfRange end unreachable @@ -3780,7 +3777,7 @@ local.get $2 call $~lib/string/String#split ) - (func $~lib/internal/number/decimalCount32 (; 42 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/decimalCount32 (; 41 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 100000 i32.lt_u @@ -3834,7 +3831,7 @@ end end ) - (func $~lib/internal/number/utoa32_lut (; 43 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/number/utoa32_lut (; 42 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) i32.const 1816 @@ -3944,7 +3941,7 @@ i32.store16 offset=4 end ) - (func $~lib/internal/number/itoa32 (; 44 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/itoa32 (; 43 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3982,7 +3979,7 @@ end local.get $2 ) - (func $~lib/internal/number/utoa32 (; 45 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/number/utoa32 (; 44 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -4001,7 +3998,7 @@ call $~lib/internal/number/utoa32_lut local.get $2 ) - (func $~lib/internal/number/decimalCount64 (; 46 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/decimalCount64 (; 45 ;) (type $Ii) (param $0 i64) (result i32) local.get $0 i64.const 1000000000000000 i64.lt_u @@ -4055,7 +4052,7 @@ end end ) - (func $~lib/internal/number/utoa64_lut (; 47 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) + (func $~lib/internal/number/utoa64_lut (; 46 ;) (type $iIi_) (param $0 i32) (param $1 i64) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4152,7 +4149,7 @@ local.get $2 call $~lib/internal/number/utoa32_lut ) - (func $~lib/internal/number/utoa64 (; 48 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/utoa64 (; 47 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -4188,7 +4185,7 @@ end local.get $2 ) - (func $~lib/internal/number/itoa64 (; 49 ;) (type $Ii) (param $0 i64) (result i32) + (func $~lib/internal/number/itoa64 (; 48 ;) (type $Ii) (param $0 i64) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -4247,7 +4244,7 @@ end local.get $3 ) - (func $~lib/internal/number/genDigits (; 50 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) + (func $~lib/internal/number/genDigits (; 49 ;) (type $iIiIiIii) (param $0 i32) (param $1 i64) (param $2 i32) (param $3 i64) (param $4 i32) (param $5 i64) (param $6 i32) (result i32) (local $7 i32) (local $8 i64) (local $9 i32) @@ -4661,7 +4658,7 @@ local.get $10 end ) - (func $~lib/internal/number/prettify (; 51 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/internal/number/prettify (; 50 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4935,7 +4932,7 @@ end end ) - (func $~lib/internal/number/dtoa_core (; 52 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) + (func $~lib/internal/number/dtoa_core (; 51 ;) (type $iFi) (param $0 i32) (param $1 f64) (result i32) (local $2 i64) (local $3 i64) (local $4 i32) @@ -5251,7 +5248,7 @@ local.get $12 i32.add ) - (func $~lib/string/String#substring (; 53 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#substring (; 52 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -5333,7 +5330,7 @@ call $~lib/internal/string/copyUnsafe local.get $2 ) - (func $~lib/internal/number/dtoa (; 54 ;) (type $Fi) (param $0 f64) (result i32) + (func $~lib/internal/number/dtoa (; 53 ;) (type $Fi) (param $0 f64) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -5386,7 +5383,7 @@ end local.get $1 ) - (func $start (; 55 ;) (type $_) + (func $start:std/string (; 54 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 5880 @@ -5516,13 +5513,13 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str local.set $1 block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -5560,7 +5557,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 0 call $~lib/string/String#padStart|trampoline @@ -5576,7 +5573,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 15 call $~lib/string/String#padStart|trampoline @@ -5592,7 +5589,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 3 call $~lib/string/String#padStart|trampoline @@ -5638,7 +5635,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 288 i32.const 5 call $~lib/string/String#padStart|trampoline @@ -5684,7 +5681,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 0 call $~lib/string/String#padEnd|trampoline @@ -5700,7 +5697,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 15 call $~lib/string/String#padEnd|trampoline @@ -5716,7 +5713,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 3 call $~lib/string/String#padEnd|trampoline @@ -5762,7 +5759,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 288 i32.const 5 call $~lib/string/String#padEnd|trampoline @@ -5941,7 +5938,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 256 call $~lib/string/String#lastIndexOf|trampoline @@ -5954,7 +5951,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 192 call $~lib/string/String#lastIndexOf|trampoline @@ -5969,7 +5966,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 256 call $~lib/string/String#lastIndexOf|trampoline @@ -5985,7 +5982,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 432 call $~lib/string/String#lastIndexOf|trampoline @@ -6000,7 +5997,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 440 call $~lib/string/String#lastIndexOf|trampoline @@ -6015,7 +6012,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 464 call $~lib/string/String#lastIndexOf|trampoline @@ -6782,7 +6779,7 @@ i32.const 976 global.set $std/string/str i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 0 call $~lib/string/String#slice|trampoline @@ -6798,7 +6795,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const -1 call $~lib/string/String#slice|trampoline @@ -6814,7 +6811,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const -5 call $~lib/string/String#slice|trampoline @@ -6890,7 +6887,7 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 0 call $~lib/string/String#split|trampoline @@ -6930,7 +6927,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 256 call $~lib/string/String#split|trampoline @@ -6946,7 +6943,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 432 call $~lib/string/String#split|trampoline @@ -6986,7 +6983,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1192 i32.const 1208 call $~lib/string/String#split|trampoline @@ -7026,7 +7023,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1192 i32.const 432 call $~lib/string/String#split|trampoline @@ -7114,7 +7111,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1224 i32.const 1248 call $~lib/string/String#split|trampoline @@ -7202,7 +7199,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1256 i32.const 432 call $~lib/string/String#split|trampoline @@ -7314,7 +7311,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1272 i32.const 432 call $~lib/string/String#split|trampoline @@ -7426,7 +7423,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1288 i32.const 432 call $~lib/string/String#split|trampoline @@ -7538,7 +7535,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 288 i32.const 256 call $~lib/string/String#split|trampoline @@ -9163,7 +9160,13 @@ unreachable end ) - (func $null (; 56 ;) (type $_) + (func $std/string/getString (; 55 ;) (type $i) (result i32) + global.get $std/string/str + ) + (func $start (; 56 ;) (type $_) + call $start:std/string + ) + (func $null (; 57 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index a1471e01be..16d06f0407 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $iiii_ (func (param i32 i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) @@ -6,7 +7,6 @@ (type $iiii (func (param i32 i32 i32) (result i32))) (type $iii_ (func (param i32 i32 i32))) (type $iiiii_ (func (param i32 i32 i32 i32 i32))) - (type $i (func (result i32))) (type $iiF (func (param i32 i32) (result f64))) (type $iF (func (param i32) (result f64))) (type $i_ (func (param i32))) @@ -15,7 +15,7 @@ (type $Fi (func (param f64) (result i32))) (type $iFi (func (param i32 f64) (result i32))) (type $iIiIiIii (func (param i32 i64 i32 i64 i32 i64 i32) (result i32))) - (type $_ (func)) + (type $i (func (result i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\10\00\00\00h\00i\00,\00 \00I\00\'\00m\00 \00a\00 \00s\00t\00r\00i\00n\00g\00") @@ -178,57 +178,13 @@ (data (i32.const 5848) "\0b\00\00\000\00.\000\000\000\000\003\005\006\008\009\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) - (global $~lib/internal/number/MAX_DOUBLE_LENGTH i32 (i32.const 28)) - (global $~lib/internal/number/_K (mut i32) (i32.const 0)) - (global $~lib/internal/number/_frc (mut i64) (i64.const 0)) - (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) - (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) - (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) - (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (global $std/string/str (mut i32) (i32.const 8)) (global $std/string/nullStr (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) - (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) + (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) - (global $NaN f64 (f64.const nan:0x8000000000000)) - (global $~lib/internal/string/CharCode.PLUS i32 (i32.const 43)) - (global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45)) - (global $~lib/internal/string/CharCode.DOT i32 (i32.const 46)) - (global $~lib/internal/string/CharCode._0 i32 (i32.const 48)) - (global $~lib/internal/string/CharCode._1 i32 (i32.const 49)) - (global $~lib/internal/string/CharCode._2 i32 (i32.const 50)) - (global $~lib/internal/string/CharCode._3 i32 (i32.const 51)) - (global $~lib/internal/string/CharCode._4 i32 (i32.const 52)) - (global $~lib/internal/string/CharCode._5 i32 (i32.const 53)) - (global $~lib/internal/string/CharCode._6 i32 (i32.const 54)) - (global $~lib/internal/string/CharCode._7 i32 (i32.const 55)) - (global $~lib/internal/string/CharCode._8 i32 (i32.const 56)) - (global $~lib/internal/string/CharCode._9 i32 (i32.const 57)) - (global $~lib/internal/string/CharCode.A i32 (i32.const 65)) - (global $~lib/internal/string/CharCode.B i32 (i32.const 66)) - (global $~lib/internal/string/CharCode.E i32 (i32.const 69)) - (global $~lib/internal/string/CharCode.N i32 (i32.const 78)) - (global $~lib/internal/string/CharCode.O i32 (i32.const 79)) - (global $~lib/internal/string/CharCode.X i32 (i32.const 88)) - (global $~lib/internal/string/CharCode.Z i32 (i32.const 90)) - (global $~lib/internal/string/CharCode.a i32 (i32.const 97)) - (global $~lib/internal/string/CharCode.b i32 (i32.const 98)) - (global $~lib/internal/string/CharCode.e i32 (i32.const 101)) - (global $~lib/internal/string/CharCode.n i32 (i32.const 110)) - (global $~lib/internal/string/CharCode.o i32 (i32.const 111)) - (global $~lib/internal/string/CharCode.x i32 (i32.const 120)) - (global $~lib/internal/string/CharCode.z i32 (i32.const 122)) (global $std/string/c (mut i32) (i32.const 0)) (global $std/string/a (mut i32) (i32.const 0)) (global $std/string/b (mut i32) (i32.const 0)) @@ -237,15 +193,33 @@ (global $~lib/builtins/u64.MAX_VALUE i64 (i64.const -1)) (global $~lib/builtins/i64.MAX_VALUE i64 (i64.const 9223372036854775807)) (global $~lib/builtins/i64.MIN_VALUE i64 (i64.const -9223372036854775808)) - (global $Infinity f64 (f64.const inf)) + (global $~lib/internal/number/MAX_DOUBLE_LENGTH i32 (i32.const 28)) + (global $~lib/internal/number/_frc_plus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_frc_minus (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp (mut i32) (i32.const 0)) + (global $~lib/internal/number/_K (mut i32) (i32.const 0)) + (global $~lib/internal/number/_frc_pow (mut i64) (i64.const 0)) + (global $~lib/internal/number/_exp_pow (mut i32) (i32.const 0)) (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) (global $~lib/builtins/f64.MAX_VALUE f64 (f64.const 1797693134862315708145274e284)) - (global $HEAP_BASE i32 (i32.const 5876)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 5876)) (export "memory" (memory $0)) (export "table" (table $0)) (export "getString" (func $std/string/getString)) (start $start) - (func $~lib/string/String#charCodeAt (; 1 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/string/String#charCodeAt (; 2 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.const 0 i32.ne @@ -273,7 +247,7 @@ i32.add i32.load16_u offset=4 ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -281,7 +255,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -298,9 +272,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -352,7 +326,7 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/string/allocateUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/string/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -361,7 +335,7 @@ local.tee $1 if (result i32) local.get $0 - global.get $~lib/internal/string/MAX_LENGTH + i32.const 536870910 i32.le_s else local.get $1 @@ -376,7 +350,7 @@ unreachable end block $~lib/memory/memory.allocate|inlined.0 (result i32) - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 local.get $0 i32.const 1 i32.shl @@ -392,7 +366,7 @@ i32.store local.get $2 ) - (func $~lib/string/String.fromCharCode (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/string/String.fromCharCode (; 5 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) i32.const 1 call $~lib/internal/string/allocateUnsafe @@ -402,7 +376,7 @@ i32.store16 offset=4 local.get $1 ) - (func $~lib/internal/string/compareUnsafe (; 5 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/internal/string/compareUnsafe (; 6 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -455,7 +429,7 @@ end local.get $5 ) - (func $~lib/string/String.__eq (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -499,7 +473,7 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $~lib/string/String.fromCodePoint (; 7 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/string/String.fromCodePoint (; 8 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -558,7 +532,7 @@ end local.get $2 ) - (func $~lib/string/String#startsWith (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#startsWith (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -625,7 +599,7 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $~lib/string/String#endsWith (; 9 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#endsWith (; 10 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -689,18 +663,18 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $~lib/string/String#endsWith|trampoline (; 10 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#endsWith|trampoline (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange end unreachable end - global.get $~lib/internal/string/MAX_LENGTH + i32.const 536870910 local.set $2 end local.get $0 @@ -708,7 +682,7 @@ local.get $2 call $~lib/string/String#endsWith ) - (func $~lib/string/String#indexOf (; 11 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#indexOf (; 12 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -802,7 +776,7 @@ end i32.const -1 ) - (func $~lib/internal/memory/memcpy (; 12 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 13 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2003,7 +1977,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 13 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 14 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -2230,7 +2204,7 @@ end end ) - (func $~lib/internal/string/repeatUnsafe (; 14 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/string/repeatUnsafe (; 15 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -2455,7 +2429,7 @@ i32.shl local.set $7 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.get $1 i32.const 1 @@ -2463,7 +2437,7 @@ i32.add local.set $6 local.get $2 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $5 block $break|5 @@ -2481,7 +2455,7 @@ i32.lt_s i32.eqz br_if $break|5 - block $memory.copy|inlined.0 + block $~lib/memory/memory.copy|inlined.0 local.get $6 local.get $8 i32.add @@ -2510,7 +2484,7 @@ unreachable end ) - (func $~lib/internal/string/copyUnsafe (; 15 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + (func $~lib/internal/string/copyUnsafe (; 16 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -2519,7 +2493,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $5 local.get $2 @@ -2527,7 +2501,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $4 @@ -2539,7 +2513,7 @@ local.get $7 call $~lib/internal/memory/memmove ) - (func $~lib/string/String#padStart (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#padStart (; 17 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2637,11 +2611,11 @@ end local.get $7 ) - (func $~lib/string/String#padStart|trampoline (; 17 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#padStart|trampoline (; 18 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -2656,7 +2630,7 @@ local.get $2 call $~lib/string/String#padStart ) - (func $~lib/string/String#padEnd (; 18 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#padEnd (; 19 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2756,11 +2730,11 @@ end local.get $7 ) - (func $~lib/string/String#padEnd|trampoline (; 19 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#padEnd|trampoline (; 20 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -2775,7 +2749,7 @@ local.get $2 call $~lib/string/String#padEnd ) - (func $~lib/string/String#lastIndexOf (; 20 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#lastIndexOf (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2867,11 +2841,11 @@ end i32.const -1 ) - (func $~lib/string/String#lastIndexOf|trampoline (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/string/String#lastIndexOf|trampoline (; 22 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -2886,9 +2860,6 @@ local.get $2 call $~lib/string/String#lastIndexOf ) - (func $std/string/getString (; 22 ;) (type $i) (result i32) - global.get $std/string/str - ) (func $~lib/internal/string/parse (; 23 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (local $2 i32) (local $3 i32) @@ -2911,7 +2882,7 @@ i32.load16_u offset=4 local.set $4 local.get $4 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.eq if local.get $2 @@ -2933,7 +2904,7 @@ local.set $5 else local.get $4 - global.get $~lib/internal/string/CharCode.PLUS + i32.const 43 i32.eq if local.get $2 @@ -2962,7 +2933,7 @@ i32.eqz if local.get $4 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.eq local.tee $6 if (result i32) @@ -2987,27 +2958,27 @@ i32.load16_u offset=4 local.set $6 local.get $6 - global.get $~lib/internal/string/CharCode.B + i32.const 66 i32.eq br_if $case0|0 local.get $6 - global.get $~lib/internal/string/CharCode.b + i32.const 98 i32.eq br_if $case1|0 local.get $6 - global.get $~lib/internal/string/CharCode.O + i32.const 79 i32.eq br_if $case2|0 local.get $6 - global.get $~lib/internal/string/CharCode.o + i32.const 111 i32.eq br_if $case3|0 local.get $6 - global.get $~lib/internal/string/CharCode.X + i32.const 88 i32.eq br_if $case4|0 local.get $6 - global.get $~lib/internal/string/CharCode.x + i32.const 120 i32.eq br_if $case5|0 br $case6|0 @@ -3105,55 +3076,55 @@ i32.load16_u offset=4 local.set $4 local.get $4 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.ge_s local.tee $6 if (result i32) local.get $4 - global.get $~lib/internal/string/CharCode._9 + i32.const 57 i32.le_s else local.get $6 end if local.get $4 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.sub local.set $4 else local.get $4 - global.get $~lib/internal/string/CharCode.A + i32.const 65 i32.ge_s local.tee $6 if (result i32) local.get $4 - global.get $~lib/internal/string/CharCode.Z + i32.const 90 i32.le_s else local.get $6 end if local.get $4 - global.get $~lib/internal/string/CharCode.A + i32.const 65 i32.const 10 i32.sub i32.sub local.set $4 else local.get $4 - global.get $~lib/internal/string/CharCode.a + i32.const 97 i32.ge_s local.tee $6 if (result i32) local.get $4 - global.get $~lib/internal/string/CharCode.z + i32.const 122 i32.le_s else local.get $6 end if local.get $4 - global.get $~lib/internal/string/CharCode.a + i32.const 97 i32.const 10 i32.sub i32.sub @@ -3218,7 +3189,7 @@ i32.load16_u offset=4 local.set $3 local.get $3 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.eq if local.get $1 @@ -3240,7 +3211,7 @@ local.set $4 else local.get $3 - global.get $~lib/internal/string/CharCode.PLUS + i32.const 43 i32.eq if local.get $1 @@ -3283,7 +3254,7 @@ i32.load16_u offset=4 local.set $3 local.get $3 - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.eq if local.get $2 @@ -3308,14 +3279,14 @@ i32.load16_u offset=4 local.set $3 local.get $3 - global.get $~lib/internal/string/CharCode.E + i32.const 69 i32.eq local.tee $6 if (result i32) local.get $6 else local.get $3 - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.eq end if @@ -3324,14 +3295,14 @@ if i32.const 0 i32.const 80 - i32.const 643 + i32.const 645 i32.const 10 call $~lib/env/abort unreachable end end local.get $3 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.sub local.set $3 local.get $3 @@ -3363,7 +3334,7 @@ br $break|0 end local.get $3 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.sub local.set $3 local.get $3 @@ -3889,7 +3860,7 @@ block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of1 $1of1 $outOfRange @@ -3908,7 +3879,7 @@ i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -3920,7 +3891,7 @@ (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -4249,9 +4220,9 @@ local.get $0 local.get $1 i32.store offset=4 - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -4326,7 +4297,7 @@ i32.gt_s if local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_s i32.eqz if @@ -4340,7 +4311,7 @@ local.get $1 local.get $2 call $~lib/internal/arraybuffer/computeSize - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.sub i32.le_s if @@ -4351,13 +4322,13 @@ local.get $1 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.copy|inlined.2 + block $~lib/memory/memory.copy|inlined.2 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $5 local.get $2 @@ -4377,9 +4348,9 @@ local.get $3 local.set $0 end - block $memory.fill|inlined.1 + block $~lib/memory/memory.fill|inlined.1 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.get $2 i32.add @@ -4784,7 +4755,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of2 $1of2 $2of2 $outOfRange end unreachable @@ -5077,7 +5048,7 @@ i32.const 1 i32.sub local.set $2 - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $1 i32.add local.set $7 @@ -5137,7 +5108,7 @@ local.get $1 if local.get $3 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $3 @@ -5557,7 +5528,7 @@ local.get $1 if local.get $2 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end local.get $2 @@ -5858,7 +5829,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $17 i32.const 65535 i32.and @@ -6030,7 +6001,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 local.get $19 i32.wrap_i64 i32.const 65535 @@ -6185,8 +6156,8 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT - global.get $~lib/internal/string/CharCode._0 + i32.const 46 + i32.const 48 i32.const 16 i32.shl i32.or @@ -6226,7 +6197,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $4 i32.const 1 @@ -6242,8 +6213,8 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT - global.get $~lib/internal/string/CharCode._0 + i32.const 46 + i32.const 48 i32.const 16 i32.shl i32.or @@ -6271,15 +6242,15 @@ i32.shl i32.add local.set $4 - block $memory.copy|inlined.3 + block $~lib/memory/memory.copy|inlined.3 local.get $4 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 2 i32.add local.set $5 local.get $4 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 i32.const 0 @@ -6298,7 +6269,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=4 local.get $1 i32.const 1 @@ -6321,9 +6292,9 @@ local.get $3 i32.sub local.set $4 - block $memory.copy|inlined.4 + block $~lib/memory/memory.copy|inlined.4 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.get $4 i32.const 1 @@ -6331,7 +6302,7 @@ i32.add local.set $7 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $1 @@ -6344,8 +6315,8 @@ call $~lib/internal/memory/memmove end local.get $0 - global.get $~lib/internal/string/CharCode._0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 48 + i32.const 46 i32.const 16 i32.shl i32.or @@ -6364,7 +6335,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/CharCode._0 + i32.const 48 i32.store16 offset=4 local.get $5 i32.const 1 @@ -6385,7 +6356,7 @@ i32.eq if local.get $0 - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.store16 offset=6 block $~lib/internal/number/genExponent|inlined.0 (result i32) local.get $0 @@ -6425,8 +6396,8 @@ call $~lib/internal/number/utoa32_lut end local.get $4 - global.get $~lib/internal/string/CharCode.MINUS - global.get $~lib/internal/string/CharCode.PLUS + i32.const 45 + i32.const 43 local.get $6 select i32.store16 offset=4 @@ -6442,15 +6413,15 @@ i32.const 1 i32.shl local.set $7 - block $memory.copy|inlined.5 + block $~lib/memory/memory.copy|inlined.5 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 4 i32.add local.set $6 local.get $0 - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add i32.const 2 i32.add @@ -6465,12 +6436,12 @@ call $~lib/internal/memory/memmove end local.get $0 - global.get $~lib/internal/string/CharCode.DOT + i32.const 46 i32.store16 offset=6 local.get $0 local.get $7 i32.add - global.get $~lib/internal/string/CharCode.e + i32.const 101 i32.store16 offset=6 local.get $1 block $~lib/internal/number/genExponent|inlined.1 (result i32) @@ -6513,8 +6484,8 @@ call $~lib/internal/number/utoa32_lut end local.get $4 - global.get $~lib/internal/string/CharCode.MINUS - global.get $~lib/internal/string/CharCode.PLUS + i32.const 45 + i32.const 43 local.get $6 select i32.store16 offset=4 @@ -6577,7 +6548,7 @@ f64.neg local.set $1 local.get $0 - global.get $~lib/internal/string/CharCode.MINUS + i32.const 45 i32.store16 offset=4 end block $~lib/internal/number/grisu2|inlined.0 (result i32) @@ -7189,20 +7160,11 @@ end local.get $3 ) - (func $start (; 64 ;) (type $_) + (func $start:std/string (; 64 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena global.get $std/string/str i32.const 8 i32.eq @@ -7335,7 +7297,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 216 i32.const 0 @@ -7377,7 +7339,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 0 i32.const 0 @@ -7396,7 +7358,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 15 i32.const 0 @@ -7415,7 +7377,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 3 i32.const 0 @@ -7464,7 +7426,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 288 i32.const 5 i32.const 0 @@ -7513,7 +7475,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 0 i32.const 0 @@ -7532,7 +7494,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 15 i32.const 0 @@ -7551,7 +7513,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 3 i32.const 0 @@ -7600,7 +7562,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 288 i32.const 5 i32.const 0 @@ -7799,7 +7761,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 256 i32.const 0 @@ -7818,7 +7780,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 192 i32.const 0 @@ -7837,7 +7799,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 256 i32.const 0 @@ -7857,7 +7819,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 432 i32.const 0 @@ -7876,7 +7838,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 440 i32.const 0 @@ -7895,7 +7857,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 464 i32.const 0 @@ -8711,7 +8673,7 @@ global.set $std/string/str block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const 0 i32.const 0 @@ -8730,7 +8692,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const -1 i32.const 0 @@ -8749,7 +8711,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/string/str i32.const -5 i32.const 0 @@ -8828,7 +8790,7 @@ end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 0 i32.const 0 @@ -8864,7 +8826,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 256 i32.const 0 @@ -8890,7 +8852,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 256 i32.const 432 i32.const 0 @@ -8926,7 +8888,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1192 i32.const 1208 i32.const 0 @@ -8962,7 +8924,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1192 i32.const 432 i32.const 0 @@ -9018,7 +8980,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1224 i32.const 1248 i32.const 0 @@ -9074,7 +9036,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1256 i32.const 432 i32.const 0 @@ -9140,7 +9102,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1272 i32.const 432 i32.const 0 @@ -9206,7 +9168,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 1288 i32.const 432 i32.const 0 @@ -9272,7 +9234,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc i32.const 288 i32.const 256 i32.const 0 @@ -10757,6 +10719,12 @@ unreachable end ) - (func $null (; 65 ;) (type $_) + (func $std/string/getString (; 65 ;) (type $i) (result i32) + global.get $std/string/str + ) + (func $start (; 66 ;) (type $_) + call $start:std/string + ) + (func $null (; 67 ;) (type $_) ) ) diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index b3e163e836..cb8ea045cd 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $i_ (func (param i32))) @@ -6,7 +7,6 @@ (type $iii_ (func (param i32 i32 i32))) (type $iii (func (param i32 i32) (result i32))) (type $ii_ (func (param i32 i32))) - (type $_ (func)) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) (type $FUNCSIG$i (func (result i32))) @@ -2440,7 +2440,7 @@ i32.const 592 call $~lib/string/String.__concat ) - (func $start (; 28 ;) (type $_) + (func $start:std/symbol (; 28 ;) (type $_) (local $0 i32) i32.const 760 global.set $~lib/allocator/arena/startOffset @@ -2617,7 +2617,10 @@ unreachable end ) - (func $null (; 29 ;) (type $_) + (func $start (; 29 ;) (type $_) + call $start:std/symbol + ) + (func $null (; 30 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index c705bc7d68..ff0be34379 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -1,4 +1,5 @@ (module + (type $_ (func)) (type $ii (func (param i32) (result i32))) (type $iiii_ (func (param i32 i32 i32 i32))) (type $i_ (func (param i32))) @@ -8,7 +9,6 @@ (type $iiiiii (func (param i32 i32 i32 i32 i32) (result i32))) (type $ii_ (func (param i32 i32))) (type $iiiii_ (func (param i32 i32 i32 i32 i32))) - (type $_ (func)) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) (data (i32.const 8) "\03\00\00\001\002\003\00") @@ -38,43 +38,40 @@ (data (i32.const 704) "\1a\00\00\00S\00y\00m\00b\00o\00l\00(\00i\00s\00C\00o\00n\00c\00a\00t\00S\00p\00r\00e\00a\00d\00a\00b\00l\00e\00)\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $~lib/symbol/nextId (mut i32) (i32.const 12)) (global $std/symbol/sym1 (mut i32) (i32.const 0)) (global $std/symbol/sym2 (mut i32) (i32.const 0)) (global $~lib/symbol/stringToId (mut i32) (i32.const 0)) - (global $~lib/map/INITIAL_CAPACITY i32 (i32.const 4)) - (global $~lib/map/BUCKET_SIZE i32 (i32.const 4)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) (global $~lib/symbol/idToString (mut i32) (i32.const 0)) - (global $~lib/internal/hash/FNV_OFFSET i32 (i32.const -2128831035)) - (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) - (global $~lib/internal/hash/FNV_PRIME i32 (i32.const 16777619)) - (global $~lib/map/EMPTY i32 (i32.const 1)) - (global $~lib/map/FREE_FACTOR f64 (f64.const 0.75)) - (global $~lib/map/FILL_FACTOR f64 (f64.const 2.6666666666666665)) (global $std/symbol/sym3 (mut i32) (i32.const 0)) (global $std/symbol/sym4 (mut i32) (i32.const 0)) (global $std/symbol/key1 (mut i32) (i32.const 0)) (global $std/symbol/key2 (mut i32) (i32.const 0)) (global $std/symbol/key3 (mut i32) (i32.const 0)) (global $std/symbol/key4 (mut i32) (i32.const 0)) - (global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) (global $~lib/symbol/Symbol.hasInstance i32 (i32.const 1)) (global $std/symbol/hasInstance (mut i32) (i32.const 0)) (global $~lib/symbol/Symbol.isConcatSpreadable i32 (i32.const 2)) (global $std/symbol/isConcatSpreadable (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 760)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 760)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/symbol/Symbol (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/symbol/Symbol (; 2 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) block (result i32) @@ -93,7 +90,7 @@ end local.get $2 ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -101,7 +98,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -118,9 +115,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -172,16 +169,16 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 4 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/arraybuffer/computeSize (; 4 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/computeSize (; 5 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -189,11 +186,11 @@ i32.sub i32.shl ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 6 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -218,7 +215,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 6 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 7 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -472,13 +469,13 @@ end end ) - (func $~lib/arraybuffer/ArrayBuffer#constructor (; 7 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/arraybuffer/ArrayBuffer#constructor (; 8 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) local.get $1 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.gt_u if i32.const 0 @@ -497,7 +494,7 @@ i32.eqz if local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -511,7 +508,7 @@ end local.get $3 ) - (func $~lib/map/Map#clear (; 8 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 9 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -519,7 +516,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -530,7 +527,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -539,7 +536,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 9 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 10 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -571,7 +568,7 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/map/Map#clear (; 10 ;) (type $i_) (param $0 i32) + (func $~lib/map/Map#clear (; 11 ;) (type $i_) (param $0 i32) local.get $0 i32.const 0 i32.const 16 @@ -579,7 +576,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.const 1 i32.sub i32.store offset=4 @@ -590,7 +587,7 @@ call $~lib/arraybuffer/ArrayBuffer#constructor i32.store offset=8 local.get $0 - global.get $~lib/map/INITIAL_CAPACITY + i32.const 4 i32.store offset=12 local.get $0 i32.const 0 @@ -599,7 +596,7 @@ i32.const 0 i32.store offset=20 ) - (func $~lib/map/Map#constructor (; 11 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/map/Map#constructor (; 12 ;) (type $ii) (param $0 i32) (result i32) block (result i32) local.get $0 i32.eqz @@ -631,11 +628,11 @@ call $~lib/map/Map#clear local.get $0 ) - (func $~lib/internal/hash/hashStr (; 12 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/hashStr (; 13 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 block $break|0 block @@ -659,7 +656,7 @@ i32.add i32.load8_u offset=4 i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $2 @@ -673,7 +670,7 @@ end local.get $1 ) - (func $~lib/internal/string/compareUnsafe (; 13 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) + (func $~lib/internal/string/compareUnsafe (; 14 ;) (type $iiiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (result i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -726,7 +723,7 @@ end local.get $5 ) - (func $~lib/string/String.__eq (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__eq (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -770,7 +767,7 @@ call $~lib/internal/string/compareUnsafe i32.eqz ) - (func $~lib/map/Map#find (; 15 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -779,7 +776,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -791,7 +788,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -809,7 +806,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -821,7 +818,7 @@ end i32.const 0 ) - (func $~lib/map/Map#has (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -836,7 +833,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#get (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -858,7 +855,7 @@ unreachable end ) - (func $~lib/map/Map#rehash (; 18 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 19 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -876,14 +873,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -898,7 +895,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -911,7 +908,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -925,7 +922,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -952,7 +949,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -998,7 +995,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 19 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 20 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1034,7 +1031,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -1055,7 +1052,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -1091,7 +1088,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -1104,16 +1101,16 @@ i32.store offset=8 end ) - (func $~lib/internal/hash/hash32 (; 20 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/hash/hash32 (; 21 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) - global.get $~lib/internal/hash/FNV_OFFSET + i32.const -2128831035 local.set $1 local.get $1 local.get $0 i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -1123,7 +1120,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -1133,7 +1130,7 @@ i32.const 255 i32.and i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 @@ -1141,12 +1138,12 @@ i32.const 24 i32.shr_u i32.xor - global.get $~lib/internal/hash/FNV_PRIME + i32.const 16777619 i32.mul local.set $1 local.get $1 ) - (func $~lib/map/Map#find (; 21 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/map/Map#find (; 22 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) local.get $0 @@ -1155,7 +1152,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add i32.load offset=8 @@ -1167,7 +1164,7 @@ block local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz local.tee $4 @@ -1185,7 +1182,7 @@ end local.get $3 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.const -1 i32.xor i32.and @@ -1197,7 +1194,7 @@ end i32.const 0 ) - (func $~lib/map/Map#rehash (; 22 ;) (type $ii_) (param $0 i32) (param $1 i32) + (func $~lib/map/Map#rehash (; 23 ;) (type $ii_) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1215,14 +1212,14 @@ local.set $2 i32.const 0 local.get $2 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.const 0 call $~lib/arraybuffer/ArrayBuffer#constructor local.set $3 local.get $2 f64.convert_i32_s - global.get $~lib/map/FILL_FACTOR + f64.const 2.6666666666666665 f64.mul i32.trunc_f64_s local.set $4 @@ -1237,7 +1234,7 @@ local.set $5 local.get $0 i32.load offset=8 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $6 local.get $6 @@ -1250,7 +1247,7 @@ i32.add local.set $7 local.get $5 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $8 block $break|0 @@ -1264,7 +1261,7 @@ local.set $9 local.get $9 i32.load offset=8 - global.get $~lib/map/EMPTY + i32.const 1 i32.and i32.eqz if @@ -1291,7 +1288,7 @@ local.set $11 local.get $3 local.get $11 - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $12 @@ -1337,7 +1334,7 @@ i32.load offset=20 i32.store offset=16 ) - (func $~lib/map/Map#set (; 23 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/map/Map#set (; 24 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1373,7 +1370,7 @@ local.get $0 i32.load offset=12 f64.convert_i32_s - global.get $~lib/map/FREE_FACTOR + f64.const 0.75 f64.mul i32.trunc_f64_s i32.lt_s @@ -1394,7 +1391,7 @@ i32.load offset=8 local.set $3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add block (result i32) local.get $0 @@ -1430,7 +1427,7 @@ local.get $0 i32.load offset=4 i32.and - global.get $~lib/map/BUCKET_SIZE + i32.const 4 i32.mul i32.add local.set $6 @@ -1443,7 +1440,7 @@ i32.store offset=8 end ) - (func $~lib/symbol/Symbol.for (; 24 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/symbol/Symbol.for (; 25 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) global.get $~lib/symbol/stringToId @@ -1490,7 +1487,7 @@ call $~lib/map/Map#set local.get $2 ) - (func $~lib/map/Map#has (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#has (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) local.get $0 local.get $1 @@ -1505,7 +1502,7 @@ i32.const 0 i32.ne ) - (func $~lib/map/Map#get (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/map/Map#get (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) local.get $0 @@ -1527,7 +1524,7 @@ unreachable end ) - (func $~lib/symbol/Symbol.keyFor (; 27 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/symbol/Symbol.keyFor (; 28 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) global.get $~lib/symbol/idToString i32.const 0 @@ -1548,7 +1545,7 @@ i32.const 0 end ) - (func $~lib/internal/string/allocateUnsafe (; 28 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/string/allocateUnsafe (; 29 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 @@ -1557,7 +1554,7 @@ local.tee $1 if (result i32) local.get $0 - global.get $~lib/internal/string/MAX_LENGTH + i32.const 536870910 i32.le_s else local.get $1 @@ -1572,7 +1569,7 @@ unreachable end block $~lib/memory/memory.allocate|inlined.1 (result i32) - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 local.get $0 i32.const 1 i32.shl @@ -1588,7 +1585,7 @@ i32.store local.get $2 ) - (func $~lib/internal/memory/memcpy (; 29 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memcpy (; 30 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2789,7 +2786,7 @@ i32.store8 end ) - (func $~lib/internal/memory/memmove (; 30 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memmove (; 31 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) local.get $0 local.get $1 @@ -3016,7 +3013,7 @@ end end ) - (func $~lib/internal/string/copyUnsafe (; 31 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) + (func $~lib/internal/string/copyUnsafe (; 32 ;) (type $iiiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (local $5 i32) (local $6 i32) (local $7 i32) @@ -3025,7 +3022,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $5 local.get $2 @@ -3033,7 +3030,7 @@ i32.const 1 i32.shl i32.add - global.get $~lib/internal/string/HEADER_SIZE + i32.const 4 i32.add local.set $6 local.get $4 @@ -3045,7 +3042,7 @@ local.get $7 call $~lib/internal/memory/memmove ) - (func $~lib/string/String#concat (; 32 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String#concat (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3103,7 +3100,7 @@ call $~lib/internal/string/copyUnsafe local.get $5 ) - (func $~lib/string/String.__concat (; 33 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/string/String.__concat (; 34 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -3114,7 +3111,7 @@ local.get $1 call $~lib/string/String#concat ) - (func $~lib/symbol/symbol#toString (; 34 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/symbol/symbol#toString (; 35 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -3300,17 +3297,8 @@ i32.const 592 call $~lib/string/String.__concat ) - (func $start (; 35 ;) (type $_) - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + (func $start:std/symbol (; 36 ;) (type $_) + call $start:~lib/allocator/arena i32.const 8 call $~lib/symbol/Symbol global.set $std/symbol/sym1 @@ -3469,6 +3457,9 @@ global.get $~lib/symbol/Symbol.isConcatSpreadable drop ) - (func $null (; 36 ;) (type $_) + (func $start (; 37 ;) (type $_) + call $start:std/symbol + ) + (func $null (; 38 ;) (type $_) ) ) diff --git a/tests/compiler/std/trace.optimized.wat b/tests/compiler/std/trace.optimized.wat index 2216c3a2c1..599049b19e 100644 --- a/tests/compiler/std/trace.optimized.wat +++ b/tests/compiler/std/trace.optimized.wat @@ -13,20 +13,11 @@ (data (i32.const 192) "\08\00\00\00f\00i\00v\00e\00_\00d\00b\00l") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~started (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/trace/main)) - (func $std/trace/main (; 1 ;) (type $_) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - ) - (func $start (; 2 ;) (type $_) + (func $start:std/trace (; 1 ;) (type $_) i32.const 8 i32.const 0 f64.const 0 @@ -92,6 +83,15 @@ f64.const 5.5 call $~lib/env/trace ) + (func $std/trace/main (; 2 ;) (type $_) + global.get $~lib/started + i32.eqz + if + call $start:std/trace + i32.const 1 + global.set $~lib/started + end + ) (func $null (; 3 ;) (type $_) nop ) diff --git a/tests/compiler/std/trace.ts b/tests/compiler/std/trace.ts index 0bd2461267..0c49346125 100644 --- a/tests/compiler/std/trace.ts +++ b/tests/compiler/std/trace.ts @@ -7,4 +7,5 @@ trace("four_int", 4, 1, 2, 3, 4); trace("five_int", 5, 1, 2, 3, 4, 5); trace("five_dbl", 5, 1.1, 2.2, 3.3, 4.4, 5.5); +@start export function main(): void {} diff --git a/tests/compiler/std/trace.untouched.wat b/tests/compiler/std/trace.untouched.wat index e7c666e8f0..799b46b0c6 100644 --- a/tests/compiler/std/trace.untouched.wat +++ b/tests/compiler/std/trace.untouched.wat @@ -13,21 +13,12 @@ (data (i32.const 192) "\08\00\00\00f\00i\00v\00e\00_\00d\00b\00l\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~started (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 212)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 212)) (export "memory" (memory $0)) (export "table" (table $0)) (export "main" (func $std/trace/main)) - (func $std/trace/main (; 1 ;) (type $_) - global.get $~started - i32.eqz - if - call $start - i32.const 1 - global.set $~started - end - ) - (func $start (; 2 ;) (type $_) + (func $start:std/trace (; 1 ;) (type $_) i32.const 8 i32.const 0 f64.const 0 @@ -93,6 +84,18 @@ f64.const 5.5 call $~lib/env/trace ) - (func $null (; 3 ;) (type $_) + (func $std/trace/main (; 2 ;) (type $_) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 3 ;) (type $_) + call $start:std/trace + ) + (func $null (; 4 ;) (type $_) ) ) diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 53175de155..236db3cd03 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -1,5 +1,6 @@ (module (type $iiii_ (func (param i32 i32 i32 i32))) + (type $_ (func)) (type $i_ (func (param i32))) (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) @@ -9,7 +10,6 @@ (type $FFi (func (param f64 f64) (result i32))) (type $iiF (func (param i32 i32) (result f64))) (type $iiiii (func (param i32 i32 i32 i32) (result i32))) - (type $_ (func)) (type $iiI_ (func (param i32 i32 i64))) (type $IIiiI (func (param i64 i64 i32 i32) (result i64))) (type $iif_ (func (param i32 i32 f32))) @@ -71,7 +71,7 @@ (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $std/typedarray/arr (mut i32) (i32.const 0)) (global $std/typedarray/af64 (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/typedarray/clampedArr (mut i32) (i32.const 0)) (global $std/typedarray/arr8 (mut i32) (i32.const 0)) (global $std/typedarray/sub8 (mut i32) (i32.const 0)) @@ -1314,7 +1314,7 @@ f64.load offset=8 local.set $7 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $3 @@ -1445,7 +1445,7 @@ f64.load offset=8 local.set $6 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $6 local.get $3 @@ -1575,7 +1575,7 @@ f64.load offset=8 local.set $7 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $3 @@ -1690,7 +1690,7 @@ f64.load offset=8 local.set $7 i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $6 local.get $7 local.get $4 @@ -2017,7 +2017,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -2252,7 +2252,7 @@ block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -2297,7 +2297,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 local.get $4 @@ -2372,7 +2372,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $2 local.get $5 @@ -2509,7 +2509,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 1 @@ -2587,7 +2587,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 1 @@ -2665,7 +2665,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $2 i32.const 2 @@ -2804,7 +2804,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $2 i32.const 3 @@ -2943,7 +2943,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 2 @@ -3024,7 +3024,7 @@ i32.lt_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 3 @@ -3099,7 +3099,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 local.get $3 @@ -3175,7 +3175,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $2 local.get $4 @@ -3286,7 +3286,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 1 @@ -3365,7 +3365,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 1 @@ -3444,7 +3444,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $2 i32.const 2 @@ -3552,7 +3552,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $3 local.get $2 i32.const 3 @@ -3660,7 +3660,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 2 @@ -3737,7 +3737,7 @@ i32.ge_s if i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $1 i32.const 3 @@ -3822,7 +3822,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 local.get $6 i32.add @@ -3938,7 +3938,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 local.get $6 i32.add @@ -4053,7 +4053,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 local.get $6 i32.add @@ -4170,7 +4170,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 i32.const 1 i32.shl @@ -4316,7 +4316,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 i32.const 1 i32.shl @@ -4462,7 +4462,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $2 i32.const 2 @@ -4642,7 +4642,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $7 local.get $2 i32.const 3 @@ -4848,7 +4848,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 i32.const 2 i32.shl @@ -4993,7 +4993,7 @@ i32.lt_s if i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $1 i32.const 3 i32.shl @@ -5107,7 +5107,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 local.get $4 @@ -5200,7 +5200,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 local.get $4 @@ -5336,7 +5336,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 i32.const 1 @@ -5432,7 +5432,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 i32.const 1 @@ -5527,7 +5527,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 i32.const 2 @@ -5666,7 +5666,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 i32.const 3 @@ -5806,7 +5806,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 i32.const 2 @@ -5906,7 +5906,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc i32.const 1 local.get $2 i32.const 3 @@ -6002,7 +6002,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $4 i32.add @@ -6102,7 +6102,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 local.get $4 i32.add @@ -6240,7 +6240,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 1 i32.shl @@ -6343,7 +6343,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 1 i32.shl @@ -6439,7 +6439,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 2 i32.shl @@ -6583,7 +6583,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 3 i32.shl @@ -6727,7 +6727,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 2 i32.shl @@ -6828,7 +6828,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $0 i32.const 3 i32.shl @@ -6934,7 +6934,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $4 i32.add @@ -7029,7 +7029,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 local.get $4 i32.add @@ -7170,7 +7170,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 1 i32.shl @@ -7262,7 +7262,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 1 i32.shl @@ -7360,7 +7360,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 2 i32.shl @@ -7499,7 +7499,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 3 i32.shl @@ -7795,7 +7795,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 2 i32.shl @@ -8052,7 +8052,7 @@ i32.ge_s br_if $break|0 i32.const 3 - global.set $~argc + global.set $~lib/argc local.get $2 i32.const 3 i32.shl @@ -8120,7 +8120,7 @@ unreachable end ) - (func $start (; 193 ;) (type $_) + (func $start:std/typedarray (; 193 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 624 @@ -8353,13 +8353,13 @@ unreachable end i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/af64 local.set $1 block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -8518,7 +8518,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr8 i32.const 0 i32.const 0 @@ -8555,7 +8555,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr8 i32.const 2 i32.const -2 @@ -8596,7 +8596,7 @@ call $~lib/typedarray/Int8Array#subarray global.set $std/typedarray/sub8 i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/sub8 i32.const 0 i32.const 0 @@ -8704,7 +8704,7 @@ unreachable end i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr32 i32.const 0 i32.const 0 @@ -8741,7 +8741,7 @@ unreachable end i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr32 i32.const 2 i32.const -2 @@ -8782,7 +8782,7 @@ call $~lib/typedarray/Int32Array#subarray global.set $std/typedarray/sub32 i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/sub32 i32.const 0 i32.const 0 @@ -9113,7 +9113,10 @@ call $std/typedarray/testArrayEvery call $std/typedarray/testArrayEvery ) - (func $null (; 194 ;) (type $_) + (func $start (; 194 ;) (type $_) + call $start:std/typedarray + ) + (func $null (; 195 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 6d1d0c2685..62d46712f0 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -1,5 +1,6 @@ (module (type $iiii_ (func (param i32 i32 i32 i32))) + (type $_ (func)) (type $i_ (func (param i32))) (type $iii (func (param i32 i32) (result i32))) (type $ii (func (param i32) (result i32))) @@ -9,7 +10,6 @@ (type $FFi (func (param f64 f64) (result i32))) (type $iiF (func (param i32 i32) (result f64))) (type $iiiii (func (param i32 i32 i32 i32) (result i32))) - (type $_ (func)) (type $iiI_ (func (param i32 i32 i64))) (type $IIiiI (func (param i64 i64 i32 i32) (result i64))) (type $iiII (func (param i32 i32 i64) (result i64))) @@ -74,17 +74,11 @@ (global $~lib/typedarray/Uint64Array.BYTES_PER_ELEMENT i32 (i32.const 8)) (global $~lib/typedarray/Float32Array.BYTES_PER_ELEMENT i32 (i32.const 4)) (global $~lib/typedarray/Float64Array.BYTES_PER_ELEMENT i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_BITS i32 (i32.const 3)) - (global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8)) - (global $~lib/internal/allocator/AL_MASK i32 (i32.const 7)) - (global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824)) (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/internal/arraybuffer/HEADER_SIZE i32 (i32.const 8)) - (global $~lib/internal/arraybuffer/MAX_BLENGTH i32 (i32.const 1073741816)) (global $std/typedarray/arr (mut i32) (i32.const 0)) (global $std/typedarray/af64 (mut i32) (i32.const 0)) - (global $~argc (mut i32) (i32.const 0)) + (global $~lib/argc (mut i32) (i32.const 0)) (global $std/typedarray/clampedArr (mut i32) (i32.const 0)) (global $std/typedarray/arr8 (mut i32) (i32.const 0)) (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) @@ -96,15 +90,27 @@ (global $std/typedarray/multisubarr1 (mut i32) (i32.const 0)) (global $std/typedarray/multisubarr2 (mut i32) (i32.const 0)) (global $std/typedarray/multisubarr3 (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 624)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 624)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $~lib/internal/arraybuffer/computeSize (; 1 ;) (type $ii) (param $0 i32) (result i32) + (func $start:~lib/allocator/arena (; 1 ;) (type $_) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + ) + (func $~lib/internal/arraybuffer/computeSize (; 2 ;) (type $ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add i32.const 1 i32.sub @@ -112,7 +118,7 @@ i32.sub i32.shl ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -120,7 +126,7 @@ (local $5 i32) (local $6 i32) local.get $0 - global.get $~lib/internal/allocator/MAX_SIZE_32 + i32.const 1073741824 i32.gt_u if unreachable @@ -137,9 +143,9 @@ i32.gt_u select i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.add - global.get $~lib/internal/allocator/AL_MASK + i32.const 7 i32.const -1 i32.xor i32.and @@ -191,11 +197,11 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 3 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/internal/arraybuffer/allocateUnsafe (; 4 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) local.get $0 - global.get $~lib/internal/arraybuffer/MAX_BLENGTH + i32.const 1073741816 i32.le_u i32.eqz if @@ -220,7 +226,7 @@ i32.store local.get $1 ) - (func $~lib/internal/memory/memset (; 4 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/memory/memset (; 5 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i64) @@ -474,12 +480,12 @@ end end ) - (func $~lib/memory/memory.allocate (; 5 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/memory/memory.allocate (; 6 ;) (type $ii) (param $0 i32) (result i32) local.get $0 call $~lib/allocator/arena/__memory_allocate return ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 6 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -503,9 +509,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.0 + block $~lib/memory/memory.fill|inlined.0 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -546,7 +552,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Int8Array#constructor (; 7 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int8Array#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -560,7 +566,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -584,9 +590,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.1 + block $~lib/memory/memory.fill|inlined.1 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -627,7 +633,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint8Array#constructor (; 9 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -641,7 +647,7 @@ local.set $0 local.get $0 ) - (func $~lib/typedarray/Uint8ClampedArray#constructor (; 10 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8ClampedArray#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -655,7 +661,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 11 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -679,9 +685,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.2 + block $~lib/memory/memory.fill|inlined.2 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -722,7 +728,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Int16Array#constructor (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int16Array#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -736,7 +742,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 13 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -760,9 +766,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.3 + block $~lib/memory/memory.fill|inlined.3 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -803,7 +809,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint16Array#constructor (; 14 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint16Array#constructor (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -817,7 +823,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 15 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -841,9 +847,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.4 + block $~lib/memory/memory.fill|inlined.4 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -884,7 +890,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Int32Array#constructor (; 16 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int32Array#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -898,7 +904,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 17 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -922,9 +928,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.5 + block $~lib/memory/memory.fill|inlined.5 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -965,7 +971,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint32Array#constructor (; 18 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint32Array#constructor (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -979,7 +985,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 19 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1003,9 +1009,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.6 + block $~lib/memory/memory.fill|inlined.6 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -1046,7 +1052,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Int64Array#constructor (; 20 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int64Array#constructor (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -1060,7 +1066,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 21 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1084,9 +1090,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.7 + block $~lib/memory/memory.fill|inlined.7 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -1127,7 +1133,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Uint64Array#constructor (; 22 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint64Array#constructor (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -1141,7 +1147,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 23 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 24 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1165,9 +1171,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.8 + block $~lib/memory/memory.fill|inlined.8 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -1208,7 +1214,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Float32Array#constructor (; 24 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float32Array#constructor (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -1222,7 +1228,7 @@ local.set $0 local.get $0 ) - (func $~lib/internal/typedarray/TypedArray#constructor (; 25 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#constructor (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1246,9 +1252,9 @@ local.get $2 call $~lib/internal/arraybuffer/allocateUnsafe local.set $3 - block $memory.fill|inlined.9 + block $~lib/memory/memory.fill|inlined.9 local.get $3 - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $4 i32.const 0 @@ -1289,7 +1295,7 @@ i32.store offset=8 local.get $0 ) - (func $~lib/typedarray/Float64Array#constructor (; 26 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#constructor (; 27 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) local.get $0 i32.eqz if @@ -1303,7 +1309,7 @@ local.set $0 local.get $0 ) - (func $std/typedarray/testInstantiate (; 27 ;) (type $i_) (param $0 i32) + (func $std/typedarray/testInstantiate (; 28 ;) (type $i_) (param $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1878,7 +1884,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 28 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 29 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -1919,7 +1925,7 @@ i32.store offset=8 end ) - (func $~lib/internal/typedarray/TypedArray#__get (; 29 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__get (; 30 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -1956,7 +1962,7 @@ i32.load offset=8 end ) - (func $~lib/typedarray/Int32Array#subarray (; 30 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int32Array#subarray (; 31 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2066,7 +2072,7 @@ i32.store offset=8 local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__set (; 31 ;) (type $iiF_) (param $0 i32) (param $1 i32) (param $2 f64) + (func $~lib/internal/typedarray/TypedArray#__set (; 32 ;) (type $iiF_) (param $0 i32) (param $1 i32) (param $2 f64) (local $3 i32) (local $4 i32) (local $5 f64) @@ -2107,7 +2113,7 @@ f64.store offset=8 end ) - (func $~lib/typedarray/Float64Array#subarray (; 32 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Float64Array#subarray (; 33 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -2217,7 +2223,7 @@ i32.store offset=8 local.get $7 ) - (func $~lib/internal/sort/insertionSort (; 33 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/insertionSort (; 34 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -2283,7 +2289,7 @@ local.set $10 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $8 local.get $10 local.get $3 @@ -2358,10 +2364,10 @@ unreachable end ) - (func $~lib/allocator/arena/__memory_free (; 34 ;) (type $i_) (param $0 i32) + (func $~lib/allocator/arena/__memory_free (; 35 ;) (type $i_) (param $0 i32) nop ) - (func $~lib/internal/sort/weakHeapSort (; 35 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $~lib/internal/sort/weakHeapSort (; 36 ;) (type $iiii_) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -2390,7 +2396,7 @@ br $~lib/memory/memory.allocate|inlined.3 end local.set $6 - block $memory.fill|inlined.10 + block $~lib/memory/memory.fill|inlined.10 local.get $6 local.set $5 i32.const 0 @@ -2487,7 +2493,7 @@ local.set $13 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $12 local.get $13 local.get $3 @@ -2724,7 +2730,7 @@ local.set $12 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $13 local.get $12 local.get $3 @@ -2891,7 +2897,7 @@ f64.store offset=8 end ) - (func $~lib/typedarray/Float64Array#sort (; 36 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#sort (; 37 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2971,7 +2977,7 @@ local.set $11 block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc local.get $10 local.get $11 local.get $3 @@ -3051,7 +3057,7 @@ local.get $2 end ) - (func $~lib/internal/sort/COMPARATOR~anonymous|1 (; 37 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32) + (func $~lib/internal/sort/COMPARATOR~anonymous|1 (; 38 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32) (local $2 i64) (local $3 i64) local.get $0 @@ -3084,11 +3090,11 @@ i64.lt_s i32.sub ) - (func $~lib/typedarray/Float64Array#sort|trampoline (; 38 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#sort|trampoline (; 39 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange - global.get $~argc + global.get $~lib/argc br_table $0of1 $1of1 $outOfRange end unreachable @@ -3103,7 +3109,7 @@ local.get $1 call $~lib/typedarray/Float64Array#sort ) - (func $~lib/internal/typedarray/TypedArray#__get (; 39 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) + (func $~lib/internal/typedarray/TypedArray#__get (; 40 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3140,7 +3146,7 @@ f64.load offset=8 end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 40 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 41 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3181,7 +3187,7 @@ i32.store8 offset=8 end ) - (func $~lib/typedarray/Uint8ClampedArray#__set (; 41 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/typedarray/Uint8ClampedArray#__set (; 42 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) local.get $0 @@ -3203,7 +3209,7 @@ select call $~lib/internal/typedarray/TypedArray#__set ) - (func $~lib/internal/typedarray/TypedArray#__get (; 42 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__get (; 43 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3240,7 +3246,7 @@ i32.load8_u offset=8 end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 43 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 44 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3281,7 +3287,7 @@ i32.store8 offset=8 end ) - (func $~lib/typedarray/Int8Array#fill (; 44 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/typedarray/Int8Array#fill (; 45 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -3374,7 +3380,7 @@ i32.add local.get $9 i32.add - global.get $~lib/internal/arraybuffer/HEADER_SIZE + i32.const 8 i32.add local.set $11 local.get $5 @@ -3390,7 +3396,7 @@ end local.get $4 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 45 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__get (; 46 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3427,7 +3433,7 @@ i32.load8_s offset=8 end ) - (func $~lib/array/Array#__get (; 46 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3460,7 +3466,7 @@ unreachable end ) - (func $std/typedarray/isInt8ArrayEqual (; 47 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/typedarray/isInt8ArrayEqual (; 48 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) block $~lib/internal/typedarray/TypedArray#get:length|inlined.3 (result i32) @@ -3532,12 +3538,12 @@ end i32.const 1 ) - (func $~lib/typedarray/Int8Array#fill|trampoline (; 48 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/typedarray/Int8Array#fill|trampoline (; 49 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -3556,7 +3562,7 @@ local.get $3 call $~lib/typedarray/Int8Array#fill ) - (func $~lib/typedarray/Int8Array#subarray (; 49 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int8Array#subarray (; 50 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3666,7 +3672,7 @@ i32.store offset=8 local.get $7 ) - (func $~lib/typedarray/Int32Array#fill (; 50 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/typedarray/Int32Array#fill (; 51 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) (local $5 i32) (local $6 i32) @@ -3788,7 +3794,7 @@ end local.get $4 ) - (func $~lib/array/Array#__get (; 51 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/array/Array#__get (; 52 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3821,7 +3827,7 @@ unreachable end ) - (func $std/typedarray/isInt32ArrayEqual (; 52 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $std/typedarray/isInt32ArrayEqual (; 53 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) block $~lib/internal/typedarray/TypedArray#get:length|inlined.6 (result i32) @@ -3885,12 +3891,12 @@ end i32.const 1 ) - (func $~lib/typedarray/Int32Array#fill|trampoline (; 53 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $~lib/typedarray/Int32Array#fill|trampoline (; 54 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) block $2of2 block $1of2 block $0of2 block $outOfRange - global.get $~argc + global.get $~lib/argc i32.const 1 i32.sub br_table $0of2 $1of2 $2of2 $outOfRange @@ -3909,12 +3915,12 @@ local.get $3 call $~lib/typedarray/Int32Array#fill ) - (func $std/typedarray/testReduce~anonymous|2 (; 54 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|2 (; 55 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Int8Array#reduce (; 55 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int8Array#reduce (; 56 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -3957,7 +3963,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i32) local.get $7 @@ -3992,7 +3998,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 56 ;) (type $_) + (func $std/typedarray/testReduce (; 57 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4033,12 +4039,12 @@ unreachable end ) - (func $std/typedarray/testReduce~anonymous|3 (; 57 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|3 (; 58 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Uint8Array#reduce (; 58 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Uint8Array#reduce (; 59 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4081,7 +4087,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result i32) local.get $7 @@ -4116,7 +4122,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 59 ;) (type $_) + (func $std/typedarray/testReduce (; 60 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4155,12 +4161,12 @@ unreachable end ) - (func $std/typedarray/testReduce~anonymous|4 (; 60 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|4 (; 61 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $std/typedarray/testReduce (; 61 ;) (type $_) + (func $std/typedarray/testReduce (; 62 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4199,7 +4205,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 62 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 63 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4240,12 +4246,12 @@ i32.store16 offset=8 end ) - (func $std/typedarray/testReduce~anonymous|5 (; 63 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|5 (; 64 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Int16Array#reduce (; 64 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int16Array#reduce (; 65 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4288,7 +4294,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.0 (result i32) local.get $7 @@ -4323,7 +4329,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 65 ;) (type $_) + (func $std/typedarray/testReduce (; 66 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4364,7 +4370,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 66 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 67 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4405,12 +4411,12 @@ i32.store16 offset=8 end ) - (func $std/typedarray/testReduce~anonymous|6 (; 67 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|6 (; 68 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Uint16Array#reduce (; 68 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Uint16Array#reduce (; 69 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4453,7 +4459,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.0 (result i32) local.get $7 @@ -4488,7 +4494,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 69 ;) (type $_) + (func $std/typedarray/testReduce (; 70 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4527,12 +4533,12 @@ unreachable end ) - (func $std/typedarray/testReduce~anonymous|7 (; 70 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|7 (; 71 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Int32Array#reduce (; 71 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int32Array#reduce (; 72 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4575,7 +4581,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i32) local.get $7 @@ -4610,7 +4616,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 72 ;) (type $_) + (func $std/typedarray/testReduce (; 73 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4647,7 +4653,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 73 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) + (func $~lib/internal/typedarray/TypedArray#__set (; 74 ;) (type $iii_) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4688,12 +4694,12 @@ i32.store offset=8 end ) - (func $std/typedarray/testReduce~anonymous|8 (; 74 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduce~anonymous|8 (; 75 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Uint32Array#reduce (; 75 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Uint32Array#reduce (; 76 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -4736,7 +4742,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.0 (result i32) local.get $7 @@ -4771,7 +4777,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 76 ;) (type $_) + (func $std/typedarray/testReduce (; 77 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -4808,7 +4814,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 77 ;) (type $iiI_) (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/internal/typedarray/TypedArray#__set (; 78 ;) (type $iiI_) (param $0 i32) (param $1 i32) (param $2 i64) (local $3 i32) (local $4 i32) (local $5 i64) @@ -4849,12 +4855,12 @@ i64.store offset=8 end ) - (func $std/typedarray/testReduce~anonymous|9 (; 78 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) + (func $std/typedarray/testReduce~anonymous|9 (; 79 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) local.get $0 local.get $1 i64.add ) - (func $~lib/typedarray/Int64Array#reduce (; 79 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) + (func $~lib/typedarray/Int64Array#reduce (; 80 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) (local $3 i32) (local $4 i32) (local $5 i64) @@ -4897,7 +4903,7 @@ br_if $break|0 block (result i64) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.0 (result i64) local.get $7 @@ -4932,7 +4938,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 80 ;) (type $_) + (func $std/typedarray/testReduce (; 81 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -4969,7 +4975,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 81 ;) (type $iiI_) (param $0 i32) (param $1 i32) (param $2 i64) + (func $~lib/internal/typedarray/TypedArray#__set (; 82 ;) (type $iiI_) (param $0 i32) (param $1 i32) (param $2 i64) (local $3 i32) (local $4 i32) (local $5 i64) @@ -5010,12 +5016,12 @@ i64.store offset=8 end ) - (func $std/typedarray/testReduce~anonymous|10 (; 82 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) + (func $std/typedarray/testReduce~anonymous|10 (; 83 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) local.get $0 local.get $1 i64.add ) - (func $~lib/typedarray/Uint64Array#reduce (; 83 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) + (func $~lib/typedarray/Uint64Array#reduce (; 84 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) (local $3 i32) (local $4 i32) (local $5 i64) @@ -5058,7 +5064,7 @@ br_if $break|0 block (result i64) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.0 (result i64) local.get $7 @@ -5093,7 +5099,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 84 ;) (type $_) + (func $std/typedarray/testReduce (; 85 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -5130,7 +5136,7 @@ unreachable end ) - (func $~lib/internal/typedarray/TypedArray#__set (; 85 ;) (type $iif_) (param $0 i32) (param $1 i32) (param $2 f32) + (func $~lib/internal/typedarray/TypedArray#__set (; 86 ;) (type $iif_) (param $0 i32) (param $1 i32) (param $2 f32) (local $3 i32) (local $4 i32) (local $5 f32) @@ -5171,12 +5177,12 @@ f32.store offset=8 end ) - (func $std/typedarray/testReduce~anonymous|11 (; 86 ;) (type $ffiif) (param $0 f32) (param $1 f32) (param $2 i32) (param $3 i32) (result f32) + (func $std/typedarray/testReduce~anonymous|11 (; 87 ;) (type $ffiif) (param $0 f32) (param $1 f32) (param $2 i32) (param $3 i32) (result f32) local.get $0 local.get $1 f32.add ) - (func $~lib/typedarray/Float32Array#reduce (; 87 ;) (type $iiff) (param $0 i32) (param $1 i32) (param $2 f32) (result f32) + (func $~lib/typedarray/Float32Array#reduce (; 88 ;) (type $iiff) (param $0 i32) (param $1 i32) (param $2 f32) (result f32) (local $3 i32) (local $4 i32) (local $5 f32) @@ -5219,7 +5225,7 @@ br_if $break|0 block (result f32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.0 (result f32) local.get $7 @@ -5254,7 +5260,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 88 ;) (type $_) + (func $std/typedarray/testReduce (; 89 ;) (type $_) (local $0 i32) (local $1 f32) i32.const 0 @@ -5291,12 +5297,12 @@ unreachable end ) - (func $std/typedarray/testReduce~anonymous|12 (; 89 ;) (type $FFiiF) (param $0 f64) (param $1 f64) (param $2 i32) (param $3 i32) (result f64) + (func $std/typedarray/testReduce~anonymous|12 (; 90 ;) (type $FFiiF) (param $0 f64) (param $1 f64) (param $2 i32) (param $3 i32) (result f64) local.get $0 local.get $1 f64.add ) - (func $~lib/typedarray/Float64Array#reduce (; 90 ;) (type $iiFF) (param $0 i32) (param $1 i32) (param $2 f64) (result f64) + (func $~lib/typedarray/Float64Array#reduce (; 91 ;) (type $iiFF) (param $0 i32) (param $1 i32) (param $2 f64) (result f64) (local $3 i32) (local $4 i32) (local $5 f64) @@ -5339,7 +5345,7 @@ br_if $break|0 block (result f64) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.13 (result f64) local.get $7 @@ -5374,7 +5380,7 @@ end local.get $5 ) - (func $std/typedarray/testReduce (; 91 ;) (type $_) + (func $std/typedarray/testReduce (; 92 ;) (type $_) (local $0 i32) (local $1 f64) i32.const 0 @@ -5411,12 +5417,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|13 (; 92 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|13 (; 93 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Int8Array#reduceRight (; 93 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int8Array#reduceRight (; 94 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5458,7 +5464,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.3 (result i32) local.get $6 @@ -5493,7 +5499,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 94 ;) (type $_) + (func $std/typedarray/testReduceRight (; 95 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -5534,12 +5540,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|14 (; 95 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|14 (; 96 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Uint8Array#reduceRight (; 96 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Uint8Array#reduceRight (; 97 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5581,7 +5587,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i32) local.get $6 @@ -5616,7 +5622,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 97 ;) (type $_) + (func $std/typedarray/testReduceRight (; 98 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -5655,12 +5661,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|15 (; 98 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|15 (; 99 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $std/typedarray/testReduceRight (; 99 ;) (type $_) + (func $std/typedarray/testReduceRight (; 100 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -5699,12 +5705,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|16 (; 100 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|16 (; 101 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Int16Array#reduceRight (; 101 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int16Array#reduceRight (; 102 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5746,7 +5752,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result i32) local.get $6 @@ -5781,7 +5787,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 102 ;) (type $_) + (func $std/typedarray/testReduceRight (; 103 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -5822,12 +5828,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|17 (; 103 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|17 (; 104 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Uint16Array#reduceRight (; 104 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Uint16Array#reduceRight (; 105 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5869,7 +5875,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result i32) local.get $6 @@ -5904,7 +5910,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 105 ;) (type $_) + (func $std/typedarray/testReduceRight (; 106 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -5943,12 +5949,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|18 (; 106 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|18 (; 107 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Int32Array#reduceRight (; 107 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Int32Array#reduceRight (; 108 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -5990,7 +5996,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.3 (result i32) local.get $6 @@ -6025,7 +6031,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 108 ;) (type $_) + (func $std/typedarray/testReduceRight (; 109 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -6062,12 +6068,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|19 (; 109 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $std/typedarray/testReduceRight~anonymous|19 (; 110 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) local.get $0 local.get $1 i32.add ) - (func $~lib/typedarray/Uint32Array#reduceRight (; 110 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $~lib/typedarray/Uint32Array#reduceRight (; 111 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (local $5 i32) @@ -6109,7 +6115,7 @@ br_if $break|0 block (result i32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result i32) local.get $6 @@ -6144,7 +6150,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 111 ;) (type $_) + (func $std/typedarray/testReduceRight (; 112 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -6181,12 +6187,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|20 (; 112 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) + (func $std/typedarray/testReduceRight~anonymous|20 (; 113 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) local.get $0 local.get $1 i64.add ) - (func $~lib/typedarray/Int64Array#reduceRight (; 113 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) + (func $~lib/typedarray/Int64Array#reduceRight (; 114 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) (local $3 i32) (local $4 i32) (local $5 i64) @@ -6228,7 +6234,7 @@ br_if $break|0 block (result i64) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result i64) local.get $6 @@ -6263,7 +6269,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 114 ;) (type $_) + (func $std/typedarray/testReduceRight (; 115 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -6300,12 +6306,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|21 (; 115 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) + (func $std/typedarray/testReduceRight~anonymous|21 (; 116 ;) (type $IIiiI) (param $0 i64) (param $1 i64) (param $2 i32) (param $3 i32) (result i64) local.get $0 local.get $1 i64.add ) - (func $~lib/typedarray/Uint64Array#reduceRight (; 116 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) + (func $~lib/typedarray/Uint64Array#reduceRight (; 117 ;) (type $iiII) (param $0 i32) (param $1 i32) (param $2 i64) (result i64) (local $3 i32) (local $4 i32) (local $5 i64) @@ -6347,7 +6353,7 @@ br_if $break|0 block (result i64) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result i64) local.get $6 @@ -6382,7 +6388,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 117 ;) (type $_) + (func $std/typedarray/testReduceRight (; 118 ;) (type $_) (local $0 i32) (local $1 i64) i32.const 0 @@ -6419,12 +6425,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|22 (; 118 ;) (type $ffiif) (param $0 f32) (param $1 f32) (param $2 i32) (param $3 i32) (result f32) + (func $std/typedarray/testReduceRight~anonymous|22 (; 119 ;) (type $ffiif) (param $0 f32) (param $1 f32) (param $2 i32) (param $3 i32) (result f32) local.get $0 local.get $1 f32.add ) - (func $~lib/typedarray/Float32Array#reduceRight (; 119 ;) (type $iiff) (param $0 i32) (param $1 i32) (param $2 f32) (result f32) + (func $~lib/typedarray/Float32Array#reduceRight (; 120 ;) (type $iiff) (param $0 i32) (param $1 i32) (param $2 f32) (result f32) (local $3 i32) (local $4 i32) (local $5 f32) @@ -6466,7 +6472,7 @@ br_if $break|0 block (result f32) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.1 (result f32) local.get $6 @@ -6501,7 +6507,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 120 ;) (type $_) + (func $std/typedarray/testReduceRight (; 121 ;) (type $_) (local $0 i32) (local $1 f32) i32.const 0 @@ -6538,12 +6544,12 @@ unreachable end ) - (func $std/typedarray/testReduceRight~anonymous|23 (; 121 ;) (type $FFiiF) (param $0 f64) (param $1 f64) (param $2 i32) (param $3 i32) (result f64) + (func $std/typedarray/testReduceRight~anonymous|23 (; 122 ;) (type $FFiiF) (param $0 f64) (param $1 f64) (param $2 i32) (param $3 i32) (result f64) local.get $0 local.get $1 f64.add ) - (func $~lib/typedarray/Float64Array#reduceRight (; 122 ;) (type $iiFF) (param $0 i32) (param $1 i32) (param $2 f64) (result f64) + (func $~lib/typedarray/Float64Array#reduceRight (; 123 ;) (type $iiFF) (param $0 i32) (param $1 i32) (param $2 f64) (result f64) (local $3 i32) (local $4 i32) (local $5 f64) @@ -6585,7 +6591,7 @@ br_if $break|0 block (result f64) i32.const 4 - global.set $~argc + global.set $~lib/argc local.get $5 block $~lib/internal/arraybuffer/LOAD|inlined.14 (result f64) local.get $6 @@ -6620,7 +6626,7 @@ end local.get $5 ) - (func $std/typedarray/testReduceRight (; 123 ;) (type $_) + (func $std/typedarray/testReduceRight (; 124 ;) (type $_) (local $0 i32) (local $1 f64) i32.const 0 @@ -6657,12 +6663,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|24 (; 124 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|24 (; 125 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Int8Array#map (; 125 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int8Array#map (; 126 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6718,7 +6724,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.4 (result i32) local.get $5 local.set $12 @@ -6768,7 +6774,7 @@ end local.get $7 ) - (func $std/typedarray/testArrayMap (; 126 ;) (type $_) + (func $std/typedarray/testArrayMap (; 127 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -6846,12 +6852,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|25 (; 127 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|25 (; 128 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Uint8Array#map (; 128 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#map (; 129 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -6907,7 +6913,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.3 (result i32) local.get $5 local.set $12 @@ -6955,7 +6961,7 @@ end local.get $7 ) - (func $std/typedarray/testArrayMap (; 129 ;) (type $_) + (func $std/typedarray/testArrayMap (; 130 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -7027,12 +7033,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|26 (; 130 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|26 (; 131 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Uint8ClampedArray#map (; 131 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8ClampedArray#map (; 132 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7088,7 +7094,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.4 (result i32) local.get $5 local.set $12 @@ -7136,7 +7142,7 @@ end local.get $7 ) - (func $std/typedarray/testArrayMap (; 132 ;) (type $_) + (func $std/typedarray/testArrayMap (; 133 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -7208,12 +7214,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|27 (; 133 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|27 (; 134 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Int16Array#map (; 134 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int16Array#map (; 135 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7269,7 +7275,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i32) local.get $5 local.set $12 @@ -7319,7 +7325,7 @@ end local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 135 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__get (; 136 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7356,7 +7362,7 @@ i32.load16_s offset=8 end ) - (func $std/typedarray/testArrayMap (; 136 ;) (type $_) + (func $std/typedarray/testArrayMap (; 137 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -7434,12 +7440,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|28 (; 137 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|28 (; 138 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Uint16Array#map (; 138 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint16Array#map (; 139 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7495,7 +7501,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i32) local.get $5 local.set $12 @@ -7543,7 +7549,7 @@ end local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 139 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__get (; 140 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7580,7 +7586,7 @@ i32.load16_u offset=8 end ) - (func $std/typedarray/testArrayMap (; 140 ;) (type $_) + (func $std/typedarray/testArrayMap (; 141 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -7652,12 +7658,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|29 (; 141 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|29 (; 142 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Int32Array#map (; 142 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int32Array#map (; 143 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7713,7 +7719,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.4 (result i32) local.get $5 local.set $12 @@ -7759,7 +7765,7 @@ end local.get $7 ) - (func $std/typedarray/testArrayMap (; 143 ;) (type $_) + (func $std/typedarray/testArrayMap (; 144 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -7825,12 +7831,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|30 (; 144 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayMap~anonymous|30 (; 145 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 local.get $0 i32.mul ) - (func $~lib/typedarray/Uint32Array#map (; 145 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint32Array#map (; 146 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7886,7 +7892,7 @@ local.set $11 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i32) local.get $5 local.set $12 @@ -7932,7 +7938,7 @@ end local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 146 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/internal/typedarray/TypedArray#__get (; 147 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -7969,7 +7975,7 @@ i32.load offset=8 end ) - (func $std/typedarray/testArrayMap (; 147 ;) (type $_) + (func $std/typedarray/testArrayMap (; 148 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -8035,12 +8041,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|31 (; 148 ;) (type $IiiI) (param $0 i64) (param $1 i32) (param $2 i32) (result i64) + (func $std/typedarray/testArrayMap~anonymous|31 (; 149 ;) (type $IiiI) (param $0 i64) (param $1 i32) (param $2 i32) (result i64) local.get $0 local.get $0 i64.mul ) - (func $~lib/typedarray/Int64Array#map (; 149 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int64Array#map (; 150 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8097,7 +8103,7 @@ local.set $11 block (result i64) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i64) local.get $5 local.set $12 @@ -8143,7 +8149,7 @@ end local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 150 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64) + (func $~lib/internal/typedarray/TypedArray#__get (; 151 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8180,7 +8186,7 @@ i64.load offset=8 end ) - (func $std/typedarray/testArrayMap (; 151 ;) (type $_) + (func $std/typedarray/testArrayMap (; 152 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -8246,12 +8252,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|32 (; 152 ;) (type $IiiI) (param $0 i64) (param $1 i32) (param $2 i32) (result i64) + (func $std/typedarray/testArrayMap~anonymous|32 (; 153 ;) (type $IiiI) (param $0 i64) (param $1 i32) (param $2 i32) (result i64) local.get $0 local.get $0 i64.mul ) - (func $~lib/typedarray/Uint64Array#map (; 153 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint64Array#map (; 154 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8308,7 +8314,7 @@ local.set $11 block (result i64) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.2 (result i64) local.get $5 local.set $12 @@ -8354,7 +8360,7 @@ end local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 154 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64) + (func $~lib/internal/typedarray/TypedArray#__get (; 155 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8391,7 +8397,7 @@ i64.load offset=8 end ) - (func $std/typedarray/testArrayMap (; 155 ;) (type $_) + (func $std/typedarray/testArrayMap (; 156 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -8457,12 +8463,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|33 (; 156 ;) (type $fiif) (param $0 f32) (param $1 i32) (param $2 i32) (result f32) + (func $std/typedarray/testArrayMap~anonymous|33 (; 157 ;) (type $fiif) (param $0 f32) (param $1 i32) (param $2 i32) (result f32) local.get $0 local.get $0 f32.mul ) - (func $~lib/typedarray/Float32Array#map (; 157 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float32Array#map (; 158 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8519,7 +8525,7 @@ local.set $11 block (result f32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.2 (result f32) local.get $5 local.set $12 @@ -8565,7 +8571,7 @@ end local.get $7 ) - (func $~lib/internal/typedarray/TypedArray#__get (; 158 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) + (func $~lib/internal/typedarray/TypedArray#__get (; 159 ;) (type $iif) (param $0 i32) (param $1 i32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8602,7 +8608,7 @@ f32.load offset=8 end ) - (func $std/typedarray/testArrayMap (; 159 ;) (type $_) + (func $std/typedarray/testArrayMap (; 160 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -8668,12 +8674,12 @@ unreachable end ) - (func $std/typedarray/testArrayMap~anonymous|34 (; 160 ;) (type $FiiF) (param $0 f64) (param $1 i32) (param $2 i32) (result f64) + (func $std/typedarray/testArrayMap~anonymous|34 (; 161 ;) (type $FiiF) (param $0 f64) (param $1 i32) (param $2 i32) (result f64) local.get $0 local.get $0 f64.mul ) - (func $~lib/typedarray/Float64Array#map (; 161 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#map (; 162 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8730,7 +8736,7 @@ local.set $11 block (result f64) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.15 (result f64) local.get $5 local.set $12 @@ -8776,7 +8782,7 @@ end local.get $7 ) - (func $std/typedarray/testArrayMap (; 162 ;) (type $_) + (func $std/typedarray/testArrayMap (; 163 ;) (type $_) (local $0 i32) (local $1 i32) i32.const 0 @@ -8842,7 +8848,7 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|35 (; 163 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|35 (; 164 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -8851,7 +8857,7 @@ i32.const 2 i32.eq ) - (func $~lib/typedarray/Int8Array#some (; 164 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int8Array#some (; 165 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -8892,7 +8898,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.6 (result i32) local.get $5 local.set $10 @@ -8932,7 +8938,7 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|36 (; 165 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|36 (; 166 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -8941,7 +8947,7 @@ i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 166 ;) (type $_) + (func $std/typedarray/testArraySome (; 167 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -8995,14 +9001,14 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|37 (; 167 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|37 (; 168 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint8Array#some (; 168 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#some (; 169 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9043,7 +9049,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.6 (result i32) local.get $5 local.set $10 @@ -9083,14 +9089,14 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|38 (; 169 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|38 (; 170 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 170 ;) (type $_) + (func $std/typedarray/testArraySome (; 171 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -9144,14 +9150,14 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|39 (; 171 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|39 (; 172 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint8ClampedArray#some (; 172 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8ClampedArray#some (; 173 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9192,7 +9198,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.8 (result i32) local.get $5 local.set $10 @@ -9232,14 +9238,14 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|40 (; 173 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|40 (; 174 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 174 ;) (type $_) + (func $std/typedarray/testArraySome (; 175 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -9293,7 +9299,7 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|41 (; 175 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|41 (; 176 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -9302,7 +9308,7 @@ i32.const 2 i32.eq ) - (func $~lib/typedarray/Int16Array#some (; 176 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int16Array#some (; 177 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9343,7 +9349,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.5 (result i32) local.get $5 local.set $10 @@ -9383,7 +9389,7 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|42 (; 177 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|42 (; 178 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -9392,7 +9398,7 @@ i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 178 ;) (type $_) + (func $std/typedarray/testArraySome (; 179 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -9446,14 +9452,14 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|43 (; 179 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|43 (; 180 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 65535 i32.and i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint16Array#some (; 180 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint16Array#some (; 181 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9494,7 +9500,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.5 (result i32) local.get $5 local.set $10 @@ -9534,14 +9540,14 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|44 (; 181 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|44 (; 182 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 65535 i32.and i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 182 ;) (type $_) + (func $std/typedarray/testArraySome (; 183 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -9595,12 +9601,12 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|45 (; 183 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|45 (; 184 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.eq ) - (func $~lib/typedarray/Int32Array#some (; 184 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int32Array#some (; 185 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9641,7 +9647,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.6 (result i32) local.get $5 local.set $10 @@ -9681,12 +9687,12 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|46 (; 185 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|46 (; 186 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 186 ;) (type $_) + (func $std/typedarray/testArraySome (; 187 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -9740,12 +9746,12 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|47 (; 187 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|47 (; 188 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint32Array#some (; 188 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint32Array#some (; 189 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9786,7 +9792,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.5 (result i32) local.get $5 local.set $10 @@ -9826,12 +9832,12 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|48 (; 189 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|48 (; 190 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 0 i32.eq ) - (func $std/typedarray/testArraySome (; 190 ;) (type $_) + (func $std/typedarray/testArraySome (; 191 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -9885,12 +9891,12 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|49 (; 191 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|49 (; 192 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.eq ) - (func $~lib/typedarray/Int64Array#some (; 192 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int64Array#some (; 193 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -9931,7 +9937,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.5 (result i64) local.get $5 local.set $10 @@ -9971,12 +9977,12 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|50 (; 193 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|50 (; 194 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 0 i64.eq ) - (func $std/typedarray/testArraySome (; 194 ;) (type $_) + (func $std/typedarray/testArraySome (; 195 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10030,12 +10036,12 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|51 (; 195 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|51 (; 196 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.eq ) - (func $~lib/typedarray/Uint64Array#some (; 196 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint64Array#some (; 197 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10076,7 +10082,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.5 (result i64) local.get $5 local.set $10 @@ -10116,12 +10122,12 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|52 (; 197 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|52 (; 198 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 0 i64.eq ) - (func $std/typedarray/testArraySome (; 198 ;) (type $_) + (func $std/typedarray/testArraySome (; 199 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10175,12 +10181,12 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|53 (; 199 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|53 (; 200 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) local.get $0 f32.const 2 f32.eq ) - (func $~lib/typedarray/Float32Array#some (; 200 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float32Array#some (; 201 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10221,7 +10227,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.5 (result f32) local.get $5 local.set $10 @@ -10261,12 +10267,12 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|54 (; 201 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|54 (; 202 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) local.get $0 f32.const 0 f32.eq ) - (func $std/typedarray/testArraySome (; 202 ;) (type $_) + (func $std/typedarray/testArraySome (; 203 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10320,12 +10326,12 @@ unreachable end ) - (func $std/typedarray/testArraySome~anonymous|55 (; 203 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|55 (; 204 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) local.get $0 f64.const 2 f64.eq ) - (func $~lib/typedarray/Float64Array#some (; 204 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#some (; 205 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10366,7 +10372,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.17 (result f64) local.get $5 local.set $10 @@ -10406,12 +10412,12 @@ i32.const 0 end ) - (func $std/typedarray/testArraySome~anonymous|56 (; 205 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArraySome~anonymous|56 (; 206 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) local.get $0 f64.const 0 f64.eq ) - (func $std/typedarray/testArraySome (; 206 ;) (type $_) + (func $std/typedarray/testArraySome (; 207 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10465,7 +10471,7 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|57 (; 207 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|57 (; 208 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -10474,7 +10480,7 @@ i32.const 2 i32.eq ) - (func $~lib/typedarray/Int8Array#findIndex (; 208 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int8Array#findIndex (; 209 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10515,7 +10521,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.8 (result i32) local.get $5 local.set $10 @@ -10555,7 +10561,7 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|58 (; 209 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|58 (; 210 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -10564,7 +10570,7 @@ i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 210 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 211 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10617,14 +10623,14 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|59 (; 211 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|59 (; 212 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint8Array#findIndex (; 212 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#findIndex (; 213 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10665,7 +10671,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.10 (result i32) local.get $5 local.set $10 @@ -10705,14 +10711,14 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|60 (; 213 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|60 (; 214 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 214 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 215 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10765,14 +10771,14 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|61 (; 215 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|61 (; 216 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint8ClampedArray#findIndex (; 216 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8ClampedArray#findIndex (; 217 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10813,7 +10819,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.12 (result i32) local.get $5 local.set $10 @@ -10853,14 +10859,14 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|62 (; 217 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|62 (; 218 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 218 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 219 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -10913,7 +10919,7 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|63 (; 219 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|63 (; 220 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -10922,7 +10928,7 @@ i32.const 2 i32.eq ) - (func $~lib/typedarray/Int16Array#findIndex (; 220 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int16Array#findIndex (; 221 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -10963,7 +10969,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.7 (result i32) local.get $5 local.set $10 @@ -11003,7 +11009,7 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|64 (; 221 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|64 (; 222 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -11012,7 +11018,7 @@ i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 222 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 223 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11065,14 +11071,14 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|65 (; 223 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|65 (; 224 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 65535 i32.and i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint16Array#findIndex (; 224 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint16Array#findIndex (; 225 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11113,7 +11119,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.7 (result i32) local.get $5 local.set $10 @@ -11153,14 +11159,14 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|66 (; 225 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|66 (; 226 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 65535 i32.and i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 226 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 227 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11213,12 +11219,12 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|67 (; 227 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|67 (; 228 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.eq ) - (func $~lib/typedarray/Int32Array#findIndex (; 228 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int32Array#findIndex (; 229 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11259,7 +11265,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.8 (result i32) local.get $5 local.set $10 @@ -11299,12 +11305,12 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|68 (; 229 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|68 (; 230 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 230 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 231 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11357,12 +11363,12 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|69 (; 231 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|69 (; 232 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.eq ) - (func $~lib/typedarray/Uint32Array#findIndex (; 232 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint32Array#findIndex (; 233 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11403,7 +11409,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.7 (result i32) local.get $5 local.set $10 @@ -11443,12 +11449,12 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|70 (; 233 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|70 (; 234 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 4 i32.eq ) - (func $std/typedarray/testArrayFindIndex (; 234 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 235 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11501,12 +11507,12 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|71 (; 235 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|71 (; 236 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.eq ) - (func $~lib/typedarray/Int64Array#findIndex (; 236 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int64Array#findIndex (; 237 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11547,7 +11553,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.7 (result i64) local.get $5 local.set $10 @@ -11587,12 +11593,12 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|72 (; 237 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|72 (; 238 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 4 i64.eq ) - (func $std/typedarray/testArrayFindIndex (; 238 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 239 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11645,12 +11651,12 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|73 (; 239 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|73 (; 240 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.eq ) - (func $~lib/typedarray/Uint64Array#findIndex (; 240 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint64Array#findIndex (; 241 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11691,7 +11697,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.7 (result i64) local.get $5 local.set $10 @@ -11731,12 +11737,12 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|74 (; 241 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|74 (; 242 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 4 i64.eq ) - (func $std/typedarray/testArrayFindIndex (; 242 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 243 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11789,12 +11795,12 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|75 (; 243 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|75 (; 244 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) local.get $0 f32.const 2 f32.eq ) - (func $~lib/typedarray/Float32Array#findIndex (; 244 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float32Array#findIndex (; 245 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11835,7 +11841,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.7 (result f32) local.get $5 local.set $10 @@ -11875,12 +11881,12 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|76 (; 245 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|76 (; 246 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) local.get $0 f32.const 4 f32.eq ) - (func $std/typedarray/testArrayFindIndex (; 246 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 247 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -11933,12 +11939,12 @@ unreachable end ) - (func $std/typedarray/testArrayFindIndex~anonymous|77 (; 247 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|77 (; 248 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) local.get $0 f64.const 2 f64.eq ) - (func $~lib/typedarray/Float64Array#findIndex (; 248 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#findIndex (; 249 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -11979,7 +11985,7 @@ br_if $break|0 block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.19 (result f64) local.get $5 local.set $10 @@ -12019,12 +12025,12 @@ i32.const -1 end ) - (func $std/typedarray/testArrayFindIndex~anonymous|78 (; 249 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayFindIndex~anonymous|78 (; 250 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) local.get $0 f64.const 4 f64.eq ) - (func $std/typedarray/testArrayFindIndex (; 250 ;) (type $_) + (func $std/typedarray/testArrayFindIndex (; 251 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -12077,7 +12083,7 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|79 (; 251 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|79 (; 252 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -12088,7 +12094,7 @@ i32.const 0 i32.eq ) - (func $~lib/typedarray/Int8Array#every (; 252 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int8Array#every (; 253 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12131,7 +12137,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.10 (result i32) local.get $5 local.set $10 @@ -12176,7 +12182,7 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|80 (; 253 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|80 (; 254 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 24 i32.shl @@ -12185,7 +12191,7 @@ i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 254 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 255 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -12239,7 +12245,7 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|81 (; 255 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|81 (; 256 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and @@ -12248,7 +12254,7 @@ i32.const 0 i32.eq ) - (func $~lib/typedarray/Uint8Array#every (; 256 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8Array#every (; 257 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12291,7 +12297,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.14 (result i32) local.get $5 local.set $10 @@ -12336,14 +12342,14 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|82 (; 257 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|82 (; 258 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 258 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 259 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -12397,7 +12403,7 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|83 (; 259 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|83 (; 260 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and @@ -12406,7 +12412,7 @@ i32.const 0 i32.eq ) - (func $~lib/typedarray/Uint8ClampedArray#every (; 260 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint8ClampedArray#every (; 261 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12449,7 +12455,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.16 (result i32) local.get $5 local.set $10 @@ -12494,14 +12500,14 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|84 (; 261 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|84 (; 262 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 255 i32.and i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 262 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 263 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -12555,7 +12561,7 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|85 (; 263 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|85 (; 264 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -12566,7 +12572,7 @@ i32.const 0 i32.eq ) - (func $~lib/typedarray/Int16Array#every (; 264 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int16Array#every (; 265 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12609,7 +12615,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i32) local.get $5 local.set $10 @@ -12654,7 +12660,7 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|86 (; 265 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|86 (; 266 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -12663,7 +12669,7 @@ i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 266 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 267 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -12717,7 +12723,7 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|87 (; 267 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|87 (; 268 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 65535 i32.and @@ -12726,7 +12732,7 @@ i32.const 0 i32.eq ) - (func $~lib/typedarray/Uint16Array#every (; 268 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint16Array#every (; 269 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12769,7 +12775,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i32) local.get $5 local.set $10 @@ -12814,14 +12820,14 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|88 (; 269 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|88 (; 270 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 65535 i32.and i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 270 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 271 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -12875,14 +12881,14 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|89 (; 271 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|89 (; 272 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.rem_s i32.const 0 i32.eq ) - (func $~lib/typedarray/Int32Array#every (; 272 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int32Array#every (; 273 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -12925,7 +12931,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.10 (result i32) local.get $5 local.set $10 @@ -12970,12 +12976,12 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|90 (; 273 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|90 (; 274 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 274 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 275 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -13029,14 +13035,14 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|91 (; 275 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|91 (; 276 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.rem_u i32.const 0 i32.eq ) - (func $~lib/typedarray/Uint32Array#every (; 276 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint32Array#every (; 277 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -13079,7 +13085,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i32) local.get $5 local.set $10 @@ -13124,12 +13130,12 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|92 (; 277 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|92 (; 278 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) local.get $0 i32.const 2 i32.eq ) - (func $std/typedarray/testArrayEvery (; 278 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 279 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -13183,14 +13189,14 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|93 (; 279 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|93 (; 280 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.rem_s i64.const 0 i64.eq ) - (func $~lib/typedarray/Int64Array#every (; 280 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Int64Array#every (; 281 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -13233,7 +13239,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i64) local.get $5 local.set $10 @@ -13278,12 +13284,12 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|94 (; 281 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|94 (; 282 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.eq ) - (func $std/typedarray/testArrayEvery (; 282 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 283 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -13337,14 +13343,14 @@ unreachable end ) - (func $std/typedarray/testArrayEvery~anonymous|95 (; 283 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|95 (; 284 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.rem_u i64.const 0 i64.eq ) - (func $~lib/typedarray/Uint64Array#every (; 284 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Uint64Array#every (; 285 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -13387,7 +13393,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result i64) local.get $5 local.set $10 @@ -13432,12 +13438,12 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|96 (; 285 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|96 (; 286 ;) (type $Iiii) (param $0 i64) (param $1 i32) (param $2 i32) (result i32) local.get $0 i64.const 2 i64.eq ) - (func $std/typedarray/testArrayEvery (; 286 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 287 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -13491,7 +13497,7 @@ unreachable end ) - (func $~lib/math/NativeMathf.mod (; 287 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32) + (func $~lib/math/NativeMathf.mod (; 288 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -13747,14 +13753,14 @@ local.get $2 f32.reinterpret_i32 ) - (func $std/typedarray/testArrayEvery~anonymous|97 (; 288 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|97 (; 289 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) local.get $0 f32.const 2 call $~lib/math/NativeMathf.mod f32.const 0 f32.eq ) - (func $~lib/typedarray/Float32Array#every (; 289 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float32Array#every (; 290 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -13797,7 +13803,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.9 (result f32) local.get $5 local.set $10 @@ -13842,12 +13848,12 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|98 (; 290 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|98 (; 291 ;) (type $fiii) (param $0 f32) (param $1 i32) (param $2 i32) (result i32) local.get $0 f32.const 2 f32.eq ) - (func $std/typedarray/testArrayEvery (; 291 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 292 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -13901,7 +13907,7 @@ unreachable end ) - (func $~lib/math/NativeMath.mod (; 292 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64) + (func $~lib/math/NativeMath.mod (; 293 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64) (local $2 i64) (local $3 i64) (local $4 i64) @@ -14159,14 +14165,14 @@ local.get $2 f64.reinterpret_i64 ) - (func $std/typedarray/testArrayEvery~anonymous|99 (; 293 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|99 (; 294 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) local.get $0 f64.const 2 call $~lib/math/NativeMath.mod f64.const 0 f64.eq ) - (func $~lib/typedarray/Float64Array#every (; 294 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/typedarray/Float64Array#every (; 295 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -14209,7 +14215,7 @@ block block (result i32) i32.const 3 - global.set $~argc + global.set $~lib/argc block $~lib/internal/arraybuffer/LOAD|inlined.21 (result f64) local.get $5 local.set $10 @@ -14254,12 +14260,12 @@ i32.const 1 end ) - (func $std/typedarray/testArrayEvery~anonymous|100 (; 295 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) + (func $std/typedarray/testArrayEvery~anonymous|100 (; 296 ;) (type $Fiii) (param $0 f64) (param $1 i32) (param $2 i32) (result i32) local.get $0 f64.const 2 f64.eq ) - (func $std/typedarray/testArrayEvery (; 296 ;) (type $_) + (func $std/typedarray/testArrayEvery (; 297 ;) (type $_) (local $0 i32) (local $1 i32) (local $2 i32) @@ -14313,7 +14319,7 @@ unreachable end ) - (func $start (; 297 ;) (type $_) + (func $start:std/typedarray (; 298 ;) (type $_) (local $0 i32) global.get $~lib/typedarray/Int8Array.BYTES_PER_ELEMENT i32.const 1 @@ -14447,16 +14453,7 @@ call $~lib/env/abort unreachable end - global.get $HEAP_BASE - global.get $~lib/internal/allocator/AL_MASK - i32.add - global.get $~lib/internal/allocator/AL_MASK - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset + call $start:~lib/allocator/arena i32.const 0 call $std/typedarray/testInstantiate i32.const 5 @@ -14726,7 +14723,7 @@ end block (result i32) i32.const 0 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/af64 i32.const 0 call $~lib/typedarray/Float64Array#sort|trampoline @@ -14884,7 +14881,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr8 i32.const 0 i32.const 0 @@ -14924,7 +14921,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr8 i32.const 2 i32.const -2 @@ -14969,7 +14966,7 @@ global.set $std/typedarray/sub8 block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/sub8 i32.const 0 i32.const 0 @@ -15090,7 +15087,7 @@ end block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr32 i32.const 0 i32.const 0 @@ -15130,7 +15127,7 @@ end block (result i32) i32.const 2 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/arr32 i32.const 2 i32.const -2 @@ -15175,7 +15172,7 @@ global.set $std/typedarray/sub32 block (result i32) i32.const 1 - global.set $~argc + global.set $~lib/argc global.get $std/typedarray/sub32 i32.const 0 i32.const 0 @@ -15559,6 +15556,9 @@ call $std/typedarray/testArrayEvery call $std/typedarray/testArrayEvery ) - (func $null (; 298 ;) (type $_) + (func $start (; 299 ;) (type $_) + call $start:std/typedarray + ) + (func $null (; 300 ;) (type $_) ) ) diff --git a/tests/compiler/switch.optimized.wat b/tests/compiler/switch.optimized.wat index 96da82ba6f..681a7874c7 100644 --- a/tests/compiler/switch.optimized.wat +++ b/tests/compiler/switch.optimized.wat @@ -67,7 +67,7 @@ end i32.const 0 ) - (func $start (; 3 ;) (type $_) + (func $start:switch (; 3 ;) (type $_) i32.const 0 call $switch/doSwitch if @@ -237,7 +237,10 @@ unreachable end ) - (func $null (; 4 ;) (type $_) + (func $start (; 4 ;) (type $_) + call $start:switch + ) + (func $null (; 5 ;) (type $_) nop ) ) diff --git a/tests/compiler/switch.untouched.wat b/tests/compiler/switch.untouched.wat index 1e5125176b..e66bb5842a 100644 --- a/tests/compiler/switch.untouched.wat +++ b/tests/compiler/switch.untouched.wat @@ -7,7 +7,7 @@ (data (i32.const 8) "\t\00\00\00s\00w\00i\00t\00c\00h\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 32)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -168,7 +168,7 @@ drop i32.const 2 ) - (func $start (; 8 ;) (type $_) + (func $start:switch (; 8 ;) (type $_) i32.const 0 call $switch/doSwitch i32.const 0 @@ -560,6 +560,9 @@ unreachable end ) - (func $null (; 9 ;) (type $_) + (func $start (; 9 ;) (type $_) + call $start:switch + ) + (func $null (; 10 ;) (type $_) ) ) diff --git a/tests/compiler/ternary.untouched.wat b/tests/compiler/ternary.untouched.wat index 7ed2f95aed..6d042c2988 100644 --- a/tests/compiler/ternary.untouched.wat +++ b/tests/compiler/ternary.untouched.wat @@ -4,11 +4,11 @@ (table $0 1 funcref) (elem (i32.const 0) $null) (global $ternary/a (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:ternary (; 0 ;) (type $_) i32.const 1 drop i32.const 1 @@ -22,6 +22,9 @@ i32.const 1 global.set $ternary/a ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:ternary + ) + (func $null (; 2 ;) (type $_) ) ) diff --git a/tests/compiler/typealias.optimized.wat b/tests/compiler/typealias.optimized.wat index a4cdaa8cd0..672711f54f 100644 --- a/tests/compiler/typealias.optimized.wat +++ b/tests/compiler/typealias.optimized.wat @@ -3,14 +3,14 @@ (type $_ (func)) (memory $0 0) (table $0 1 funcref) - (elem (i32.const 0) $start) + (elem (i32.const 0) $null) (export "memory" (memory $0)) (export "table" (table $0)) (export "alias" (func $typealias/alias)) (func $typealias/alias (; 0 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $start (; 1 ;) (type $_) + (func $null (; 1 ;) (type $_) nop ) ) diff --git a/tests/compiler/typealias.ts b/tests/compiler/typealias.ts index 2d9ded09fe..b6b1449047 100644 --- a/tests/compiler/typealias.ts +++ b/tests/compiler/typealias.ts @@ -1,4 +1,7 @@ -type alias = i32; +export type alias = i32; +// TODO: Without 'export' this yields 'ERROR TS2395: Individual declarations in merged declaration...' +// which differs from TypeScript, but we don't have individual element and type spaces per file and this +// just merges. export function alias(a: alias): alias { return a; diff --git a/tests/compiler/typealias.untouched.wat b/tests/compiler/typealias.untouched.wat index 5307c5a377..ea80ff5470 100644 --- a/tests/compiler/typealias.untouched.wat +++ b/tests/compiler/typealias.untouched.wat @@ -4,17 +4,13 @@ (memory $0 0) (table $0 1 funcref) (elem (i32.const 0) $null) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (export "alias" (func $typealias/alias)) - (start $start) (func $typealias/alias (; 0 ;) (type $ii) (param $0 i32) (result i32) local.get $0 ) - (func $start (; 1 ;) (type $_) - nop - ) - (func $null (; 2 ;) (type $_) + (func $null (; 1 ;) (type $_) ) ) diff --git a/tests/compiler/unary.optimized.wat b/tests/compiler/unary.optimized.wat index 56f48d4bea..d545bee165 100644 --- a/tests/compiler/unary.optimized.wat +++ b/tests/compiler/unary.optimized.wat @@ -10,7 +10,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:unary (; 0 ;) (type $_) (local $0 f32) (local $1 f64) (local $2 i32) @@ -236,7 +236,10 @@ local.get $1 global.set $unary/F ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:unary + ) + (func $null (; 2 ;) (type $_) nop ) ) diff --git a/tests/compiler/unary.untouched.wat b/tests/compiler/unary.untouched.wat index 919b9131a7..cc920e110c 100644 --- a/tests/compiler/unary.untouched.wat +++ b/tests/compiler/unary.untouched.wat @@ -7,11 +7,11 @@ (global $unary/I (mut i64) (i64.const 0)) (global $unary/f (mut f32) (f32.const 0)) (global $unary/F (mut f64) (f64.const 0)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 0 ;) (type $_) + (func $start:unary (; 0 ;) (type $_) (local $0 i32) (local $1 i64) (local $2 f32) @@ -366,6 +366,9 @@ end global.set $unary/F ) - (func $null (; 1 ;) (type $_) + (func $start (; 1 ;) (type $_) + call $start:unary + ) + (func $null (; 2 ;) (type $_) ) ) diff --git a/tests/compiler/void.untouched.wat b/tests/compiler/void.untouched.wat index 9bf845e0b4..9153c91541 100644 --- a/tests/compiler/void.untouched.wat +++ b/tests/compiler/void.untouched.wat @@ -6,14 +6,14 @@ (elem (i32.const 0) $null) (global $void/u8Val1 (mut i32) (i32.const 1)) (global $void/u8Val2 (mut i32) (i32.const 255)) - (global $HEAP_BASE i32 (i32.const 8)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) (func $void/anInt (; 0 ;) (type $i) (result i32) i32.const 2 ) - (func $start (; 1 ;) (type $_) + (func $start:void (; 1 ;) (type $_) i32.const 1 drop call $void/anInt @@ -23,6 +23,9 @@ i32.add drop ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:void + ) + (func $null (; 3 ;) (type $_) ) ) diff --git a/tests/compiler/while.optimized.wat b/tests/compiler/while.optimized.wat index fd05d6b2f9..fc2e40c37e 100644 --- a/tests/compiler/while.optimized.wat +++ b/tests/compiler/while.optimized.wat @@ -12,7 +12,7 @@ (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:while (; 1 ;) (type $_) (local $0 i32) loop $continue|0 global.get $while/n @@ -176,7 +176,10 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:while + ) + (func $null (; 3 ;) (type $_) nop ) ) diff --git a/tests/compiler/while.untouched.wat b/tests/compiler/while.untouched.wat index a0fef6aed9..00995b643c 100644 --- a/tests/compiler/while.untouched.wat +++ b/tests/compiler/while.untouched.wat @@ -9,11 +9,11 @@ (global $while/n (mut i32) (i32.const 10)) (global $while/m (mut i32) (i32.const 0)) (global $while/o (mut i32) (i32.const 0)) - (global $HEAP_BASE i32 (i32.const 28)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 28)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start (; 1 ;) (type $_) + (func $start:while (; 1 ;) (type $_) (local $0 i32) block $break|0 loop $continue|0 @@ -212,6 +212,9 @@ unreachable end ) - (func $null (; 2 ;) (type $_) + (func $start (; 2 ;) (type $_) + call $start:while + ) + (func $null (; 3 ;) (type $_) ) )