From 50afadafb704adeff3afce0c4b2b913be6c493e5 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 09:47:44 -0300 Subject: [PATCH 1/8] upgrade dependencies --- package-lock.json | 214 +- package.json | 15 +- src/compiler/nodes.ts | 212 +- src/compiler/phases/binaryen.mts | 10 + src/compiler/phases/codeGenerationPhase.ts | 142 +- src/compiler/types.ts | 2 +- src/index-bin.ts | 2 +- .../compiler/0-struct.lys.optimized.wast | 269 +- .../compiler/0-wast.lys.optimized.wast | 85 +- .../compiler/1-wast-sha3.lys.optimized.wast | 3617 +++++++---------- test/fixtures/compiler/a.lys.optimized.wast | 22 +- test/fixtures/compiler/b.lys.optimized.wast | 14 +- .../compiler/booleanLogic.lys.optimized.wast | 16 +- .../compiler/bytes.lys.optimized.wast | 20 +- test/fixtures/compiler/c.lys.optimized.wast | 14 +- .../compiler/deconstruct.lys.optimized.wast | 42 +- .../dynamicLhsMatch.lys.optimized.wast | 23 +- .../compiler/emptyFn.lys.optimized.wast | 14 +- .../compiler/extern.lys.optimized.wast | 18 +- .../fixtures/compiler/fib1.lys.optimized.wast | 44 +- .../fixtures/compiler/fib2.lys.optimized.wast | 44 +- .../fixtures/compiler/fib3.lys.optimized.wast | 44 +- .../compiler/getter.lys.optimized.wast | 31 +- .../globalMutability.lys.optimized.wast | 14 +- test/fixtures/compiler/if.lys.optimized.wast | 52 +- test/fixtures/compiler/if2.lys.optimized.wast | 50 +- .../compiler/infix.lys.optimized.wast | 18 +- test/fixtures/compiler/is.lys.optimized.wast | 16 +- .../compiler/iterator-loco.lys.optimized.wast | 283 +- .../compiler/loops.lys.optimized.wast | 19 +- .../compiler/mutability.lys.optimized.wast | 16 +- test/fixtures/compiler/nop.lys.optimized.wast | 14 +- .../compiler/panic-match.lys.optimized.wast | 20 +- .../patternMatchinIs.lys.optimized.wast | 578 ++- .../patternMatching.lys.optimized.wast | 382 +- .../execution/fibo.lys.optimized.wast | 152 +- .../execution/implicitCast.lys.optimized.wast | 98 +- .../indirect-smoke.lys.optimized.wast | 106 +- test/fixtures/execution/is.lys.optimized.wast | 463 +-- .../isPatternMatching.lys.optimized.wast | 491 +-- ...PatternMatchingVariable.lys.optimized.wast | 398 +- .../execution/numberOps.lys.optimized.wast | 126 +- ...ternMatchingDeconstruct.lys.optimized.wast | 375 +- .../recursiveStruct.lys.optimized.wast | 344 +- .../setStructValues.lys.optimized.wast | 1131 +++--- .../simpleIterator.lys.optimized.wast | 413 +- .../execution/strConcat.lys.optimized.wast | 1064 +++-- .../stringifyNumbers.lys.optimized.wast | 1199 +++--- .../structValuesExtended.lys.optimized.wast | 667 ++- .../execution/traverseTree.lys.optimized.wast | 358 +- tsconfig.json | 6 +- 51 files changed, 6271 insertions(+), 7496 deletions(-) create mode 100644 src/compiler/phases/binaryen.mts diff --git a/package-lock.json b/package-lock.json index b3d892f..9f675b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,12 @@ "version": "0.1.11-beta.0", "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/wast-printer": "1.11.1", + "@webassemblyjs/ast": "^1.14.1", + "@webassemblyjs/wast-printer": "^1.14.1", "arg": "^4.1.3", - "binaryen": "^100.0.0", + "binaryen": "^121.0.0", "ebnf": "^1.9.0", - "wabt": "^1.0.30" + "wabt": "^1.0.36" }, "bin": { "lys": "dist/bin.js" @@ -23,7 +23,7 @@ "@types/git-rev-sync": "^1.12.0", "@types/glob": "^7.1.3", "@types/mocha": "^10.0.0", - "@types/node": "^16.18.2", + "@types/node": "^22.10.9", "@types/node-fetch": "^2.5.7", "@types/semver": "^6.2.1", "expect": "^29.2.2", @@ -34,8 +34,8 @@ "node-fetch": "^2.6.0", "nyc": "^15.1.0", "semver": "^6.3.0", - "ts-node": "^10.9.1", - "typescript": "^4.8.4" + "ts-node": "^10.9.2", + "typescript": "^5.7.3" } }, "node_modules/@ampproject/remapping": { @@ -607,10 +607,14 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.18.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.2.tgz", - "integrity": "sha512-KIGQJyya+opDCFvDSZMNNS899ov5jlNdtN7PypgHWeb8e+5vWISdwTRo/ClsNVlmDihzOGqFyNBDamUs7TQQCA==", - "dev": true + "version": "22.10.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.9.tgz", + "integrity": "sha512-Ir6hwgsKyNESl/gLOcEz3krR4CBGgliDqBQ2ma4wIhEx0w+xnoeTq3tdrNw15kU3SxogDjOgv9sqdtLW8mIHaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } }, "node_modules/@types/node-fetch": { "version": "2.5.7", @@ -650,45 +654,51 @@ "dev": true }, "node_modules/@webassemblyjs/ast": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", - "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", + "integrity": "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==", + "license": "MIT", "dependencies": { - "@webassemblyjs/helper-numbers": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + "@webassemblyjs/helper-numbers": "1.13.2", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2" } }, "node_modules/@webassemblyjs/floating-point-hex-parser": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", - "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz", + "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==", + "license": "MIT" }, "node_modules/@webassemblyjs/helper-api-error": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", - "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz", + "integrity": "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==", + "license": "MIT" }, "node_modules/@webassemblyjs/helper-numbers": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", - "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz", + "integrity": "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==", + "license": "MIT", "dependencies": { - "@webassemblyjs/floating-point-hex-parser": "1.11.1", - "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/floating-point-hex-parser": "1.13.2", + "@webassemblyjs/helper-api-error": "1.13.2", "@xtuc/long": "4.2.2" } }, "node_modules/@webassemblyjs/helper-wasm-bytecode": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", - "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz", + "integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==", + "license": "MIT" }, "node_modules/@webassemblyjs/wast-printer": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", - "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.14.1.tgz", + "integrity": "sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==", + "license": "MIT", "dependencies": { - "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/ast": "1.14.1", "@xtuc/long": "4.2.2" } }, @@ -832,11 +842,20 @@ } }, "node_modules/binaryen": { - "version": "100.0.0", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-100.0.0.tgz", - "integrity": "sha512-nxOt8d8/VXAuSVEtAWUdKrqpqCy365QqD223EzzB1GzS5himiZAfM/R5lXx+M/5q8TB8cYp3tYxv5rTjNTJveQ==", + "version": "121.0.0", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-121.0.0.tgz", + "integrity": "sha512-St5LX+CmVdDQMf+DDHWdne7eDK+8tH9TE4Kc+Xk3s5+CzVYIKeJbWuXgsKVbkdLJXGUc2eflFqjThQy555mBag==", + "license": "Apache-2.0", "bin": { - "wasm-opt": "bin/wasm-opt" + "wasm-as": "bin/wasm-as", + "wasm-ctor-eval": "bin/wasm-ctor-eval", + "wasm-dis": "bin/wasm-dis", + "wasm-merge": "bin/wasm-merge", + "wasm-metadce": "bin/wasm-metadce", + "wasm-opt": "bin/wasm-opt", + "wasm-reduce": "bin/wasm-reduce", + "wasm-shell": "bin/wasm-shell", + "wasm2js": "bin/wasm2js" } }, "node_modules/brace-expansion": { @@ -2941,10 +2960,11 @@ "dev": true }, "node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, + "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -3011,18 +3031,26 @@ } }, "node_modules/typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + }, "node_modules/update-browserslist-db": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", @@ -3065,14 +3093,15 @@ "dev": true }, "node_modules/wabt": { - "version": "1.0.30", - "resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.30.tgz", - "integrity": "sha512-qM1QnttJhjZ4vTSuXvder43yxgGhVffT/0wMc0SwYpboEW0/ENISpei/2kIDEMPrnNfTQ4GdvD7JIFV0IJPYog==", + "version": "1.0.36", + "resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.36.tgz", + "integrity": "sha512-GAfEcFyvYRZ51xIZKeeCmIKytTz3ejCeEU9uevGNhEnqt9qXp3a8Q2O4ByZr6rKWcd8jV/Oj5cbDJFtmTYdchg==", + "license": "Apache-2.0", "bin": { "wasm-decompile": "bin/wasm-decompile", "wasm-interp": "bin/wasm-interp", "wasm-objdump": "bin/wasm-objdump", - "wasm-opcodecnt": "bin/wasm-opcodecnt", + "wasm-stats": "bin/wasm-stats", "wasm-strip": "bin/wasm-strip", "wasm-validate": "bin/wasm-validate", "wasm2c": "bin/wasm2c", @@ -3666,10 +3695,13 @@ "dev": true }, "@types/node": { - "version": "16.18.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.2.tgz", - "integrity": "sha512-KIGQJyya+opDCFvDSZMNNS899ov5jlNdtN7PypgHWeb8e+5vWISdwTRo/ClsNVlmDihzOGqFyNBDamUs7TQQCA==", - "dev": true + "version": "22.10.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.9.tgz", + "integrity": "sha512-Ir6hwgsKyNESl/gLOcEz3krR4CBGgliDqBQ2ma4wIhEx0w+xnoeTq3tdrNw15kU3SxogDjOgv9sqdtLW8mIHaw==", + "dev": true, + "requires": { + "undici-types": "~6.20.0" + } }, "@types/node-fetch": { "version": "2.5.7", @@ -3709,45 +3741,45 @@ "dev": true }, "@webassemblyjs/ast": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", - "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", + "integrity": "sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==", "requires": { - "@webassemblyjs/helper-numbers": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + "@webassemblyjs/helper-numbers": "1.13.2", + "@webassemblyjs/helper-wasm-bytecode": "1.13.2" } }, "@webassemblyjs/floating-point-hex-parser": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", - "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz", + "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==" }, "@webassemblyjs/helper-api-error": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", - "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.13.2.tgz", + "integrity": "sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==" }, "@webassemblyjs/helper-numbers": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", - "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.13.2.tgz", + "integrity": "sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==", "requires": { - "@webassemblyjs/floating-point-hex-parser": "1.11.1", - "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/floating-point-hex-parser": "1.13.2", + "@webassemblyjs/helper-api-error": "1.13.2", "@xtuc/long": "4.2.2" } }, "@webassemblyjs/helper-wasm-bytecode": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", - "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==" + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.13.2.tgz", + "integrity": "sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==" }, "@webassemblyjs/wast-printer": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", - "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.14.1.tgz", + "integrity": "sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==", "requires": { - "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/ast": "1.14.1", "@xtuc/long": "4.2.2" } }, @@ -3857,9 +3889,9 @@ "dev": true }, "binaryen": { - "version": "100.0.0", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-100.0.0.tgz", - "integrity": "sha512-nxOt8d8/VXAuSVEtAWUdKrqpqCy365QqD223EzzB1GzS5himiZAfM/R5lXx+M/5q8TB8cYp3tYxv5rTjNTJveQ==" + "version": "121.0.0", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-121.0.0.tgz", + "integrity": "sha512-St5LX+CmVdDQMf+DDHWdne7eDK+8tH9TE4Kc+Xk3s5+CzVYIKeJbWuXgsKVbkdLJXGUc2eflFqjThQy555mBag==" }, "brace-expansion": { "version": "1.1.11", @@ -5390,9 +5422,9 @@ "dev": true }, "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "requires": { "@cspotcode/source-map-support": "^0.8.0", @@ -5434,9 +5466,15 @@ } }, "typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", + "dev": true + }, + "undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", "dev": true }, "update-browserslist-db": { @@ -5462,9 +5500,9 @@ "dev": true }, "wabt": { - "version": "1.0.30", - "resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.30.tgz", - "integrity": "sha512-qM1QnttJhjZ4vTSuXvder43yxgGhVffT/0wMc0SwYpboEW0/ENISpei/2kIDEMPrnNfTQ4GdvD7JIFV0IJPYog==" + "version": "1.0.36", + "resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.36.tgz", + "integrity": "sha512-GAfEcFyvYRZ51xIZKeeCmIKytTz3ejCeEU9uevGNhEnqt9qXp3a8Q2O4ByZr6rKWcd8jV/Oj5cbDJFtmTYdchg==" }, "webidl-conversions": { "version": "3.0.1", diff --git a/package.json b/package.json index 416b9c7..076e628 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "dist/index.js", "typings": "dist/index.d.ts", + "types": "dist/index.d.ts", "bin": { "lys": "dist/bin.js" }, @@ -27,18 +28,18 @@ "printWidth": 120 }, "dependencies": { - "@webassemblyjs/ast": "1.11.1", - "@webassemblyjs/wast-printer": "1.11.1", + "@webassemblyjs/ast": "^1.14.1", + "@webassemblyjs/wast-printer": "^1.14.1", "arg": "^4.1.3", - "binaryen": "^100.0.0", + "binaryen": "^121.0.0", "ebnf": "^1.9.0", - "wabt": "^1.0.30" + "wabt": "^1.0.36" }, "devDependencies": { "@types/git-rev-sync": "^1.12.0", "@types/glob": "^7.1.3", "@types/mocha": "^10.0.0", - "@types/node": "^16.18.2", + "@types/node": "^22.10.9", "@types/node-fetch": "^2.5.7", "@types/semver": "^6.2.1", "expect": "^29.2.2", @@ -49,8 +50,8 @@ "node-fetch": "^2.6.0", "nyc": "^15.1.0", "semver": "^6.3.0", - "ts-node": "^10.9.1", - "typescript": "^4.8.4" + "ts-node": "^10.9.2", + "typescript": "^5.7.3" }, "files": [ "LICENSE", diff --git a/src/compiler/nodes.ts b/src/compiler/nodes.ts index 2d4102f..27cd83f 100644 --- a/src/compiler/nodes.ts +++ b/src/compiler/nodes.ts @@ -21,7 +21,11 @@ export class Global implements LocalGlobalHeapReference { export class Local implements LocalGlobalHeapReference { type?: Type; /** index in the function */ - constructor(public index: number, public name: string, public declarationNode?: Nodes.Node) {} + constructor( + public index: number, + public name: string, + public declarationNode?: Nodes.Node, + ) {} } export enum PhaseFlags { @@ -32,7 +36,7 @@ export enum PhaseFlags { TypeCheck, PreCompilation, Compilation, - CodeGeneration + CodeGeneration, } export namespace Nodes { @@ -73,7 +77,7 @@ export namespace Nodes { } get children(): Node[] { - return this.childrenOrEmpty.filter($ => !!$) as Node[]; + return this.childrenOrEmpty.filter(($) => !!$) as Node[]; } abstract get childrenOrEmpty(): (Node | void)[]; @@ -91,7 +95,7 @@ export namespace Nodes { getAnnotationsByClass(klass: IAnnotationConstructor): T[] { const ret: T[] = []; if (this.annotations) { - this.annotations.forEach($ => { + this.annotations.forEach(($) => { if ($ instanceof klass) ret.push($); }); } @@ -101,7 +105,7 @@ export namespace Nodes { getAnnotation(klass: IAnnotationConstructor): T | null { const ret: T[] = []; if (this.annotations) { - this.annotations.forEach($ => { + this.annotations.forEach(($) => { if ($ instanceof klass) ret.push($); }); } @@ -113,7 +117,7 @@ export namespace Nodes { this.annotations && this.annotations.delete(name); } else { this.annotations && - this.getAnnotationsByClass(name).forEach($ => this.annotations && this.annotations.delete($)); + this.getAnnotationsByClass(name).forEach(($) => this.annotations && this.annotations.delete($)); } } @@ -127,7 +131,7 @@ export namespace Nodes { getAnnotations(klass?: IAnnotationConstructor): T[] { const ret: T[] = []; if (this.annotations) { - this.annotations.forEach($ => { + this.annotations.forEach(($) => { if (!klass || $ instanceof klass) ret.push($ as T); }); } @@ -150,7 +154,10 @@ export namespace Nodes { return []; } - constructor(astNode: ASTNode, public name: string) { + constructor( + astNode: ASTNode, + public name: string, + ) { super(astNode); } @@ -161,12 +168,15 @@ export namespace Nodes { } export class QNameNode extends Node { - constructor(astNode: ASTNode, public readonly names: NameIdentifierNode[]) { + constructor( + astNode: ASTNode, + public readonly names: NameIdentifierNode[], + ) { super(astNode); } static fromString(name: string, astNode: ASTNode): QNameNode { - const names = name.split('::').map($ => NameIdentifierNode.fromString($, astNode)); + const names = name.split('::').map(($) => NameIdentifierNode.fromString($, astNode)); const r = new QNameNode(astNode, names); return r; } @@ -178,14 +188,14 @@ export namespace Nodes { deconstruct() { const moduleName = this.names .slice(0, -1) - .map($ => $.name) + .map(($) => $.name) .join('::'); const variable = this.names[this.names.length - 1].name; return { moduleName, variable }; } get text() { - return this.names.map($ => $.name).join('::'); + return this.names.map(($) => $.name).join('::'); } } @@ -200,7 +210,10 @@ export namespace Nodes { export class SignatureParameterNode extends TypeNode { parameterName?: NameIdentifierNode; - constructor(astNode: ASTNode, public readonly parameterType: TypeNode) { + constructor( + astNode: ASTNode, + public readonly parameterType: TypeNode, + ) { super(astNode); } @@ -214,7 +227,10 @@ export namespace Nodes { effect?: TypeNode; returnType?: TypeNode; - constructor(astNode: ASTNode, public readonly parameters: SignatureParameterNode[]) { + constructor( + astNode: ASTNode, + public readonly parameters: SignatureParameterNode[], + ) { super(astNode); } @@ -238,7 +254,10 @@ export namespace Nodes { isLocal: boolean = false; resolvedReference?: Reference; - constructor(astNode: ASTNode, public readonly variable: QNameNode) { + constructor( + astNode: ASTNode, + public readonly variable: QNameNode, + ) { super(astNode); } @@ -250,7 +269,10 @@ export namespace Nodes { export class BlockNode extends ExpressionNode { label?: string; - constructor(astNode: ASTNode, public readonly statements: Node[]) { + constructor( + astNode: ASTNode, + public readonly statements: Node[], + ) { super(astNode); } @@ -266,7 +288,7 @@ export namespace Nodes { astNode: ASTNode, public readonly lhs: ExpressionNode, public readonly operator: string, - public readonly memberName: NameIdentifierNode + public readonly memberName: NameIdentifierNode, ) { super(astNode); } @@ -280,7 +302,7 @@ export namespace Nodes { constructor( astNode: ASTNode, public readonly decoratorName: NameIdentifierNode, - public readonly args: LiteralNode[] + public readonly args: LiteralNode[], ) { super(astNode); } @@ -305,7 +327,7 @@ export namespace Nodes { version: 0, nextPhase: PhaseFlags.Semantic, isTypeAnalysisPassNeeded: true, - areTypesResolved: false + areTypesResolved: false, }; typeNumbers: Map = new Map(); @@ -322,7 +344,10 @@ export namespace Nodes { parameterType?: TypeNode; defaultValue?: ExpressionNode; - constructor(astNode: ASTNode, public readonly parameterName: NameIdentifierNode) { + constructor( + astNode: ASTNode, + public readonly parameterName: NameIdentifierNode, + ) { super(astNode); } @@ -351,14 +376,17 @@ export namespace Nodes { private tempF32s: Local[] | null = null; private tempF64s: Local[] | null = null; - constructor(astNode: ASTNode, public readonly functionName: NameIdentifierNode) { + constructor( + astNode: ASTNode, + public readonly functionName: NameIdentifierNode, + ) { super(astNode); } processParameters() { let localIndex = 0; - this.parameters.forEach(parameter => { + this.parameters.forEach((parameter) => { let local = new Local(localIndex++, parameter.parameterName.name, parameter.parameterName); this.localsByIndex[local.index] = local; parameter.annotate(new annotations.LocalIdentifier(local)); @@ -372,7 +400,7 @@ export namespace Nodes { let local = new Local( localIndex, declaration ? declaration.internalIdentifier! : 'var$' + localIndex.toString(10), - declaration + declaration, ); local.type = type; @@ -495,7 +523,7 @@ export namespace Nodes { constructor( astNode: ASTNode, public readonly targetImpl: ReferenceNode, - public readonly directives: DirectiveNode[] + public readonly directives: DirectiveNode[], ) { super(astNode); } @@ -505,7 +533,7 @@ export namespace Nodes { ...(this.decorators || []), this.targetImpl, ...(this.baseImpl ? [this.baseImpl] : []), - ...(this.directives || []) + ...(this.directives || []), ]; } } @@ -514,7 +542,10 @@ export namespace Nodes { allItems: boolean = true; alias: NameIdentifierNode | null = null; - constructor(astNode: ASTNode, public readonly module: QNameNode) { + constructor( + astNode: ASTNode, + public readonly module: QNameNode, + ) { super(astNode); } @@ -527,7 +558,7 @@ export namespace Nodes { constructor( astNode: ASTNode, public readonly functionNode: FunctionNode, - public readonly decorators: DecoratorNode[] + public readonly decorators: DecoratorNode[], ) { super(astNode); } @@ -548,7 +579,10 @@ export namespace Nodes { export class OverloadedFunctionNode extends DirectiveNode { functions: FunDirectiveNode[] = []; - constructor(astNode: ASTNode, public readonly functionName: NameIdentifierNode) { + constructor( + astNode: ASTNode, + public readonly functionName: NameIdentifierNode, + ) { super(astNode); } @@ -560,7 +594,11 @@ export namespace Nodes { export class VarDeclarationNode extends Node { variableType?: TypeNode; - constructor(astNode: ASTNode, public readonly variableName: NameIdentifierNode, public value: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly variableName: NameIdentifierNode, + public value: ExpressionNode, + ) { super(astNode); } @@ -570,7 +608,10 @@ export namespace Nodes { } export class VarDirectiveNode extends DirectiveNode { - constructor(astNode: ASTNode, public readonly decl: VarDeclarationNode) { + constructor( + astNode: ASTNode, + public readonly decl: VarDeclarationNode, + ) { super(astNode); } @@ -580,7 +621,11 @@ export namespace Nodes { } export class AssignmentNode extends Node { - constructor(astNode: ASTNode, public readonly lhs: ExpressionNode, public readonly rhs: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly lhs: ExpressionNode, + public readonly rhs: ExpressionNode, + ) { super(astNode); } @@ -592,7 +637,10 @@ export namespace Nodes { export class TypeDirectiveNode extends DirectiveNode { valueType?: TypeNode; - constructor(astNode: ASTNode, public readonly variableName: NameIdentifierNode) { + constructor( + astNode: ASTNode, + public readonly variableName: NameIdentifierNode, + ) { super(astNode); } @@ -605,7 +653,11 @@ export namespace Nodes { readonly namespaceNames: Map = new Map(); selfTypeName?: NameIdentifierNode; - constructor(astNode: ASTNode, public readonly traitName: NameIdentifierNode, public directives: DirectiveNode[]) { + constructor( + astNode: ASTNode, + public readonly traitName: NameIdentifierNode, + public directives: DirectiveNode[], + ) { super(astNode); } @@ -618,7 +670,7 @@ export namespace Nodes { constructor( astNode: ASTNode, public readonly variableName: NameIdentifierNode, - public readonly declarations: StructDeclarationNode[] + public readonly declarations: StructDeclarationNode[], ) { super(astNode); } @@ -629,12 +681,19 @@ export namespace Nodes { } export abstract class LiteralNode extends ExpressionNode { - get value(): T {throw new Error('not implemented')} - set value(_:T) {throw new Error('not implemented')} + get value(): T { + throw new Error('not implemented'); + } + set value(_: T) { + throw new Error('not implemented'); + } rawValue: string = ''; resolvedReference?: Reference; - constructor(astNode: ASTNode, public typeName: string) { + constructor( + astNode: ASTNode, + public typeName: string, + ) { super(astNode); if (astNode) { this.rawValue = astNode.text; @@ -678,7 +737,10 @@ export namespace Nodes { } export class StructTypeNode extends TypeNode { - constructor(astNode: ASTNode, public readonly parameters: ParameterNode[]) { + constructor( + astNode: ASTNode, + public readonly parameters: ParameterNode[], + ) { super(astNode); } @@ -702,7 +764,6 @@ export namespace Nodes { } export class HexLiteral extends IntegerLiteral { - suffixReference?: ReferenceNode; get value(): number { return parseInt(this.rawValue, 16); } @@ -763,7 +824,7 @@ export namespace Nodes { constructor( astNode: ASTNode, public functionNode: ExpressionNode, - public readonly argumentsNode: ExpressionNode[] + public readonly argumentsNode: ExpressionNode[], ) { super(astNode); } @@ -778,7 +839,7 @@ export namespace Nodes { astNode: ASTNode, public readonly operator: NameIdentifierNode, public lhs: ExpressionNode, - public rhs: ExpressionNode + public rhs: ExpressionNode, ) { super(astNode); } @@ -840,7 +901,11 @@ export namespace Nodes { } argumentsNode: Node[] = []; - constructor(astNode: ASTNode, public readonly operator: NameIdentifierNode, rhs: TypeNode) { + constructor( + astNode: ASTNode, + public readonly operator: NameIdentifierNode, + rhs: TypeNode, + ) { super(astNode); this.rhs = rhs; @@ -852,7 +917,11 @@ export namespace Nodes { } export class WasmAtomNode extends Node { - constructor(astNode: ASTNode, public readonly symbol: string, public readonly args: ExpressionNode[]) { + constructor( + astNode: ASTNode, + public readonly symbol: string, + public readonly args: ExpressionNode[], + ) { super(astNode); } @@ -862,7 +931,10 @@ export namespace Nodes { } export class WasmExpressionNode extends ExpressionNode { - constructor(astNode: ASTNode, public readonly atoms: WasmAtomNode[]) { + constructor( + astNode: ASTNode, + public readonly atoms: WasmAtomNode[], + ) { super(astNode); } @@ -873,10 +945,12 @@ export namespace Nodes { export abstract class MatcherNode extends ExpressionNode { declaredName?: NameIdentifierNode; - parent?: PatternMatcherNode; booleanReference?: Reference; - constructor(astNode: ASTNode, public readonly rhs: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly rhs: ExpressionNode, + ) { super(astNode); } @@ -892,7 +966,7 @@ export namespace Nodes { astNode: ASTNode, public readonly condition: ExpressionNode, public readonly truePart: ExpressionNode, - public readonly falsePart?: ExpressionNode + public readonly falsePart?: ExpressionNode, ) { super(astNode); } @@ -903,7 +977,11 @@ export namespace Nodes { } export class MatchConditionNode extends MatcherNode { - constructor(astNode: ASTNode, public readonly condition: ExpressionNode, public readonly rhs: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly condition: ExpressionNode, + public readonly rhs: ExpressionNode, + ) { super(astNode, rhs); } @@ -916,7 +994,11 @@ export namespace Nodes { deconstructorNames?: NameIdentifierNode[]; resolvedFunctionType?: FunctionType; - constructor(astNode: ASTNode, public readonly typeReference: ReferenceNode, public rhs: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly typeReference: ReferenceNode, + public rhs: ExpressionNode, + ) { super(astNode, rhs); } @@ -928,7 +1010,11 @@ export namespace Nodes { export class MatchLiteralNode extends MatcherNode { resolvedFunctionType?: FunctionType; - constructor(astNode: ASTNode, public readonly literal: LiteralNode, public readonly rhs: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly literal: LiteralNode, + public readonly rhs: ExpressionNode, + ) { super(astNode, rhs); } @@ -958,7 +1044,7 @@ export namespace Nodes { constructor( astNode: ASTNode, public readonly declaredName: NameIdentifierNode, - public readonly parameters: ParameterNode[] + public readonly parameters: ParameterNode[], ) { super(astNode); } @@ -971,7 +1057,10 @@ export namespace Nodes { export class EffectDeclarationNode extends Node { elements?: FunctionTypeNode[]; - constructor(astNode: ASTNode, public readonly name: NameIdentifierNode) { + constructor( + astNode: ASTNode, + public readonly name: NameIdentifierNode, + ) { super(astNode); } @@ -985,7 +1074,11 @@ export namespace Nodes { export class PatternMatcherNode extends ExpressionNode { carryType?: Type; - constructor(astNode: ASTNode, public readonly lhs: ExpressionNode, public readonly matchingSet: MatcherNode[]) { + constructor( + astNode: ASTNode, + public readonly lhs: ExpressionNode, + public readonly matchingSet: MatcherNode[], + ) { super(astNode); } @@ -995,7 +1088,10 @@ export namespace Nodes { } export class LoopNode extends ExpressionNode { - constructor(astNode: ASTNode, public readonly body: ExpressionNode) { + constructor( + astNode: ASTNode, + public readonly body: ExpressionNode, + ) { super(astNode); } @@ -1020,21 +1116,21 @@ export namespace Nodes { export function findNodesByType( astRoot: { children: any[] }, type: { new (...args: any[]): T }, - list: T[] = [] + list: T[] = [], ): T[] { if (astRoot instanceof type) { list.push(astRoot); } - astRoot.children.forEach($ => findNodesByType($, type, list)); + astRoot.children.forEach(($) => findNodesByType($, type, list)); return list; } export function findNodesByTypeInChildren( astRoot: { children: any[] }, type: { new (...args: any[]): T }, - list: T[] = [] + list: T[] = [], ): T[] { - astRoot.children.forEach($ => { + astRoot.children.forEach(($) => { if ($ instanceof type) { list.push($); } diff --git a/src/compiler/phases/binaryen.mts b/src/compiler/phases/binaryen.mts new file mode 100644 index 0000000..a1fa218 --- /dev/null +++ b/src/compiler/phases/binaryen.mts @@ -0,0 +1,10 @@ +declare const globalThis: any; + +export async function loadBinaryen() { + const b = await import('binaryen'); + globalThis['Binaryen'] = { + TOTAL_MEMORY: 16777216 * 8, + }; + + return b; +} diff --git a/src/compiler/phases/codeGenerationPhase.ts b/src/compiler/phases/codeGenerationPhase.ts index 30f0d52..f21e826 100644 --- a/src/compiler/phases/codeGenerationPhase.ts +++ b/src/compiler/phases/codeGenerationPhase.ts @@ -1,13 +1,9 @@ -import * as t from '@webassemblyjs/ast'; +import * as ast from '@webassemblyjs/ast'; import { print } from '@webassemblyjs/wast-printer'; +const t = ast as any; declare var globalThis: any; -globalThis['Binaryen'] = { - TOTAL_MEMORY: 16777216 * 8 -}; - -import binaryen from 'binaryen'; import _wabt from 'wabt'; import { annotations } from '../annotations'; import { flatten } from '../helpers'; @@ -57,7 +53,7 @@ function getStarterFunction(statements: any[]) { return t.func( starterName, // name fnType, // signature - statements // body + statements, // body ); } @@ -74,9 +70,9 @@ function getTypeForFunctionType(fn: Type | null, errorNode: Nodes.Node) { return t.signature( fn.parameterTypes.map(($, $$) => ({ id: fn.parameterNames[$$] || '$param' + $$, - valtype: $.binaryenType + valtype: $.binaryenType, })), - retType + retType, ); } throw new LysCompilerError(fn + ' has no return type', errorNode); @@ -102,8 +98,8 @@ function emitFunction(fn: Nodes.FunctionNode, document: Nodes.DocumentNode, pars restartFunctionSeqId(fn); - const locals = fn.additionalLocals.map($ => - t.instruction('local', [t.identifier($.name), t.valtypeLiteral($.type!.binaryenType)]) + const locals = fn.additionalLocals.map(($) => + t.instruction('local', [t.identifier($.name), t.valtypeLiteral($.type!.binaryenType)]), ); if (!fn.body) throw new LysCompilerError('Function has no body', fn); @@ -111,7 +107,7 @@ function emitFunction(fn: Nodes.FunctionNode, document: Nodes.DocumentNode, pars const moduleFun = t.func( t.identifier(fn.functionName.internalIdentifier), // name fnType, // signature - [...locals, ...emitList(fn.body, document, parsingContext)] // body + [...locals, ...emitList(fn.body, document, parsingContext)], // body ); return moduleFun; @@ -126,17 +122,17 @@ function emitLoop(node: Nodes.LoopNode, document: Nodes.DocumentNode, parsingCon const breakLabel = t.identifier('Break' + loopId); return t.blockInstruction(breakLabel, [ - t.loopInstruction(continueLabel, void 0, emitList(node.body, document, parsingContext)) + t.loopInstruction(continueLabel, void 0, emitList(node.body, document, parsingContext)), ]); } function emitMatchingNode( match: Nodes.PatternMatcherNode, document: Nodes.DocumentNode, - parsingContext: ParsingContext + parsingContext: ParsingContext, ) { const matchers = match.matchingSet.slice(0); - const ixDefaultBranch = matchers.findIndex($ => $ instanceof Nodes.MatchDefaultNode); + const ixDefaultBranch = matchers.findIndex(($) => $ instanceof Nodes.MatchDefaultNode); const local = match.getAnnotation(annotations.LocalIdentifier)!.local; @@ -163,13 +159,13 @@ function emitMatchingNode( const condition = t.callInstruction(t.identifier(ofType.name.internalIdentifier), [ t.instruction('local.get', [t.identifier(local.name)]), - emit(node.literal, document, parsingContext) + emit(node.literal, document, parsingContext), ]); const body = emit(node.rhs, document, parsingContext); return { condition, - body + body, }; } else if (node instanceof Nodes.MatchCaseIsNode) { const ofType = node.resolvedFunctionType; @@ -179,23 +175,23 @@ function emitMatchingNode( const local = match.getAnnotation(annotations.LocalIdentifier)!.local; const condition = t.callInstruction(t.identifier(ofType.name.internalIdentifier), [ - t.instruction('local.get', [t.identifier(local.name)]) + t.instruction('local.get', [t.identifier(local.name)]), ]); const body = emit(node.rhs, document, parsingContext); return { condition, - body + body, }; } throw new LysCompilerError("I don't know how handle this", node); }) - .filter($ => !!$); + .filter(($) => !!$); const exitBlock = 'B' + getFunctionSeqId(match); const exitLabel = t.identifier(exitBlock); const breaks = blocks - .filter($ => !!$.condition) + .filter(($) => !!$.condition) .map(($, $$) => t.instruction('br_if', [t.identifier(`${exitBlock}_${$$}`), $.condition])); const ret = blocks.reduceRight((prev, curr, ix) => { @@ -219,7 +215,7 @@ function emitMatchingNode( function emitList(nodes: Nodes.Node[] | Nodes.Node, document: Nodes.DocumentNode, parsingContext: ParsingContext) { if (nodes instanceof Array) { - return flatten(nodes.map($ => emit($, document, parsingContext))); + return flatten(nodes.map(($) => emit($, document, parsingContext))); } else { return flatten([emit(nodes, document, parsingContext)]); } @@ -233,7 +229,7 @@ function emitWast(node: Nodes.WasmAtomNode, document: Nodes.DocumentNode, parsin if (ofType.of.length > 1) { throw new LysCompilerError( 'This reference has multiple overloads. From WASM you can only reference non-overloaded functions', - node + node, ); } ofType = ofType.of[0]; @@ -264,7 +260,7 @@ function emitWast(node: Nodes.WasmAtomNode, document: Nodes.DocumentNode, parsin return t.instruction( node.symbol, - (node.args || []).map($ => emitWast($ as any, document, parsingContext)) + (node.args || []).map(($) => emitWast($ as any, document, parsingContext)), ); } @@ -278,7 +274,7 @@ function emitImplicitCall(node: Nodes.Node, document: Nodes.DocumentNode, parsin return t.callInstruction( t.identifier(ofType.name.internalIdentifier), - implicitCallData.implicitCall.argumentsNode.map($ => emit($, document, parsingContext)) + implicitCallData.implicitCall.argumentsNode.map(($) => emit($, document, parsingContext)), ); } @@ -288,7 +284,7 @@ function getReferencedSymbol(node: Nodes.Node): { symbol: string; type: 'VALUE' if (local) { return { symbol: local.local.name, - type: 'VALUE' + type: 'VALUE', }; } @@ -301,7 +297,7 @@ function getReferencedSymbol(node: Nodes.Node): { symbol: string; type: 'VALUE' return { symbol: fn.nameIdentifier.internalIdentifier, - type: 'TABLE' + type: 'TABLE', }; } @@ -318,7 +314,7 @@ function getTypeSignature(fn: Type | null, errorNode: Nodes.Node, parsingContext const retType = ret.binaryenType ? [ret.binaryenType] : []; const name = - 'lys::' + fn.parameterTypes.map($ => $.binaryenType).join('_') + '->' + (retType.join('_') || 'void'); + 'lys::' + fn.parameterTypes.map(($) => $.binaryenType).join('_') + '->' + (retType.join('_') || 'void'); if (!parsingContext.signatures.has(name)) { parsingContext.signatures.set( @@ -326,12 +322,12 @@ function getTypeSignature(fn: Type | null, errorNode: Nodes.Node, parsingContext t.typeInstruction( t.identifier(name), t.signature( - fn.parameterTypes.map($ => ({ - valtype: $.binaryenType + fn.parameterTypes.map(($) => ({ + valtype: $.binaryenType, })), - retType - ) - ) + retType, + ), + ), ); } @@ -364,8 +360,8 @@ function emit(node: Nodes.Node, document: Nodes.DocumentNode, parsingContext: Pa return t.callIndirectInstruction( signature, node.argumentsNode - .map($ => emit($, document, parsingContext)) - .concat(emit(node.functionNode, document, parsingContext)) + .map(($) => emit($, document, parsingContext)) + .concat(emit(node.functionNode, document, parsingContext)), ); } } @@ -378,12 +374,12 @@ function emit(node: Nodes.Node, document: Nodes.DocumentNode, parsingContext: Pa return t.callInstruction( t.identifier(funType.name.internalIdentifier), - node.argumentsNode.map($ => emit($, document, parsingContext)) + node.argumentsNode.map(($) => emit($, document, parsingContext)), ); } else if (node instanceof Nodes.UnknownExpressionNode) { return t.instruction('unreachable', []); } else if (node instanceof Nodes.WasmExpressionNode) { - return flatten(node.atoms.map($ => emitWast($, document, parsingContext))); + return flatten(node.atoms.map(($) => emitWast($, document, parsingContext))); } else if (node instanceof Nodes.ContinueNode) { const loopLabel = node.getAnnotation(annotations.CurrentLoop)!.loop.getAnnotation(annotations.LabelId)!; return t.instruction('br', [t.identifier('Loop' + loopLabel.label)]); @@ -425,9 +421,9 @@ function emit(node: Nodes.Node, document: Nodes.DocumentNode, parsingContext: Pa t.identifier('tee_global_' + getFunctionSeqId(node)), [ t.instruction('global.set', [t.identifier(local.name), emit(node.rhs, document, parsingContext)]), - t.instruction('global.get', [t.identifier(local.name)]) + t.instruction('global.get', [t.identifier(local.name)]), ], - TypeHelpers.getNodeType(node.rhs)!.binaryenType + TypeHelpers.getNodeType(node.rhs)!.binaryenType, ); } else { const local = node.lhs.getAnnotation(annotations.LocalIdentifier)!.local; @@ -443,7 +439,7 @@ function emit(node: Nodes.Node, document: Nodes.DocumentNode, parsingContext: Pa const type = TypeHelpers.getNodeType(node)!.binaryenType; let instr: any[] = []; - node.statements.forEach($ => { + node.statements.forEach(($) => { // TODO: Drop here things let emited = emit($, document, parsingContext); const type = TypeHelpers.getNodeType($); @@ -470,7 +466,7 @@ function emit(node: Nodes.Node, document: Nodes.DocumentNode, parsingContext: Pa [emit(node.condition, document, parsingContext)], TypeHelpers.getNodeType(node)!.binaryenType, emitList(node.truePart, document, parsingContext), - node.falsePart ? emitList(node.falsePart, document, parsingContext) : [] + node.falsePart ? emitList(node.falsePart, document, parsingContext) : [], ); } else if (node instanceof Nodes.ReferenceNode) { const ref = getReferencedSymbol(node); @@ -524,7 +520,10 @@ export class CodeGenerationPhaseResult { buffer?: Uint8Array; sourceMap: string | null = null; - constructor(public document: Nodes.DocumentNode, public parsingContext: ParsingContext) { + constructor( + public document: Nodes.DocumentNode, + public parsingContext: ParsingContext, + ) { failWithErrors(`Compilation`, parsingContext); try { @@ -536,10 +535,12 @@ export class CodeGenerationPhaseResult { async validate( optimize: boolean = true, - debug = false + debug = false, ): Promise<{ callGraph?: string; }> { + const { default: binaryen } = await import('binaryen'); + let text = print(this.programAST); const theWabt = await wabt; @@ -548,21 +549,27 @@ export class CodeGenerationPhaseResult { try { wabtModule = theWabt.parseWat(this.document.moduleName, text, {}); } catch (e: any) { - const invalidFile = this.parsingContext.system.resolvePath(this.parsingContext.system.getCurrentDirectory(), 'failed_debug_wat.wat') - this.parsingContext.system.writeFile(invalidFile, text) - console.error('Error while parsing generated code. Writing debug WAT to ' + invalidFile) + const invalidFile = this.parsingContext.system.resolvePath( + this.parsingContext.system.getCurrentDirectory(), + 'failed_debug_wat.wat', + ); + this.parsingContext.system.writeFile(invalidFile, text); + console.error('Error while parsing generated code. Writing debug WAT to ' + invalidFile); console.error(e); - throw e; + throw e; } try { wabtModule.resolveNames(); wabtModule.validate(); } catch (e: any) { - const invalidFile = this.parsingContext.system.resolvePath(this.parsingContext.system.getCurrentDirectory(), 'failed_debug_wat.wat') - this.parsingContext.system.writeFile(invalidFile, text) + const invalidFile = this.parsingContext.system.resolvePath( + this.parsingContext.system.getCurrentDirectory(), + 'failed_debug_wat.wat', + ); + this.parsingContext.system.writeFile(invalidFile, text); - console.error('Error while resolving names and validate code. Writing debug WAT to ' + invalidFile) + console.error('Error while resolving names and validate code. Writing debug WAT to ' + invalidFile); console.error(e); this.parsingContext.messageCollector.error(e, this.document.astNode); @@ -638,6 +645,7 @@ export class CodeGenerationPhaseResult { async emitText() { if (this.buffer) { + const { default: binaryen } = await import('binaryen'); const module = binaryen.readBinary(this.buffer); const ret = module.emitText(); module.dispose(); @@ -662,8 +670,8 @@ export class CodeGenerationPhaseResult { memoryBase: 0, tableBase: 0, memory: new WebAssembly.Memory({ initial: 256 }), - table: new WebAssembly.Table({ initial: 0, element: 'funcref' }) - } + table: new WebAssembly.Table({ initial: 0, element: 'funcref' }), + }, }; // Create the instance. @@ -717,7 +725,7 @@ export class CodeGenerationPhaseResult { } }, startMemory); - const createdGlobals = globals.map($ => { + const createdGlobals = globals.map(($) => { // TODO: If the value is a literal, do not defer initialization to starters const mut = 'var'; // TODO: $ instanceof Nodes.ValDeclarationNode ? 'const' : 'var'; @@ -727,19 +735,19 @@ export class CodeGenerationPhaseResult { const identifier = t.identifier(local.name); starters.push( - t.instruction('global.set', [identifier, ...emitList($.decl.value, document, this.parsingContext)]) + t.instruction('global.set', [identifier, ...emitList($.decl.value, document, this.parsingContext)]), ); return t.global( t.globalType(binaryenType, mut), [t.objectInstruction('const', binaryenType, [t.numberLiteralFromRaw(0)])], // emitList($.decl.value, compilationPhase.document), - identifier + identifier, ); }); - functions.forEach($ => { + functions.forEach(($) => { if ($.parent instanceof Nodes.TraitDirectiveNode) return; - $.functions.forEach(fun => { + $.functions.forEach((fun) => { const functionName = fun.functionNode.functionName; if (functionName.hasAnnotation(annotations.Extern)) { @@ -750,8 +758,8 @@ export class CodeGenerationPhaseResult { t.moduleImport( extern.module, extern.fn, - t.funcImportDescr(t.identifier(functionName.internalIdentifier), fnType) - ) + t.funcImportDescr(t.identifier(functionName.internalIdentifier), fnType), + ), ); } else { createdFunctions.push(emitFunction(fun.functionNode, document, this.parsingContext)); @@ -763,8 +771,8 @@ export class CodeGenerationPhaseResult { exportedElements.push( t.moduleExport( exportedAnnotation.exportedName, - t.moduleExportDescr('Func', t.identifier(functionName.internalIdentifier)) - ) + t.moduleExportDescr('Func', t.identifier(functionName.internalIdentifier)), + ), ); } }); @@ -775,7 +783,7 @@ export class CodeGenerationPhaseResult { moduleParts: [...dataSection, ...createdGlobals, ...(exports ? exportedElements : []), ...createdFunctions], starters, endMemory, - imports + imports, }; } @@ -784,7 +792,7 @@ export class CodeGenerationPhaseResult { const moduleList = getModuleSet(this.document, this.parsingContext); - moduleList.forEach($ => { + moduleList.forEach(($) => { const compilation = this.parsingContext.getPhase($, PhaseFlags.Compilation); if (!exportList.includes(compilation)) { @@ -796,7 +804,7 @@ export class CodeGenerationPhaseResult { const moduleParts: any[] = []; - const generatedModules = exportList.map($ => { + const generatedModules = exportList.map(($) => { const ret = this.generatePhase($, currentMemory); currentMemory = ret.endMemory; moduleParts.push(...ret.imports); @@ -807,7 +815,7 @@ export class CodeGenerationPhaseResult { const tableElems = this.parsingContext.getOrderedTable(); - this.parsingContext.signatures.forEach($ => moduleParts.push($)); + this.parsingContext.signatures.forEach(($) => moduleParts.push($)); const table = t.table('funcref', t.limit(tableElems.length), t.identifier('lys::internal-functions')); const elem = t.elem( @@ -816,7 +824,7 @@ export class CodeGenerationPhaseResult { // offset [t.objectInstruction('const', 'i32', [t.numberLiteralFromRaw(0)])], // elems - tableElems.map(x => t.identifier(x)) + tableElems.map((x) => t.identifier(x)), ); const memory = t.memory(t.limit(1), t.identifier('mem')); @@ -830,7 +838,7 @@ export class CodeGenerationPhaseResult { moduleParts.push(memory); moduleParts.push(t.moduleExport('memory', t.moduleExportDescr('Memory', t.identifier('mem')))); - generatedModules.reverse().forEach(ret => { + generatedModules.reverse().forEach((ret) => { moduleParts.push(...ret.moduleParts); starters.push(...ret.starters); }); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index eca1e55..84db7a6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -515,7 +515,7 @@ export class UnionType extends Type { } if (nativeTypes.size === 1) { - return nativeTypes.values().next().value; + return nativeTypes.values().next().value!; } else { throw new Error('Cannot find a suitable low level type for ' + this.toString()); } diff --git a/src/index-bin.ts b/src/index-bin.ts index c4a0654..0d8a21e 100644 --- a/src/index-bin.ts +++ b/src/index-bin.ts @@ -313,7 +313,7 @@ export async function main(cwd: string, argv: string[]) { let running = false; watch(cwd, { recursive: true }, (event, fileName) => { - const fqn = parsingContext.getModuleFQNForFile(fileName); + const fqn = parsingContext.getModuleFQNForFile(fileName!); const inContext = parsingContext.modulesInContext.has(fqn); if (inContext) { diff --git a/test/fixtures/compiler/0-struct.lys.optimized.wast b/test/fixtures/compiler/0-struct.lys.optimized.wast index 5a87821..397602c 100644 --- a/test/fixtures/compiler/0-struct.lys.optimized.wast +++ b/test/fixtures/compiler/0-struct.lys.optimized.wast @@ -1,71 +1,69 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $none_=>_i64 (func (result i64))) + (type $0 (func (result i32))) + (type $1 (func)) + (type $2 (func (param i32 i32))) + (type $3 (func (param i32))) + (type $4 (func (param i32) (result i32))) + (type $5 (func (param i64) (result i32))) (import "test" "registerAssertion" (func $fimport$0 (param i32 i32))) - (memory $0 1) - (data (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") (global $global$0 (mut i64) (i64.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 49) "\02\00\00\000") + (data $20 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getLastErrorMessage" (func $0)) (export "test_getMaxMemory" (func $2)) - (export "isRed" (func $7)) - (export "testColors" (func $8)) - (start $9) + (export "isRed" (func $4)) + (export "testColors" (func $5)) + (start $6) (func $0 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$0) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$0) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) (func $1 (param $0 i32) @@ -78,7 +76,7 @@ (i32.eqz (local.get $0) ) - (block + (then (i64.store (i32.wrap_i64 (local.tee $1 @@ -102,21 +100,9 @@ ) ) (func $2 (result i32) - (global.get $global$4) + (global.get $global$3) ) (func $3 (param $0 i32) (result i32) - (local $1 i32) - (call $5 - (local.tee $1 - (call $4 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $4 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -125,32 +111,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$2) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$1) (i32.add (i32.add (local.tee $1 - (global.get $global$4) + (global.get $global$3) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -164,98 +154,105 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$4 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$3 + (local.get $2) ) - ) - (func $5 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $6 (result i64) + (func $4 (param $0 i64) (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) + ) + (i32.const 1) + ) + ) + (func $5 (local $0 i64) + (local $1 i32) + (call $1 + (i32.const 1) + ) + (call $1 + (i32.const 1) + ) + (call $1 + (i32.const 1) + ) (i32.store (i32.wrap_i64 (local.tee $0 @@ -273,8 +270,10 @@ ) (i32.store (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $1 + (i32.wrap_i64 + (local.get $0) + ) ) (i32.const 4) ) @@ -282,41 +281,16 @@ ) (i32.store (i32.add - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) (i32.const 8) ) (i32.const 5) ) - (local.get $0) - ) - (func $7 (param $0 i64) (result i32) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 1) - ) - ) - (func $8 - (call $1 - (i32.const 1) - ) - (call $1 - (i32.const 1) - ) - (call $1 - (i32.const 1) - ) (call $1 (i32.ne (i32.wrap_i64 (i64.shr_u - (call $6) + (local.get $0) (i64.const 32) ) ) @@ -324,7 +298,7 @@ ) ) ) - (func $9 + (func $6 (global.set $global$0 (i64.const 8589934592) ) @@ -337,8 +311,5 @@ (global.set $global$3 (i32.const 65536) ) - (global.set $global$4 - (global.get $global$3) - ) ) ) diff --git a/test/fixtures/compiler/0-wast.lys.optimized.wast b/test/fixtures/compiler/0-wast.lys.optimized.wast index b2244c7..ffc46e7 100644 --- a/test/fixtures/compiler/0-wast.lys.optimized.wast +++ b/test/fixtures/compiler/0-wast.lys.optimized.wast @@ -1,33 +1,32 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "main" (func $2)) - (start $3) + (export "main" (func $1)) + (start $2) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) - (func $1 + (func $1 (result i32) (local $0 i32) (local $1 i32) (local $2 i32) - (local $3 i32) (if - (i32.lt_u + (i32.eqz (global.get $global$1) - (i32.const 1) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u @@ -37,7 +36,7 @@ (global.get $global$0) (i32.add (local.tee $0 - (global.get $global$3) + (global.get $global$2) ) (i32.const 32) ) @@ -55,60 +54,41 @@ (i32.const 16) ) ) - (block + (then (drop (memory.grow (select (local.get $2) - (local.tee $3 - (local.tee $0 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) + (local.tee $0 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $1) + (local.get $0) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) - (i32.gt_u - (local.get $2) - (local.get $3) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow + (i32.lt_u (local.get $0) + (local.get $2) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 + (global.set $global$2 (local.get $1) ) - ) - (func $2 (result i32) - (call $1) (i32.const 9) ) - (func $3 + (func $2 (global.set $global$0 (i32.const 15) ) @@ -118,8 +98,5 @@ (global.set $global$2 (i32.const 65536) ) - (global.set $global$3 - (global.get $global$2) - ) ) ) diff --git a/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast b/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast index b47e997..999d4ca 100644 --- a/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast +++ b/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast @@ -1,49 +1,48 @@ (module - (type $i64_=>_none (func (param i64))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) - (type $none_=>_none (func)) - (type $i64_i64_=>_none (func (param i64 i64))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_=>_i64 (func (param i32) (result i64))) - (type $i64_=>_i64 (func (param i64) (result i64))) - (type $i64_i64_=>_i64 (func (param i64 i64) (result i64))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (param i32 i32))) + (type $1 (func (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func (param i32 i32 i32))) + (type $4 (func (param i32))) + (type $5 (func (param i32) (result i64))) + (type $6 (func (param i64) (result i64))) + (type $7 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "keccak" (func $15)) - (start $16) + (export "keccak" (func $7)) + (start $8) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) - (local $4 i32) (if (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u @@ -54,14 +53,14 @@ (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -81,52 +80,36 @@ (i32.const 16) ) ) - (block + (then (drop (memory.grow (select (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (local.tee $3 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $0) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 + (global.set $global$2 (local.get $0) ) (i32.add @@ -148,13 +131,13 @@ (local.get $0) ) ) - (loop $label$1 + (loop $label (if (i32.gt_u (local.get $2) (local.get $3) ) - (block + (then (i32.store8 (i32.add (local.get $3) @@ -177,7 +160,7 @@ (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) @@ -189,13 +172,13 @@ (local.get $1) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 (local.get $0) (i32.load8_u @@ -208,2096 +191,1492 @@ (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) ) - (func $4 (param $0 i64) (param $1 i64) (result i64) + (func $4 (param $0 i32) (param $1 i32) (local $2 i32) - (local $3 i64) - (call $3 - (local.tee $2 - (call $1 - (i32.const 16) - ) - ) - (i32.const 16) - ) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (local $17 i32) + (local $18 i32) + (local $19 i32) + (local $20 i32) + (local $21 i32) + (local $22 i32) + (local $23 i32) + (local $24 i32) + (local $25 i32) + (local $26 i64) + (local $27 i64) + (local $28 i64) + (local $29 i64) + (local $30 i64) + (local $31 i64) + (local $32 i64) + (local $33 i64) + (local $34 i64) + (local $35 i64) (i64.store (i32.wrap_i64 - (local.tee $3 - (i64.or - (i64.extend_i32_u - (local.get $2) - ) - (i64.const 4294967296) + (local.tee $27 + (i64.extend_i32_s + (local.get $1) ) ) ) - (local.get $0) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $3) - ) - (i32.const 8) - ) - (local.get $1) - ) - (local.get $3) - ) - (func $5 (param $0 i64) - (local $1 i64) - (local $2 i64) - (local $3 i64) - (local $4 i64) - (local $5 i64) - (local $6 i64) - (local.set $2 (i64.xor (i64.load - (i32.add + (local.tee $3 (i32.wrap_i64 - (local.get $0) + (local.get $27) ) - (i32.const 160) ) ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.tee $26 + (i64.extend_i32_s (local.get $0) ) - (i32.const 120) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 80) - ) - ) - (i64.xor - (i64.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 40) - ) - ) ) ) ) ) ) - (local.set $3 + (i64.store + (local.tee $0 + (i32.add + (local.get $3) + (i32.const 8) + ) + ) (i64.xor (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 176) - ) + (local.get $0) ) - (i64.xor - (i64.load - (i32.add + (i64.load + (i32.add + (local.tee $0 (i32.wrap_i64 - (local.get $0) + (local.get $26) ) - (i32.const 136) ) + (i32.const 8) ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 96) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 16) - ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 56) - ) - ) - ) + ) + ) + ) + (i64.store + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 16) + ) + ) + (i64.xor + (i64.load + (local.get $2) + ) + (i64.load + (i32.add + (local.get $0) + (i32.const 16) ) ) ) ) - (local.set $4 + (i64.store + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 24) + ) + ) (i64.xor + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 184) + (local.get $0) + (i32.const 24) ) ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 144) - ) + ) + ) + (i64.store + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 32) + ) + ) + (i64.xor + (i64.load + (local.get $2) + ) + (i64.load + (i32.add + (local.get $0) + (i32.const 32) ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 104) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 24) - ) - ) - (i64.load - (i32.sub - (i32.wrap_i64 - (local.get $0) - ) - (i32.const -64) - ) - ) - ) + ) + ) + ) + (i64.store + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 40) + ) + ) + (i64.xor + (i64.load + (local.get $2) + ) + (i64.load + (i32.add + (local.get $0) + (i32.const 40) ) ) ) ) (i64.store - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 48) + ) ) (i64.xor - (local.tee $1 - (i64.xor - (local.tee $5 - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 192) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 152) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 112) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 32) - ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 72) - ) - ) - ) - ) - ) - ) - ) - (i64.rotl - (local.tee $6 - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 168) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 128) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 88) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 8) - ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 48) - ) - ) - ) - ) - ) - ) - ) - (i64.const 1) - ) - ) + (i64.load + (local.get $2) ) (i64.load - (i32.wrap_i64 + (i32.add (local.get $0) + (i32.const 48) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 56) ) - (i32.const 40) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 40) + (local.get $0) + (i32.const 56) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.sub + (local.get $3) + (i32.const -64) ) - (i32.const 80) ) (i64.xor - (local.get $1) (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 80) + (local.get $2) + ) + (i64.load + (i32.sub + (local.get $0) + (i32.const -64) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 72) ) - (i32.const 120) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 120) + (local.get $0) + (i32.const 72) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 80) ) - (i32.const 160) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 160) + (local.get $0) + (i32.const 80) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 88) ) - (i32.const 8) ) (i64.xor - (local.tee $1 - (i64.xor - (i64.rotl - (local.get $3) - (i64.const 1) - ) - (local.get $2) - ) + (i64.load + (local.get $2) ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 8) + (local.get $0) + (i32.const 88) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 96) ) - (i32.const 48) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 48) + (local.get $0) + (i32.const 96) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 104) ) - (i32.const 88) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 88) + (local.get $0) + (i32.const 104) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 112) ) - (i32.const 128) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 128) + (local.get $0) + (i32.const 112) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.add + (local.get $3) + (i32.const 120) ) - (i32.const 168) ) (i64.xor - (local.get $1) + (i64.load + (local.get $2) + ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 168) + (local.get $0) + (i32.const 120) ) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 16) - ) - (i64.xor - (local.tee $1 - (i64.xor - (i64.rotl - (local.get $4) - (i64.const 1) - ) - (local.get $6) - ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 16) - ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $3 + (i32.add + (local.get $3) + (i32.const 128) ) - (i32.const 56) ) (i64.xor - (local.get $1) (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 56) - ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.get $3) ) - (i32.const 96) - ) - (i64.xor - (local.get $1) (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 96) + (local.get $0) + (i32.const 128) ) ) ) ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 136) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 136) - ) + (local.set $31 + (i64.extend_i32_s + (i32.add + (local.get $1) + (i32.const 400) ) ) ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 176) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 176) - ) + (local.set $32 + (i64.extend_i32_s + (i32.add + (local.get $1) + (i32.const 592) ) ) ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.set $3 + (i32.const 0) + ) + (loop $label2 + (if + (i32.lt_s + (local.get $3) + (i32.const 24) ) - (i32.const 24) - ) - (i64.xor - (local.tee $1 - (i64.xor - (i64.rotl - (local.get $5) - (i64.const 1) + (then + (local.set $28 + (i64.xor + (i64.load + (local.tee $25 + (i32.add + (local.tee $0 + (i32.wrap_i64 + (local.get $27) + ) + ) + (i32.const 160) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 120) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $2 + (i32.add + (local.get $0) + (i32.const 80) + ) + ) + ) + (i64.xor + (local.tee $33 + (i64.load + (local.get $0) + ) + ) + (i64.load + (local.tee $4 + (i32.add + (local.get $0) + (i32.const 40) + ) + ) + ) + ) + ) + ) ) - (local.get $3) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (local.set $29 + (i64.xor + (i64.load + (local.tee $5 + (i32.add + (local.get $0) + (i32.const 176) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $6 + (i32.add + (local.get $0) + (i32.const 136) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $7 + (i32.add + (local.get $0) + (i32.const 96) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $8 + (i32.add + (local.get $0) + (i32.const 16) + ) + ) + ) + (i64.load + (local.tee $9 + (i32.add + (local.get $0) + (i32.const 56) + ) + ) + ) + ) + ) + ) ) - (i32.const 24) ) - ) - ) - ) - (i64.store - (i32.sub - (i32.wrap_i64 - (local.get $0) - ) - (i32.const -64) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.sub - (i32.wrap_i64 - (local.get $0) + (local.set $30 + (i64.xor + (i64.load + (local.tee $10 + (i32.add + (local.get $0) + (i32.const 184) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $11 + (i32.add + (local.get $0) + (i32.const 144) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $12 + (i32.add + (local.get $0) + (i32.const 104) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $13 + (i32.add + (local.get $0) + (i32.const 24) + ) + ) + ) + (i64.load + (local.tee $14 + (i32.sub + (local.get $0) + (i32.const -64) + ) + ) + ) + ) + ) + ) ) - (i32.const -64) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 104) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $0) + (i64.xor + (local.get $33) + (local.tee $26 + (i64.xor + (local.tee $34 + (i64.xor + (i64.load + (local.tee $15 + (i32.add + (local.get $0) + (i32.const 192) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $16 + (i32.add + (local.get $0) + (i32.const 152) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $17 + (i32.add + (local.get $0) + (i32.const 112) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $18 + (i32.add + (local.get $0) + (i32.const 32) + ) + ) + ) + (i64.load + (local.tee $19 + (i32.add + (local.get $0) + (i32.const 72) + ) + ) + ) + ) + ) + ) + ) + ) + (i64.rotl + (local.tee $35 + (i64.xor + (i64.load + (local.tee $20 + (i32.add + (local.get $0) + (i32.const 168) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $21 + (i32.add + (local.get $0) + (i32.const 128) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $22 + (i32.add + (local.get $0) + (i32.const 88) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $23 + (i32.add + (local.get $0) + (i32.const 8) + ) + ) + ) + (i64.load + (local.tee $24 + (i32.add + (local.get $0) + (i32.const 48) + ) + ) + ) + ) + ) + ) + ) + ) + (i64.const 1) + ) + ) + ) ) - (i32.const 104) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 144) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $4) + (i64.xor + (local.get $26) + (i64.load + (local.get $4) + ) ) - (i32.const 144) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 184) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $2) + (i64.xor + (local.get $26) + (i64.load + (local.get $2) + ) ) - (i32.const 184) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 32) - ) - (i64.xor - (local.tee $1 - (i64.xor - (i64.rotl - (local.get $2) - (i64.const 1) + (i64.store + (local.get $1) + (i64.xor + (local.get $26) + (i64.load + (local.get $1) + ) ) - (local.get $4) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $25) + (i64.xor + (local.get $26) + (i64.load + (i32.add + (local.get $0) + (i32.const 160) + ) + ) ) - (i32.const 32) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 72) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $23) + (i64.xor + (local.tee $26 + (i64.xor + (i64.rotl + (local.get $29) + (i64.const 1) + ) + (local.get $28) + ) + ) + (i64.load + (local.get $23) + ) ) - (i32.const 72) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 112) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $24) + (i64.xor + (local.get $26) + (i64.load + (local.get $24) + ) ) - (i32.const 112) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 152) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $22) + (i64.xor + (local.get $26) + (i64.load + (local.get $22) + ) ) - (i32.const 152) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 192) - ) - (i64.xor - (local.get $1) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) + (i64.store + (local.get $21) + (i64.xor + (local.get $26) + (i64.load + (local.get $21) + ) ) - (i32.const 192) ) - ) - ) - ) - ) - (func $6 (param $0 i64) (param $1 i64) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (loop $label$1 - (if - (i32.lt_u - (local.get $2) - (i32.const 24) - ) - (block - (local.set $4 - (i64.rotl + (i64.store + (local.get $20) + (i64.xor + (local.get $26) (i64.load - (i32.add - (local.tee $3 - (i32.shl - (i32.add - (local.get $2) - (i32.const 1) - ) - (i32.const 3) - ) - ) - (i32.wrap_i64 - (local.get $0) - ) - ) + (local.get $20) ) - (i64.load8_u - (i32.add - (local.get $2) - (i32.wrap_i64 - (local.get $1) + ) + ) + (i64.store + (local.get $8) + (i64.xor + (local.tee $26 + (i64.xor + (i64.rotl + (local.get $30) + (i64.const 1) ) + (local.get $35) ) ) + (i64.load + (local.get $8) + ) ) ) (i64.store - (i32.add - (local.get $3) - (i32.wrap_i64 - (local.get $0) - ) - ) - (local.get $4) - ) - (local.set $2 - (i32.add - (local.get $2) - (i32.const 1) - ) - ) - (br $label$1) - ) - ) - ) - ) - (func $7 (param $0 i64) - (local $1 i64) - (local.set $1 - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 8) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 8) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 48) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 48) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 72) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 72) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 176) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 176) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 112) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 112) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 160) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 160) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 16) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 16) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 96) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 96) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 104) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 104) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 152) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 152) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 184) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 184) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 120) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 120) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 32) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 32) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 192) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 192) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 168) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 168) - ) - (i64.load - (i32.sub - (i32.wrap_i64 - (local.get $0) - ) - (i32.const -64) - ) - ) - ) - (i64.store - (i32.sub - (i32.wrap_i64 - (local.get $0) - ) - (i32.const -64) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 128) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 128) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 40) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 40) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 24) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 24) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 144) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 144) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 136) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 136) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 88) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 88) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 56) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 56) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 80) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 80) - ) - (local.get $1) - ) - ) - (func $8 (param $0 i64) - (local $1 i32) - (local $2 i64) - (local $3 i64) - (loop $label$1 - (if - (i32.lt_u - (local.get $1) - (i32.const 25) - ) - (block - (local.set $2 - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (local.get $1) - (i32.const 3) - ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (local.get $1) - (i32.const 3) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (local.get $1) - (i32.const 3) - ) - ) - ) - (i64.and - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 2) - ) - (i32.const 3) - ) - ) - ) - (i64.xor - (local.tee $3 - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 1) - ) - (i32.const 3) - ) - ) - ) - ) - (i64.const -1) - ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 1) - ) - (i32.const 3) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 1) - ) - (i32.const 3) - ) - ) - ) - (i64.and - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 3) - ) - (i32.const 3) - ) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 2) - ) - (i32.const 3) - ) - ) - ) - (i64.const -1) - ) + (local.get $9) + (i64.xor + (local.get $26) + (i64.load + (local.get $9) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 2) - ) - (i32.const 3) - ) - ) + (local.get $7) (i64.xor + (local.get $26) (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 2) - ) - (i32.const 3) - ) - ) - ) - (i64.and - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 4) - ) - (i32.const 3) - ) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 3) - ) - (i32.const 3) - ) - ) - ) - (i64.const -1) - ) + (local.get $7) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 3) - ) - (i32.const 3) - ) - ) + (local.get $6) (i64.xor + (local.get $26) (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 3) - ) - (i32.const 3) - ) - ) - ) - (i64.and - (local.get $2) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 4) - ) - (i32.const 3) - ) - ) - ) - (i64.const -1) - ) + (local.get $6) ) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 4) - ) - (i32.const 3) - ) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.shl - (i32.add - (local.get $1) - (i32.const 4) - ) - (i32.const 3) - ) - ) + (local.get $5) + (i64.xor + (local.get $26) + (i64.load + (local.get $5) ) - (i64.and - (local.get $3) + ) + ) + (i64.store + (local.get $13) + (i64.xor + (local.tee $26 (i64.xor - (local.get $2) - (i64.const -1) + (i64.rotl + (local.get $34) + (i64.const 1) + ) + (local.get $29) ) ) + (i64.load + (local.get $13) + ) ) ) - (local.set $1 - (i32.add - (local.get $1) - (i32.const 5) + (i64.store + (local.get $14) + (i64.xor + (local.get $26) + (i64.load + (local.get $14) + ) ) ) - (br $label$1) - ) - ) - ) - ) - (func $9 (param $0 i32) - (local $1 i64) - (local $2 i64) - (local $3 i64) - (local.set $2 - (i64.extend_i32_s - (i32.add - (local.get $0) - (i32.const 400) - ) - ) - ) - (local.set $3 - (i64.extend_i32_s - (i32.add - (local.get $0) - (i32.const 592) - ) - ) - ) - (local.set $1 - (i64.extend_i32_s - (local.get $0) - ) - ) - (local.set $0 - (i32.const 0) - ) - (loop $label$1 - (if - (i32.lt_s - (local.get $0) - (i32.const 24) - ) - (block - (call $5 - (local.get $1) - ) - (call $6 - (local.get $1) - (local.get $3) - ) - (call $7 - (local.get $1) - ) - (call $8 - (local.get $1) - ) (i64.store - (i32.wrap_i64 - (local.get $1) + (local.get $12) + (i64.xor + (local.get $26) + (i64.load + (local.get $12) + ) ) + ) + (i64.store + (local.get $11) (i64.xor + (local.get $26) (i64.load - (i32.wrap_i64 - (local.get $1) - ) + (local.get $11) ) + ) + ) + (i64.store + (local.get $10) + (i64.xor + (local.get $26) (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.shl - (local.get $0) - (i32.const 3) + (local.get $10) + ) + ) + ) + (i64.store + (local.get $18) + (i64.xor + (local.tee $26 + (i64.xor + (i64.rotl + (local.get $28) + (i64.const 1) ) + (local.get $30) ) ) + (i64.load + (local.get $18) + ) ) ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) + (i64.store + (local.get $19) + (i64.xor + (local.get $26) + (i64.load + (local.get $19) + ) ) ) - (br $label$1) - ) - ) - ) - ) - (func $10 (param $0 i32) (param $1 i32) - (local $2 i64) - (local $3 i64) - (i64.store - (i32.wrap_i64 - (local.tee $2 - (i64.extend_i32_s - (local.get $1) - ) - ) - ) - (i64.xor - (i64.load - (i32.wrap_i64 - (local.get $2) - ) - ) - (i64.load - (i32.wrap_i64 - (local.tee $3 - (i64.extend_i32_s - (local.get $0) + (i64.store + (local.get $17) + (i64.xor + (local.get $26) + (i64.load + (local.get $17) ) ) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 8) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $16) + (i64.xor + (local.get $26) + (i64.load + (local.get $16) + ) ) - (i32.const 8) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $15) + (i64.xor + (local.get $26) + (i64.load + (local.get $15) + ) ) - (i32.const 8) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 16) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 16) + (local.set $0 + (i32.const 0) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (loop $label + (if + (i32.lt_u + (local.get $0) + (i32.const 24) + ) + (then + (local.set $26 + (i64.rotl + (i64.load + (i32.add + (local.tee $2 + (i32.wrap_i64 + (local.get $27) + ) + ) + (local.tee $4 + (i32.shl + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 1) + ) + ) + (i32.const 3) + ) + ) + ) + ) + (i64.load8_u + (i32.add + (local.get $0) + (i32.wrap_i64 + (local.get $32) + ) + ) + ) + ) + ) + (i64.store + (i32.add + (local.get $2) + (local.get $4) + ) + (local.get $26) + ) + (local.set $0 + (local.get $1) + ) + (br $label) + ) ) - (i32.const 16) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 24) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (local.set $26 + (i64.load + (local.tee $1 + (i32.add + (local.tee $0 + (i32.wrap_i64 + (local.get $27) + ) + ) + (i32.const 8) + ) + ) ) - (i32.const 24) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 48) + ) + ) ) - (i32.const 24) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 32) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 72) + ) + ) ) - (i32.const 32) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 176) + ) + ) ) - (i32.const 32) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 40) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 112) + ) + ) ) - (i32.const 40) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 160) + ) + ) ) - (i32.const 40) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 48) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 16) + ) + ) ) - (i32.const 48) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 96) + ) + ) ) - (i32.const 48) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 56) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 104) + ) + ) ) - (i32.const 56) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 152) + ) + ) ) - (i32.const 56) ) - ) - ) - ) - (i64.store - (i32.sub - (i32.wrap_i64 - (local.get $2) - ) - (i32.const -64) - ) - (i64.xor - (i64.load - (i32.sub - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 184) + ) + ) ) - (i32.const -64) ) - ) - (i64.load - (i32.sub - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 120) + ) + ) ) - (i32.const -64) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 72) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 32) + ) + ) ) - (i32.const 72) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 192) + ) + ) ) - (i32.const 72) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 80) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 168) + ) + ) ) - (i32.const 80) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.sub + (local.get $0) + (i32.const -64) + ) + ) ) - (i32.const 80) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 88) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 128) + ) + ) ) - (i32.const 88) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 40) + ) + ) ) - (i32.const 88) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 96) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 24) + ) + ) ) - (i32.const 96) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 144) + ) + ) ) - (i32.const 96) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 104) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 136) + ) + ) ) - (i32.const 104) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 88) + ) + ) ) - (i32.const 104) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 112) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 56) + ) + ) ) - (i32.const 112) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.get $1) + (i64.load + (local.tee $0 + (i32.add + (local.get $0) + (i32.const 80) + ) + ) ) - (i32.const 112) ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 120) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.store + (local.get $0) + (local.get $26) + ) + (local.set $0 + (i32.const 0) + ) + (loop $label1 + (if + (i32.lt_u + (local.get $0) + (i32.const 25) + ) + (then + (local.set $26 + (i64.load + (i32.add + (local.tee $1 + (i32.wrap_i64 + (local.get $27) + ) + ) + (local.tee $2 + (i32.shl + (local.get $0) + (i32.const 3) + ) + ) + ) + ) + ) + (i64.store + (local.tee $2 + (i32.add + (local.get $1) + (local.get $2) + ) + ) + (i64.xor + (i64.load + (local.get $2) + ) + (i64.and + (i64.load + (i32.add + (local.tee $2 + (i32.shl + (i32.add + (local.get $0) + (i32.const 2) + ) + (i32.const 3) + ) + ) + (local.get $1) + ) + ) + (i64.xor + (local.tee $28 + (i64.load + (i32.add + (local.tee $4 + (i32.shl + (i32.add + (local.get $0) + (i32.const 1) + ) + (i32.const 3) + ) + ) + (local.get $1) + ) + ) + ) + (i64.const -1) + ) + ) + ) + ) + (i64.store + (local.tee $4 + (i32.add + (local.get $1) + (local.get $4) + ) + ) + (i64.xor + (i64.load + (local.get $4) + ) + (i64.and + (i64.load + (i32.add + (local.tee $4 + (i32.shl + (i32.add + (local.get $0) + (i32.const 3) + ) + (i32.const 3) + ) + ) + (local.get $1) + ) + ) + (i64.xor + (i64.load + (local.tee $5 + (i32.add + (local.get $1) + (local.get $2) + ) + ) + ) + (i64.const -1) + ) + ) + ) + ) + (i64.store + (local.get $5) + (i64.xor + (i64.load + (i32.add + (local.get $1) + (local.get $2) + ) + ) + (i64.and + (i64.load + (i32.add + (local.get $1) + (local.tee $2 + (i32.shl + (i32.add + (local.get $0) + (i32.const 4) + ) + (i32.const 3) + ) + ) + ) + ) + (i64.xor + (i64.load + (local.tee $5 + (i32.add + (local.get $1) + (local.get $4) + ) + ) + ) + (i64.const -1) + ) + ) + ) + ) + (i64.store + (local.get $5) + (i64.xor + (i64.load + (i32.add + (local.get $1) + (local.get $4) + ) + ) + (i64.and + (local.get $26) + (i64.xor + (i64.load + (local.tee $4 + (i32.add + (local.get $1) + (local.get $2) + ) + ) + ) + (i64.const -1) + ) + ) + ) + ) + (i64.store + (local.get $4) + (i64.xor + (i64.load + (i32.add + (local.get $1) + (local.get $2) + ) + ) + (i64.and + (local.get $28) + (i64.xor + (local.get $26) + (i64.const -1) + ) + ) + ) + ) + (local.set $0 + (i32.add + (local.get $0) + (i32.const 5) + ) + ) + (br $label1) + ) ) - (i32.const 120) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $3) + (i64.store + (local.tee $0 + (i32.wrap_i64 + (local.get $27) + ) ) - (i32.const 120) - ) - ) - ) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $2) - ) - (i32.const 128) - ) - (i64.xor - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $2) + (i64.xor + (i64.load + (local.get $0) + ) + (i64.load + (i32.add + (i32.wrap_i64 + (local.get $31) + ) + (i32.shl + (local.get $3) + (i32.const 3) + ) + ) + ) ) - (i32.const 128) ) - ) - (i64.load - (i32.add - (i32.wrap_i64 + (local.set $3 + (i32.add (local.get $3) + (i32.const 1) ) - (i32.const 128) ) + (br $label2) ) ) ) - (call $9 - (local.get $1) - ) ) - (func $11 (param $0 i32) + (func $5 (param $0 i32) (local $1 i64) + (local $2 i32) (call $3 (local.get $0) (i32.const 616) @@ -2317,8 +1696,10 @@ ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) + (local.tee $2 + (i32.wrap_i64 + (local.get $1) + ) ) (i32.const 8) ) @@ -2326,198 +1707,154 @@ ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 16) ) (i64.const -9223372036854742902) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 24) ) (i64.const -9223372034707259392) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 32) ) (i64.const 32907) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 40) ) (i64.const 2147483649) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 48) ) (i64.const -9223372034707259263) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 56) ) (i64.const -9223372036854743031) ) (i64.store (i32.sub - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const -64) ) (i64.const 138) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 72) ) (i64.const 136) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 80) ) (i64.const 2147516425) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 88) ) (i64.const 2147483658) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 96) ) (i64.const 2147516555) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 104) ) (i64.const -9223372036854775669) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 112) ) (i64.const -9223372036854742903) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 120) ) (i64.const -9223372036854743037) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 128) ) (i64.const -9223372036854743038) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 136) ) (i64.const -9223372036854775680) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 144) ) (i64.const 32778) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 152) ) (i64.const -9223372034707292150) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 160) ) (i64.const -9223372034707259263) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 168) ) (i64.const -9223372036854742912) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 176) ) (i64.const 2147483649) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $1) - ) + (local.get $2) (i32.const 184) ) (i64.const -9223372034707259384) @@ -2743,26 +2080,94 @@ (i32.const 14) ) ) - (func $12 (param $0 i32) (param $1 i32) (param $2 i32) + (func $6 (param $0 i32) (result i64) + (local $1 i32) + (local $2 i32) + (call $3 + (local.tee $1 + (call $1 + (local.tee $2 + (i32.add + (local.get $0) + (i32.const 4) + ) + ) + ) + ) + (local.get $2) + ) + (i32.store + (local.get $1) + (local.get $0) + ) + (i64.or + (i64.extend_i32_u + (local.get $1) + ) + (i64.const 38654705664) + ) + ) + (func $7 (param $0 i64) (result i64) + (local $1 i32) + (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i64) - (local $7 i32) - (local.set $5 + (local $6 i32) + (local $7 i64) + (local $8 i64) + (call $5 (i32.add - (local.get $0) + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (global.get $global$3) + ) + ) + ) + (i32.const 4) + ) + ) + (local.set $3 + (i32.add + (local.tee $1 + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 4) + ) + ) + (local.set $2 + (i32.load + (local.get $1) + ) + ) + (local.set $6 + (i32.add + (local.tee $5 + (i32.add + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (global.get $global$3) + ) + ) + ) + (i32.const 4) + ) + ) (i32.const 208) ) ) (if - (local.tee $3 + (local.tee $4 (i32.load (i32.wrap_i64 - (local.tee $6 + (local.tee $0 (i64.extend_i32_s (i32.add - (local.get $0) + (local.get $5) (i32.const 200) ) ) @@ -2770,82 +2175,79 @@ ) ) ) - (block - (call $2 - (i32.add - (local.get $3) - (local.get $5) - ) - (block (result i32) - (local.set $7 - (local.get $1) - ) - (if - (i32.gt_u - (local.tee $4 - (i32.sub - (i32.const 136) - (local.get $3) - ) - ) - (local.get $2) - ) - (local.set $4 - (local.get $2) + (then + (if + (i32.gt_u + (local.tee $1 + (i32.sub + (i32.const 136) + (local.get $4) ) ) - (local.get $7) + (local.get $2) ) - (local.get $4) + (then + (local.set $1 + (local.get $2) + ) + ) + ) + (call $2 + (i32.add + (local.get $4) + (local.get $6) + ) + (local.get $3) + (local.get $1) ) (if (i32.eq - (local.tee $3 + (local.tee $4 (i32.add - (local.get $3) + (local.get $1) (local.get $4) ) ) (i32.const 136) ) - (block - (call $10 - (local.get $1) - (local.get $0) + (then + (call $4 + (local.get $3) + (local.get $5) ) - (local.set $3 + (local.set $4 (i32.const 0) ) ) ) (i32.store (i32.wrap_i64 - (local.get $6) + (local.get $0) ) - (local.get $3) + (local.get $4) ) (local.set $2 (i32.sub (local.get $2) - (local.get $4) + (local.get $1) ) ) ) ) - (loop $label$4 + (loop $label (if (i32.ge_u (local.get $2) (i32.const 136) ) - (block - (call $10 - (local.get $1) - (local.get $0) + (then + (call $4 + (local.get $3) + (local.get $5) ) - (local.set $1 + (local.set $3 (i32.add - (local.get $1) + (local.get $3) (i32.const 136) ) ) @@ -2855,43 +2257,65 @@ (i32.const 136) ) ) - (br $label$4) + (br $label) ) ) ) (if (local.get $2) - (block + (then (call $2 (i32.add - (local.get $3) - (local.get $5) + (local.get $4) + (local.get $6) ) - (local.get $1) + (local.get $3) (local.get $2) ) (i32.store (i32.wrap_i64 - (local.get $6) + (local.get $0) ) (i32.add (local.get $2) - (local.get $3) + (local.get $4) ) ) ) ) - ) - (func $13 (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (local $5 i64) - (local.set $4 + (local.set $6 + (i32.add + (i32.wrap_i64 + (i64.load + (i32.add + (local.tee $1 + (i32.wrap_i64 + (local.tee $7 + (global.get $global$3) + ) + ) + ) + (i32.const 8) + ) + ) + ) + (i32.const 4) + ) + ) + (local.set $0 (i64.extend_i32_s - (local.tee $3 + (local.tee $5 (i32.add - (local.get $0) + (local.tee $3 + (i32.add + (i32.wrap_i64 + (i64.load + (local.get $1) + ) + ) + (i32.const 4) + ) + ) (i32.const 208) ) ) @@ -2899,80 +2323,70 @@ ) (call $3 (i32.add - (local.tee $2 + (local.tee $1 (i32.load - (i32.wrap_i64 - (i64.extend_i32_s - (i32.add - (local.get $0) - (i32.const 200) - ) - ) + (i32.add + (local.get $3) + (i32.const 200) ) ) ) - (local.get $3) + (local.get $5) ) (i32.sub (i32.const 136) - (local.get $2) + (local.get $1) ) ) (i32.store8 - (i32.add - (local.get $2) - (i32.wrap_i64 - (local.get $4) + (local.tee $1 + (i32.add + (local.get $1) + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) ) ) (i32.or (i32.load8_u - (i32.add - (local.get $2) - (i32.wrap_i64 - (local.get $4) - ) - ) + (local.get $1) ) (i32.const 1) ) ) (i32.store8 - (i32.add - (i32.wrap_i64 - (local.get $4) + (local.tee $1 + (i32.add + (local.get $2) + (i32.const 135) ) - (i32.const 135) ) (i32.or (i32.load8_u - (i32.add - (i32.wrap_i64 - (local.get $4) - ) - (i32.const 135) - ) + (local.get $1) ) (i32.const 128) ) ) - (call $10 + (call $4 + (local.get $5) (local.get $3) - (local.get $0) ) (i64.store (i32.wrap_i64 - (local.tee $4 + (local.tee $8 (i64.extend_i32_s - (local.get $1) + (local.get $6) ) ) ) (i64.load (i32.wrap_i64 - (local.tee $5 + (local.tee $0 (i64.extend_i32_s - (local.get $0) + (local.get $3) ) ) ) @@ -2980,15 +2394,19 @@ ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $4) + (local.tee $2 + (i32.wrap_i64 + (local.get $8) + ) ) (i32.const 8) ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $5) + (local.tee $1 + (i32.wrap_i64 + (local.get $0) + ) ) (i32.const 8) ) @@ -2996,139 +2414,42 @@ ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $4) - ) + (local.get $2) (i32.const 16) ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $5) - ) + (local.get $1) (i32.const 16) ) ) ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $4) - ) + (local.get $2) (i32.const 24) ) (i64.load (i32.add - (i32.wrap_i64 - (local.get $5) - ) + (local.get $1) (i32.const 24) ) ) ) - ) - (func $14 (param $0 i32) (result i64) - (local $1 i32) - (local $2 i32) - (call $3 - (local.tee $1 - (call $1 - (local.tee $2 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - ) - ) - (local.get $2) - ) - (i32.store - (local.get $1) - (local.get $0) - ) - (i64.or - (i64.extend_i32_u - (local.get $1) - ) - (i64.const 38654705664) - ) - ) - (func $15 (param $0 i64) (result i64) - (call $11 - (i32.add - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (global.get $global$4) - ) - ) - ) - (i32.const 4) - ) - ) - (call $12 - (i32.add - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (global.get $global$4) - ) - ) - ) - (i32.const 4) - ) - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - ) - (call $13 - (i32.add - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.tee $0 - (global.get $global$4) - ) - ) - ) - ) - (i32.const 4) - ) - (i32.add - (i32.wrap_i64 - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 8) - ) - ) - ) - (i32.const 4) - ) - ) (i64.load (i32.add (i32.wrap_i64 - (local.get $0) + (local.get $7) ) (i32.const 8) ) ) ) - (func $16 + (func $8 (local $0 i64) (local $1 i64) + (local $2 i64) + (local $3 i32) (global.set $global$0 (i32.const 15) ) @@ -3138,20 +2459,17 @@ (global.set $global$2 (i32.const 65536) ) - (global.set $global$3 - (global.get $global$2) - ) (local.set $0 - (call $14 + (call $6 (i32.const 616) ) ) - (local.set $1 - (call $14 + (local.set $2 + (call $6 (i32.const 32) ) ) - (call $11 + (call $5 (i32.add (i32.wrap_i64 (local.get $0) @@ -3159,11 +2477,38 @@ (i32.const 4) ) ) - (global.set $global$4 - (call $4 - (local.get $0) - (local.get $1) + (call $3 + (local.tee $3 + (call $1 + (i32.const 16) + ) + ) + (i32.const 16) + ) + (i64.store + (i32.wrap_i64 + (local.tee $1 + (i64.or + (i64.extend_i32_u + (local.get $3) + ) + (i64.const 4294967296) + ) + ) + ) + (local.get $0) + ) + (i64.store + (i32.add + (i32.wrap_i64 + (local.get $1) + ) + (i32.const 8) ) + (local.get $2) + ) + (global.set $global$3 + (local.get $1) ) ) ) diff --git a/test/fixtures/compiler/a.lys.optimized.wast b/test/fixtures/compiler/a.lys.optimized.wast index 754488a..543f3fa 100644 --- a/test/fixtures/compiler/a.lys.optimized.wast +++ b/test/fixtures/compiler/a.lys.optimized.wast @@ -1,16 +1,16 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $f32_f32_=>_f32 (func (param f32 f32) (result f32))) - (type $none_=>_none (func)) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $f32_f64_=>_f32 (func (param f32 f64) (result f32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param f32 f32) (result f32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func (param f32 f64) (result f32))) + (type $4 (func (param i32 i32) (result i32))) + (type $5 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test" (func $2)) diff --git a/test/fixtures/compiler/b.lys.optimized.wast b/test/fixtures/compiler/b.lys.optimized.wast index edd3403..9807295 100644 --- a/test/fixtures/compiler/b.lys.optimized.wast +++ b/test/fixtures/compiler/b.lys.optimized.wast @@ -1,12 +1,12 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "outerFunction" (func $1)) diff --git a/test/fixtures/compiler/booleanLogic.lys.optimized.wast b/test/fixtures/compiler/booleanLogic.lys.optimized.wast index 5ec1d0d..3965d0c 100644 --- a/test/fixtures/compiler/booleanLogic.lys.optimized.wast +++ b/test/fixtures/compiler/booleanLogic.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32) (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test" (func $1)) diff --git a/test/fixtures/compiler/bytes.lys.optimized.wast b/test/fixtures/compiler/bytes.lys.optimized.wast index c69834f..409481c 100644 --- a/test/fixtures/compiler/bytes.lys.optimized.wast +++ b/test/fixtures/compiler/bytes.lys.optimized.wast @@ -1,16 +1,16 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_i64 (func (result i64))) - (memory $0 1) - (data (i32.const 59) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 72) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 87) "\02\00\00\000") - (data (i32.const 94) "\02\00\00\000") - (data (i32.const 16) "\0c\00\00\00a\00s\00d\00a\00s\00d") - (data (i32.const 33) "\10\00\00\00u\00t\00f\00 \00\ab\00\100\110\bb") + (type $0 (func (result i32))) + (type $1 (func (result i64))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 59) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 72) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 87) "\02\00\00\000") + (data $3 (i32.const 94) "\02\00\00\000") + (data $4 (i32.const 16) "\0c\00\00\00a\00s\00d\00a\00s\00d") + (data $5 (i32.const 33) "\10\00\00\00u\00t\00f\00 \00\ab\00\100\110\bb") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "main" (func $1)) diff --git a/test/fixtures/compiler/c.lys.optimized.wast b/test/fixtures/compiler/c.lys.optimized.wast index 28d98c9..f08305f 100644 --- a/test/fixtures/compiler/c.lys.optimized.wast +++ b/test/fixtures/compiler/c.lys.optimized.wast @@ -1,12 +1,12 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "outer" (func $1)) diff --git a/test/fixtures/compiler/deconstruct.lys.optimized.wast b/test/fixtures/compiler/deconstruct.lys.optimized.wast index 157692a..bba9880 100644 --- a/test/fixtures/compiler/deconstruct.lys.optimized.wast +++ b/test/fixtures/compiler/deconstruct.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i64) (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "isRed" (func $1)) @@ -16,33 +16,31 @@ (global.get $global$0) ) (func $1 (param $0 i64) (result i32) - (block $label$1 (result i32) + (local $1 i32) + (block $block (result i32) (if (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) ) ) (i32.const 1) ) - (block + (then (drop - (br_if $label$1 + (br_if $block (i32.const 0) (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 4) ) ) ) - (br $label$1 + (br $block (i32.eq (i32.load (i32.wrap_i64 diff --git a/test/fixtures/compiler/dynamicLhsMatch.lys.optimized.wast b/test/fixtures/compiler/dynamicLhsMatch.lys.optimized.wast index 21ca267..313ae55 100644 --- a/test/fixtures/compiler/dynamicLhsMatch.lys.optimized.wast +++ b/test/fixtures/compiler/dynamicLhsMatch.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32) (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test" (func $1)) @@ -17,10 +17,9 @@ (global.get $global$0) ) (func $1 (param $0 i32) (result i32) - (i32.eqz - (i32.eqz - (local.get $0) - ) + (i32.ne + (local.get $0) + (i32.const 0) ) ) (func $2 diff --git a/test/fixtures/compiler/emptyFn.lys.optimized.wast b/test/fixtures/compiler/emptyFn.lys.optimized.wast index 1d415ec..b0d91d2 100644 --- a/test/fixtures/compiler/emptyFn.lys.optimized.wast +++ b/test/fixtures/compiler/emptyFn.lys.optimized.wast @@ -1,12 +1,12 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func)) + (type $1 (func (result i32))) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "main" (func $1)) diff --git a/test/fixtures/compiler/extern.lys.optimized.wast b/test/fixtures/compiler/extern.lys.optimized.wast index 24ce8e6..2dc186c 100644 --- a/test/fixtures/compiler/extern.lys.optimized.wast +++ b/test/fixtures/compiler/extern.lys.optimized.wast @@ -1,16 +1,16 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) + (type $0 (func)) + (type $1 (func (param i32 i32))) + (type $2 (func (param i32))) + (type $3 (func (result i32))) (import "env" "printf" (func $fimport$0 (param i32 i32))) (import "env" "putchar" (func $fimport$1 (param i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "main" (func $1)) diff --git a/test/fixtures/compiler/fib1.lys.optimized.wast b/test/fixtures/compiler/fib1.lys.optimized.wast index 353fd1c..d2bd2fa 100644 --- a/test/fixtures/compiler/fib1.lys.optimized.wast +++ b/test/fixtures/compiler/fib1.lys.optimized.wast @@ -1,14 +1,14 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32 i32) (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "fib" (func $2)) @@ -17,30 +17,32 @@ (global.get $global$0) ) (func $1 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (block $label$1 (result i32) + (block $block (result i32) (if (local.get $0) - (block + (then (if (i32.ne (local.get $0) (i32.const 1) ) - (br $label$1 - (call $1 - (i32.sub - (local.get $0) - (i32.const 1) - ) - (local.get $2) - (i32.add - (local.get $1) + (then + (br $block + (call $1 + (i32.sub + (local.get $0) + (i32.const 1) + ) (local.get $2) + (i32.add + (local.get $1) + (local.get $2) + ) ) ) ) ) - (br $label$1 + (br $block (local.get $2) ) ) diff --git a/test/fixtures/compiler/fib2.lys.optimized.wast b/test/fixtures/compiler/fib2.lys.optimized.wast index 4e0aa96..ff2c637 100644 --- a/test/fixtures/compiler/fib2.lys.optimized.wast +++ b/test/fixtures/compiler/fib2.lys.optimized.wast @@ -1,14 +1,14 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32 i32) (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "fib" (func $2)) @@ -23,18 +23,22 @@ (local.get $0) (i32.const 0) ) - (call $1 - (i32.sub - (local.get $0) - (i32.const 1) - ) - (local.get $2) - (i32.add - (local.get $1) + (then + (call $1 + (i32.sub + (local.get $0) + (i32.const 1) + ) (local.get $2) + (i32.add + (local.get $1) + (local.get $2) + ) ) ) - (local.get $1) + (else + (local.get $1) + ) ) ) (func $2 (param $0 i32) (result i32) @@ -45,8 +49,10 @@ ) ) (func $3 (result i32) - (call $2 + (call $1 (i32.const 46) + (i32.const 0) + (i32.const 1) ) ) (func $4 diff --git a/test/fixtures/compiler/fib3.lys.optimized.wast b/test/fixtures/compiler/fib3.lys.optimized.wast index 4e0aa96..ff2c637 100644 --- a/test/fixtures/compiler/fib3.lys.optimized.wast +++ b/test/fixtures/compiler/fib3.lys.optimized.wast @@ -1,14 +1,14 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32 i32) (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "fib" (func $2)) @@ -23,18 +23,22 @@ (local.get $0) (i32.const 0) ) - (call $1 - (i32.sub - (local.get $0) - (i32.const 1) - ) - (local.get $2) - (i32.add - (local.get $1) + (then + (call $1 + (i32.sub + (local.get $0) + (i32.const 1) + ) (local.get $2) + (i32.add + (local.get $1) + (local.get $2) + ) ) ) - (local.get $1) + (else + (local.get $1) + ) ) ) (func $2 (param $0 i32) (result i32) @@ -45,8 +49,10 @@ ) ) (func $3 (result i32) - (call $2 + (call $1 (i32.const 46) + (i32.const 0) + (i32.const 1) ) ) (func $4 diff --git a/test/fixtures/compiler/getter.lys.optimized.wast b/test/fixtures/compiler/getter.lys.optimized.wast index 61ad1d5..85430b7 100644 --- a/test/fixtures/compiler/getter.lys.optimized.wast +++ b/test/fixtures/compiler/getter.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i64) (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "main" (func $1)) @@ -16,11 +16,14 @@ (global.get $global$0) ) (func $1 (param $0 i64) (result i32) + (local $1 i32) (i32.or (i32.load (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $1 + (i32.wrap_i64 + (local.get $0) + ) ) (i32.const 8) ) @@ -28,18 +31,14 @@ (i32.or (i32.shl (i32.load - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) ) (i32.const 16) ) (i32.shl (i32.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) (i32.const 4) ) ) diff --git a/test/fixtures/compiler/globalMutability.lys.optimized.wast b/test/fixtures/compiler/globalMutability.lys.optimized.wast index e6478c4..4c05896 100644 --- a/test/fixtures/compiler/globalMutability.lys.optimized.wast +++ b/test/fixtures/compiler/globalMutability.lys.optimized.wast @@ -1,14 +1,14 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "main" (func $1)) diff --git a/test/fixtures/compiler/if.lys.optimized.wast b/test/fixtures/compiler/if.lys.optimized.wast index 0d574c0..7f2770e 100644 --- a/test/fixtures/compiler/if.lys.optimized.wast +++ b/test/fixtures/compiler/if.lys.optimized.wast @@ -1,14 +1,14 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32) (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "gcd" (func $1)) @@ -24,26 +24,34 @@ (local.get $0) (local.get $1) ) - (call $1 - (i32.sub - (local.get $0) + (then + (call $1 + (i32.sub + (local.get $0) + (local.get $1) + ) (local.get $1) ) - (local.get $1) ) - (if (result i32) - (i32.lt_s - (local.get $0) - (local.get $1) - ) - (call $1 - (local.get $0) - (i32.sub + (else + (if (result i32) + (i32.lt_s + (local.get $0) (local.get $1) + ) + (then + (call $1 + (local.get $0) + (i32.sub + (local.get $1) + (local.get $0) + ) + ) + ) + (else (local.get $0) ) ) - (local.get $0) ) ) ) diff --git a/test/fixtures/compiler/if2.lys.optimized.wast b/test/fixtures/compiler/if2.lys.optimized.wast index b668b99..330a50c 100644 --- a/test/fixtures/compiler/if2.lys.optimized.wast +++ b/test/fixtures/compiler/if2.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32) (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "gcd" (func $1)) @@ -22,26 +22,34 @@ (local.get $0) (local.get $1) ) - (call $1 - (i32.sub - (local.get $0) + (then + (call $1 + (i32.sub + (local.get $0) + (local.get $1) + ) (local.get $1) ) - (local.get $1) ) - (if (result i32) - (i32.lt_s - (local.get $0) - (local.get $1) - ) - (call $1 - (local.get $0) - (i32.sub + (else + (if (result i32) + (i32.lt_s + (local.get $0) (local.get $1) + ) + (then + (call $1 + (local.get $0) + (i32.sub + (local.get $1) + (local.get $0) + ) + ) + ) + (else (local.get $0) ) ) - (local.get $0) ) ) ) diff --git a/test/fixtures/compiler/infix.lys.optimized.wast b/test/fixtures/compiler/infix.lys.optimized.wast index cb85d58..f79738d 100644 --- a/test/fixtures/compiler/infix.lys.optimized.wast +++ b/test/fixtures/compiler/infix.lys.optimized.wast @@ -1,14 +1,14 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $f32_f32_=>_f32 (func (param f32 f32) (result f32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32 i32) (result i32))) + (type $2 (func (param f32 f32) (result f32))) + (type $3 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "testInt" (func $1)) diff --git a/test/fixtures/compiler/is.lys.optimized.wast b/test/fixtures/compiler/is.lys.optimized.wast index ccefab6..d48cf9a 100644 --- a/test/fixtures/compiler/is.lys.optimized.wast +++ b/test/fixtures/compiler/is.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i64_=>_i64 (func (param i64) (result i64))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i64) (result i64))) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "identity" (func $1)) diff --git a/test/fixtures/compiler/iterator-loco.lys.optimized.wast b/test/fixtures/compiler/iterator-loco.lys.optimized.wast index 53f3307..bebd2ad 100644 --- a/test/fixtures/compiler/iterator-loco.lys.optimized.wast +++ b/test/fixtures/compiler/iterator-loco.lys.optimized.wast @@ -1,40 +1,24 @@ (module - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $i64_=>_i64 (func (param i64) (result i64))) - (type $i32_i32_=>_i64 (func (param i32 i32) (result i64))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32) (result i32))) + (type $2 (func (param i32 i32) (result i32))) + (type $3 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test" (func $6)) - (start $7) + (export "test" (func $2)) + (start $3) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (param $0 i32) (result i32) - (local $1 i32) - (call $3 - (local.tee $1 - (call $2 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $2 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -43,32 +27,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$0) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -82,101 +70,89 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$2 + (local.get $2) ) - ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $4 (param $0 i32) (param $1 i32) (result i64) + (func $2 (param $0 i32) (param $1 i32) (result i32) (local $2 i64) + (local $3 i64) + (local $4 i32) (i32.store (i32.wrap_i64 - (local.tee $2 + (local.tee $3 (i64.or (i64.extend_i32_u (call $1 @@ -192,92 +168,66 @@ (i32.store (i32.add (i32.wrap_i64 - (local.get $2) + (local.get $3) ) (i32.const 4) ) (local.get $1) ) - (local.get $2) - ) - (func $5 (param $0 i64) (result i64) - (local $1 i32) - (local $2 i64) - (if (result i64) - (i32.le_s - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) - ) - ) - (block (result i64) - (local.set $1 - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - ) - (i32.store - (i32.wrap_i64 - (local.tee $2 - (i64.or - (i64.extend_i32_u - (call $1 - (i32.const 4) - ) - ) - (i64.const 12884901888) - ) - ) - ) - (local.get $1) - ) - (i32.store - (i32.wrap_i64 - (local.get $0) - ) - (i32.add - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) - ) - (local.get $2) - ) - (i64.const 8589934592) - ) - ) - (func $6 (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i64) - (local $4 i64) - (local.set $3 - (call $4 - (local.get $0) - (local.get $1) - ) - ) - (loop $label$1 + (loop $label (if (i32.eq (i32.wrap_i64 (i64.shr_u - (local.tee $4 - (call $5 - (local.get $3) + (local.tee $2 + (if (result i64) + (i32.le_s + (local.tee $1 + (i32.load + (local.tee $0 + (i32.wrap_i64 + (local.get $3) + ) + ) + ) + ) + (i32.load + (i32.add + (local.get $0) + (i32.const 4) + ) + ) + ) + (then + (i32.store + (i32.wrap_i64 + (local.tee $2 + (i64.or + (i64.extend_i32_u + (call $1 + (i32.const 4) + ) + ) + (i64.const 12884901888) + ) + ) + ) + (local.get $1) + ) + (i32.store + (local.get $0) + (i32.add + (i32.load + (local.get $0) + ) + (i32.const 1) + ) + ) + (local.get $2) + ) + (else + (i64.const 8589934592) + ) ) ) (i64.const 32) @@ -285,24 +235,24 @@ ) (i32.const 3) ) - (block - (local.set $2 + (then + (local.set $4 (i32.add - (local.get $2) + (local.get $4) (i32.load (i32.wrap_i64 - (local.get $4) + (local.get $2) ) ) ) ) - (br $label$1) + (br $label) ) ) ) - (local.get $2) + (local.get $4) ) - (func $7 + (func $3 (global.set $global$0 (i32.const 15) ) @@ -312,8 +262,5 @@ (global.set $global$2 (i32.const 65536) ) - (global.set $global$3 - (global.get $global$2) - ) ) ) diff --git a/test/fixtures/compiler/loops.lys.optimized.wast b/test/fixtures/compiler/loops.lys.optimized.wast index a190868..d9cce32 100644 --- a/test/fixtures/compiler/loops.lys.optimized.wast +++ b/test/fixtures/compiler/loops.lys.optimized.wast @@ -1,12 +1,12 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func)) + (type $1 (func (result i32))) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test" (func $1)) @@ -25,15 +25,16 @@ (local.set $0 (i32.const 1) ) - (loop $label$1 + (loop $label (local.set $0 (i32.add (local.get $0) (i32.const 1) ) ) - (br $label$1) + (br $label) ) + (unreachable) ) (func $3 (global.set $global$0 diff --git a/test/fixtures/compiler/mutability.lys.optimized.wast b/test/fixtures/compiler/mutability.lys.optimized.wast index 1bcb602..c5e95c8 100644 --- a/test/fixtures/compiler/mutability.lys.optimized.wast +++ b/test/fixtures/compiler/mutability.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_i32 (func (param i32) (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32) (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "main" (func $1)) diff --git a/test/fixtures/compiler/nop.lys.optimized.wast b/test/fixtures/compiler/nop.lys.optimized.wast index 986b236..79e8b62 100644 --- a/test/fixtures/compiler/nop.lys.optimized.wast +++ b/test/fixtures/compiler/nop.lys.optimized.wast @@ -1,12 +1,12 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func)) + (type $1 (func (result i32))) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "x" (func $1)) diff --git a/test/fixtures/compiler/panic-match.lys.optimized.wast b/test/fixtures/compiler/panic-match.lys.optimized.wast index 3b0bfe4..7dc9a33 100644 --- a/test/fixtures/compiler/panic-match.lys.optimized.wast +++ b/test/fixtures/compiler/panic-match.lys.optimized.wast @@ -1,13 +1,13 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $none_=>_i32 (func (result i32))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (result i32))) + (type $1 (func (param i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test" (func $1)) @@ -21,7 +21,9 @@ (local.get $0) (i32.const 1) ) - (unreachable) + (then + (unreachable) + ) ) ) (func $2 diff --git a/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast b/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast index bef7b46..4c3c566 100644 --- a/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast +++ b/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast @@ -1,84 +1,78 @@ (module - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (type $none_=>_i64 (func (result i64))) + (type $0 (func (param i64) (result i32))) + (type $1 (func (result i32))) + (type $2 (func)) + (type $3 (func (param i32 i32))) + (type $4 (func (param i32))) + (type $5 (func (param i32) (result i32))) + (type $6 (func (result i64))) (import "test" "registerAssertion" (func $fimport$0 (param i32 i32))) - (memory $0 1) - (data (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") (global $global$0 (mut i64) (i64.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i32) (i32.const 0)) - (global $global$5 (mut i32) (i32.const 0)) - (global $global$6 (mut i32) (i32.const 0)) - (global $global$7 (mut i32) (i32.const 0)) - (global $global$8 (mut i64) (i64.const 0)) - (global $global$9 (mut i64) (i64.const 0)) - (global $global$10 (mut i64) (i64.const 0)) + (global $global$4 (mut i64) (i64.const 0)) + (global $global$5 (mut i64) (i64.const 0)) + (global $global$6 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 49) "\02\00\00\000") + (data $20 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getLastErrorMessage" (func $0)) (export "test_getMaxMemory" (func $2)) - (export "isA" (func $8)) - (export "isB" (func $9)) - (export "isEnum" (func $10)) - (export "isRed" (func $11)) - (export "isColor" (func $12)) - (export "isCustom" (func $13)) - (export "testPassing" (func $14)) - (start $15) + (export "isA" (func $5)) + (export "isB" (func $6)) + (export "isEnum" (func $7)) + (export "isRed" (func $8)) + (export "isColor" (func $9)) + (export "isCustom" (func $10)) + (export "testPassing" (func $11)) + (start $12) (func $0 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$0) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$0) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) (func $1 (param $0 i32) @@ -91,14 +85,13 @@ (i32.eqz (local.get $0) ) - (block + (then (i64.store (i32.wrap_i64 (local.tee $1 (i64.or (i64.extend_i32_u (call $3 - (i32.const 1) (i32.const 8) ) ) @@ -116,26 +109,9 @@ ) ) (func $2 (result i32) - (global.get $global$7) + (global.get $global$3) ) - (func $3 (param $0 i32) (param $1 i32) (result i32) - (call $5 - (local.tee $1 - (call $4 - (local.tee $0 - (i32.mul - (local.get $0) - (local.get $1) - ) - ) - ) - ) - (i32.const 0) - (local.get $0) - ) - (local.get $1) - ) - (func $4 (param $0 i32) (result i32) + (func $3 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -144,182 +120,126 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u - (global.get $global$4) + (global.get $global$2) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $1 + (local.tee $2 (i32.and (i32.add - (global.get $global$3) + (global.get $global$1) (i32.add + (i32.add + (local.tee $1 + (global.get $global$3) + ) + (i32.const 16) + ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) ) - (i32.add - (local.tee $0 - (global.get $global$7) - ) - (i32.const 16) - ) ) ) (i32.xor - (global.get $global$3) + (global.get $global$1) (i32.const -1) ) ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$7 - (local.get $1) - ) - (i32.add - (local.get $0) - (i32.const 16) + (global.set $global$3 + (local.get $2) ) - ) - (func $5 (param $0 i32) (param $1 i32) (param $2 i32) - (local.set $2 + (local.set $0 (i32.add (local.get $0) - (local.get $2) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if - (i32.eqz - (i32.eq - (local.get $0) - (local.get $2) - ) + (i32.ne + (local.get $0) + (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u - (local.get $1) + (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) - ) - ) - ) - ) - (func $6 (param $0 i64) (result i32) - (i32.or - (i32.or - (i32.or - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 4) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 5) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 6) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) + (br $label) ) - (i32.const 7) ) ) + (local.get $2) ) - (func $7 (result i64) + (func $4 (result i64) (local $0 i64) (i32.store (i32.wrap_i64 @@ -327,7 +247,6 @@ (i64.or (i64.extend_i32_u (call $3 - (i32.const 1) (i32.const 4) ) ) @@ -339,7 +258,7 @@ ) (local.get $0) ) - (func $8 (param $0 i64) (result i32) + (func $5 (param $0 i64) (result i32) (i32.eq (i32.wrap_i64 (i64.shr_u @@ -350,7 +269,7 @@ (i32.const 1) ) ) - (func $9 (param $0 i64) (result i32) + (func $6 (param $0 i64) (result i32) (i32.eq (i32.wrap_i64 (i64.shr_u @@ -361,44 +280,33 @@ (i32.const 2) ) ) - (func $10 (param $0 i64) (result i32) - (if (result i32) - (i32.or - (i32.or - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 1) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 2) - ) - ) - (i32.eq + (func $7 (param $0 i64) (result i32) + (local $1 i32) + (i32.or + (i32.eq + (local.tee $1 (i32.wrap_i64 (i64.shr_u (local.get $0) (i64.const 32) ) ) - (i32.const 3) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $1) + (i32.const 1) + ) + (i32.eq + (local.get $1) + (i32.const 2) ) ) - (i32.const 1) - (i32.const 0) ) ) - (func $11 (param $0 i64) (result i32) + (func $8 (param $0 i64) (result i32) (i32.eq (i32.wrap_i64 (i64.shr_u @@ -409,22 +317,39 @@ (i32.const 4) ) ) - (func $12 (param $0 i64) (result i32) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.eqz - (call $6 + (func $9 (param $0 i64) (result i32) + (local $1 i32) + (i32.or + (i32.eq + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u (local.get $0) + (i64.const 32) ) ) ) + (i32.const 7) + ) + (i32.or + (i32.or + (i32.eq + (local.get $1) + (i32.const 4) + ) + (i32.eq + (local.get $1) + (i32.const 5) + ) + ) + (i32.eq + (local.get $1) + (i32.const 6) + ) ) - (i32.const 1) ) ) - (func $13 (param $0 i64) (result i32) + (func $10 (param $0 i64) (result i32) (i32.eq (i32.wrap_i64 (i64.shr_u @@ -435,18 +360,13 @@ (i32.const 7) ) ) - (func $14 + (func $11 + (local $0 i32) (call $1 (i32.const 1) ) (call $1 - (i32.eqz - (i32.eqz - (call $10 - (i64.const 4294967296) - ) - ) - ) + (i32.const 1) ) (call $1 (i32.const 1) @@ -455,13 +375,7 @@ (i32.const 1) ) (call $1 - (i32.eqz - (i32.eqz - (call $10 - (i64.const 8589934592) - ) - ) - ) + (i32.const 1) ) (call $1 (i32.const 1) @@ -470,13 +384,7 @@ (i32.const 1) ) (call $1 - (i32.eqz - (i32.eqz - (call $10 - (i64.const 12884901888) - ) - ) - ) + (i32.const 1) ) (call $1 (i32.const 1) @@ -485,7 +393,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$8) + (global.get $global$4) (i64.const 32) ) ) @@ -496,7 +404,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$8) + (global.get $global$4) (i64.const 32) ) ) @@ -504,10 +412,26 @@ ) ) (call $1 - (i32.eqz - (i32.eqz - (call $10 - (global.get $global$8) + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (global.get $global$4) + (i64.const 32) + ) + ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) + (i32.const 1) + ) + (i32.eq + (local.get $0) + (i32.const 2) ) ) ) @@ -516,7 +440,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$9) + (global.get $global$5) (i64.const 32) ) ) @@ -527,7 +451,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$9) + (global.get $global$5) (i64.const 32) ) ) @@ -535,10 +459,26 @@ ) ) (call $1 - (i32.eqz - (i32.eqz - (call $10 - (global.get $global$9) + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (global.get $global$5) + (i64.const 32) + ) + ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) + (i32.const 1) + ) + (i32.eq + (local.get $0) + (i32.const 2) ) ) ) @@ -547,7 +487,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$10) + (global.get $global$6) (i64.const 32) ) ) @@ -558,7 +498,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$10) + (global.get $global$6) (i64.const 32) ) ) @@ -566,10 +506,26 @@ ) ) (call $1 - (i32.eqz - (i32.eqz - (call $10 - (global.get $global$10) + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (global.get $global$6) + (i64.const 32) + ) + ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) + (i32.const 1) + ) + (i32.eq + (local.get $0) + (i32.const 2) ) ) ) @@ -578,7 +534,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$10) + (global.get $global$6) (i64.const 32) ) ) @@ -589,10 +545,32 @@ (i32.const 1) ) (call $1 - (i32.eqz - (i32.eqz - (call $12 - (call $7) + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (call $4) + (i64.const 32) + ) + ) + ) + (i32.const 7) + ) + (i32.or + (i32.or + (i32.eq + (local.get $0) + (i32.const 4) + ) + (i32.eq + (local.get $0) + (i32.const 5) + ) + ) + (i32.eq + (local.get $0) + (i32.const 6) ) ) ) @@ -601,7 +579,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) @@ -612,7 +590,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) @@ -623,7 +601,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) @@ -631,50 +609,26 @@ ) ) ) - (func $15 + (func $12 (global.set $global$0 (i64.const 8589934592) ) (global.set $global$1 - (i32.const 4) + (i32.const 15) ) (global.set $global$2 - (i32.const 16) - ) - (global.set $global$3 - (i32.sub - (global.get $global$2) - (i32.const 1) - ) - ) - (global.set $global$4 (i32.const 1073741824) ) - (global.set $global$5 + (global.set $global$3 (i32.const 65536) ) - (global.set $global$6 - (i32.and - (i32.add - (global.get $global$3) - (i32.const 65536) - ) - (i32.xor - (global.get $global$3) - (i32.const -1) - ) - ) - ) - (global.set $global$7 - (global.get $global$6) - ) - (global.set $global$8 + (global.set $global$4 (i64.const 4294967296) ) - (global.set $global$9 + (global.set $global$5 (i64.const 4294967296) ) - (global.set $global$10 + (global.set $global$6 (i64.const 4294967296) ) ) diff --git a/test/fixtures/compiler/patternMatching.lys.optimized.wast b/test/fixtures/compiler/patternMatching.lys.optimized.wast index 11e2268..9081735 100644 --- a/test/fixtures/compiler/patternMatching.lys.optimized.wast +++ b/test/fixtures/compiler/patternMatching.lys.optimized.wast @@ -1,211 +1,85 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $i64_=>_i64 (func (param i64) (result i64))) - (memory $0 1) - (data (i32.const 21) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 49) "\02\00\00\000") - (data (i32.const 56) "\02\00\00\000") + (type $0 (func (param i32) (result i32))) + (type $1 (func (result i32))) + (type $2 (func (param i64) (result i32))) + (type $3 (func (param i64) (result i64))) + (type $4 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") + (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") + (data $2 (i32.const 49) "\02\00\00\000") + (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test" (func $3)) - (export "test2" (func $4)) - (export "test3" (func $5)) - (export "test4" (func $6)) - (start $7) + (export "test" (func $1)) + (export "test2" (func $2)) + (export "test3" (func $3)) + (export "test4" (func $4)) + (start $5) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) - (func $1 (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (if - (i32.lt_u - (global.get $global$1) - (i32.const 4) - ) - (unreachable) - ) - (if - (i32.gt_u - (local.tee $1 - (i32.and - (i32.add - (global.get $global$0) - (i32.add - (local.tee $0 - (global.get $global$3) - ) - (i32.const 32) - ) - ) - (i32.xor - (global.get $global$0) - (i32.const -1) - ) - ) - ) - (i32.shl - (local.tee $2 - (memory.size) - ) - (i32.const 16) - ) - ) - (block - (drop - (memory.grow - (select - (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) - ) - (i32.const -65536) - ) - (i32.const 16) - ) - ) - ) - (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow - (local.get $3) - ) - ) - (if - (i32.const 0) - (unreachable) - ) - ) - ) - ) - ) - (global.set $global$3 - (local.get $1) - ) - (i32.add - (local.get $0) - (i32.const 16) - ) - ) - (func $2 (param $0 i32) - (local $1 i32) - (local.set $1 - (i32.add - (local.get $0) - (i32.const 4) - ) - ) - (loop $label$1 - (if - (i32.ne - (local.get $0) - (local.get $1) - ) - (block - (i32.store8 - (local.get $0) - (i32.load8_u - (i32.const 0) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $label$1) - ) - ) - ) - ) - (func $3 (param $0 i32) (result i32) + (func $1 (param $0 i32) (result i32) (i32.eq (local.get $0) (i32.const 1) ) ) - (func $4 (param $0 i32) (result i32) - (block $label$1 (result i32) + (func $2 (param $0 i32) (result i32) + (block $block (result i32) (if (i32.ne (local.get $0) (i32.const 10) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 20) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 30) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 40) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 50) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 60) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 70) ) - (block + (then (if (i32.ne (local.get $0) (i32.const 80) ) - (block + (then (drop - (br_if $label$1 + (br_if $block (i32.const 0) (i32.ne (local.get $0) @@ -213,42 +87,42 @@ ) ) ) - (br $label$1 + (br $block (i32.const 9) ) ) ) - (br $label$1 + (br $block (i32.const 8) ) ) ) - (br $label$1 + (br $block (i32.const 7) ) ) ) - (br $label$1 + (br $block (i32.const 6) ) ) ) - (br $label$1 + (br $block (i32.const 5) ) ) ) - (br $label$1 + (br $block (i32.const 4) ) ) ) - (br $label$1 + (br $block (i32.const 3) ) ) ) - (br $label$1 + (br $block (i32.const 2) ) ) @@ -256,33 +130,31 @@ (i32.const 1) ) ) - (func $5 (param $0 i64) (result i32) - (block $label$1 (result i32) + (func $3 (param $0 i64) (result i32) + (local $1 i32) + (block $block1 (result i32) (if (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) ) ) (i32.const 2) ) - (block - (block $label$3 - (br_if $label$3 + (then + (block $block + (br_if $block (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 1) ) ) ) - (br $label$1 + (br $block1 (i32.const 0) ) ) @@ -290,60 +162,153 @@ (i32.const 1) ) ) - (func $6 (param $0 i64) (result i64) + (func $4 (param $0 i64) (result i64) (local $1 i32) - (block $label$1 (result i64) - (if - (i32.ne + (local $2 i32) + (local $3 i32) + (local $4 i32) + (if + (i32.ne + (local.tee $1 (i32.wrap_i64 (i64.shr_u (local.get $0) (i64.const 32) ) ) - (i32.const 2) ) - (block - (block $label$3 - (br_if $label$3 - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (i32.const 2) + ) + (then + (block $block + (br_if $block + (i32.eq + (local.get $1) + (i32.const 1) + ) + ) + ) + (if + (i32.lt_u + (global.get $global$1) + (i32.const 4) + ) + (then + (unreachable) + ) + ) + (if + (i32.gt_u + (local.tee $2 + (i32.and + (i32.add + (global.get $global$0) + (i32.add + (local.tee $1 + (global.get $global$2) + ) + (i32.const 32) + ) + ) + (i32.xor + (global.get $global$0) + (i32.const -1) + ) + ) + ) + (i32.shl + (local.tee $3 + (memory.size) + ) + (i32.const 16) + ) + ) + (then + (drop + (memory.grow + (select + (local.get $3) + (local.tee $4 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) + ) + (i32.const 65535) + ) + (i32.const -65536) + ) + (i32.const 16) + ) + ) + (i32.gt_u + (local.get $3) + (local.get $4) ) ) - (i32.const 1) ) ) ) - (call $2 + ) + (global.set $global$2 + (local.get $2) + ) + (local.set $3 + (i32.add (local.tee $1 - (call $1) + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) ) + (i32.const 4) ) - (i32.store - (i32.wrap_i64 - (local.tee $0 - (i64.or - (i64.extend_i32_u - (local.get $1) - ) - (i64.const 8589934592) + ) + (loop $label + (if + (i32.ne + (local.get $1) + (local.get $3) + ) + (then + (i32.store8 + (local.get $1) + (i32.load8_u + (i32.const 0) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) ) ) + (br $label) ) - (i32.const 0) ) - (br $label$1 - (local.get $0) + ) + (i32.store + (i32.wrap_i64 + (local.tee $0 + (i64.or + (i64.extend_i32_u + (local.get $2) + ) + (i64.const 8589934592) + ) + ) ) + (i32.const 0) ) ) - (local.get $0) ) + (local.get $0) ) - (func $7 + (func $5 (global.set $global$0 (i32.const 15) ) @@ -353,8 +318,5 @@ (global.set $global$2 (i32.const 65536) ) - (global.set $global$3 - (global.get $global$2) - ) ) ) diff --git a/test/fixtures/execution/fibo.lys.optimized.wast b/test/fixtures/execution/fibo.lys.optimized.wast index 566a764..63a032a 100644 --- a/test/fixtures/execution/fibo.lys.optimized.wast +++ b/test/fixtures/execution/fibo.lys.optimized.wast @@ -1,46 +1,46 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_none (func (param i64))) - (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) - (type $i64_i32_=>_none (func (param i64 i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) + (type $0 (func)) + (type $1 (func (param i32 i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32))) + (type $4 (func (param i64 i32))) + (type $5 (func (param i32 i32 i64))) + (type $6 (func (param i64))) + (type $7 (func (param i32 i32 i32) (result i32))) + (type $8 (func (param i32) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (import "env" "printf" (func $fimport$3 (param i32 i32))) - (memory $0 1) - (data (i32.const 316) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 343) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 376) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 403) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 436) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 471) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 512) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 547) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 588) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 623) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 664) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 699) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 740) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 767) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 800) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 827) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 860) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 274) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 287) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 302) "\02\00\00\000") - (data (i32.const 309) "\02\00\00\000") - (data (i32.const 16) "\12\00\00\00f\00i\00b\00o\00n\00a\00c\00c\00i") - (data (i32.const 39) "4\00\00\00f\00i\00b\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003") - (data (i32.const 96) "R\00\00\00f\00i\00b\00P\00a\00t\00t\00e\00r\00n\00M\00a\00t\00c\00h\00i\00n\00g\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003") - (data (i32.const 183) "\12\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l") - (data (i32.const 206) ":\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l\00(\001\000\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \003\006\002\008\008\000\000") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 316) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 343) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 376) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 403) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 436) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 471) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 512) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 547) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 588) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 623) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 664) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 699) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 740) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 767) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 800) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 827) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 860) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 274) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 287) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 302) "\02\00\00\000") + (data $20 (i32.const 309) "\02\00\00\000") + (data $21 (i32.const 16) "\12\00\00\00f\00i\00b\00o\00n\00a\00c\00c\00i") + (data $22 (i32.const 39) "4\00\00\00f\00i\00b\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003") + (data $23 (i32.const 96) "R\00\00\00f\00i\00b\00P\00a\00t\00t\00e\00r\00n\00M\00a\00t\00c\00h\00i\00n\00g\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003") + (data $24 (i32.const 183) "\12\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l") + (data $25 (i32.const 206) ":\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l\00(\001\000\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \003\006\002\008\008\000\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $1)) (export "test_getLastErrorMessage" (func $3)) @@ -72,7 +72,7 @@ (local.get $0) (local.get $1) ) - (block + (then (call $0 (i64.const 12884902688) (local.get $0) @@ -86,30 +86,30 @@ ) (func $3 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$1) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$1) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) (func $4 (param $0 i64) @@ -125,36 +125,44 @@ (local.get $0) (i32.const 0) ) - (call $5 - (i32.sub - (local.get $0) - (i32.const 1) - ) - (local.get $2) - (i32.add - (local.get $1) + (then + (call $5 + (i32.sub + (local.get $0) + (i32.const 1) + ) (local.get $2) + (i32.add + (local.get $1) + (local.get $2) + ) ) ) - (local.get $1) + (else + (local.get $1) + ) ) ) (func $6 (param $0 i32) (result i32) (if (result i32) - (i32.ge_s + (i32.gt_s (local.get $0) - (i32.const 1) + (i32.const 0) ) - (i32.mul - (call $6 - (i32.sub - (local.get $0) - (i32.const 1) + (then + (i32.mul + (call $6 + (i32.sub + (local.get $0) + (i32.const 1) + ) ) + (local.get $0) ) - (local.get $0) ) - (i32.const 1) + (else + (i32.const 1) + ) ) ) (func $7 diff --git a/test/fixtures/execution/implicitCast.lys.optimized.wast b/test/fixtures/execution/implicitCast.lys.optimized.wast index e2f379a..af5dd2a 100644 --- a/test/fixtures/execution/implicitCast.lys.optimized.wast +++ b/test/fixtures/execution/implicitCast.lys.optimized.wast @@ -1,41 +1,41 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_none (func (param i64))) - (type $i32_i32_=>_none (func (param i32 i32))) + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32))) + (type $3 (func (param i32 i32))) + (type $4 (func (param i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 214) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 241) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 274) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 301) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 334) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 369) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 410) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 445) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 486) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 521) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 562) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 597) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 638) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 665) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 698) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 725) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 758) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 172) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 185) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 200) "\02\00\00\000") - (data (i32.const 207) "\02\00\00\000") - (data (i32.const 16) ".\00\00\00I\00m\00p\00l\00i\00c\00i\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00a\00s\00t\00i\00n\00g") - (data (i32.const 67) "$\00\00\00e\00q\00(\001\000\00_\00u\001\006\00,\00 \001\000\00_\00i\003\002\00)") - (data (i32.const 108) "\0e\00\00\00m\00a\00t\00c\00h\00 \000") - (data (i32.const 127) "\0e\00\00\00m\00a\00t\00c\00h\00 \001") - (data (i32.const 146) "\10\00\00\000\00.\000\00 \00=\00=\00 \000") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 214) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 241) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 274) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 301) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 334) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 369) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 410) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 445) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 486) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 521) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 562) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 597) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 638) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 665) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 698) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 725) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 758) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 172) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 185) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 200) "\02\00\00\000") + (data $20 (i32.const 207) "\02\00\00\000") + (data $21 (i32.const 16) ".\00\00\00I\00m\00p\00l\00i\00c\00i\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00a\00s\00t\00i\00n\00g") + (data $22 (i32.const 67) "$\00\00\00e\00q\00(\001\000\00_\00u\001\006\00,\00 \001\000\00_\00i\003\002\00)") + (data $23 (i32.const 108) "\0e\00\00\00m\00a\00t\00c\00h\00 \000") + (data $24 (i32.const 127) "\0e\00\00\00m\00a\00t\00c\00h\00 \001") + (data $25 (i32.const 146) "\10\00\00\000\00.\000\00 \00=\00=\00 \000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test_getLastErrorMessage" (func $1)) @@ -46,30 +46,30 @@ ) (func $1 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$1) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$1) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) (func $2 (param $0 i64) diff --git a/test/fixtures/execution/indirect-smoke.lys.optimized.wast b/test/fixtures/execution/indirect-smoke.lys.optimized.wast index 8fcbc00..cd8aaa1 100644 --- a/test/fixtures/execution/indirect-smoke.lys.optimized.wast +++ b/test/fixtures/execution/indirect-smoke.lys.optimized.wast @@ -1,45 +1,45 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_none (func (param i64))) - (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) - (type $i64_i32_=>_none (func (param i64 i32))) + (type $0 (func)) + (type $1 (func (param i32 i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32))) + (type $4 (func (param i64 i32))) + (type $5 (func (param i32 i32 i64))) + (type $6 (func (param i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (import "env" "printf" (func $fimport$3 (param i32 i32))) - (memory $0 1) - (data (i32.const 245) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 272) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 305) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 332) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 365) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 400) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 441) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 476) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 517) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 552) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 593) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 628) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 789) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 203) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 216) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 231) "\02\00\00\000") - (data (i32.const 238) "\02\00\00\000") - (data (i32.const 16) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00n\00o\00 \00a\00r\00g\00u\00m\00e\00n\00t\00s") - (data (i32.const 93) "\02\00\00\00A") - (data (i32.const 100) "\02\00\00\00B") - (data (i32.const 107) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00o\00n\00e\00 \00a\00r\00g\00u\00m\00e\00n\00t") - (data (i32.const 184) "\02\00\00\00A") - (data (i32.const 191) "\02\00\00\00B") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 245) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 272) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 305) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 332) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 365) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 400) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 441) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 476) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 517) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 552) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 593) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 628) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 789) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 203) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 216) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 231) "\02\00\00\000") + (data $20 (i32.const 238) "\02\00\00\000") + (data $21 (i32.const 16) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00n\00o\00 \00a\00r\00g\00u\00m\00e\00n\00t\00s") + (data $22 (i32.const 93) "\02\00\00\00A") + (data $23 (i32.const 100) "\02\00\00\00B") + (data $24 (i32.const 107) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00o\00n\00e\00 \00a\00r\00g\00u\00m\00e\00n\00t") + (data $25 (i32.const 184) "\02\00\00\00A") + (data $26 (i32.const 191) "\02\00\00\00B") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $1)) (export "test_getLastErrorMessage" (func $3)) @@ -71,7 +71,7 @@ (local.get $0) (local.get $1) ) - (block + (then (call $0 (i64.const 12884902617) (local.get $0) @@ -85,30 +85,30 @@ ) (func $3 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$1) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$1) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) (func $4 (param $0 i64) diff --git a/test/fixtures/execution/is.lys.optimized.wast b/test/fixtures/execution/is.lys.optimized.wast index d8a318e..c8ece01 100644 --- a/test/fixtures/execution/is.lys.optimized.wast +++ b/test/fixtures/execution/is.lys.optimized.wast @@ -1,66 +1,52 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $none_=>_i64 (func (result i64))) + (type $0 (func)) + (type $1 (func (param i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32 i32))) + (type $4 (func (param i32) (result i32))) + (type $5 (func (result i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 100) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 127) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 160) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 187) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 220) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 255) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 296) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 331) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 372) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 407) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 448) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 483) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 524) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 551) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 584) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 611) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 644) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 58) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 71) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 86) "\02\00\00\000") - (data (i32.const 93) "\02\00\00\000") - (data (i32.const 16) " \00\00\00<\00e\00x\00p\00r\00>\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) + (global $global$3 (mut i64) (i64.const 0)) (global $global$4 (mut i64) (i64.const 0)) (global $global$5 (mut i64) (i64.const 0)) (global $global$6 (mut i64) (i64.const 0)) - (global $global$7 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 100) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 127) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 160) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 187) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 220) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 255) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 296) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 331) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 372) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 407) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 448) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 483) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 524) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 551) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 584) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 611) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 644) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 58) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 71) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 86) "\02\00\00\000") + (data $20 (i32.const 93) "\02\00\00\000") + (data $21 (i32.const 16) " \00\00\00<\00e\00x\00p\00r\00>\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $4)) - (export "main" (func $8)) - (start $9) + (export "test_getLastErrorMessage" (func $2)) + (export "main" (func $5)) + (start $6) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (param $0 i32) (result i32) - (local $1 i32) - (call $3 - (local.tee $1 - (call $2 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $2 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -69,32 +55,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$0) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -108,125 +98,111 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$2 + (local.get $2) ) - ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $4 (result i32) + (func $2 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $5 (param $0 i32) + (func $3 (param $0 i32) (local $1 i64) (call $fimport$1 (local.get $0) @@ -236,7 +212,7 @@ (i32.eqz (local.get $0) ) - (block + (then (i64.store (i32.wrap_i64 (local.tee $1 @@ -252,58 +228,14 @@ ) (i64.const 12884902532) ) - (global.set $global$4 + (global.set $global$3 (local.get $1) ) (unreachable) ) ) ) - (func $6 (param $0 i64) (result i32) - (i32.or - (i32.or - (i32.or - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 4) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 5) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 6) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 7) - ) - ) - ) - (func $7 (result i64) + (func $4 (result i64) (local $0 i64) (i32.store (i32.wrap_i64 @@ -322,259 +254,251 @@ ) (local.get $0) ) - (func $8 - (local $0 i64) + (func $5 + (local $0 i32) (call $fimport$0 (i32.const 16) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$4) (i64.const 32) ) ) (i32.const 1) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$4) (i64.const 32) ) ) (i32.const 2) ) ) - (call $5 + (call $3 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (global.get $global$5) - ) + (global.get $global$4) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$5) (i64.const 32) ) ) (i32.const 1) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$5) (i64.const 32) ) ) (i32.const 2) ) ) - (call $5 + (call $3 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (global.get $global$6) - ) + (global.get $global$5) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$7) + (global.get $global$6) (i64.const 32) ) ) (i32.const 1) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$7) + (global.get $global$6) (i64.const 32) ) ) (i32.const 2) ) ) - (call $5 + (call $3 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (global.get $global$7) - ) + (global.get $global$6) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$7) + (global.get $global$6) (i64.const 32) ) ) (i32.const 4) ) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 - (i32.eqz - (i32.eqz - (call $6 - (call $7) + (call $3 + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (call $4) + (i64.const 32) + ) + ) + ) + (i32.const 7) + ) + (i32.or + (i32.or + (i32.eq + (local.get $0) + (i32.const 4) + ) + (i32.eq + (local.get $0) + (i32.const 5) + ) + ) + (i32.eq + (local.get $0) + (i32.const 6) ) ) ) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) (i32.const 7) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) (i32.const 4) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) @@ -583,7 +507,7 @@ ) (call $fimport$2) ) - (func $9 + (func $6 (global.set $global$0 (i32.const 15) ) @@ -594,10 +518,10 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) + (i64.const 8589934592) ) (global.set $global$4 - (i64.const 8589934592) + (i64.const 4294967296) ) (global.set $global$5 (i64.const 4294967296) @@ -605,8 +529,5 @@ (global.set $global$6 (i64.const 4294967296) ) - (global.set $global$7 - (i64.const 4294967296) - ) ) ) diff --git a/test/fixtures/execution/isPatternMatching.lys.optimized.wast b/test/fixtures/execution/isPatternMatching.lys.optimized.wast index 7656f75..a238e0c 100644 --- a/test/fixtures/execution/isPatternMatching.lys.optimized.wast +++ b/test/fixtures/execution/isPatternMatching.lys.optimized.wast @@ -1,66 +1,52 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $none_=>_i64 (func (result i64))) + (type $0 (func)) + (type $1 (func (param i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32 i32))) + (type $4 (func (param i32) (result i32))) + (type $5 (func (result i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 114) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 141) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 174) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 201) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 234) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 269) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 310) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 345) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 538) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 565) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 598) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 625) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 658) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 72) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 85) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 100) "\02\00\00\000") - (data (i32.const 107) "\02\00\00\000") - (data (i32.const 16) ".\00\00\00i\00s\00 \00w\00i\00t\00h\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) + (global $global$3 (mut i64) (i64.const 0)) (global $global$4 (mut i64) (i64.const 0)) (global $global$5 (mut i64) (i64.const 0)) (global $global$6 (mut i64) (i64.const 0)) - (global $global$7 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 114) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 141) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 174) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 201) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 234) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 269) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 310) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 345) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 538) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 565) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 598) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 625) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 658) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 72) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 85) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 100) "\02\00\00\000") + (data $20 (i32.const 107) "\02\00\00\000") + (data $21 (i32.const 16) ".\00\00\00i\00s\00 \00w\00i\00t\00h\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $4)) - (export "main" (func $8)) - (start $9) + (export "test_getLastErrorMessage" (func $2)) + (export "main" (func $5)) + (start $6) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (param $0 i32) (result i32) - (local $1 i32) - (call $3 - (local.tee $1 - (call $2 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $2 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -69,32 +55,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$0) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -108,125 +98,111 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$2 + (local.get $2) ) - ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $4 (result i32) + (func $2 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $5 (param $0 i32) + (func $3 (param $0 i32) (local $1 i64) (call $fimport$1 (local.get $0) @@ -236,7 +212,7 @@ (i32.eqz (local.get $0) ) - (block + (then (i64.store (i32.wrap_i64 (local.tee $1 @@ -252,58 +228,14 @@ ) (i64.const 12884902546) ) - (global.set $global$4 + (global.set $global$3 (local.get $1) ) (unreachable) ) ) ) - (func $6 (param $0 i64) (result i32) - (i32.or - (i32.or - (i32.or - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 4) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 5) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 6) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 7) - ) - ) - ) - (func $7 (result i64) + (func $4 (result i64) (local $0 i64) (i32.store (i32.wrap_i64 @@ -322,281 +254,251 @@ ) (local.get $0) ) - (func $8 - (local $0 i64) + (func $5 + (local $0 i32) (call $fimport$0 (i32.const 16) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$4) (i64.const 32) ) ) (i32.const 1) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$4) (i64.const 32) ) ) (i32.const 2) ) ) - (call $5 + (call $3 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (global.get $global$5) - ) + (global.get $global$4) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$5) (i64.const 32) ) ) (i32.const 1) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$5) (i64.const 32) ) ) (i32.const 2) ) ) - (call $5 + (call $3 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (global.get $global$6) - ) + (global.get $global$5) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$7) + (global.get $global$6) (i64.const 32) ) ) (i32.const 1) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$7) + (global.get $global$6) (i64.const 32) ) ) (i32.const 2) ) ) - (call $5 + (call $3 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (global.get $global$7) - ) + (global.get $global$6) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$7) + (global.get $global$6) (i64.const 32) ) ) (i32.const 4) ) ) - (call $5 + (call $3 (i32.const 1) ) - (call $5 - (i32.eqz - (i32.eqz - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.eqz - (call $6 - (call $7) - ) - ) + (call $3 + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (call $4) + (i64.const 32) ) ) - (i32.const 1) + ) + (i32.const 7) + ) + (i32.or + (i32.or + (i32.eq + (local.get $0) + (i32.const 4) + ) + (i32.eq + (local.get $0) + (i32.const 5) + ) + ) + (i32.eq + (local.get $0) + (i32.const 6) ) ) ) ) - (call $5 - (i32.eqz - (i32.eqz - (block $label$2 (result i32) - (drop - (br_if $label$2 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (call $7) - (i64.const 32) - ) - ) - (i32.const 7) - ) - ) - ) - (i32.const 1) + (call $3 + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (call $4) + (i64.const 32) ) ) + (i32.const 7) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) (i32.const 4) ) ) - (call $5 + (call $3 (i32.ne (i32.wrap_i64 (i64.shr_u - (call $7) + (call $4) (i64.const 32) ) ) @@ -605,7 +507,7 @@ ) (call $fimport$2) ) - (func $9 + (func $6 (global.set $global$0 (i32.const 15) ) @@ -616,10 +518,10 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) + (i64.const 8589934592) ) (global.set $global$4 - (i64.const 8589934592) + (i64.const 4294967296) ) (global.set $global$5 (i64.const 4294967296) @@ -627,8 +529,5 @@ (global.set $global$6 (i64.const 4294967296) ) - (global.set $global$7 - (i64.const 4294967296) - ) ) ) diff --git a/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast b/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast index bbc8dd3..c1efc0b 100644 --- a/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast +++ b/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast @@ -1,222 +1,198 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i64_=>_i64 (func (param i64) (result i64))) + (type $0 (func)) + (type $1 (func (param i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32 i32))) + (type $4 (func (param i64) (result i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 168) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 195) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 228) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 255) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 288) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 323) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 364) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 399) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 440) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 475) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 516) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 551) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 592) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 619) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 652) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 679) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 712) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 126) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 139) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 154) "\02\00\00\000") - (data (i32.const 161) "\02\00\00\000") - (data (i32.const 16) "d\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00\'\00c\00a\00s\00e\00 \00X\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>\00\'\00 \00s\00e\00t\00t\00i\00n\00g\00 \00X") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 168) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 195) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 228) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 255) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 288) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 323) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 364) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 399) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 440) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 475) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 516) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 551) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 592) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 619) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 652) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 679) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 712) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 126) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 139) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 154) "\02\00\00\000") + (data $20 (i32.const 161) "\02\00\00\000") + (data $21 (i32.const 16) "d\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00\'\00c\00a\00s\00e\00 \00X\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>\00\'\00 \00s\00e\00t\00t\00i\00n\00g\00 \00X") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $3)) - (export "main" (func $6)) - (start $7) + (export "test_getLastErrorMessage" (func $1)) + (export "main" (func $4)) + (start $5) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (result i32) - (local $0 i32) + (local $0 i64) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) + ) + (i64.const 32) + ) + ) + (i32.const 3) + ) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) + ) + ) + ) + (else + (i32.const 0) + ) + ) + ) + (func $2 (param $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) - (local $4 i32) - (if - (i32.lt_u - (global.get $global$1) - (i32.const 8) - ) - (unreachable) + (local $4 i64) + (call $fimport$1 + (local.get $0) + (i32.const 712) ) (if - (i32.gt_u - (local.tee $1 - (i32.and - (i32.add - (global.get $global$0) - (i32.add - (local.tee $0 - (global.get $global$3) - ) - (i32.const 32) - ) - ) - (i32.xor - (global.get $global$0) - (i32.const -1) - ) + (i32.eqz + (local.get $0) + ) + (then + (if + (i32.lt_u + (global.get $global$1) + (i32.const 8) ) - ) - (i32.shl - (local.tee $2 - (memory.size) + (then + (unreachable) ) - (i32.const 16) ) - ) - (block - (drop - (memory.grow - (select - (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) - ) - (i32.const -65536) + (if + (i32.gt_u + (local.tee $1 + (i32.and + (i32.add + (global.get $global$0) + (i32.add + (local.tee $0 + (global.get $global$2) ) - (i32.const 16) + (i32.const 32) ) ) + (i32.xor + (global.get $global$0) + (i32.const -1) + ) ) - (i32.gt_u - (local.get $2) - (local.get $4) + ) + (i32.shl + (local.tee $2 + (memory.size) ) + (i32.const 16) ) ) - ) - (if - (i32.const 0) - (block + (then (drop (memory.grow - (local.get $3) + (select + (local.get $2) + (local.tee $3 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $1) + (local.get $0) + ) + (i32.const 65535) + ) + (i32.const -65536) + ) + (i32.const 16) + ) + ) + (i32.gt_u + (local.get $2) + (local.get $3) + ) + ) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) - ) - ) - (global.set $global$3 - (local.get $1) - ) - (i32.add - (local.get $0) - (i32.const 16) - ) - ) - (func $2 (param $0 i32) - (local $1 i32) - (local.set $1 - (i32.add - (local.get $0) - (i32.const 8) - ) - ) - (loop $label$1 - (if - (i32.ne - (local.get $0) + (global.set $global$2 (local.get $1) ) - (block - (i32.store8 - (local.get $0) - (i32.load8_u - (i32.const 0) + (local.set $2 + (i32.add + (local.tee $0 + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 16) + ) + ) ) + (i32.const 8) ) - (local.set $0 - (i32.add + ) + (loop $label + (if + (i32.ne (local.get $0) - (i32.const 1) + (local.get $2) ) - ) - (br $label$1) - ) - ) - ) - ) - (func $3 (result i32) - (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) + (then + (i32.store8 + (local.get $0) + (i32.load8_u + (i32.const 0) ) - (i64.const 32) ) + (local.set $0 + (i32.add + (local.get $0) + (i32.const 1) + ) + ) + (br $label) ) - (i32.const 3) - ) - ) - ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) - ) - ) - ) - ) - ) - (func $4 (param $0 i32) - (local $1 i64) - (call $fimport$1 - (local.get $0) - (i32.const 712) - ) - (if - (i32.eqz - (local.get $0) - ) - (block - (call $2 - (local.tee $0 - (call $1) ) ) (i64.store (i32.wrap_i64 - (local.tee $1 + (local.tee $4 (i64.or (i64.extend_i32_u - (local.get $0) + (local.get $1) ) (i64.const 12884901888) ) @@ -224,75 +200,58 @@ ) (i64.const 12884902600) ) - (global.set $global$4 - (local.get $1) + (global.set $global$3 + (local.get $4) ) (unreachable) ) ) ) - (func $5 (param $0 i64) (result i64) - (block $label$1 (result i64) + (func $3 (param $0 i64) (result i64) + (local $1 i32) + (block $block (result i64) (if (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) ) ) (i32.const 4) ) - (block + (then (drop - (br_if $label$1 + (br_if $block (i64.const 17179869184) (i32.eqz (i32.or (i32.or (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 2) ) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 3) ) ) ) ) ) - (br $label$1 + (br $block (select (i64.const 21474836480) (i64.const 17179869184) (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 1) ) ) @@ -302,15 +261,15 @@ (local.get $0) ) ) - (func $6 + (func $4 (call $fimport$0 (i32.const 16) ) - (call $4 + (call $2 (i32.eq (i32.wrap_i64 (i64.shr_u - (call $5 + (call $3 (i64.const 17179869184) ) (i64.const 32) @@ -319,11 +278,11 @@ (i32.const 4) ) ) - (call $4 + (call $2 (i32.eq (i32.wrap_i64 (i64.shr_u - (call $5 + (call $3 (i64.const 25769803776) ) (i64.const 32) @@ -332,11 +291,11 @@ (i32.const 4) ) ) - (call $4 + (call $2 (i32.eq (i32.wrap_i64 (i64.shr_u - (call $5 + (call $3 (i64.const 4294967296) ) (i64.const 32) @@ -345,11 +304,11 @@ (i32.const 4) ) ) - (call $4 + (call $2 (i32.eq (i32.wrap_i64 (i64.shr_u - (call $5 + (call $3 (i64.const 8589934592) ) (i64.const 32) @@ -358,11 +317,11 @@ (i32.const 5) ) ) - (call $4 + (call $2 (i32.eq (i32.wrap_i64 (i64.shr_u - (call $5 + (call $3 (i64.const 34359738368) ) (i64.const 32) @@ -373,7 +332,7 @@ ) (call $fimport$2) ) - (func $7 + (func $5 (global.set $global$0 (i32.const 15) ) @@ -384,9 +343,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/numberOps.lys.optimized.wast b/test/fixtures/execution/numberOps.lys.optimized.wast index 4627d2b..c221190 100644 --- a/test/fixtures/execution/numberOps.lys.optimized.wast +++ b/test/fixtures/execution/numberOps.lys.optimized.wast @@ -1,55 +1,55 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_none (func (param i64))) - (type $i32_i32_=>_none (func (param i32 i32))) + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32))) + (type $3 (func (param i32 i32))) + (type $4 (func (param i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 410) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 437) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 470) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 497) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 530) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 565) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 606) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 641) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 682) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 717) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 758) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 793) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 834) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 861) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 894) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 921) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 954) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 368) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 381) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 396) "\02\00\00\000") - (data (i32.const 403) "\02\00\00\000") - (data (i32.const 16) "(\00\00\00N\00u\00m\00b\00e\00r\00 \00s\00a\00n\00i\00t\00y\00 \00c\00h\00e\00c\00k\00s") - (data (i32.const 61) "\02\00\00\001") - (data (i32.const 68) "\0c\00\00\000\00 \00/\00 \001\000") - (data (i32.const 85) "\0e\00\00\001\000\00 \00/\00 \001\000") - (data (i32.const 104) "\10\00\00\001\000\00 \00/\00 \001\000\000") - (data (i32.const 125) "\02\00\00\002") - (data (i32.const 132) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002") - (data (i32.const 177) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002") - (data (i32.const 222) "(\00\00\000\00x\008\000\000\000\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002") - (data (i32.const 267) "\02\00\00\003") - (data (i32.const 274) "\02\00\00\004") - (data (i32.const 281) "\02\00\00\005") - (data (i32.const 288) "\02\00\00\006") - (data (i32.const 295) "\02\00\00\007") - (data (i32.const 302) "\02\00\00\008") - (data (i32.const 309) "\02\00\00\009") - (data (i32.const 316) "\04\00\00\001\000") - (data (i32.const 325) "\0e\00\00\00s\00q\00r\00t\00(\001\00)") - (data (i32.const 344) "\0e\00\00\00s\00q\00r\00t\00(\004\00)") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 410) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 437) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 470) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 497) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 530) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 565) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 606) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 641) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 682) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 717) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 758) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 793) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 834) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 861) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 894) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 921) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 954) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 368) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 381) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 396) "\02\00\00\000") + (data $20 (i32.const 403) "\02\00\00\000") + (data $21 (i32.const 16) "(\00\00\00N\00u\00m\00b\00e\00r\00 \00s\00a\00n\00i\00t\00y\00 \00c\00h\00e\00c\00k\00s") + (data $22 (i32.const 61) "\02\00\00\001") + (data $23 (i32.const 68) "\0c\00\00\000\00 \00/\00 \001\000") + (data $24 (i32.const 85) "\0e\00\00\001\000\00 \00/\00 \001\000") + (data $25 (i32.const 104) "\10\00\00\001\000\00 \00/\00 \001\000\000") + (data $26 (i32.const 125) "\02\00\00\002") + (data $27 (i32.const 132) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002") + (data $28 (i32.const 177) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002") + (data $29 (i32.const 222) "(\00\00\000\00x\008\000\000\000\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002") + (data $30 (i32.const 267) "\02\00\00\003") + (data $31 (i32.const 274) "\02\00\00\004") + (data $32 (i32.const 281) "\02\00\00\005") + (data $33 (i32.const 288) "\02\00\00\006") + (data $34 (i32.const 295) "\02\00\00\007") + (data $35 (i32.const 302) "\02\00\00\008") + (data $36 (i32.const 309) "\02\00\00\009") + (data $37 (i32.const 316) "\04\00\00\001\000") + (data $38 (i32.const 325) "\0e\00\00\00s\00q\00r\00t\00(\001\00)") + (data $39 (i32.const 344) "\0e\00\00\00s\00q\00r\00t\00(\004\00)") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) (export "test_getLastErrorMessage" (func $1)) @@ -60,30 +60,30 @@ ) (func $1 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$1) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$1) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) (func $2 (param $0 i64) diff --git a/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast b/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast index ed381ae..509bad2 100644 --- a/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast +++ b/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast @@ -1,78 +1,122 @@ (module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $i32_i32_i32_=>_i64 (func (param i32 i32 i32) (result i64))) + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32))) + (type $3 (func (param i32 i32))) + (type $4 (func (param i32 i32 i64))) + (type $5 (func (param i32 i32 i32) (result i64))) + (type $6 (func (param i64) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 358) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 385) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 418) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 445) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 478) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 513) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 554) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 589) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 630) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 665) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 706) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 741) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 782) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 809) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 842) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 869) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 902) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 316) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 329) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 344) "\02\00\00\000") - (data (i32.const 351) "\02\00\00\000") - (data (i32.const 16) "B\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00d\00e\00c\00o\00n\00s\00t\00r\00u\00c\00t") - (data (i32.const 87) "\14\00\00\00i\00s\00R\00e\00d\00(\00R\00e\00d\00)") - (data (i32.const 112) "\18\00\00\00i\00s\00R\00e\00d\00(\00G\00r\00e\00e\00n\00)") - (data (i32.const 141) "\16\00\00\00i\00s\00R\00e\00d\00(\00B\00l\00u\00e\00)") - (data (i32.const 168) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\000\00,\000\00)\00)") - (data (i32.const 217) "(\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\000\00,\001\00,\003\00)\00)") - (data (i32.const 262) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\001\00,\003\00)\00)") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 358) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 385) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 418) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 445) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 478) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 513) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 554) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 589) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 630) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 665) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 706) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 741) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 782) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 809) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 842) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 869) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 902) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 316) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 329) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 344) "\02\00\00\000") + (data $20 (i32.const 351) "\02\00\00\000") + (data $21 (i32.const 16) "B\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00d\00e\00c\00o\00n\00s\00t\00r\00u\00c\00t") + (data $22 (i32.const 87) "\14\00\00\00i\00s\00R\00e\00d\00(\00R\00e\00d\00)") + (data $23 (i32.const 112) "\18\00\00\00i\00s\00R\00e\00d\00(\00G\00r\00e\00e\00n\00)") + (data $24 (i32.const 141) "\16\00\00\00i\00s\00R\00e\00d\00(\00B\00l\00u\00e\00)") + (data $25 (i32.const 168) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\000\00,\000\00)\00)") + (data $26 (i32.const 217) "(\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\000\00,\001\00,\003\00)\00)") + (data $27 (i32.const 262) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\001\00,\003\00)\00)") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $4)) - (export "main" (func $7)) - (start $8) + (export "test_getLastErrorMessage" (func $2)) + (export "main" (func $5)) + (start $6) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) - (func $1 (result i32) - (local $0 i32) - (local $1 i32) - (local $2 i32) + (func $1 (param $0 i32) (param $1 i32) (param $2 i64) + (call $fimport$1 + (i32.eq + (i32.eqz + (local.get $0) + ) + (i32.eqz + (local.get $1) + ) + ) + (i32.wrap_i64 + (local.get $2) + ) + ) + ) + (func $2 (result i32) + (local $0 i64) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) + ) + (i64.const 32) + ) + ) + (i32.const 3) + ) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) + ) + ) + ) + (else + (i32.const 0) + ) + ) + ) + (func $3 (param $0 i32) (param $1 i32) (param $2 i32) (result i64) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i64) (if (i32.lt_u (global.get $global$1) (i32.const 12) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $1 + (local.tee $4 (i32.and (i32.add (global.get $global$0) (i32.add - (local.tee $0 - (global.get $global$3) + (local.tee $3 + (global.get $global$2) ) (i32.const 32) ) @@ -84,154 +128,86 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $5 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) + (local.get $5) + (local.tee $6 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $4) + (local.get $3) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow - (local.get $3) + (local.get $5) + (local.get $6) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $1) - ) - (i32.add - (local.get $0) - (i32.const 16) + (global.set $global$2 + (local.get $4) ) - ) - (func $2 (param $0 i32) - (local $1 i32) - (local.set $1 + (local.set $5 (i32.add - (local.get $0) + (local.tee $3 + (local.tee $4 + (i32.add + (local.get $3) + (i32.const 16) + ) + ) + ) (i32.const 12) ) ) - (loop $label$1 + (loop $label (if (i32.ne - (local.get $0) - (local.get $1) + (local.get $3) + (local.get $5) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $3) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $3 (i32.add - (local.get $0) + (local.get $3) (i32.const 1) ) ) - (br $label$1) - ) - ) - ) - ) - (func $3 (param $0 i32) (param $1 i32) (param $2 i64) - (call $fimport$1 - (i32.eq - (i32.eqz - (local.get $0) - ) - (i32.eqz - (local.get $1) - ) - ) - (i32.wrap_i64 - (local.get $2) - ) - ) - ) - (func $4 (result i32) - (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) - ) - (i32.const 3) - ) - ) - ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) - ) + (br $label) ) ) ) - ) - (func $5 (param $0 i32) (param $1 i32) (param $2 i32) (result i64) - (local $3 i32) - (local $4 i64) - (call $2 - (local.tee $3 - (call $1) - ) - ) (i32.store (i32.wrap_i64 - (local.tee $4 + (local.tee $7 (i64.or (i64.extend_i32_u - (local.get $3) + (local.get $4) ) (i64.const 17179869184) ) @@ -241,8 +217,10 @@ ) (i32.store (i32.add - (i32.wrap_i64 - (local.get $4) + (local.tee $0 + (i32.wrap_i64 + (local.get $7) + ) ) (i32.const 4) ) @@ -250,49 +228,47 @@ ) (i32.store (i32.add - (i32.wrap_i64 - (local.get $4) - ) + (local.get $0) (i32.const 8) ) (local.get $2) ) - (local.get $4) + (local.get $7) ) - (func $6 (param $0 i64) (result i32) - (block $label$1 (result i32) + (func $4 (param $0 i64) (result i32) + (local $1 i32) + (block $block (result i32) (if (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) ) ) (i32.const 1) ) - (block + (then (drop - (br_if $label$1 + (br_if $block (i32.const 0) (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 4) ) ) ) - (br $label$1 + (br $block (i32.and (i32.eqz (i32.load (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $1 + (i32.wrap_i64 + (local.get $0) + ) ) (i32.const 8) ) @@ -302,18 +278,14 @@ (i32.eqz (i32.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) (i32.const 4) ) ) ) (i32.eq (i32.load - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) ) (i32.const 255) ) @@ -325,34 +297,34 @@ (i32.const 1) ) ) - (func $7 + (func $5 (call $fimport$0 (i32.const 16) ) - (call $3 - (call $6 + (call $1 + (call $4 (i64.const 4294967296) ) (i32.const 1) (i64.const 12884901975) ) - (call $3 - (call $6 + (call $1 + (call $4 (i64.const 8589934592) ) (i32.const 0) (i64.const 12884902000) ) - (call $3 - (call $6 + (call $1 + (call $4 (i64.const 12884901888) ) (i32.const 0) (i64.const 12884902029) ) - (call $3 - (call $6 - (call $5 + (call $1 + (call $4 + (call $3 (i32.const 255) (i32.const 0) (i32.const 0) @@ -361,9 +333,9 @@ (i32.const 1) (i64.const 12884902056) ) - (call $3 - (call $6 - (call $5 + (call $1 + (call $4 + (call $3 (i32.const 0) (i32.const 1) (i32.const 3) @@ -372,9 +344,9 @@ (i32.const 0) (i64.const 12884902105) ) - (call $3 - (call $6 - (call $5 + (call $1 + (call $4 + (call $3 (i32.const 255) (i32.const 1) (i32.const 3) @@ -385,7 +357,7 @@ ) (call $fimport$2) ) - (func $8 + (func $6 (global.set $global$0 (i32.const 15) ) @@ -396,9 +368,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/recursiveStruct.lys.optimized.wast b/test/fixtures/execution/recursiveStruct.lys.optimized.wast index 59945ed..0277d72 100644 --- a/test/fixtures/execution/recursiveStruct.lys.optimized.wast +++ b/test/fixtures/execution/recursiveStruct.lys.optimized.wast @@ -1,76 +1,67 @@ (module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i64_=>_i64 (func (param i64) (result i64))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_i64_=>_none (func (param i32 i64))) + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i64) (result i64))) + (type $3 (func (param i32))) + (type $4 (func (param i32 i32))) + (type $5 (func (param i32 i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) - (memory $0 1) - (data (i32.const 246) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 273) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 306) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 333) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 366) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 401) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 442) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 477) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 518) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 553) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 594) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 629) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 670) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 697) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 730) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 757) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 790) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 204) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 217) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 232) "\02\00\00\000") - (data (i32.const 239) "\02\00\00\000") - (data (i32.const 16) "&\00\00\00F\00o\00r\00e\00s\00t\00 \00&\00 \00T\00r\00e\00e\00 \00t\00e\00s\00t\00s") - (data (i32.const 59) "\10\00\00\00a\00 \00i\00s\00 \00N\00i\00l") - (data (i32.const 80) "\14\00\00\00a\00 \00i\00s\00 \00F\00o\00r\00e\00s") - (data (i32.const 105) "\14\00\00\00b\00 \00i\00s\00 \00F\00o\00r\00e\00s") - (data (i32.const 130) "\12\00\00\00c\00 \00i\00s\00 \00C\00o\00n\00s") - (data (i32.const 153) "\12\00\00\00e\00 \00i\00s\00 \00N\00o\00d\00e") - (data (i32.const 176) "\12\00\00\00e\00 \00i\00s\00 \00T\00r\00e\00e") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 246) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 273) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 306) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 333) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 366) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 401) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 442) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 477) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 518) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 553) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 594) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 629) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 670) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 697) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 730) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 757) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 790) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 204) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 217) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 232) "\02\00\00\000") + (data $20 (i32.const 239) "\02\00\00\000") + (data $21 (i32.const 16) "&\00\00\00F\00o\00r\00e\00s\00t\00 \00&\00 \00T\00r\00e\00e\00 \00t\00e\00s\00t\00s") + (data $22 (i32.const 59) "\10\00\00\00a\00 \00i\00s\00 \00N\00i\00l") + (data $23 (i32.const 80) "\14\00\00\00a\00 \00i\00s\00 \00F\00o\00r\00e\00s") + (data $24 (i32.const 105) "\14\00\00\00b\00 \00i\00s\00 \00F\00o\00r\00e\00s") + (data $25 (i32.const 130) "\12\00\00\00c\00 \00i\00s\00 \00C\00o\00n\00s") + (data $26 (i32.const 153) "\12\00\00\00e\00 \00i\00s\00 \00N\00o\00d\00e") + (data $27 (i32.const 176) "\12\00\00\00e\00 \00i\00s\00 \00T\00r\00e\00e") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $4)) - (export "main" (func $8)) - (start $9) + (export "test_getLastErrorMessage" (func $2)) + (export "main" (func $6)) + (start $7) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (result i32) - (local $0 i32) - (call $3 - (local.tee $0 - (call $2) - ) - ) - (local.get $0) - ) - (func $2 (result i32) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) - (local $4 i32) (if (i32.lt_u (global.get $global$1) (i32.const 8) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u @@ -80,7 +71,7 @@ (global.get $global$0) (i32.add (local.tee $0 - (global.get $global$3) + (global.get $global$2) ) (i32.const 32) ) @@ -98,74 +89,58 @@ (i32.const 16) ) ) - (block + (then (drop (memory.grow (select (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) + (local.tee $3 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $1) + (local.get $0) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 + (global.set $global$2 (local.get $1) ) - (i32.add - (local.get $0) - (i32.const 16) - ) - ) - (func $3 (param $0 i32) - (local $1 i32) - (local.set $1 + (local.set $2 (i32.add - (local.get $0) + (local.tee $0 + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 16) + ) + ) + ) (i32.const 8) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) - (block + (then (i32.store8 (local.get $0) (i32.load8_u @@ -178,40 +153,41 @@ (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $1) ) - (func $4 (result i32) + (func $2 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $5 (param $0 i32) (param $1 i64) + (func $3 (param $0 i32) (param $1 i64) (call $fimport$1 (local.get $0) (i32.wrap_i64 @@ -219,7 +195,7 @@ ) ) ) - (func $6 (param $0 i64) (result i64) + (func $4 (param $0 i64) (result i64) (local $1 i64) (i64.store (i32.wrap_i64 @@ -236,7 +212,7 @@ ) (local.get $1) ) - (func $7 (param $0 i64) (result i64) + (func $5 (param $0 i64) (result i64) (local $1 i64) (i64.store (i32.wrap_i64 @@ -253,8 +229,8 @@ ) (local.get $1) ) - (func $8 - (local $0 i64) + (func $6 + (local $0 i32) (local $1 i64) (local $2 i64) (local $3 i64) @@ -262,102 +238,89 @@ (i32.const 16) ) (local.set $1 - (call $7 + (call $5 (i64.const 4294967296) ) ) - (call $5 - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (block (result i64) - (local.set $3 - (call $7 - (i64.const 12884901888) - ) - ) - (drop - (call $7 - (call $6 - (i64.const 4294967296) - ) - ) - ) - (local.set $0 - (call $6 - (i64.const 12884901888) - ) - ) - (call $5 - (i32.const 1) - (i64.const 12884901947) - ) - (call $5 - (i32.const 1) - (i64.const 12884901968) - ) - (call $5 - (i32.or - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $1) - (i64.const 32) - ) - ) - (i32.const 3) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $1) - (i64.const 32) - ) - ) - (i32.const 4) - ) - ) - (i64.const 12884901993) + (local.set $2 + (call $5 + (i64.const 12884901888) + ) + ) + (drop + (call $5 + (call $4 + (i64.const 4294967296) + ) + ) + ) + (local.set $3 + (call $4 + (i64.const 12884901888) + ) + ) + (call $3 + (i32.const 1) + (i64.const 12884901947) + ) + (call $3 + (i32.const 1) + (i64.const 12884901968) + ) + (call $3 + (i32.or + (i32.eq + (local.tee $0 + (i32.wrap_i64 + (i64.shr_u + (local.get $1) + (i64.const 32) ) - (local.get $3) ) - (i64.const 32) ) + (i32.const 3) + ) + (i32.eq + (local.get $0) + (i32.const 4) ) - (i32.const 4) ) - (i64.const 12884902018) + (i64.const 12884901993) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (local.get $0) + (local.get $2) (i64.const 32) ) ) - (i32.const 2) + (i32.const 4) ) - (i64.const 12884902041) + (i64.const 12884902018) ) - (call $5 - (i32.or - (i32.eq + (call $3 + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.get $0) + (local.get $3) (i64.const 32) ) ) + ) + (i32.const 2) + ) + (i64.const 12884902041) + ) + (call $3 + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) @@ -365,7 +328,7 @@ ) (call $fimport$2) ) - (func $9 + (func $7 (global.set $global$0 (i32.const 15) ) @@ -376,9 +339,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/setStructValues.lys.optimized.wast b/test/fixtures/execution/setStructValues.lys.optimized.wast index c80b785..425e889 100644 --- a/test/fixtures/execution/setStructValues.lys.optimized.wast +++ b/test/fixtures/execution/setStructValues.lys.optimized.wast @@ -1,110 +1,97 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i64_=>_none (func (param i64))) - (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_i64 (func (result i64))) - (type $i32_=>_none (func (param i32))) - (type $i32_i64_=>_none (func (param i32 i64))) - (type $i64_i32_=>_none (func (param i64 i32))) - (type $i64_i64_i64_=>_none (func (param i64 i64 i64))) + (type $0 (func (param i32 i32))) + (type $1 (func)) + (type $2 (func (result i32))) + (type $3 (func (param i32 i32 i64))) + (type $4 (func (param i32))) + (type $5 (func (param i32) (result i32))) + (type $6 (func (param i64 i32))) + (type $7 (func (param i64 i64 i64))) + (type $8 (func (param i64))) + (type $9 (func (param i32 i64))) + (type $10 (func (result i64))) (import "test" "printMemory" (func $fimport$0 (param i32 i32))) (import "test" "pushTest" (func $fimport$1 (param i32))) (import "test" "registerAssertion" (func $fimport$2 (param i32 i32))) (import "test" "popTest" (func $fimport$3)) (import "env" "printf" (func $fimport$4 (param i32 i32))) - (memory $0 1) - (data (i32.const 1669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 1696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 1729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 1756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 1789) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1824) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1865) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1900) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1941) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1976) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 2017) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 2052) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 2093) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 2120) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 2153) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 2180) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 2213) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 1627) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 1640) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 1655) "\02\00\00\000") - (data (i32.const 1662) "\02\00\00\000") - (data (i32.const 16) "\10\00\00\00t\00e\00s\00t\00L\00o\00a\00d") - (data (i32.const 37) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \000") - (data (i32.const 74) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000") - (data (i32.const 111) "\12\00\00\00t\00e\00s\00t\00S\00t\00o\00r\00e") - (data (i32.const 134) "\16\00\00\00t\00e\00s\00t\00N\00u\00m\00b\00e\00r\00s") - (data (i32.const 161) " \00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00=\00=\00 \00-\001") - (data (i32.const 198) "<\00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \00-\001\00 \00a\00s\00 \00u\003\002") - (data (i32.const 263) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00%\00X") - (data (i32.const 296) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00%\00X") - (data (i32.const 329) "L\00\00\000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004") - (data (i32.const 410) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \003") - (data (i32.const 447) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001") - (data (i32.const 516) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\003\002") - (data (i32.const 585) "\16\00\00\00V\00A\00R\00 \00=\00=\00 \00V\00A\00R\002") - (data (i32.const 612) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004") - (data (i32.const 695) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00u\006\004") - (data (i32.const 778) "2\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \000\00x\000\001") - (data (i32.const 833) "@\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00,\00 \005\00 \00a\00s\00 \00u\003\002\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \005") - (data (i32.const 902) "(\00\00\00s\00e\00t\00 \00v\00a\00l\00u\00e\00s\00 \00i\00n\00 \00s\00t\00r\00u\00c\00t") - (data (i32.const 947) "4\00\00\00g\00e\00t\00t\00e\00r\00s\00 \00o\00f\00 \00t\00h\00e\00 \00c\00o\00n\00s\00t\00r\00u\00c\00t\00o\00r") - (data (i32.const 1004) "\16\00\00\00a\00 \00i\00s\00 \00C\00a\00t\00B\00a\00g") - (data (i32.const 1031) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r") - (data (i32.const 1060) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r") - (data (i32.const 1089) "\14\00\00\00a\00.\00f\00 \00i\00s\00 \00R\00e\00d") - (data (i32.const 1114) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d") - (data (i32.const 1139) "\0e\00\00\00s\00e\00t\00t\00e\00r\00s") - (data (i32.const 1158) "&\00\00\00y\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D") - (data (i32.const 1201) "\0c\00\00\00y\00 \00=\00=\00 \00y") - (data (i32.const 1218) "\10\00\00\00t\00m\00p\00 \00=\00=\00 \00y") - (data (i32.const 1239) "\10\00\00\00a\00.\00f\00 \00=\00=\00 \00y") - (data (i32.const 1260) "\14\00\00\00a\00.\00f\00 \00=\00=\00 \00t\00m\00p") - (data (i32.const 1285) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d") - (data (i32.const 1310) " \00\00\00v\00a\00l\00i\00d\00a\00t\00e\00 \00s\00e\00t\00t\00e\00r\00s") - (data (i32.const 1347) "\1a\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00u\00s\00t\00o\00m") - (data (i32.const 1378) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d") - (data (i32.const 1403) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r") - (data (i32.const 1432) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r") - (data (i32.const 1461) "&\00\00\00x\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D") - (data (i32.const 1504) "\"\00\00\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D") - (data (i32.const 1543) "J\00\00\00a\00.\00f\00 \00i\00s\00 \00n\00o\00t\00 \00C\00u\00s\00t\00o\00m\00 \00i\00n\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) + (global $global$3 (mut i64) (i64.const 0)) (global $global$4 (mut i64) (i64.const 0)) (global $global$5 (mut i64) (i64.const 0)) - (global $global$6 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 1669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 1696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 1729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 1756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 1789) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 1824) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 1865) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 1900) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 1941) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 1976) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 2017) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 2052) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 2093) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 2120) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 2153) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 2180) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 2213) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 1627) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 1640) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 1655) "\02\00\00\000") + (data $20 (i32.const 1662) "\02\00\00\000") + (data $21 (i32.const 16) "\10\00\00\00t\00e\00s\00t\00L\00o\00a\00d") + (data $22 (i32.const 37) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \000") + (data $23 (i32.const 74) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000") + (data $24 (i32.const 111) "\12\00\00\00t\00e\00s\00t\00S\00t\00o\00r\00e") + (data $25 (i32.const 134) "\16\00\00\00t\00e\00s\00t\00N\00u\00m\00b\00e\00r\00s") + (data $26 (i32.const 161) " \00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00=\00=\00 \00-\001") + (data $27 (i32.const 198) "<\00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \00-\001\00 \00a\00s\00 \00u\003\002") + (data $28 (i32.const 263) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00%\00X") + (data $29 (i32.const 296) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00%\00X") + (data $30 (i32.const 329) "L\00\00\000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004") + (data $31 (i32.const 410) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \003") + (data $32 (i32.const 447) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001") + (data $33 (i32.const 516) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\003\002") + (data $34 (i32.const 585) "\16\00\00\00V\00A\00R\00 \00=\00=\00 \00V\00A\00R\002") + (data $35 (i32.const 612) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004") + (data $36 (i32.const 695) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00u\006\004") + (data $37 (i32.const 778) "2\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \000\00x\000\001") + (data $38 (i32.const 833) "@\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00,\00 \005\00 \00a\00s\00 \00u\003\002\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \005") + (data $39 (i32.const 902) "(\00\00\00s\00e\00t\00 \00v\00a\00l\00u\00e\00s\00 \00i\00n\00 \00s\00t\00r\00u\00c\00t") + (data $40 (i32.const 947) "4\00\00\00g\00e\00t\00t\00e\00r\00s\00 \00o\00f\00 \00t\00h\00e\00 \00c\00o\00n\00s\00t\00r\00u\00c\00t\00o\00r") + (data $41 (i32.const 1004) "\16\00\00\00a\00 \00i\00s\00 \00C\00a\00t\00B\00a\00g") + (data $42 (i32.const 1031) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r") + (data $43 (i32.const 1060) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r") + (data $44 (i32.const 1089) "\14\00\00\00a\00.\00f\00 \00i\00s\00 \00R\00e\00d") + (data $45 (i32.const 1114) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d") + (data $46 (i32.const 1139) "\0e\00\00\00s\00e\00t\00t\00e\00r\00s") + (data $47 (i32.const 1158) "&\00\00\00y\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D") + (data $48 (i32.const 1201) "\0c\00\00\00y\00 \00=\00=\00 \00y") + (data $49 (i32.const 1218) "\10\00\00\00t\00m\00p\00 \00=\00=\00 \00y") + (data $50 (i32.const 1239) "\10\00\00\00a\00.\00f\00 \00=\00=\00 \00y") + (data $51 (i32.const 1260) "\14\00\00\00a\00.\00f\00 \00=\00=\00 \00t\00m\00p") + (data $52 (i32.const 1285) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d") + (data $53 (i32.const 1310) " \00\00\00v\00a\00l\00i\00d\00a\00t\00e\00 \00s\00e\00t\00t\00e\00r\00s") + (data $54 (i32.const 1347) "\1a\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00u\00s\00t\00o\00m") + (data $55 (i32.const 1378) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d") + (data $56 (i32.const 1403) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r") + (data $57 (i32.const 1432) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r") + (data $58 (i32.const 1461) "&\00\00\00x\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D") + (data $59 (i32.const 1504) "\"\00\00\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D") + (data $60 (i32.const 1543) "J\00\00\00a\00.\00f\00 \00i\00s\00 \00n\00o\00t\00 \00C\00u\00s\00t\00o\00m\00 \00i\00n\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $9)) - (export "main" (func $16)) - (start $17) + (export "test_getLastErrorMessage" (func $6)) + (export "main" (func $10)) + (start $11) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (param $0 i32) (result i32) - (local $1 i32) - (call $3 - (local.tee $1 - (call $2 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $2 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -113,32 +100,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$0) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -152,97 +143,83 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$2 + (local.get $2) ) - ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $4 (param $0 i64) (param $1 i32) + (func $2 (param $0 i64) (param $1 i32) (call $fimport$4 (i32.wrap_i64 (local.get $0) @@ -250,48 +227,8 @@ (local.get $1) ) ) - (func $5 (param $0 i64) - (call $11 - (i64.eq - (local.get $0) - (i64.const -1412567295) - ) - (i64.const 12884902583) - ) - (if - (i64.ne - (local.get $0) - (i64.const -1412567295) - ) - (block - (call $4 - (i64.const 12884903677) - (i32.wrap_i64 - (i64.shr_s - (local.get $0) - (i64.const 32) - ) - ) - ) - (call $4 - (i64.const 12884903712) - (i32.const -1) - ) - (call $4 - (i64.const 12884903753) - (i32.wrap_i64 - (local.get $0) - ) - ) - (call $4 - (i64.const 12884903788) - (i32.const -1412567295) - ) - ) - ) - ) - (func $6 (param $0 i64) (param $1 i64) (param $2 i64) - (call $11 + (func $3 (param $0 i64) (param $1 i64) (param $2 i64) + (call $8 (i64.eq (local.get $0) (local.get $1) @@ -303,8 +240,8 @@ (local.get $0) (local.get $1) ) - (block - (call $4 + (then + (call $2 (i64.const 12884903829) (i32.wrap_i64 (i64.shr_s @@ -313,7 +250,7 @@ ) ) ) - (call $4 + (call $2 (i64.const 12884903864) (i32.wrap_i64 (i64.shr_s @@ -322,13 +259,13 @@ ) ) ) - (call $4 + (call $2 (i64.const 12884903905) (i32.wrap_i64 (local.get $0) ) ) - (call $4 + (call $2 (i64.const 12884903940) (i32.wrap_i64 (local.get $1) @@ -337,8 +274,8 @@ ) ) ) - (func $7 (param $0 i32) (param $1 i32) (param $2 i64) - (call $11 + (func $4 (param $0 i32) (param $1 i32) (param $2 i64) + (call $8 (i32.eq (local.get $0) (local.get $1) @@ -350,20 +287,20 @@ (local.get $0) (local.get $1) ) - (block - (call $4 + (then + (call $2 (i64.const 12884903981) (local.get $0) ) - (call $4 + (call $2 (i64.const 12884904008) (local.get $1) ) ) ) ) - (func $8 (param $0 i32) (param $1 i32) (param $2 i64) - (call $11 + (func $5 (param $0 i32) (param $1 i32) (param $2 i64) + (call $8 (i32.eq (local.get $0) (local.get $1) @@ -375,54 +312,54 @@ (local.get $0) (local.get $1) ) - (block - (call $4 + (then + (call $2 (i64.const 12884904041) (local.get $0) ) - (call $4 + (call $2 (i64.const 12884904068) (local.get $1) ) ) ) ) - (func $9 (result i32) + (func $6 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $10 (param $0 i64) + (func $7 (param $0 i64) (call $fimport$1 (i32.wrap_i64 (local.get $0) ) ) ) - (func $11 (param $0 i32) (param $1 i64) + (func $8 (param $0 i32) (param $1 i64) (call $fimport$2 (local.get $0) (i32.wrap_i64 @@ -430,35 +367,7 @@ ) ) ) - (func $12 (result i64) - (local $0 i64) - (i64.store - (i32.wrap_i64 - (local.tee $0 - (i64.or - (i64.extend_i32_u - (call $1 - (i32.const 16) - ) - ) - (i64.const 17179869184) - ) - ) - ) - (i64.const 8589934592) - ) - (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 8) - ) - (i64.const 4294967296) - ) - (local.get $0) - ) - (func $13 (result i64) + (func $9 (result i64) (local $0 i64) (i32.store (i32.wrap_i64 @@ -486,295 +395,131 @@ ) (local.get $0) ) - (func $14 - (call $10 - (i64.const 12884901999) - ) - (i32.store - (i32.wrap_i64 - (global.get $global$5) - ) - (i32.const 3) + (func $10 + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i64) + (local $5 i64) + (local $6 i64) + (call $7 + (i64.const 12884902790) ) - (i32.store + (i64.store (i32.wrap_i64 - (global.get $global$6) + (local.tee $4 + (i64.or + (i64.extend_i32_u + (call $1 + (i32.const 16) + ) + ) + (i64.const 17179869184) + ) + ) ) - (i32.const -1412567295) + (i64.const 8589934592) ) - (i32.store - (i32.add - (i32.wrap_i64 - (global.get $global$6) + (i64.store + (local.tee $3 + (i32.add + (local.tee $0 + (i32.wrap_i64 + (local.get $4) + ) + ) + (i32.const 8) ) - (i32.const 5) ) - (i32.const 5) - ) - (call $fimport$3) - ) - (func $15 - (call $10 - (i64.const 12884902022) + (i64.const 4294967296) ) - (call $8 - (i32.const -1) - (i32.const -1) - (i64.const 12884902049) + (call $fimport$0 + (local.get $0) + (i32.const 16) ) (call $7 - (i32.const -1) - (i32.const -1) - (i64.const 12884902086) - ) - (call $10 - (i64.const 12884901904) + (i64.const 12884902835) ) (call $8 - (i32.load + (i32.eq (i32.wrap_i64 - (global.get $global$5) + (i64.shr_u + (local.get $4) + (i64.const 32) + ) ) + (i32.const 4) ) - (i32.const 0) - (i64.const 12884901925) + (i64.const 12884902892) ) (call $8 - (i32.load - (i32.wrap_i64 - (global.get $global$6) - ) - ) - (i32.const 0) - (i64.const 12884901962) - ) - (call $fimport$3) - (call $14) - (call $4 - (i64.const 12884902151) - (i32.load - (i32.wrap_i64 - (global.get $global$5) + (i32.or + (i32.eq + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (i64.load + (local.get $0) + ) + (i64.const 32) + ) + ) + ) + (i32.const 3) ) - ) - ) - (call $4 - (i64.const 12884902184) - (i32.load - (i32.wrap_i64 - (global.get $global$6) + (i32.or + (i32.eq + (local.get $1) + (i32.const 1) + ) + (i32.eq + (local.get $1) + (i32.const 2) + ) ) ) - ) - (call $6 - (i64.const 2882400001) - (i64.const 2882400001) - (i64.const 12884902217) + (i64.const 12884902919) ) (call $8 - (i32.load - (i32.wrap_i64 - (global.get $global$5) - ) - ) - (i32.const 3) - (i64.const 12884902298) - ) - (call $7 - (i32.load - (i32.wrap_i64 - (global.get $global$6) - ) - ) - (i32.const -1412567295) - (i64.const 12884902335) - ) - (call $8 - (i32.load - (i32.wrap_i64 - (global.get $global$6) - ) - ) - (i32.const -1412567295) - (i64.const 12884902404) - ) - (call $6 - (i64.extend_i32_s - (i32.load - (i32.wrap_i64 - (global.get $global$6) - ) - ) - ) - (i64.const -1412567295) - (i64.const 12884902473) - ) - (call $6 - (i64.extend_i32_s - (i32.load - (i32.wrap_i64 - (global.get $global$6) - ) - ) - ) - (i64.const -1412567295) - (i64.const 12884902500) - ) - (call $5 - (i64.extend_i32_s - (i32.load - (i32.wrap_i64 - (global.get $global$6) - ) - ) - ) - ) - (call $8 - (i32.load8_u - (i32.wrap_i64 - (global.get $global$6) - ) - ) - (i32.const 1) - (i64.const 12884902666) - ) - (call $8 - (i32.load8_u - (i32.add - (i32.wrap_i64 - (global.get $global$6) - ) - (i32.const 5) - ) - ) - (i32.const 5) - (i64.const 12884902721) - ) - (call $fimport$3) - ) - (func $16 - (local $0 i32) - (local $1 i64) - (local $2 i64) - (local $3 i64) - (local $4 i32) - (call $10 - (i64.const 12884902790) - ) - (call $fimport$0 - (i32.wrap_i64 - (local.tee $1 - (call $12) - ) - ) - (i32.const 16) - ) - (call $10 - (i64.const 12884902835) - ) - (call $11 - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $1) - (i64.const 32) - ) - ) - (i32.const 4) - ) - (i64.const 12884902892) - ) - (call $11 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $2 (i32.wrap_i64 (i64.shr_u - (local.tee $2 - (i64.load - (i32.wrap_i64 - (local.get $1) + (i64.load + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 8) ) ) ) (i64.const 32) ) ) - (i32.const 1) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) - (i32.const 2) - ) - ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) ) (i32.const 3) ) - ) - (i64.const 12884902919) - ) - (call $11 - (i32.or (i32.or (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.tee $2 - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $1) - ) - (i32.const 8) - ) - ) - ) - (i64.const 32) - ) - ) + (local.get $2) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) + (local.get $2) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) (i64.const 12884902948) ) - (call $11 + (call $8 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.wrap_i64 - (local.get $1) - ) + (local.get $0) ) (i64.const 32) ) @@ -783,17 +528,12 @@ ) (i64.const 12884902977) ) - (call $11 + (call $8 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $1) - ) - (i32.const 8) - ) + (local.get $3) ) (i64.const 32) ) @@ -803,12 +543,12 @@ (i64.const 12884903002) ) (call $fimport$3) - (call $10 + (call $7 (i64.const 12884903027) ) (i32.store (i32.wrap_i64 - (local.tee $2 + (local.tee $5 (i64.or (i64.extend_i32_u (call $1 @@ -821,11 +561,11 @@ ) (i32.const -1430532899) ) - (call $11 + (call $8 (i32.eq (i32.load (i32.wrap_i64 - (local.get $2) + (local.get $5) ) ) (i32.const -1430532899) @@ -833,70 +573,52 @@ (i64.const 12884903046) ) (i64.store - (i32.wrap_i64 - (local.get $1) - ) - (local.get $2) + (local.get $0) + (local.get $5) ) - (call $11 + (call $8 (i32.const 1) (i64.const 12884903089) ) - (call $11 + (call $8 (i64.eq - (local.get $2) - (local.tee $3 + (local.get $5) + (local.tee $6 (i64.load - (i32.wrap_i64 - (local.get $1) - ) + (local.get $0) ) ) ) (i64.const 12884903106) ) - (call $11 + (call $8 (i64.eq - (local.get $2) + (local.get $5) (i64.load - (i32.wrap_i64 - (local.get $1) - ) + (local.get $0) ) ) (i64.const 12884903127) ) - (call $11 + (call $8 (i64.eq - (local.get $3) + (local.get $6) (i64.load - (i32.wrap_i64 - (local.get $1) - ) + (local.get $0) ) ) (i64.const 12884903148) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $1) - ) - (i32.const 8) - ) + (local.get $1) (i64.const 8589934592) ) - (call $11 + (call $8 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $1) - ) - (i32.const 8) - ) + (local.get $1) ) (i64.const 32) ) @@ -906,17 +628,15 @@ (i64.const 12884903173) ) (call $fimport$3) - (call $10 + (call $7 (i64.const 12884903198) ) - (call $11 + (call $8 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.wrap_i64 - (local.get $1) - ) + (local.get $0) ) (i64.const 32) ) @@ -925,17 +645,12 @@ ) (i64.const 12884903235) ) - (call $11 + (call $8 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $1) - ) - (i32.const 8) - ) + (local.get $1) ) (i64.const 32) ) @@ -944,98 +659,71 @@ ) (i64.const 12884903266) ) - (call $11 + (call $8 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $2 - (i64.load - (i32.wrap_i64 - (local.get $1) - ) - ) + (i64.load + (local.get $0) ) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) (i64.const 12884903291) ) - (call $11 + (call $8 (i32.or - (i32.or - (i32.eq + (i32.eq + (local.tee $0 (i32.wrap_i64 (i64.shr_u - (local.tee $2 - (i64.load - (i32.add - (i32.wrap_i64 - (local.get $1) - ) - (i32.const 8) - ) - ) + (i64.load + (local.get $1) ) (i64.const 32) ) ) + ) + (i32.const 3) + ) + (i32.or + (i32.eq + (local.get $0) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) + (local.get $0) (i32.const 2) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) - (i32.const 3) - ) ) (i64.const 12884903320) ) - (block $label$1 + (block $block (if (i32.ne (i32.wrap_i64 (i64.shr_u - (local.tee $1 + (local.tee $4 (i64.load (i32.wrap_i64 - (local.get $1) + (local.get $4) ) ) ) @@ -1044,47 +732,231 @@ ) (i32.const 3) ) - (block - (call $11 + (then + (call $8 (i32.const 0) (i64.const 12884903431) ) - (br $label$1) + (br $block) ) ) - (call $11 + (call $8 (i32.eq - (block (result i32) - (local.set $4 - (i32.load - (i32.wrap_i64 - (local.get $1) - ) - ) - ) - (call $11 - (i32.eq - (i32.load - (i32.wrap_i64 - (local.get $1) - ) - ) - (i32.const -1430532899) + (local.tee $0 + (i32.load + (i32.wrap_i64 + (local.get $4) ) - (i64.const 12884903349) ) - (local.get $4) ) (i32.const -1430532899) ) + (i64.const 12884903349) + ) + (call $8 + (i32.eq + (local.get $0) + (i32.const -1430532899) + ) (i64.const 12884903392) ) ) (call $fimport$3) - (call $15) + (call $7 + (i64.const 12884902022) + ) + (call $5 + (i32.const -1) + (i32.const -1) + (i64.const 12884902049) + ) + (call $4 + (i32.const -1) + (i32.const -1) + (i64.const 12884902086) + ) + (call $7 + (i64.const 12884901904) + ) + (call $5 + (i32.load + (i32.wrap_i64 + (global.get $global$4) + ) + ) + (i32.const 0) + (i64.const 12884901925) + ) + (call $5 + (i32.load + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i32.const 0) + (i64.const 12884901962) + ) + (call $fimport$3) + (call $7 + (i64.const 12884901999) + ) + (i32.store + (i32.wrap_i64 + (global.get $global$4) + ) + (i32.const 3) + ) + (i32.store + (local.tee $0 + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i32.const -1412567295) + ) + (i32.store + (i32.add + (local.get $0) + (i32.const 5) + ) + (i32.const 5) + ) + (call $fimport$3) + (call $2 + (i64.const 12884902151) + (i32.load + (i32.wrap_i64 + (global.get $global$4) + ) + ) + ) + (call $2 + (i64.const 12884902184) + (i32.load + (i32.wrap_i64 + (global.get $global$5) + ) + ) + ) + (call $3 + (i64.const 2882400001) + (i64.const 2882400001) + (i64.const 12884902217) + ) + (call $5 + (i32.load + (i32.wrap_i64 + (global.get $global$4) + ) + ) + (i32.const 3) + (i64.const 12884902298) + ) + (call $4 + (i32.load + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i32.const -1412567295) + (i64.const 12884902335) + ) + (call $5 + (i32.load + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i32.const -1412567295) + (i64.const 12884902404) + ) + (call $3 + (i64.load32_s + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i64.const -1412567295) + (i64.const 12884902473) + ) + (call $3 + (i64.load32_s + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i64.const -1412567295) + (i64.const 12884902500) + ) + (call $8 + (i64.eq + (local.tee $4 + (i64.load32_s + (i32.wrap_i64 + (global.get $global$5) + ) + ) + ) + (i64.const -1412567295) + ) + (i64.const 12884902583) + ) + (if + (i64.ne + (local.get $4) + (i64.const -1412567295) + ) + (then + (call $2 + (i64.const 12884903677) + (i32.wrap_i64 + (i64.shr_s + (local.get $4) + (i64.const 32) + ) + ) + ) + (call $2 + (i64.const 12884903712) + (i32.const -1) + ) + (call $2 + (i64.const 12884903753) + (i32.wrap_i64 + (local.get $4) + ) + ) + (call $2 + (i64.const 12884903788) + (i32.const -1412567295) + ) + ) + ) + (call $5 + (i32.load8_u + (i32.wrap_i64 + (global.get $global$5) + ) + ) + (i32.const 1) + (i64.const 12884902666) + ) + (call $5 + (i32.load8_u + (i32.add + (i32.wrap_i64 + (global.get $global$5) + ) + (i32.const 5) + ) + ) + (i32.const 5) + (i64.const 12884902721) + ) + (call $fimport$3) (call $fimport$3) ) - (func $17 + (func $11 (global.set $global$0 (i32.const 15) ) @@ -1095,16 +967,13 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) + (i64.const 8589934592) ) (global.set $global$4 - (i64.const 8589934592) + (call $9) ) (global.set $global$5 - (call $13) - ) - (global.set $global$6 - (call $13) + (call $9) ) ) ) diff --git a/test/fixtures/execution/simpleIterator.lys.optimized.wast b/test/fixtures/execution/simpleIterator.lys.optimized.wast index a6bb73f..8be35aa 100644 --- a/test/fixtures/execution/simpleIterator.lys.optimized.wast +++ b/test/fixtures/execution/simpleIterator.lys.optimized.wast @@ -1,50 +1,47 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i64_i32_=>_none (func (param i64 i32))) - (type $none_=>_i64 (func (result i64))) - (type $i64_=>_i64 (func (param i64) (result i64))) + (type $0 (func)) + (type $1 (func (param i32 i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32))) + (type $4 (func (param i64 i32))) + (type $5 (func (param i32) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (import "env" "printf" (func $fimport$3 (param i32 i32))) - (memory $0 1) - (data (i32.const 121) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 148) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 181) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 208) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 241) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 276) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 317) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 352) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 393) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 428) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 469) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 504) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 545) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 572) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 605) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 632) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 665) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 79) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 92) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 107) "\02\00\00\000") - (data (i32.const 114) "\02\00\00\000") - (data (i32.const 16) "\1a\00\00\00I\00t\00e\00r\00a\00t\00o\00r\00 \00t\00e\00s\00t") - (data (i32.const 47) "\16\00\00\00s\00p\00e\00c\00 \00t\00e\00s\00t\00 \001") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 121) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 148) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 181) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 208) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 241) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 276) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 317) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 352) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 393) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 428) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 469) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 504) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 545) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 572) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 605) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 632) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 665) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 79) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 92) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 107) "\02\00\00\000") + (data $20 (i32.const 114) "\02\00\00\000") + (data $21 (i32.const 16) "\1a\00\00\00I\00t\00e\00r\00a\00t\00o\00r\00 \00t\00e\00s\00t") + (data $22 (i32.const 47) "\16\00\00\00s\00p\00e\00c\00 \00t\00e\00s\00t\00 \001") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $1)) - (export "test_getLastErrorMessage" (func $6)) - (export "main" (func $10)) - (start $11) + (export "test_getLastErrorMessage" (func $3)) + (export "main" (func $4)) + (start $5) (func $0 (param $0 i64) (param $1 i32) (call $fimport$3 (i32.wrap_i64 @@ -54,21 +51,9 @@ ) ) (func $1 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $2 (param $0 i32) (result i32) - (local $1 i32) - (call $4 - (local.tee $1 - (call $3 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $3 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -77,32 +62,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$0) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -116,154 +105,122 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$2 + (local.get $2) ) - ) - (func $4 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $5 (param $0 i32) - (call $fimport$1 + (func $3 (result i32) + (local $0 i64) + (if (result i32) (i32.eq - (local.get $0) - (i32.const 55) - ) - (i32.const 47) - ) - (if - (i32.ne - (local.get $0) - (i32.const 55) - ) - (block - (call $0 - (i64.const 12884902493) - (local.get $0) - ) - (call $0 - (i64.const 12884902520) - (i32.const 55) + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) + ) + (i64.const 32) + ) ) + (i32.const 3) ) - ) - ) - (func $6 (result i32) - (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne + (then + (i32.wrap_i64 + (i64.load (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (local.get $0) ) - (i32.const 3) ) ) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) - ) - ) + (else + (i32.const 0) ) ) ) - (func $7 (result i64) - (local $0 i64) + (func $4 + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i64) + (local $4 i64) + (call $fimport$0 + (i32.const 16) + ) (i32.store (i32.wrap_i64 - (local.tee $0 + (local.tee $4 (i64.or (i64.extend_i32_u (call $2 @@ -279,89 +236,66 @@ (i32.store (i32.add (i32.wrap_i64 - (local.get $0) + (local.get $4) ) (i32.const 4) ) (i32.const 10) ) - (local.get $0) - ) - (func $8 (param $0 i64) (result i64) - (local $1 i32) - (local $2 i64) - (if (result i64) - (i32.le_s - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) - ) - ) - (block (result i64) - (local.set $1 - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - ) - (i32.store - (i32.wrap_i64 - (local.tee $2 - (i64.or - (i64.extend_i32_u - (call $2 - (i32.const 4) - ) - ) - (i64.const 12884901888) - ) - ) - ) - (local.get $1) - ) - (i32.store - (i32.wrap_i64 - (local.get $0) - ) - (i32.add - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) - ) - (local.get $2) - ) - (i64.const 8589934592) - ) - ) - (func $9 (result i32) - (local $0 i32) - (local $1 i64) - (local $2 i64) - (local.set $1 - (call $7) - ) - (loop $label$1 + (loop $label (if (i32.eq (i32.wrap_i64 (i64.shr_u - (local.tee $2 - (call $8 - (local.get $1) + (local.tee $3 + (if (result i64) + (i32.le_s + (local.tee $2 + (i32.load + (local.tee $1 + (i32.wrap_i64 + (local.get $4) + ) + ) + ) + ) + (i32.load + (i32.add + (local.get $1) + (i32.const 4) + ) + ) + ) + (then + (i32.store + (i32.wrap_i64 + (local.tee $3 + (i64.or + (i64.extend_i32_u + (call $2 + (i32.const 4) + ) + ) + (i64.const 12884901888) + ) + ) + ) + (local.get $2) + ) + (i32.store + (local.get $1) + (i32.add + (i32.load + (local.get $1) + ) + (i32.const 1) + ) + ) + (local.get $3) + ) + (else + (i64.const 8589934592) + ) ) ) (i64.const 32) @@ -369,33 +303,47 @@ ) (i32.const 3) ) - (block + (then (local.set $0 (i32.add (local.get $0) (i32.load (i32.wrap_i64 - (local.get $2) + (local.get $3) ) ) ) ) - (br $label$1) + (br $label) ) ) ) - (local.get $0) - ) - (func $10 - (call $fimport$0 - (i32.const 16) + (call $fimport$1 + (i32.eq + (local.get $0) + (i32.const 55) + ) + (i32.const 47) ) - (call $5 - (call $9) + (if + (i32.ne + (local.get $0) + (i32.const 55) + ) + (then + (call $0 + (i64.const 12884902493) + (local.get $0) + ) + (call $0 + (i64.const 12884902520) + (i32.const 55) + ) + ) ) (call $fimport$2) ) - (func $11 + (func $5 (global.set $global$0 (i32.const 15) ) @@ -406,9 +354,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/strConcat.lys.optimized.wast b/test/fixtures/execution/strConcat.lys.optimized.wast index 4fb9119..2c2a155 100644 --- a/test/fixtures/execution/strConcat.lys.optimized.wast +++ b/test/fixtures/execution/strConcat.lys.optimized.wast @@ -1,93 +1,89 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i64_=>_none (func (param i64))) - (type $none_=>_i32 (func (result i32))) - (type $i64_i64_=>_i64 (func (param i64 i64) (result i64))) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_i64_=>_none (func (param i32 i32 i64))) - (type $i32_i64_=>_none (func (param i32 i64))) - (type $i32_f64_=>_none (func (param i32 f64))) - (type $i64_i32_=>_none (func (param i64 i32))) - (type $i64_i64_i64_=>_none (func (param i64 i64 i64))) - (type $i64_f64_=>_none (func (param i64 f64))) - (type $f64_f64_i64_=>_none (func (param f64 f64 i64))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i64_i32_=>_i32 (func (param i64 i32) (result i32))) - (type $i64_i64_=>_i32 (func (param i64 i64) (result i32))) - (type $i32_=>_i64 (func (param i32) (result i64))) + (type $0 (func)) + (type $1 (func (param i32 i32))) + (type $2 (func (param i64))) + (type $3 (func (result i32))) + (type $4 (func (param i32))) + (type $5 (func (param i32 f64))) + (type $6 (func (param i64 i32))) + (type $7 (func (param i64 f64))) + (type $8 (func (param i32 i32 i32) (result i32))) + (type $9 (func (param f64 f64 i64))) + (type $10 (func (param i32 i32 i64))) + (type $11 (func (param i64 i64 i64))) + (type $12 (func (param i32 i64))) + (type $13 (func (param i64 i64) (result i64))) + (type $14 (func (param i64 i64) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (import "env" "printf" (func $fimport$3 (param i32 i32))) (import "env" "printf" (func $fimport$4 (param i32 f64))) - (memory $0 1) - (data (i32.const 1123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 1150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 1183) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 1210) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 1243) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1278) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1319) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1354) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1395) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1430) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1471) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1506) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 1574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 1607) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 1634) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 1667) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 1081) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 1094) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 1109) "\02\00\00\000") - (data (i32.const 1116) "\02\00\00\000") - (data (i32.const 16) ".\00\00\00T\00e\00s\00t\00 \00b\00y\00t\00e\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n") - (data (i32.const 67) "\06\00\00\00a\00b\00c") - (data (i32.const 78) "\08\00\00\001\002\003\004") - (data (i32.const 91) "\1a\00\00\00a\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \003") - (data (i32.const 122) "\1a\00\00\00b\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \004") - (data (i32.const 153) "\1a\00\00\00c\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \007") - (data (i32.const 184) "\0e\00\00\00a\00b\00c\001\002\003\004") - (data (i32.const 203) "$\00\00\00c\00 \00=\00=\00 \00\'\00a\00b\00c\001\002\003\004\00\'\00 \00(\001\00)") - (data (i32.const 244) "\0e\00\00\00a\00b\00c\001\002\003\004") - (data (i32.const 263) "$\00\00\00c\00 \00=\00=\00 \00\'\00a\00b\00c\001\002\003\004\00\'\00 \00(\002\00)") - (data (i32.const 304) "\1c\00\00\00d\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \002\008") - (data (i32.const 337) "\1c\00\00\00a\00b\00c\001\002\003\004\00a\00b\00c\001\002\003\004") - (data (i32.const 370) ",\00\00\00T\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00o\00p\00e\00r\00a\00t\00i\00o\00n\00s") - (data (i32.const 419) "\0c\00\00\00a\00s\00d\00n\'5\d8\11\dc") - (data (i32.const 436) "\1e\00\00\00s\00t\00r\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \006") - (data (i32.const 471) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \000") - (data (i32.const 494) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \001") - (data (i32.const 517) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \002") - (data (i32.const 540) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \003") - (data (i32.const 563) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \004") - (data (i32.const 586) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \005") - (data (i32.const 609) "(\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n") - (data (i32.const 654) "\04\00\00\00d\00s") - (data (i32.const 663) "\04\00\00\00s\00a") - (data (i32.const 672) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \004") - (data (i32.const 723) "4\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00 \00U\00T\00F\001\006") - (data (i32.const 780) "\04\00\00\00a\00b") - (data (i32.const 789) "\06\00\00\00\b5\00\9c&\0e\fe") - (data (i32.const 800) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \005") - (data (i32.const 851) "$\00\00\00a\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") - (data (i32.const 892) "$\00\00\00b\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") - (data (i32.const 933) "$\00\00\00\b5\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") - (data (i32.const 974) ".\00\00\000\00x\002\006\009\00C\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") - (data (i32.const 1025) ".\00\00\000\00x\00F\00E\000\00E\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 1123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 1150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 1183) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 1210) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 1243) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 1278) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 1319) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 1354) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 1395) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 1430) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 1471) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 1506) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 1547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 1574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 1607) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 1634) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 1667) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 1081) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 1094) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 1109) "\02\00\00\000") + (data $20 (i32.const 1116) "\02\00\00\000") + (data $21 (i32.const 16) ".\00\00\00T\00e\00s\00t\00 \00b\00y\00t\00e\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n") + (data $22 (i32.const 67) "\06\00\00\00a\00b\00c") + (data $23 (i32.const 78) "\08\00\00\001\002\003\004") + (data $24 (i32.const 91) "\1a\00\00\00a\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \003") + (data $25 (i32.const 122) "\1a\00\00\00b\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \004") + (data $26 (i32.const 153) "\1a\00\00\00c\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \007") + (data $27 (i32.const 184) "\0e\00\00\00a\00b\00c\001\002\003\004") + (data $28 (i32.const 203) "$\00\00\00c\00 \00=\00=\00 \00\'\00a\00b\00c\001\002\003\004\00\'\00 \00(\001\00)") + (data $29 (i32.const 244) "\0e\00\00\00a\00b\00c\001\002\003\004") + (data $30 (i32.const 263) "$\00\00\00c\00 \00=\00=\00 \00\'\00a\00b\00c\001\002\003\004\00\'\00 \00(\002\00)") + (data $31 (i32.const 304) "\1c\00\00\00d\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \002\008") + (data $32 (i32.const 337) "\1c\00\00\00a\00b\00c\001\002\003\004\00a\00b\00c\001\002\003\004") + (data $33 (i32.const 370) ",\00\00\00T\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00o\00p\00e\00r\00a\00t\00i\00o\00n\00s") + (data $34 (i32.const 419) "\0c\00\00\00a\00s\00d\00n\'5\d8\11\dc") + (data $35 (i32.const 436) "\1e\00\00\00s\00t\00r\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \006") + (data $36 (i32.const 471) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \000") + (data $37 (i32.const 494) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \001") + (data $38 (i32.const 517) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \002") + (data $39 (i32.const 540) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \003") + (data $40 (i32.const 563) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \004") + (data $41 (i32.const 586) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \005") + (data $42 (i32.const 609) "(\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n") + (data $43 (i32.const 654) "\04\00\00\00d\00s") + (data $44 (i32.const 663) "\04\00\00\00s\00a") + (data $45 (i32.const 672) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \004") + (data $46 (i32.const 723) "4\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00 \00U\00T\00F\001\006") + (data $47 (i32.const 780) "\04\00\00\00a\00b") + (data $48 (i32.const 789) "\06\00\00\00\b5\00\9c&\0e\fe") + (data $49 (i32.const 800) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \005") + (data $50 (i32.const 851) "$\00\00\00a\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") + (data $51 (i32.const 892) "$\00\00\00b\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") + (data $52 (i32.const 933) "$\00\00\00\b5\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") + (data $53 (i32.const 974) ".\00\00\000\00x\002\006\009\00C\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") + (data $54 (i32.const 1025) ".\00\00\000\00x\00F\00E\000\00E\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $3)) - (export "test_getLastErrorMessage" (func $10)) - (export "main" (func $18)) - (start $19) + (export "test_getLastErrorMessage" (func $8)) + (export "main" (func $13)) + (start $14) (func $0 (param $0 i64) (call $fimport$3 (i32.wrap_i64 @@ -113,116 +109,9 @@ ) ) (func $3 (result i32) - (global.get $global$3) - ) - (func $4 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (if - (i32.eqz - (local.get $0) - ) - (unreachable) - ) - (if - (i32.lt_u - (global.get $global$1) - (local.get $0) - ) - (unreachable) - ) - (if - (i32.gt_u - (local.tee $0 - (i32.and - (i32.add - (global.get $global$0) - (i32.add - (i32.add - (local.tee $1 - (global.get $global$3) - ) - (i32.const 16) - ) - (select - (local.get $0) - (i32.const 16) - (i32.gt_u - (local.get $0) - (i32.const 16) - ) - ) - ) - ) - (i32.xor - (global.get $global$0) - (i32.const -1) - ) - ) - ) - (i32.shl - (local.tee $2 - (memory.size) - ) - (i32.const 16) - ) - ) - (block - (drop - (memory.grow - (select - (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) - ) - (i32.const -65536) - ) - (i32.const 16) - ) - ) - ) - (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow - (local.get $3) - ) - ) - (if - (i32.const 0) - (unreachable) - ) - ) - ) - ) - ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) - ) + (global.get $global$2) ) - (func $5 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $4 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i64) (local $5 i64) @@ -236,13 +125,13 @@ (local.get $0) ) ) - (loop $label$1 + (loop $label (if (i32.gt_u (local.get $2) (local.get $3) ) - (block + (then (i32.store8 (i32.add (local.get $3) @@ -265,7 +154,7 @@ (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) @@ -274,39 +163,8 @@ (local.get $2) ) ) - (func $6 (param $0 i32) (param $1 i32) - (local.set $1 - (i32.add - (local.get $0) - (local.get $1) - ) - ) - (loop $label$1 - (if - (i32.ne - (local.get $0) - (local.get $1) - ) - (block - (i32.store8 - (local.get $0) - (i32.load8_u - (i32.const 0) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $label$1) - ) - ) - ) - ) - (func $7 (param $0 f64) (param $1 f64) (param $2 i64) - (call $12 + (func $5 (param $0 f64) (param $1 f64) (param $2 i64) + (call $10 (f64.eq (local.get $0) (local.get $1) @@ -318,7 +176,7 @@ (local.get $0) (local.get $1) ) - (block + (then (call $2 (i64.const 12884903011) (local.get $0) @@ -330,8 +188,8 @@ ) ) ) - (func $8 (param $0 i32) (param $1 i32) (param $2 i64) - (call $12 + (func $6 (param $0 i32) (param $1 i32) (param $2 i64) + (call $10 (i32.eq (local.get $0) (local.get $1) @@ -343,7 +201,7 @@ (local.get $0) (local.get $1) ) - (block + (then (call $1 (i64.const 12884903435) (local.get $0) @@ -355,9 +213,9 @@ ) ) ) - (func $9 (param $0 i64) (param $1 i64) (param $2 i64) - (call $12 - (call $16 + (func $7 (param $0 i64) (param $1 i64) (param $2 i64) + (call $10 + (call $12 (local.get $0) (local.get $1) ) @@ -365,12 +223,12 @@ ) (if (i32.eqz - (call $16 + (call $12 (local.get $0) (local.get $1) ) ) - (block + (then (call $0 (local.get $0) ) @@ -380,42 +238,42 @@ ) ) ) - (func $10 (result i32) + (func $8 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $11 (param $0 i64) + (func $9 (param $0 i64) (call $fimport$0 (i32.wrap_i64 (local.get $0) ) ) ) - (func $12 (param $0 i32) (param $1 i64) + (func $10 (param $0 i32) (param $1 i64) (call $fimport$1 (local.get $0) (i32.wrap_i64 @@ -423,85 +281,182 @@ ) ) ) - (func $13 (param $0 i64) (param $1 i64) (result i64) - (call $15 - (local.get $0) - (local.get $1) + (func $11 (param $0 i64) (param $1 i64) (result i64) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i64) + (if + (i32.eqz + (local.tee $2 + (local.tee $8 + (i32.add + (local.tee $7 + (i32.add + (local.tee $5 + (i32.and + (i32.load + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const -2) + ) + ) + (local.tee $6 + (i32.and + (i32.load + (i32.wrap_i64 + (local.get $1) + ) + ) + (i32.const -2) + ) + ) + ) + ) + (i32.const 4) + ) + ) + ) + ) + (then + (unreachable) + ) + ) + (if + (i32.lt_u + (global.get $global$1) + (local.get $2) + ) + (then + (unreachable) + ) ) - ) - (func $14 (param $0 i64) (param $1 i32) (result i32) (if (i32.gt_u - (local.get $1) - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.and + (i32.add + (global.get $global$0) + (i32.add + (i32.add + (local.tee $3 + (global.get $global$2) + ) + (i32.const 16) + ) + (select + (i32.const 16) + (local.get $2) + (i32.le_u + (local.get $2) + (i32.const 16) + ) + ) + ) + ) + (i32.xor + (global.get $global$0) + (i32.const -1) + ) + ) + ) + (i32.shl + (local.tee $4 + (memory.size) + ) + (i32.const 16) + ) + ) + (then + (drop + (memory.grow + (select + (local.get $4) + (local.tee $9 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $3) + ) + (i32.const 65535) + ) + (i32.const -65536) + ) + (i32.const 16) + ) + ) + (i32.gt_u + (local.get $4) + (local.get $9) + ) ) ) - (i32.const 1) ) ) - (unreachable) ) - (i32.load16_u + (global.set $global$2 + (local.get $2) + ) + (local.set $4 (i32.add - (i32.wrap_i64 - (i64.extend_i32_s + (local.get $8) + (local.tee $2 + (local.tee $3 (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) + (local.get $3) + (i32.const 16) ) ) ) - (i32.shl - (local.get $1) - (i32.const 1) + ) + ) + (loop $label + (if + (i32.ne + (local.get $2) + (local.get $4) + ) + (then + (i32.store8 + (local.get $2) + (i32.load8_u + (i32.const 0) + ) + ) + (local.set $2 + (i32.add + (local.get $2) + (i32.const 1) + ) + ) + (br $label) ) ) ) - ) - (func $15 (param $0 i64) (param $1 i64) (result i64) - (local $2 i32) - (local $3 i32) - (local $4 i64) + (i32.store + (local.get $3) + (local.get $7) + ) (drop - (call $5 - (call $5 + (call $4 + (call $4 (i32.add (i32.wrap_i64 - (local.tee $4 - (call $17 - (i32.add - (local.tee $2 - (i32.shl - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) - (i32.const 1) - ) - ) - (local.tee $3 - (i32.shl - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $1) - ) - ) - (i32.const 1) - ) - (i32.const 1) - ) - ) + (local.tee $10 + (i64.or + (i64.extend_i32_u + (local.get $3) ) + (i64.const 38654705664) ) ) ) @@ -513,7 +468,7 @@ ) (i32.const 4) ) - (local.get $2) + (local.get $5) ) (i32.add (i32.wrap_i64 @@ -521,144 +476,176 @@ ) (i32.const 4) ) - (local.get $3) + (local.get $6) ) ) (i64.or (i64.and - (local.get $4) + (local.get $10) (i64.const 4294967295) ) (i64.const 12884901888) ) ) - (func $16 (param $0 i64) (param $1 i64) (result i32) + (func $12 (param $0 i64) (param $1 i64) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) (if (result i32) (i32.eq (i32.shr_u (i32.load - (i32.wrap_i64 - (local.get $0) + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) ) ) (i32.const 1) ) (i32.shr_u (i32.load - (i32.wrap_i64 - (local.get $1) + (local.tee $3 + (i32.wrap_i64 + (local.get $1) + ) ) ) (i32.const 1) - ) - ) - (if (result i32) - (i32.eq - (i32.wrap_i64 - (local.get $0) - ) - (i32.wrap_i64 - (local.get $1) - ) - ) - (i32.const 1) - (block (result i32) - (local.set $2 - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) + ) + ) + (then + (if (result i32) + (i32.eq + (local.get $2) + (local.get $3) ) - (local.set $3 + (then (i32.const 1) ) - (loop $label$4 - (block $label$5 - (br_if $label$5 - (i32.eqz - (local.get $2) + (else + (local.set $2 + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $0) + ) ) + (i32.const 1) ) - (if - (i32.ne - (call $14 - (local.get $0) + ) + (local.set $3 + (i32.const 1) + ) + (loop $label + (block $block + (br_if $block + (i32.eqz + (local.get $2) + ) + ) + (if + (i32.gt_u (local.tee $2 (i32.sub (local.get $2) (i32.const 1) ) ) + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 1) + ) ) - (call $14 - (local.get $1) + (then + (unreachable) + ) + ) + (if + (i32.gt_u (local.get $2) + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $1) + ) + ) + (i32.const 1) + ) + ) + (then + (unreachable) ) ) - (block - (local.set $3 - (i32.const 0) + (if + (i32.ne + (i32.load16_u + (i32.add + (local.tee $4 + (i32.shl + (local.get $2) + (i32.const 1) + ) + ) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 4) + ) + ) + ) + (i32.load16_u + (i32.add + (local.get $4) + (i32.add + (i32.wrap_i64 + (local.get $1) + ) + (i32.const 4) + ) + ) + ) + ) + (then + (local.set $3 + (i32.const 0) + ) + (br $block) ) - (br $label$5) + ) + (br_if $label + (local.get $2) ) ) - (br_if $label$4 - (local.get $2) - ) - ) - ) - (local.get $3) - ) - ) - (i32.const 0) - ) - ) - (func $17 (param $0 i32) (result i64) - (local $1 i32) - (local $2 i32) - (call $6 - (local.tee $1 - (call $4 - (local.tee $2 - (i32.add - (local.get $0) - (i32.const 4) ) + (local.get $3) ) ) ) - (local.get $2) - ) - (i32.store - (local.get $1) - (local.get $0) - ) - (i64.or - (i64.extend_i32_u - (local.get $1) + (else + (i32.const 0) ) - (i64.const 38654705664) ) ) - (func $18 + (func $13 (local $0 i64) (local $1 i64) - (call $11 + (local $2 i32) + (call $9 (i64.const 12884901904) ) (local.set $0 - (call $15 + (call $11 (i64.const 12884901955) (i64.const 12884901966) ) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.const 67) @@ -668,7 +655,7 @@ (i32.const 3) (i64.const 12884901979) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.const 78) @@ -678,7 +665,7 @@ (i32.const 4) (i64.const 12884902010) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.wrap_i64 @@ -690,23 +677,23 @@ (i32.const 7) (i64.const 12884902041) ) - (call $9 + (call $7 (local.get $0) (i64.const 12884902072) (i64.const 12884902091) ) (local.set $1 - (call $15 + (call $11 (local.get $0) (local.get $0) ) ) - (call $9 + (call $7 (local.get $0) (i64.const 12884902132) (i64.const 12884902151) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.wrap_i64 @@ -718,16 +705,16 @@ (i32.const 14) (i64.const 12884902192) ) - (call $9 + (call $7 (local.get $1) (i64.const 12884902225) (local.get $1) ) (call $fimport$2) - (call $11 + (call $9 (i64.const 12884902258) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.const 419) @@ -737,75 +724,152 @@ (i32.const 6) (i64.const 12884902324) ) - (call $7 + (if + (i32.lt_u + (i32.shr_u + (i32.load + (i32.const 419) + ) + (i32.const 1) + ) + (i32.const 0) + ) + (then + (unreachable) + ) + ) + (call $5 (f64.convert_i32_u - (call $14 - (i64.const 12884902307) - (i32.const 0) + (i32.load16_u + (i32.const 423) ) ) (f64.const 97) (i64.const 12884902359) ) - (call $7 - (f64.convert_i32_u - (call $14 - (i64.const 12884902307) + (if + (i32.eqz + (i32.shr_u + (i32.load + (i32.const 419) + ) (i32.const 1) ) ) + (then + (unreachable) + ) + ) + (call $5 + (f64.convert_i32_u + (i32.load16_u + (i32.const 425) + ) + ) (f64.const 115) (i64.const 12884902382) ) - (call $7 + (if + (i32.lt_u + (i32.shr_u + (i32.load + (i32.const 419) + ) + (i32.const 1) + ) + (i32.const 2) + ) + (then + (unreachable) + ) + ) + (call $5 (f64.convert_i32_u - (call $14 - (i64.const 12884902307) - (i32.const 2) + (i32.load16_u + (i32.const 427) ) ) (f64.const 100) (i64.const 12884902405) ) - (call $7 + (if + (i32.lt_u + (i32.shr_u + (i32.load + (i32.const 419) + ) + (i32.const 1) + ) + (i32.const 3) + ) + (then + (unreachable) + ) + ) + (call $5 (f64.convert_i32_u - (call $14 - (i64.const 12884902307) - (i32.const 3) + (i32.load16_u + (i32.const 429) ) ) (f64.const 10094) (i64.const 12884902428) ) - (call $7 + (if + (i32.lt_u + (i32.shr_u + (i32.load + (i32.const 419) + ) + (i32.const 1) + ) + (i32.const 4) + ) + (then + (unreachable) + ) + ) + (call $5 (f64.convert_i32_u - (call $14 - (i64.const 12884902307) - (i32.const 4) + (i32.load16_u + (i32.const 431) ) ) (f64.const 55349) (i64.const 12884902451) ) - (call $7 + (if + (i32.lt_u + (i32.shr_u + (i32.load + (i32.const 419) + ) + (i32.const 1) + ) + (i32.const 5) + ) + (then + (unreachable) + ) + ) + (call $5 (f64.convert_i32_u - (call $14 - (i64.const 12884902307) - (i32.const 5) + (i32.load16_u + (i32.const 433) ) ) (f64.const 56337) (i64.const 12884902474) ) (call $fimport$2) - (call $11 + (call $9 (i64.const 12884902497) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.wrap_i64 - (call $13 + (call $11 (i64.const 12884902542) (i64.const 12884902551) ) @@ -817,15 +881,15 @@ (i64.const 12884902560) ) (call $fimport$2) - (call $11 + (call $9 (i64.const 12884902611) ) - (call $8 + (call $6 (i32.shr_u (i32.load (i32.wrap_i64 (local.tee $0 - (call $13 + (call $11 (i64.const 12884902668) (i64.const 12884902677) ) @@ -837,49 +901,148 @@ (i32.const 5) (i64.const 12884902688) ) - (call $8 - (call $14 - (local.get $0) + (if + (i32.lt_u + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 1) + ) (i32.const 0) ) + (then + (unreachable) + ) + ) + (call $6 + (i32.load16_u + (i32.add + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 4) + ) + ) (i32.const 97) (i64.const 12884902739) ) - (call $8 - (call $14 - (local.get $0) - (i32.const 1) + (if + (i32.eqz + (i32.shr_u + (i32.load + (local.get $2) + ) + (i32.const 1) + ) + ) + (then + (unreachable) + ) + ) + (call $6 + (i32.load16_u + (i32.add + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 6) + ) ) (i32.const 98) (i64.const 12884902780) ) - (call $8 - (call $14 - (local.get $0) + (if + (i32.lt_u + (i32.shr_u + (i32.load + (local.get $2) + ) + (i32.const 1) + ) (i32.const 2) ) + (then + (unreachable) + ) + ) + (call $6 + (i32.load16_u + (i32.add + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 8) + ) + ) (i32.const 181) (i64.const 12884902821) ) - (call $8 - (call $14 - (local.get $0) + (if + (i32.lt_u + (i32.shr_u + (i32.load + (local.get $2) + ) + (i32.const 1) + ) (i32.const 3) ) + (then + (unreachable) + ) + ) + (call $6 + (i32.load16_u + (i32.add + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 10) + ) + ) (i32.const 9884) (i64.const 12884902862) ) - (call $8 - (call $14 - (local.get $0) + (if + (i32.lt_u + (i32.shr_u + (i32.load + (local.get $2) + ) + (i32.const 1) + ) (i32.const 4) ) + (then + (unreachable) + ) + ) + (call $6 + (i32.load16_u + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 12) + ) + ) (i32.const 65038) (i64.const 12884902913) ) (call $fimport$2) ) - (func $19 + (func $14 (global.set $global$0 (i32.const 15) ) @@ -890,9 +1053,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/stringifyNumbers.lys.optimized.wast b/test/fixtures/execution/stringifyNumbers.lys.optimized.wast index 1bb9f97..1b63240 100644 --- a/test/fixtures/execution/stringifyNumbers.lys.optimized.wast +++ b/test/fixtures/execution/stringifyNumbers.lys.optimized.wast @@ -1,193 +1,81 @@ (module - (type $none_=>_none (func)) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i32_i64_=>_none (func (param i32 i64))) - (type $i64_=>_none (func (param i64))) - (type $i64_i32_=>_none (func (param i64 i32))) - (type $i64_i64_=>_none (func (param i64 i64))) - (type $none_=>_i32 (func (result i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $i64_=>_i64 (func (param i64) (result i64))) - (type $i64_i64_=>_i64 (func (param i64 i64) (result i64))) - (type $i32_=>_none (func (param i32))) - (type $i64_i64_i32_=>_none (func (param i64 i64 i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) - (type $i64_i32_=>_i32 (func (param i64 i32) (result i32))) - (type $i64_i64_=>_i32 (func (param i64 i64) (result i32))) - (type $i32_=>_i64 (func (param i32) (result i64))) + (type $0 (func)) + (type $1 (func (param i32 i64))) + (type $2 (func (param i32 i32))) + (type $3 (func (result i32))) + (type $4 (func (param i64 i32))) + (type $5 (func (param i64 i64))) + (type $6 (func (param i32))) + (type $7 (func (param i32 i32 i32) (result i32))) + (type $8 (func (param i64))) + (type $9 (func (param i32) (result i64))) + (type $10 (func (param i64 i64) (result i64))) + (type $11 (func (param i64) (result i32))) + (type $12 (func (param i64 i64 i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (import "env" "printf" (func $fimport$3 (param i32 i32))) - (memory $0 1) - (data (i32.const 692) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 719) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 752) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 779) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 812) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 847) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 888) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 923) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 964) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 999) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 1040) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1075) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 1116) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 1143) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 1176) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 1203) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 1236) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 650) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 663) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 678) "\02\00\00\000") - (data (i32.const 685) "\02\00\00\000") - (data (i32.const 16) "\1c\00\00\00 \00 \00 \00 \00n\00u\00m\00b\00e\00r\00:\00 \00%\00d") - (data (i32.const 49) "\1c\00\00\00 \00 \00 \00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 82) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 115) "$\00\00\00a\00s\00s\00e\00r\00t\00N\00u\00m\00b\00e\00r\00L\00e\00n\00g\00t\00h") - (data (i32.const 156) "\10\00\00\00G\00i\00v\00e\00n\00:\00 \00\'") - (data (i32.const 177) "\1a\00\00\00\'\00 \00E\00x\00p\00e\00c\00t\00e\00d\00:\00 \00\'") - (data (i32.const 208) "\02\00\00\00\'") - (data (i32.const 215) "\0c\00\00\00g\00i\00v\00e\00n\00:") - (data (i32.const 232) "\12\00\00\00e\00x\00p\00e\00c\00t\00e\00d\00:") - (data (i32.const 255) "4\00\00\00s\00t\00r\00i\00n\00g\00i\00f\00y\00c\00a\00t\00i\00o\00n\00 \00o\00f\00 \00n\00u\00m\00b\00e\00r\00s") - (data (i32.const 312) "(\00\00\00t\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00e\00q\00u\00a\00l\00i\00t\00y") - (data (i32.const 357) "\08\00\00\00a\00b\00c\00d") - (data (i32.const 370) "\08\00\00\00a\00b\00c\00d") - (data (i32.const 383) "8\00\00\00g\00e\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00h\00a\00r\00a\00c\00t\00e\00r\00s\00 \00l\00e\00n\00g\00t\00h") - (data (i32.const 444) "(\00\00\00n\00u\00m\00b\00e\00r\00 \00s\00e\00r\00i\00a\00l\00i\00z\00a\00t\00i\00o\00n") - (data (i32.const 489) "\02\00\00\001") - (data (i32.const 496) "\04\00\00\00-\001") - (data (i32.const 505) "\0e\00\00\002\002\002\002\002\002\002") - (data (i32.const 524) "\0e\00\00\003\003\003\003\003\003\003") - (data (i32.const 543) "\0e\00\00\00-\004\004\004\004\004\004") - (data (i32.const 562) "\12\00\00\001\002\003\004\005\006\007\008\009") - (data (i32.const 585) "\0c\00\00\001\000\000\000\000\000") - (data (i32.const 602) "\08\00\00\002\000\000\000") - (data (i32.const 615) "\0c\00\00\003\000\000\000\000\000") - (data (i32.const 632) "\08\00\00\004\000\000\000") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 692) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 719) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 752) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 779) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 812) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 847) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 888) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 923) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 964) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 999) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 1040) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 1075) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 1116) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 1143) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 1176) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 1203) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 1236) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 650) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 663) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 678) "\02\00\00\000") + (data $20 (i32.const 685) "\02\00\00\000") + (data $21 (i32.const 16) "\1c\00\00\00 \00 \00 \00 \00n\00u\00m\00b\00e\00r\00:\00 \00%\00d") + (data $22 (i32.const 49) "\1c\00\00\00 \00 \00 \00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $23 (i32.const 82) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $24 (i32.const 115) "$\00\00\00a\00s\00s\00e\00r\00t\00N\00u\00m\00b\00e\00r\00L\00e\00n\00g\00t\00h") + (data $25 (i32.const 156) "\10\00\00\00G\00i\00v\00e\00n\00:\00 \00\'") + (data $26 (i32.const 177) "\1a\00\00\00\'\00 \00E\00x\00p\00e\00c\00t\00e\00d\00:\00 \00\'") + (data $27 (i32.const 208) "\02\00\00\00\'") + (data $28 (i32.const 215) "\0c\00\00\00g\00i\00v\00e\00n\00:") + (data $29 (i32.const 232) "\12\00\00\00e\00x\00p\00e\00c\00t\00e\00d\00:") + (data $30 (i32.const 255) "4\00\00\00s\00t\00r\00i\00n\00g\00i\00f\00y\00c\00a\00t\00i\00o\00n\00 \00o\00f\00 \00n\00u\00m\00b\00e\00r\00s") + (data $31 (i32.const 312) "(\00\00\00t\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00e\00q\00u\00a\00l\00i\00t\00y") + (data $32 (i32.const 357) "\08\00\00\00a\00b\00c\00d") + (data $33 (i32.const 370) "\08\00\00\00a\00b\00c\00d") + (data $34 (i32.const 383) "8\00\00\00g\00e\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00h\00a\00r\00a\00c\00t\00e\00r\00s\00 \00l\00e\00n\00g\00t\00h") + (data $35 (i32.const 444) "(\00\00\00n\00u\00m\00b\00e\00r\00 \00s\00e\00r\00i\00a\00l\00i\00z\00a\00t\00i\00o\00n") + (data $36 (i32.const 489) "\02\00\00\001") + (data $37 (i32.const 496) "\04\00\00\00-\001") + (data $38 (i32.const 505) "\0e\00\00\002\002\002\002\002\002\002") + (data $39 (i32.const 524) "\0e\00\00\003\003\003\003\003\003\003") + (data $40 (i32.const 543) "\0e\00\00\00-\004\004\004\004\004\004") + (data $41 (i32.const 562) "\12\00\00\001\002\003\004\005\006\007\008\009") + (data $42 (i32.const 585) "\0c\00\00\001\000\000\000\000\000") + (data $43 (i32.const 602) "\08\00\00\002\000\000\000") + (data $44 (i32.const 615) "\0c\00\00\003\000\000\000\000\000") + (data $45 (i32.const 632) "\08\00\00\004\000\000\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $6)) - (export "main" (func $24)) - (start $25) + (export "test_getLastErrorMessage" (func $3)) + (export "main" (func $15)) + (start $16) (func $0 (result i32) - (global.get $global$3) - ) - (func $1 (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (if - (i32.eqz - (local.get $0) - ) - (unreachable) - ) - (if - (i32.lt_u - (global.get $global$1) - (local.get $0) - ) - (unreachable) - ) - (if - (i32.gt_u - (local.tee $0 - (i32.and - (i32.add - (global.get $global$0) - (i32.add - (i32.add - (local.tee $1 - (global.get $global$3) - ) - (i32.const 16) - ) - (select - (local.get $0) - (i32.const 16) - (i32.gt_u - (local.get $0) - (i32.const 16) - ) - ) - ) - ) - (i32.xor - (global.get $global$0) - (i32.const -1) - ) - ) - ) - (i32.shl - (local.tee $2 - (memory.size) - ) - (i32.const 16) - ) - ) - (block - (drop - (memory.grow - (select - (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) - ) - (i32.const -65536) - ) - (i32.const 16) - ) - ) - ) - (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow - (local.get $3) - ) - ) - (if - (i32.const 0) - (unreachable) - ) - ) - ) - ) - ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) - ) + (global.get $global$2) ) - (func $2 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $1 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i64) (local $5 i64) @@ -201,13 +89,13 @@ (local.get $0) ) ) - (loop $label$1 + (loop $label (if (i32.gt_u (local.get $2) (local.get $3) ) - (block + (then (i32.store8 (i32.add (local.get $3) @@ -230,7 +118,7 @@ (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) @@ -239,38 +127,7 @@ (local.get $2) ) ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 - (i32.add - (local.get $0) - (local.get $1) - ) - ) - (loop $label$1 - (if - (i32.ne - (local.get $0) - (local.get $1) - ) - (block - (i32.store8 - (local.get $0) - (i32.load8_u - (i32.const 0) - ) - ) - (local.set $0 - (i32.add - (local.get $0) - (i32.const 1) - ) - ) - (br $label$1) - ) - ) - ) - ) - (func $4 (param $0 i64) (param $1 i32) + (func $2 (param $0 i64) (param $1 i32) (call $fimport$3 (i32.wrap_i64 (local.get $0) @@ -278,48 +135,42 @@ (local.get $1) ) ) - (func $5 (param $0 i64) - (call $4 - (local.get $0) - (i32.const 0) - ) - ) - (func $6 (result i32) + (func $3 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $7 (param $0 i64) + (func $4 (param $0 i64) (call $fimport$0 (i32.wrap_i64 (local.get $0) ) ) ) - (func $8 (param $0 i32) (param $1 i64) + (func $5 (param $0 i32) (param $1 i64) (call $fimport$1 (local.get $0) (i32.wrap_i64 @@ -327,13 +178,16 @@ ) ) ) - (func $9 (param $0 i32) (result i64) + (func $6 (param $0 i32) (result i64) (local $1 i32) (local $2 i32) - (call $3 - (local.tee $1 - (call $1 - (local.tee $2 + (local $3 i32) + (local $4 i32) + (local $5 i32) + (if + (i32.eqz + (local.tee $1 + (local.tee $4 (i32.add (local.get $0) (i32.const 4) @@ -341,229 +195,214 @@ ) ) ) - (local.get $2) - ) - (i32.store - (local.get $1) - (local.get $0) - ) - (i64.or - (i64.extend_i32_u - (local.get $1) + (then + (unreachable) ) - (i64.const 38654705664) ) - ) - (func $10 (param $0 i64) (param $1 i64) (result i64) - (call $12 - (local.get $0) - (local.get $1) - ) - ) - (func $11 (param $0 i64) (param $1 i32) (result i32) (if - (i32.gt_u + (i32.lt_u + (global.get $global$1) (local.get $1) - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) ) - (unreachable) + (then + (unreachable) + ) ) - (i32.load16_u - (i32.add - (i32.wrap_i64 - (i64.extend_i32_s + (if + (i32.gt_u + (local.tee $1 + (i32.and (i32.add - (i32.wrap_i64 - (local.get $0) + (global.get $global$0) + (i32.add + (i32.add + (local.tee $2 + (global.get $global$2) + ) + (i32.const 16) + ) + (select + (i32.const 16) + (local.get $1) + (i32.le_u + (local.get $1) + (i32.const 16) + ) + ) ) - (i32.const 4) + ) + (i32.xor + (global.get $global$0) + (i32.const -1) ) ) ) (i32.shl - (local.get $1) - (i32.const 1) + (local.tee $3 + (memory.size) + ) + (i32.const 16) ) ) - ) - ) - (func $12 (param $0 i64) (param $1 i64) (result i64) - (local $2 i32) - (local $3 i32) - (local $4 i64) - (drop - (call $2 - (call $2 - (i32.add - (i32.wrap_i64 - (local.tee $4 - (call $9 - (i32.add - (local.tee $2 - (i32.shl - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) - (i32.const 1) - ) - ) - (local.tee $3 - (i32.shl - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $1) - ) - ) - (i32.const 1) - ) - (i32.const 1) + (then + (drop + (memory.grow + (select + (local.get $3) + (local.tee $5 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $1) + (local.get $2) ) + (i32.const 65535) ) + (i32.const -65536) ) + (i32.const 16) ) ) + (i32.gt_u + (local.get $3) + (local.get $5) + ) ) - (i32.const 4) ) - (i32.add - (i32.wrap_i64 - (local.get $0) + ) + ) + ) + (global.set $global$2 + (local.get $1) + ) + (local.set $3 + (i32.add + (local.get $4) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $2) + (i32.const 16) ) - (i32.const 4) ) - (local.get $2) ) - (i32.add - (i32.wrap_i64 + ) + ) + (loop $label + (if + (i32.ne + (local.get $1) + (local.get $3) + ) + (then + (i32.store8 (local.get $1) + (i32.load8_u + (i32.const 0) + ) ) - (i32.const 4) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + (br $label) ) - (local.get $3) ) ) + (i32.store + (local.get $2) + (local.get $0) + ) (i64.or - (i64.and - (local.get $4) - (i64.const 4294967295) + (i64.extend_i32_u + (local.get $2) ) - (i64.const 12884901888) + (i64.const 38654705664) ) ) - (func $13 (param $0 i64) (param $1 i64) (result i32) + (func $7 (param $0 i64) (param $1 i64) (result i64) (local $2 i32) (local $3 i32) - (if (result i32) - (i32.eq - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) - (i32.shr_u - (i32.load + (local $4 i32) + (local $5 i32) + (drop + (call $1 + (call $1 + (i32.add (i32.wrap_i64 - (local.get $1) - ) - ) - (i32.const 1) - ) - ) - (if (result i32) - (i32.eq - (i32.wrap_i64 - (local.get $0) - ) - (i32.wrap_i64 - (local.get $1) - ) - ) - (i32.const 1) - (block (result i32) - (local.set $2 - (i32.shr_u - (i32.load - (i32.wrap_i64 - (local.get $0) - ) - ) - (i32.const 1) - ) - ) - (local.set $3 - (i32.const 1) - ) - (loop $label$4 - (block $label$5 - (br_if $label$5 - (i32.eqz - (local.get $2) - ) - ) - (if - (i32.ne - (call $11 - (local.get $0) - (local.tee $2 - (i32.sub - (local.get $2) - (i32.const 1) + (local.tee $0 + (call $6 + (i32.add + (local.tee $3 + (i32.and + (i32.load + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) + ) + (i32.const -2) + ) + ) + (local.tee $5 + (i32.and + (i32.load + (local.tee $4 + (i32.wrap_i64 + (local.get $1) + ) + ) + ) + (i32.const -2) ) ) ) - (call $11 - (local.get $1) - (local.get $2) - ) - ) - (block - (local.set $3 - (i32.const 0) - ) - (br $label$5) ) ) - (br_if $label$4 - (local.get $2) - ) ) + (i32.const 4) + ) + (i32.add + (local.get $2) + (i32.const 4) ) (local.get $3) ) + (i32.add + (local.get $4) + (i32.const 4) + ) + (local.get $5) + ) + ) + (i64.or + (i64.and + (local.get $0) + (i64.const 4294967295) ) - (i32.const 0) + (i64.const 12884901888) ) ) - (func $14 (param $0 i64) (result i32) + (func $8 (param $0 i64) (result i32) (local $1 i32) (if (result i32) (i64.eqz (local.get $0) ) - (i32.const 1) - (block (result i32) + (then + (i32.const 1) + ) + (else (if (i64.lt_s (local.get $0) (i64.const 0) ) - (block + (then (local.set $1 (i32.const 1) ) @@ -575,14 +414,14 @@ ) ) ) - (loop $label$4 + (loop $label (local.set $1 (i32.add (local.get $1) (i32.const 1) ) ) - (br_if $label$4 + (br_if $label (i64.gt_s (local.tee $0 (i64.div_s @@ -598,40 +437,9 @@ ) ) ) - (func $15 (param $0 i64) (result i32) - (local $1 i32) - (if (result i32) - (i64.eqz - (local.get $0) - ) - (i32.const 1) - (block (result i32) - (loop $label$3 - (local.set $1 - (i32.add - (local.get $1) - (i32.const 1) - ) - ) - (br_if $label$3 - (i64.ne - (local.tee $0 - (i64.div_u - (local.get $0) - (i64.const 10) - ) - ) - (i64.const 0) - ) - ) - ) - (local.get $1) - ) - ) - ) - (func $16 (param $0 i64) (param $1 i64) (param $2 i32) + (func $9 (param $0 i64) (param $1 i64) (param $2 i32) (local $3 i32) - (loop $label$1 + (loop $label (if (i32.lt_u (i32.load @@ -654,20 +462,18 @@ (i32.const 1) ) ) - (unreachable) + (then + (unreachable) + ) ) (i32.store16 (i32.add (local.get $3) - (i32.wrap_i64 - (i64.extend_i32_s - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) + (i32.add + (i32.wrap_i64 + (local.get $0) ) + (i32.const 4) ) ) (i32.add @@ -680,151 +486,177 @@ (i32.const 48) ) ) - (br_if $label$1 - (i32.eqz - (i64.eqz - (local.tee $1 - (i64.div_u - (local.get $1) - (i64.const 10) - ) + (br_if $label + (i64.ne + (local.tee $1 + (i64.div_u + (local.get $1) + (i64.const 10) ) ) + (i64.const 0) ) ) ) ) - (func $17 (param $0 i64) (result i64) - (local $1 i32) + (func $10 (param $0 i64) (param $1 i64) (local $2 i64) - (if (result i64) - (i64.eqz - (local.get $0) - ) - (i64.const 12884902566) - (block (result i64) - (local.set $2 + (local $3 i32) + (call $14 + (if (result i64) + (i64.eqz + (local.get $0) + ) + (then + (i64.const 12884902573) + ) + (else (call $9 - (i32.shl - (local.tee $1 - (call $14 - (local.get $0) + (local.tee $2 + (call $6 + (i32.shl + (local.tee $3 + (if (result i32) + (i64.eqz + (local.tee $2 + (local.get $0) + ) + ) + (then + (i32.const 1) + ) + (else + (loop $label + (local.set $3 + (i32.add + (local.get $3) + (i32.const 1) + ) + ) + (br_if $label + (i64.ne + (local.tee $2 + (i64.div_u + (local.get $2) + (i64.const 10) + ) + ) + (i64.const 0) + ) + ) + ) + (local.get $3) + ) + ) + ) + (i32.const 1) ) ) - (i32.const 1) ) - ) - ) - (if - (i64.gt_s (local.get $0) - (i64.const 0) + (local.get $3) ) - (call $16 - (local.get $2) - (local.get $0) - (local.get $1) + (i64.or + (i64.and + (local.get $2) + (i64.const 4294967295) + ) + (i64.const 12884901888) ) - (call $16 - (local.get $2) - (i64.sub - (i64.const 0) + ) + ) + (local.get $1) + ) + ) + (func $11 (param $0 i32) (param $1 i64) + (local $2 i64) + (local $3 i64) + (call $14 + (if (result i64) + (i64.eqz + (local.tee $2 + (i64.extend_i32_s (local.get $0) ) - (local.get $1) ) ) - (if - (i64.lt_s - (local.get $0) - (i64.const 0) - ) - (i32.store16 - (i32.wrap_i64 - (i64.extend_i32_s - (i32.add - (i32.wrap_i64 + (then + (i64.const 12884902566) + ) + (else + (local.set $3 + (call $6 + (i32.shl + (local.tee $0 + (call $8 (local.get $2) ) - (i32.const 4) ) + (i32.const 1) ) ) - (i32.const 45) ) - ) - (i64.or - (i64.and - (local.get $2) - (i64.const 4294967295) + (if + (i64.gt_s + (local.get $2) + (i64.const 0) + ) + (then + (call $9 + (local.get $3) + (local.get $2) + (local.get $0) + ) + ) + (else + (call $9 + (local.get $3) + (i64.sub + (i64.const 0) + (local.get $2) + ) + (local.get $0) + ) + ) ) - (i64.const 12884901888) - ) - ) - ) - ) - (func $18 (param $0 i64) (result i64) - (local $1 i32) - (local $2 i64) - (if (result i64) - (i64.eqz - (local.get $0) - ) - (i64.const 12884902573) - (block (result i64) - (call $16 - (local.tee $2 - (call $9 - (i32.shl - (local.tee $1 - (call $15 - (local.get $0) + (if + (i64.lt_s + (local.get $2) + (i64.const 0) + ) + (then + (i32.store16 + (i32.add + (i32.wrap_i64 + (local.get $3) ) + (i32.const 4) ) - (i32.const 1) + (i32.const 45) ) ) ) - (local.get $0) - (local.get $1) - ) - (i64.or - (i64.and - (local.get $2) - (i64.const 4294967295) + (i64.or + (i64.and + (local.get $3) + (i64.const 4294967295) + ) + (i64.const 12884901888) ) - (i64.const 12884901888) - ) - ) - ) - ) - (func $19 (param $0 i64) (param $1 i64) - (call $23 - (call $18 - (local.get $0) - ) - (local.get $1) - ) - ) - (func $20 (param $0 i32) (param $1 i64) - (call $23 - (call $17 - (i64.extend_i32_s - (local.get $0) ) ) (local.get $1) ) ) - (func $21 (param $0 i32) (param $1 i64) - (call $19 + (func $12 (param $0 i32) (param $1 i64) + (call $10 (i64.extend_i32_u (local.get $0) ) (local.get $1) ) ) - (func $22 (param $0 i64) (param $1 i32) + (func $13 (param $0 i64) (param $1 i32) (local $2 i32) (local $3 i32) (if @@ -833,43 +665,45 @@ (i32.eq (local.get $1) (local.tee $2 - (call $14 + (call $8 (local.get $0) ) ) ) ) ) - (block - (call $4 + (then + (call $2 (i64.const 12884901904) (i32.wrap_i64 (local.get $0) ) ) - (call $4 + (call $2 (i64.const 12884901937) (local.get $2) ) - (call $4 + (call $2 (i64.const 12884901970) (local.get $1) ) ) ) - (call $8 + (call $5 (local.get $3) (i64.const 12884902003) ) ) - (func $23 (param $0 i64) (param $1 i64) + (func $14 (param $0 i64) (param $1 i64) (local $2 i32) - (local $3 i64) - (local.set $3 - (call $10 - (call $10 - (call $10 - (call $10 + (local $3 i32) + (local $4 i32) + (local $5 i64) + (local.set $5 + (call $7 + (call $7 + (call $7 + (call $7 (i64.const 12884902044) (local.get $0) ) @@ -883,155 +717,295 @@ (if (i32.eqz (local.tee $2 - (call $13 - (local.get $0) - (local.get $1) + (if (result i32) + (i32.eq + (i32.shr_u + (i32.load + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) + ) + (i32.const 1) + ) + (i32.shr_u + (i32.load + (local.tee $3 + (i32.wrap_i64 + (local.get $1) + ) + ) + ) + (i32.const 1) + ) + ) + (then + (if (result i32) + (i32.eq + (local.get $2) + (local.get $3) + ) + (then + (i32.const 1) + ) + (else + (local.set $2 + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 1) + ) + ) + (local.set $3 + (i32.const 1) + ) + (loop $label + (block $block + (br_if $block + (i32.eqz + (local.get $2) + ) + ) + (if + (i32.gt_u + (local.tee $2 + (i32.sub + (local.get $2) + (i32.const 1) + ) + ) + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $0) + ) + ) + (i32.const 1) + ) + ) + (then + (unreachable) + ) + ) + (if + (i32.gt_u + (local.get $2) + (i32.shr_u + (i32.load + (i32.wrap_i64 + (local.get $1) + ) + ) + (i32.const 1) + ) + ) + (then + (unreachable) + ) + ) + (if + (i32.ne + (i32.load16_u + (i32.add + (local.tee $4 + (i32.shl + (local.get $2) + (i32.const 1) + ) + ) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 4) + ) + ) + ) + (i32.load16_u + (i32.add + (local.get $4) + (i32.add + (i32.wrap_i64 + (local.get $1) + ) + (i32.const 4) + ) + ) + ) + ) + (then + (local.set $3 + (i32.const 0) + ) + (br $block) + ) + ) + (br_if $label + (local.get $2) + ) + ) + ) + (local.get $3) + ) + ) + ) + (else + (i32.const 0) + ) ) ) ) - (block - (call $5 + (then + (call $2 (i64.const 12884902103) + (i32.const 0) ) - (call $5 + (call $2 (local.get $0) + (i32.const 0) ) - (call $5 + (call $2 (i64.const 12884902120) + (i32.const 0) ) - (call $5 + (call $2 (local.get $1) + (i32.const 0) ) ) ) - (call $8 + (call $5 (local.get $2) - (local.get $3) + (local.get $5) ) ) - (func $24 - (call $7 + (func $15 + (call $4 (i64.const 12884902143) ) - (call $7 + (call $4 (i64.const 12884902200) ) - (call $23 + (call $14 (i64.const 12884902245) (i64.const 12884902258) ) (call $fimport$2) - (call $7 + (call $4 (i64.const 12884902271) ) - (call $22 + (call $13 (i64.const 2) (i32.const 1) ) - (call $22 + (call $13 (i64.const 4444) (i32.const 4) ) - (call $22 + (call $13 (i64.const -2) (i32.const 2) ) - (call $22 + (call $13 (i64.const -33) (i32.const 3) ) - (call $22 + (call $13 (i64.const -1) (i32.const 2) ) - (call $22 + (call $13 (i64.const 0) (i32.const 1) ) - (call $22 + (call $13 (i64.const 2222222) (i32.const 7) ) - (call $22 + (call $13 (i64.const 3333333) (i32.const 7) ) - (call $22 + (call $13 (i64.const -444444) (i32.const 7) ) - (call $22 + (call $13 (i64.const 123456789) (i32.const 9) ) - (call $22 + (call $13 (i64.const 100000) (i32.const 6) ) - (call $22 + (call $13 (i64.const 2000) (i32.const 4) ) - (call $22 + (call $13 (i64.const 300000) (i32.const 6) ) - (call $22 + (call $13 (i64.const 4000) (i32.const 4) ) - (call $22 + (call $13 (i64.const -4000) (i32.const 5) ) (call $fimport$2) - (call $7 + (call $4 (i64.const 12884902332) ) - (call $20 + (call $11 (i32.const 1) (i64.const 12884902377) ) - (call $20 + (call $11 (i32.const -1) (i64.const 12884902384) ) - (call $19 + (call $10 (i64.const 2222222) (i64.const 12884902393) ) - (call $20 + (call $11 (i32.const 3333333) (i64.const 12884902412) ) - (call $20 + (call $11 (i32.const -444444) (i64.const 12884902431) ) - (call $21 + (call $12 (i32.const 123456789) (i64.const 12884902450) ) - (call $21 + (call $12 (i32.const 100000) (i64.const 12884902473) ) - (call $21 + (call $12 (i32.const 2000) (i64.const 12884902490) ) - (call $20 + (call $11 (i32.const 300000) (i64.const 12884902503) ) - (call $20 + (call $11 (i32.const 4000) (i64.const 12884902520) ) (call $fimport$2) (call $fimport$2) ) - (func $25 + (func $16 (global.set $global$0 (i32.const 15) ) @@ -1042,9 +1016,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/structValuesExtended.lys.optimized.wast b/test/fixtures/execution/structValuesExtended.lys.optimized.wast index 181f9d6..77c7910 100644 --- a/test/fixtures/execution/structValuesExtended.lys.optimized.wast +++ b/test/fixtures/execution/structValuesExtended.lys.optimized.wast @@ -1,89 +1,75 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $f32_=>_none (func (param f32))) - (type $i32_i64_=>_none (func (param i32 i64))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $none_=>_i64 (func (result i64))) + (type $0 (func)) + (type $1 (func (param i32))) + (type $2 (func (result i32))) + (type $3 (func (param f32))) + (type $4 (func (param i32 i32))) + (type $5 (func (param i32) (result i32))) + (type $6 (func (param i32 i64))) + (type $7 (func (param i64) (result i32))) (import "test" "printNumber" (func $fimport$0 (param f32))) (import "test" "printNumber" (func $fimport$1 (param i32))) (import "test" "pushTest" (func $fimport$2 (param i32))) (import "test" "registerAssertion" (func $fimport$3 (param i32 i32))) (import "test" "popTest" (func $fimport$4)) - (memory $0 1) - (data (i32.const 266) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 293) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 326) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 353) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 538) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 573) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 614) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 649) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 690) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 717) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 750) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 777) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 810) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 224) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 237) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 252) "\02\00\00\000") - (data (i32.const 259) "\02\00\00\000") - (data (i32.const 16) ",\00\00\00s\00t\00r\00u\00c\00t\00 \00v\00a\00l\00u\00e\00s\00 \00e\00x\00t\00e\00n\00d\00e\00d") - (data (i32.const 65) "\02\00\00\00A") - (data (i32.const 72) "\02\00\00\00B") - (data (i32.const 79) "\02\00\00\00C") - (data (i32.const 86) "\02\00\00\00D") - (data (i32.const 93) "\02\00\00\00E") - (data (i32.const 100) "\02\00\00\00F") - (data (i32.const 107) "\02\00\00\00G") - (data (i32.const 114) "\02\00\00\00H") - (data (i32.const 121) "\02\00\00\00I") - (data (i32.const 128) "\02\00\00\00J") - (data (i32.const 135) "\02\00\00\00K") - (data (i32.const 142) "\02\00\00\00L") - (data (i32.const 149) "\02\00\00\00M") - (data (i32.const 156) "\02\00\00\00N") - (data (i32.const 163) "\02\00\00\00\d1") - (data (i32.const 170) "\02\00\00\00O") - (data (i32.const 177) "\02\00\00\00P") - (data (i32.const 184) "\02\00\00\00Q") - (data (i32.const 191) "\02\00\00\00V") - (data (i32.const 198) "\02\00\00\00W") - (data (i32.const 205) "\02\00\00\00X") - (data (i32.const 212) "\02\00\00\00Y") (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) + (global $global$3 (mut i64) (i64.const 0)) + (memory $0 1) + (data $0 (i32.const 266) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 293) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 326) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 353) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 538) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 573) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 614) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 649) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 690) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 717) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 750) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 777) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 810) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 224) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 237) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 252) "\02\00\00\000") + (data $20 (i32.const 259) "\02\00\00\000") + (data $21 (i32.const 16) ",\00\00\00s\00t\00r\00u\00c\00t\00 \00v\00a\00l\00u\00e\00s\00 \00e\00x\00t\00e\00n\00d\00e\00d") + (data $22 (i32.const 65) "\02\00\00\00A") + (data $23 (i32.const 72) "\02\00\00\00B") + (data $24 (i32.const 79) "\02\00\00\00C") + (data $25 (i32.const 86) "\02\00\00\00D") + (data $26 (i32.const 93) "\02\00\00\00E") + (data $27 (i32.const 100) "\02\00\00\00F") + (data $28 (i32.const 107) "\02\00\00\00G") + (data $29 (i32.const 114) "\02\00\00\00H") + (data $30 (i32.const 121) "\02\00\00\00I") + (data $31 (i32.const 128) "\02\00\00\00J") + (data $32 (i32.const 135) "\02\00\00\00K") + (data $33 (i32.const 142) "\02\00\00\00L") + (data $34 (i32.const 149) "\02\00\00\00M") + (data $35 (i32.const 156) "\02\00\00\00N") + (data $36 (i32.const 163) "\02\00\00\00\d1") + (data $37 (i32.const 170) "\02\00\00\00O") + (data $38 (i32.const 177) "\02\00\00\00P") + (data $39 (i32.const 184) "\02\00\00\00Q") + (data $40 (i32.const 191) "\02\00\00\00V") + (data $41 (i32.const 198) "\02\00\00\00W") + (data $42 (i32.const 205) "\02\00\00\00X") + (data $43 (i32.const 212) "\02\00\00\00Y") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $4)) - (export "main" (func $8)) - (start $9) + (export "test_getLastErrorMessage" (func $2)) + (export "main" (func $5)) + (start $6) (func $0 (result i32) - (global.get $global$3) + (global.get $global$2) ) (func $1 (param $0 i32) (result i32) - (local $1 i32) - (call $3 - (local.tee $1 - (call $2 - (local.get $0) - ) - ) - (local.get $0) - ) - (local.get $1) - ) - (func $2 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -92,32 +78,36 @@ (i32.eqz (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.lt_u (global.get $global$1) (local.get $0) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $0 + (local.tee $2 (i32.and (i32.add (global.get $global$0) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$2) ) (i32.const 16) ) (select - (local.get $0) (i32.const 16) - (i32.gt_u + (local.get $0) + (i32.le_u (local.get $0) (i32.const 16) ) @@ -131,125 +121,111 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $3 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) + (local.get $3) (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $0) - (local.get $1) - ) - (i32.const 65535) + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) - (local.get $4) - ) - ) - ) - ) - (if - (i32.const 0) - (block - (drop - (memory.grow (local.get $3) + (local.get $4) ) ) - (if - (i32.const 0) - (unreachable) - ) ) ) ) ) - (global.set $global$3 - (local.get $0) - ) - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$2 + (local.get $2) ) - ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 + (local.set $0 (i32.add (local.get $0) - (local.get $1) + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + ) ) ) - (loop $label$1 + (loop $label (if (i32.ne (local.get $0) (local.get $1) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $1) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) + (local.get $2) ) - (func $4 (result i32) + (func $2 (result i32) (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$4) - ) - (i64.const 32) - ) + (if (result i32) + (i32.eq + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$3) ) - (i32.const 3) + (i64.const 32) ) ) + (i32.const 3) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) + (then + (i32.wrap_i64 + (i64.load + (i32.wrap_i64 + (local.get $0) + ) ) ) ) + (else + (i32.const 0) + ) ) ) - (func $5 (param $0 i32) (param $1 i64) + (func $3 (param $0 i32) (param $1 i64) (call $fimport$3 (local.get $0) (i32.wrap_i64 @@ -257,66 +233,59 @@ ) ) ) - (func $6 (param $0 i64) (result i32) + (func $4 (param $0 i64) (result i32) + (local $1 i32) (i32.or + (i32.eq + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) + ) + ) + (i32.const 5) + ) (i32.or (i32.or (i32.or (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 1) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 2) ) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 3) ) ) (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 4) ) ) - (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - (i32.const 5) - ) ) ) - (func $7 (result i64) - (local $0 i64) + (func $5 + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i64) + (call $fimport$2 + (i32.const 16) + ) (i32.store (i32.wrap_i64 - (local.tee $0 + (local.tee $7 (i64.or (i64.extend_i32_u (call $1 @@ -331,73 +300,65 @@ ) (i32.store8 (i32.add - (i32.wrap_i64 - (local.get $0) + (local.tee $0 + (i32.wrap_i64 + (local.get $7) + ) ) (i32.const 4) ) (i32.const 1) ) (f32.store - (i32.add - (i32.wrap_i64 + (local.tee $2 + (i32.add (local.get $0) + (i32.const 5) ) - (i32.const 5) ) (f32.const 3) ) (i64.store - (i32.add - (i32.wrap_i64 + (local.tee $4 + (i32.add (local.get $0) + (i32.const 9) ) - (i32.const 9) ) (i64.const 8) ) (f64.store - (i32.add - (i32.wrap_i64 + (local.tee $5 + (i32.add (local.get $0) + (i32.const 17) ) - (i32.const 17) ) (f64.const 0.4000000059604645) ) (i64.store - (i32.add - (i32.wrap_i64 + (local.tee $1 + (i32.add (local.get $0) + (i32.const 25) ) - (i32.const 25) ) (i64.const 8589934592) ) (i64.store - (i32.add - (i32.wrap_i64 + (local.tee $3 + (i32.add (local.get $0) + (i32.const 33) ) - (i32.const 33) ) (i64.const 8589934592) ) - (local.get $0) - ) - (func $8 - (local $0 i64) - (local $1 i64) - (call $fimport$2 - (i32.const 16) - ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u - (local.tee $0 - (call $7) - ) + (local.get $7) (i64.const 32) ) ) @@ -405,85 +366,62 @@ ) (i64.const 12884901953) ) - (call $5 + (call $3 (i32.eq (i32.load - (i32.wrap_i64 - (local.get $0) - ) + (local.get $0) ) (i32.const 1) ) (i64.const 12884901960) ) - (call $5 - (i32.eqz - (i32.eqz - (i32.load8_u + (call $3 + (i32.ne + (i32.load8_u + (local.tee $6 (i32.add - (i32.wrap_i64 - (local.get $0) - ) + (local.get $0) (i32.const 4) ) ) ) + (i32.const 0) ) (i64.const 12884901967) ) - (call $5 + (call $3 (f32.eq (f32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 5) - ) + (local.get $2) ) (f32.const 3) ) (i64.const 12884901974) ) - (call $5 + (call $3 (i64.eq (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 9) - ) + (local.get $4) ) (i64.const 8) ) (i64.const 12884901981) ) - (call $5 + (call $3 (f64.eq (f64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 17) - ) + (local.get $5) ) (f64.const 0.4000000059604645) ) (i64.const 12884901988) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) + (local.get $1) ) (i64.const 32) ) @@ -492,17 +430,12 @@ ) (i64.const 12884901995) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 33) - ) + (local.get $3) ) (i64.const 32) ) @@ -511,87 +444,50 @@ ) (i64.const 12884902002) ) - (call $5 - (call $6 + (call $3 + (call $4 (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) + (local.get $1) ) ) (i64.const 12884902009) ) - (call $5 - (call $6 + (call $3 + (call $4 (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 33) - ) + (local.get $3) ) ) (i64.const 12884902016) ) (i32.store - (i32.wrap_i64 - (local.get $0) - ) + (local.get $0) (i32.const 5) ) (i32.store8 - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) + (local.get $6) (i32.const 0) ) (f32.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 5) - ) + (local.get $2) (f32.const -999) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 9) - ) + (local.get $4) (i64.const 3735928559) ) (f64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 17) - ) + (local.get $5) (f64.const 608000000925854355947520) ) (call $fimport$0 (f32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 5) - ) + (local.get $2) ) ) (i32.store (i32.wrap_i64 - (local.tee $1 + (local.tee $7 (i64.or (i64.extend_i32_u (call $1 @@ -605,31 +501,16 @@ (i32.const 333) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) (local.get $1) + (local.get $7) ) (call $fimport$0 (f32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 5) - ) + (local.get $2) ) ) (i64.store - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 33) - ) + (local.get $3) (i64.const 4294967296) ) (call $fimport$1 @@ -637,112 +518,72 @@ ) (call $fimport$1 (i32.load - (i32.wrap_i64 - (local.get $0) - ) + (local.get $0) ) ) - (call $5 + (call $3 (i32.eq (i32.load - (i32.wrap_i64 - (local.get $0) - ) + (local.get $0) ) (i32.const 5) ) (i64.const 12884902023) ) (call $fimport$1 - (i32.eqz - (i32.eqz - (i32.load8_u - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) - ) + (i32.ne + (i32.load8_u + (local.get $6) ) + (i32.const 0) ) ) - (call $5 + (call $3 (i32.eqz (i32.load8_u - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 4) - ) + (local.get $6) ) ) (i64.const 12884902030) ) (call $fimport$0 (f32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 5) - ) + (local.get $2) ) ) - (call $5 + (call $3 (f32.eq (f32.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 5) - ) + (local.get $2) ) (f32.const -999) ) (i64.const 12884902037) ) - (call $5 + (call $3 (i64.eq (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 9) - ) + (local.get $4) ) (i64.const 3735928559) ) (i64.const 12884902044) ) - (call $5 + (call $3 (f64.eq (f64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 17) - ) + (local.get $5) ) (f64.const 608000000925854355947520) ) (i64.const 12884902051) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) + (local.get $1) ) (i64.const 32) ) @@ -751,17 +592,12 @@ ) (i64.const 12884902058) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 33) - ) + (local.get $3) ) (i64.const 32) ) @@ -770,43 +606,28 @@ ) (i64.const 12884902065) ) - (call $5 - (call $6 + (call $3 + (call $4 (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) + (local.get $1) ) ) (i64.const 12884902072) ) - (call $5 - (call $6 + (call $3 + (call $4 (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 33) - ) + (local.get $3) ) ) (i64.const 12884902079) ) - (call $5 + (call $3 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) + (local.get $1) ) (i64.const 32) ) @@ -815,19 +636,14 @@ ) (i64.const 12884902086) ) - (block $label$1 + (block $block (if (i32.ne (i32.wrap_i64 (i64.shr_u - (local.tee $0 + (local.tee $7 (i64.load - (i32.add - (i32.wrap_i64 - (local.get $0) - ) - (i32.const 25) - ) + (local.get $1) ) ) (i64.const 32) @@ -835,19 +651,19 @@ ) (i32.const 5) ) - (block - (call $5 + (then + (call $3 (i32.const 0) (i64.const 12884902100) ) - (br $label$1) + (br $block) ) ) - (call $5 + (call $3 (i32.eq (i32.load (i32.wrap_i64 - (local.get $0) + (local.get $7) ) ) (i32.const 333) @@ -857,7 +673,7 @@ ) (call $fimport$4) ) - (func $9 + (func $6 (global.set $global$0 (i32.const 15) ) @@ -868,9 +684,6 @@ (i32.const 65536) ) (global.set $global$3 - (global.get $global$2) - ) - (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/traverseTree.lys.optimized.wast b/test/fixtures/execution/traverseTree.lys.optimized.wast index e6ac342..04e1139 100644 --- a/test/fixtures/execution/traverseTree.lys.optimized.wast +++ b/test/fixtures/execution/traverseTree.lys.optimized.wast @@ -1,49 +1,48 @@ (module - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $none_=>_i32 (func (result i32))) - (type $i32_i32_=>_none (func (param i32 i32))) - (type $i64_i32_=>_none (func (param i64 i32))) - (type $i64_=>_i32 (func (param i64) (result i32))) - (type $i32_i64_=>_i64 (func (param i32 i64) (result i64))) + (type $0 (func)) + (type $1 (func (param i32 i32))) + (type $2 (func (result i32))) + (type $3 (func (param i32))) + (type $4 (func (param i64 i32))) + (type $5 (func (param i32 i64) (result i64))) + (type $6 (func (param i64) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (import "env" "printf" (func $fimport$3 (param i32 i32))) - (memory $0 1) - (data (i32.const 139) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 166) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 199) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 226) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") - (data (i32.const 487) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 522) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") - (data (i32.const 563) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") - (data (i32.const 590) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") - (data (i32.const 623) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") - (data (i32.const 650) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") - (data (i32.const 683) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") - (data (i32.const 97) "\08\00\00\00t\00r\00u\00e") - (data (i32.const 110) "\n\00\00\00f\00a\00l\00s\00e") - (data (i32.const 125) "\02\00\00\000") - (data (i32.const 132) "\02\00\00\000") - (data (i32.const 16) "\1a\00\00\00T\00r\00a\00v\00e\00r\00s\00e\00 \00t\00r\00e\00e") - (data (i32.const 47) "(\00\00\00s\00u\00m\00(\00t\00r\00e\00e\00)\00 \00r\00e\00t\00u\00r\00n\00s\00 \004\005") (global $global$0 (mut i64) (i64.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i32) (i32.const 0)) + (memory $0 1) + (data $0 (i32.const 139) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $1 (i32.const 166) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $2 (i32.const 199) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $3 (i32.const 226) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $4 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $5 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $6 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $7 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $8 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X") + (data $9 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X") + (data $10 (i32.const 487) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X") + (data $11 (i32.const 522) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X") + (data $12 (i32.const 563) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X") + (data $13 (i32.const 590) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X") + (data $14 (i32.const 623) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") + (data $15 (i32.const 650) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") + (data $16 (i32.const 683) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)") + (data $17 (i32.const 97) "\08\00\00\00t\00r\00u\00e") + (data $18 (i32.const 110) "\n\00\00\00f\00a\00l\00s\00e") + (data $19 (i32.const 125) "\02\00\00\000") + (data $20 (i32.const 132) "\02\00\00\000") + (data $21 (i32.const 16) "\1a\00\00\00T\00r\00a\00v\00e\00r\00s\00e\00 \00t\00r\00e\00e") + (data $22 (i32.const 47) "(\00\00\00s\00u\00m\00(\00t\00r\00e\00e\00)\00 \00r\00e\00t\00u\00r\00n\00s\00 \004\005") (export "memory" (memory $0)) - (export "test_getLastErrorMessage" (func $2)) - (export "test_getMaxMemory" (func $3)) - (export "main" (func $8)) - (start $9) + (export "test_getLastErrorMessage" (func $1)) + (export "test_getMaxMemory" (func $2)) + (export "main" (func $5)) + (start $6) (func $0 (param $0 i64) (param $1 i32) (call $fimport$3 (i32.wrap_i64 @@ -52,84 +51,61 @@ (local.get $1) ) ) - (func $1 (param $0 i32) - (call $fimport$1 + (func $1 (result i32) + (local $0 i64) + (if (result i32) (i32.eq - (local.get $0) - (i32.const 45) - ) - (i32.const 47) - ) - (if - (i32.ne - (local.get $0) - (i32.const 45) - ) - (block - (call $0 - (i64.const 12884902511) - (local.get $0) - ) - (call $0 - (i64.const 12884902538) - (i32.const 45) + (i32.wrap_i64 + (i64.shr_u + (local.tee $0 + (global.get $global$0) + ) + (i64.const 32) + ) ) + (i32.const 3) ) - ) - ) - (func $2 (result i32) - (local $0 i64) - (block $label$1 (result i32) - (drop - (br_if $label$1 - (i32.const 0) - (i32.ne + (then + (i32.wrap_i64 + (i64.load (i32.wrap_i64 - (i64.shr_u - (local.tee $0 - (global.get $global$0) - ) - (i64.const 32) - ) + (local.get $0) ) - (i32.const 3) ) ) ) - (i32.wrap_i64 - (i64.load - (i32.wrap_i64 - (local.get $0) - ) - ) + (else + (i32.const 0) ) ) ) - (func $3 (result i32) - (global.get $global$4) + (func $2 (result i32) + (global.get $global$3) ) - (func $4 (result i32) - (local $0 i32) - (local $1 i32) + (func $3 (param $0 i32) (param $1 i64) (result i64) (local $2 i32) (local $3 i32) (local $4 i32) + (local $5 i32) + (local $6 i64) (if (i32.lt_u (global.get $global$2) (i32.const 20) ) - (unreachable) + (then + (unreachable) + ) ) (if (i32.gt_u - (local.tee $1 + (local.tee $3 (i32.and (i32.add (global.get $global$1) (i32.add - (local.tee $0 - (global.get $global$4) + (local.tee $2 + (global.get $global$3) ) (i32.const 36) ) @@ -141,111 +117,86 @@ ) ) (i32.shl - (local.tee $2 + (local.tee $4 (memory.size) ) (i32.const 16) ) ) - (block + (then (drop (memory.grow (select - (local.get $2) - (local.tee $4 - (local.tee $3 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $1) - (local.get $0) - ) - (i32.const 65535) + (local.get $4) + (local.tee $5 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $3) + (local.get $2) ) - (i32.const -65536) + (i32.const 65535) ) - (i32.const 16) + (i32.const -65536) ) + (i32.const 16) ) ) (i32.gt_u - (local.get $2) (local.get $4) + (local.get $5) ) ) ) ) - (if - (i32.const 0) - (block - (drop - (memory.grow - (local.get $3) - ) - ) - (if - (i32.const 0) - (unreachable) - ) - ) - ) ) ) - (global.set $global$4 - (local.get $1) - ) - (i32.add - (local.get $0) - (i32.const 16) + (global.set $global$3 + (local.get $3) ) - ) - (func $5 (param $0 i32) - (local $1 i32) - (local.set $1 + (local.set $4 (i32.add - (local.get $0) + (local.tee $2 + (local.tee $3 + (i32.add + (local.get $2) + (i32.const 16) + ) + ) + ) (i32.const 20) ) ) - (loop $label$1 + (loop $label (if (i32.ne - (local.get $0) - (local.get $1) + (local.get $2) + (local.get $4) ) - (block + (then (i32.store8 - (local.get $0) + (local.get $2) (i32.load8_u (i32.const 0) ) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) + (local.get $2) (i32.const 1) ) ) - (br $label$1) + (br $label) ) ) ) - ) - (func $6 (param $0 i32) (param $1 i64) (result i64) - (local $2 i32) - (local $3 i64) - (call $5 - (local.tee $2 - (call $4) - ) - ) (i32.store (i32.wrap_i64 - (local.tee $3 + (local.tee $6 (i64.or (i64.extend_i32_u - (local.get $2) + (local.get $3) ) (i64.const 4294967296) ) @@ -255,8 +206,10 @@ ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $3) + (local.tee $0 + (i32.wrap_i64 + (local.get $6) + ) ) (i32.const 4) ) @@ -264,78 +217,71 @@ ) (i64.store (i32.add - (i32.wrap_i64 - (local.get $3) - ) + (local.get $0) (i32.const 12) ) (i64.const 8589934592) ) - (local.get $3) + (local.get $6) ) - (func $7 (param $0 i64) (result i32) + (func $4 (param $0 i64) (result i32) (local $1 i32) - (local $2 i64) - (block $label$1 (result i32) + (local $2 i32) + (block $block1 (result i32) (if (i32.ne - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) ) ) (i32.const 2) ) - (block - (block $label$3 - (br_if $label$3 + (then + (block $block + (br_if $block (i32.eq - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) + (local.get $1) (i32.const 1) ) ) ) - (local.set $1 + (local.set $2 (i32.load - (i32.wrap_i64 - (local.get $0) + (local.tee $1 + (i32.wrap_i64 + (local.get $0) + ) ) ) ) - (local.set $2 + (local.set $0 (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) (i32.const 12) ) ) ) - (br $label$1 + (br $block1 (i32.add (i32.add - (call $7 + (call $4 (i64.load (i32.add - (i32.wrap_i64 - (local.get $0) - ) + (local.get $1) (i32.const 4) ) ) ) - (local.get $1) - ) - (call $7 (local.get $2) ) + (call $4 + (local.get $0) + ) ) ) ) @@ -343,24 +289,47 @@ (i32.const 0) ) ) - (func $8 + (func $5 + (local $0 i32) (call $fimport$0 (i32.const 16) ) - (call $1 - (call $7 - (call $6 - (i32.const 42) - (call $6 - (i32.const 3) - (i64.const 8589934592) + (call $fimport$1 + (i32.eq + (local.tee $0 + (call $4 + (call $3 + (i32.const 42) + (call $3 + (i32.const 3) + (i64.const 8589934592) + ) + ) ) ) + (i32.const 45) + ) + (i32.const 47) + ) + (if + (i32.ne + (local.get $0) + (i32.const 45) + ) + (then + (call $0 + (i64.const 12884902511) + (local.get $0) + ) + (call $0 + (i64.const 12884902538) + (i32.const 45) + ) ) ) (call $fimport$2) ) - (func $9 + (func $6 (global.set $global$0 (i64.const 8589934592) ) @@ -373,8 +342,5 @@ (global.set $global$3 (i32.const 65536) ) - (global.set $global$4 - (global.get $global$3) - ) ) ) diff --git a/tsconfig.json b/tsconfig.json index 3bbeb04..05c5293 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,9 @@ "compilerOptions": { "baseUrl": ".", "paths": { "*": ["types/*"] }, - "module": "commonjs", - "target": "es2020", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "target": "es2022", "diagnostics": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, @@ -13,7 +14,6 @@ "declaration": true, "allowJs": true, "outDir": "dist", - "moduleResolution": "node", "stripInternal": true, "pretty": true, "forceConsistentCasingInFileNames": true, From 7d8e27d9f9e424c43c41d5c6a75459f3e25ddd66 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 09:48:37 -0300 Subject: [PATCH 2/8] remove extra file --- src/compiler/phases/binaryen.mts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 src/compiler/phases/binaryen.mts diff --git a/src/compiler/phases/binaryen.mts b/src/compiler/phases/binaryen.mts deleted file mode 100644 index a1fa218..0000000 --- a/src/compiler/phases/binaryen.mts +++ /dev/null @@ -1,10 +0,0 @@ -declare const globalThis: any; - -export async function loadBinaryen() { - const b = await import('binaryen'); - globalThis['Binaryen'] = { - TOTAL_MEMORY: 16777216 * 8, - }; - - return b; -} From 96b11eb00077289cb53ccef12e64554b301a19e2 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 11:26:38 -0300 Subject: [PATCH 3/8] reduce compilation time, remove flawed wabt dependency --- src/compiler/phases/codeGenerationPhase.ts | 108 ++--- src/index-bin.ts | 2 +- src/utils/libs/env.ts | 3 + .../compiler/0-struct.lys.optimized.wast | 92 ++-- test/fixtures/compiler/0-struct.lys.wast | 44 +- .../compiler/0-wast.lys.optimized.wast | 44 +- test/fixtures/compiler/0-wast.lys.wast | 10 +- .../compiler/1-wast-sha3.lys.optimized.wast | 259 ++++++----- test/fixtures/compiler/1-wast-sha3.lys.wast | 10 +- test/fixtures/compiler/a.lys.wast | 10 +- test/fixtures/compiler/b.lys.wast | 10 +- test/fixtures/compiler/booleanLogic.lys.wast | 10 +- test/fixtures/compiler/bytes.lys.wast | 14 +- test/fixtures/compiler/c.lys.wast | 10 +- test/fixtures/compiler/deconstruct.lys.wast | 10 +- .../compiler/dynamicLhsMatch.lys.wast | 10 +- test/fixtures/compiler/emptyFn.lys.wast | 10 +- test/fixtures/compiler/extern.lys.wast | 10 +- test/fixtures/compiler/fib1.lys.wast | 10 +- test/fixtures/compiler/fib2.lys.wast | 10 +- test/fixtures/compiler/fib3.lys.wast | 10 +- test/fixtures/compiler/getter.lys.wast | 10 +- .../compiler/globalMutability.lys.wast | 10 +- test/fixtures/compiler/if.lys.wast | 10 +- test/fixtures/compiler/if2.lys.wast | 10 +- test/fixtures/compiler/infix.lys.wast | 10 +- test/fixtures/compiler/is.lys.wast | 10 +- .../compiler/iterator-loco.lys.optimized.wast | 97 ++-- test/fixtures/compiler/iterator-loco.lys.wast | 10 +- test/fixtures/compiler/loops.lys.wast | 10 +- test/fixtures/compiler/mutability.lys.wast | 10 +- test/fixtures/compiler/nop.lys.wast | 10 +- test/fixtures/compiler/panic-match.lys.wast | 10 +- .../patternMatchinIs.lys.optimized.wast | 124 +++-- .../compiler/patternMatchinIs.lys.wast | 44 +- .../patternMatching.lys.optimized.wast | 239 +++++----- .../compiler/patternMatching.lys.wast | 10 +- test/fixtures/execution/fibo.lys.wast | 54 +-- .../execution/implicitCast.lys.optimized.wast | 12 +- test/fixtures/execution/implicitCast.lys.wast | 54 +-- .../indirect-smoke.lys.optimized.wast | 55 ++- .../execution/indirect-smoke.lys.wast | 58 +-- test/fixtures/execution/is.lys.optimized.wast | 132 ++++-- test/fixtures/execution/is.lys.wast | 46 +- .../isPatternMatching.lys.optimized.wast | 132 ++++-- .../execution/isPatternMatching.lys.wast | 46 +- ...PatternMatchingVariable.lys.optimized.wast | 16 +- .../isPatternMatchingVariable.lys.wast | 46 +- .../execution/numberOps.lys.optimized.wast | 26 +- test/fixtures/execution/numberOps.lys.wast | 82 ++-- ...ternMatchingDeconstruct.lys.optimized.wast | 50 +- .../patternMatchingDeconstruct.lys.wast | 58 +-- .../recursiveStruct.lys.optimized.wast | 106 ++++- .../execution/recursiveStruct.lys.wast | 58 +-- .../setStructValues.lys.optimized.wast | 434 +++++++++++------- .../execution/setStructValues.lys.wast | 124 ++--- .../simpleIterator.lys.optimized.wast | 98 ++-- .../execution/simpleIterator.lys.wast | 48 +- .../execution/strConcat.lys.optimized.wast | 70 ++- test/fixtures/execution/strConcat.lys.wast | 112 ++--- .../stringifyNumbers.lys.optimized.wast | 76 ++- .../execution/stringifyNumbers.lys.wast | 94 ++-- .../structValuesExtended.lys.optimized.wast | 338 ++++++++++---- .../execution/structValuesExtended.lys.wast | 90 ++-- .../execution/traverseTree.lys.optimized.wast | 108 +++-- test/fixtures/execution/traverseTree.lys.wast | 48 +- 66 files changed, 2352 insertions(+), 1639 deletions(-) diff --git a/src/compiler/phases/codeGenerationPhase.ts b/src/compiler/phases/codeGenerationPhase.ts index f21e826..e015fcf 100644 --- a/src/compiler/phases/codeGenerationPhase.ts +++ b/src/compiler/phases/codeGenerationPhase.ts @@ -2,9 +2,6 @@ import * as ast from '@webassemblyjs/ast'; import { print } from '@webassemblyjs/wast-printer'; const t = ast as any; -declare var globalThis: any; - -import _wabt from 'wabt'; import { annotations } from '../annotations'; import { flatten } from '../helpers'; import { Nodes, findNodesByType, PhaseFlags } from '../nodes'; @@ -24,8 +21,6 @@ type CompilationModuleResult = { imports: any[]; }; -const wabt = _wabt(); - const starterName = t.identifier('%%START%%'); declare var WebAssembly: any; @@ -541,97 +536,49 @@ export class CodeGenerationPhaseResult { }> { const { default: binaryen } = await import('binaryen'); - let text = print(this.programAST); - - const theWabt = await wabt; - let wabtModule: ReturnType; - - try { - wabtModule = theWabt.parseWat(this.document.moduleName, text, {}); - } catch (e: any) { - const invalidFile = this.parsingContext.system.resolvePath( - this.parsingContext.system.getCurrentDirectory(), - 'failed_debug_wat.wat', - ); - this.parsingContext.system.writeFile(invalidFile, text); - console.error('Error while parsing generated code. Writing debug WAT to ' + invalidFile); - console.error(e); - throw e; - } - - try { - wabtModule.resolveNames(); - wabtModule.validate(); - } catch (e: any) { - const invalidFile = this.parsingContext.system.resolvePath( - this.parsingContext.system.getCurrentDirectory(), - 'failed_debug_wat.wat', - ); - this.parsingContext.system.writeFile(invalidFile, text); - - console.error('Error while resolving names and validate code. Writing debug WAT to ' + invalidFile); - console.error(e); - - this.parsingContext.messageCollector.error(e, this.document.astNode); - throw e; - } - - const binary = wabtModule.toBinary({ log: false, write_debug_names: debug }); - wabtModule.destroy(); + const parseText = (text: string) => { + try { + return binaryen.parseText(text); + } catch (e: any) { + const invalidFile = this.parsingContext.system.resolvePath( + this.parsingContext.system.getCurrentDirectory(), + 'failed_debug_wat.wat', + ); + this.parsingContext.system.writeFile(invalidFile, text); + console.error('Error while parsing generated code. Writing debug WAT to ' + invalidFile); + console.error(e); + throw e; + } + }; try { binaryen.setOptimizeLevel(optimizeLevel); binaryen.setShrinkLevel(shrinkLevel); binaryen.setDebugInfo(debug || !optimize); - const module = binaryen.readBinary(binary.buffer); + let text = print(this.programAST); + const module = parseText(text); + + // if (!debug) { + // module.runPasses(['duplicate-function-elimination']); + // } - if (!debug) { - module.runPasses(['duplicate-function-elimination']); - } module.runPasses(['remove-unused-module-elements']); + if (optimize) { + module.optimize(); + } + if (module.validate() === 0) { this.parsingContext.messageCollector.error(new LysCompilerError('binaryen validation failed', this.document)); } if (debug) { let last = module.emitBinary('sourceMap.map'); - - if (optimize) { - do { - module.optimize(); - let next = module.emitBinary('sourceMap.map'); - if (next.binary.length >= last.binary.length) { - // a if (next.length > last.length) { - // a this.parsingContext.system.write('Last converge was suboptimial.\n'); - // a } - break; - } - last = next; - } while (true); - } - this.buffer = last.binary; this.sourceMap = last.sourceMap; } else { - let last = module.emitBinary(); - - if (optimize) { - do { - module.optimize(); - let next = module.emitBinary(); - if (next.length >= last.length) { - // a if (next.length > last.length) { - // a this.parsingContext.system.write('Last converge was suboptimial.\n'); - // a } - break; - } - last = next; - } while (true); - } - - this.buffer = last; + this.buffer = module.emitBinary(); } module.dispose(); @@ -719,7 +666,8 @@ export class CodeGenerationPhaseResult { const numberLiteral = t.numberLiteralFromRaw(offset, 'i32'); const offsetToken = t.objectInstruction('const', 'i32', [numberLiteral]); - dataSection.push(t.data(t.memIndexLiteral(0), offsetToken, t.byteArray(bytes))); + // dataSection.push(t.data(t.memIndexLiteral(dataCount++), offsetToken, t.byteArray(bytes))); + dataSection.push(t.data(t.identifier(`mem_${offset}`), offsetToken, t.byteArray(bytes))); return offset + size; } @@ -820,7 +768,7 @@ export class CodeGenerationPhaseResult { const table = t.table('funcref', t.limit(tableElems.length), t.identifier('lys::internal-functions')); const elem = t.elem( // table - t.indexLiteral(0), + t.identifier('elem_table_0'), // offset [t.objectInstruction('const', 'i32', [t.numberLiteralFromRaw(0)])], // elems diff --git a/src/index-bin.ts b/src/index-bin.ts index 0d8a21e..78f0cf4 100644 --- a/src/index-bin.ts +++ b/src/index-bin.ts @@ -163,7 +163,7 @@ async function emit(parsingContext: ReturnType): Promi writeFileSync(parsingContext.outFileFullWithoutExtension + '.wasm', codeGen.buffer); - let src = []; + let src: string[] = []; src.push('Object.defineProperty(exports, "__esModule", { value: true });'); src.push('const modules = [];'); diff --git a/src/utils/libs/env.ts b/src/utils/libs/env.ts index 64109f0..9cd2b09 100644 --- a/src/utils/libs/env.ts +++ b/src/utils/libs/env.ts @@ -15,6 +15,9 @@ function printHexByte(x: number) { export default function(getInstance: () => any) { return { env: { + putchar: function() { + throw new Error('putchar not implemented') + }, printf: function(offset: number, ...args: number[]) { try { let str = readString(getInstance().exports.memory.buffer, offset); diff --git a/test/fixtures/compiler/0-struct.lys.optimized.wast b/test/fixtures/compiler/0-struct.lys.optimized.wast index 397602c..8e0b332 100644 --- a/test/fixtures/compiler/0-struct.lys.optimized.wast +++ b/test/fixtures/compiler/0-struct.lys.optimized.wast @@ -3,13 +3,17 @@ (type $1 (func)) (type $2 (func (param i32 i32))) (type $3 (func (param i32))) - (type $4 (func (param i32) (result i32))) + (type $4 (func (param i32 i32) (result i32))) (type $5 (func (param i64) (result i32))) (import "test" "registerAssertion" (func $fimport$0 (param i32 i32))) (global $global$0 (mut i64) (i64.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i32) (i32.const 0)) (memory $0 1) (data $0 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -83,6 +87,7 @@ (i64.or (i64.extend_i32_u (call $3 + (i32.const 1) (i32.const 8) ) ) @@ -100,16 +105,22 @@ ) ) (func $2 (result i32) - (global.get $global$3) + (global.get $global$7) ) - (func $3 (param $0 i32) (result i32) - (local $1 i32) + (func $3 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -117,7 +128,7 @@ ) (if (i32.lt_u - (global.get $global$2) + (global.get $global$4) (local.get $0) ) (then @@ -126,14 +137,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$1) + (global.get $global$3) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$7) ) (i32.const 16) ) @@ -148,13 +159,13 @@ ) ) (i32.xor - (global.get $global$1) + (global.get $global$3) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -164,13 +175,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -181,22 +192,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$3 - (local.get $2) + (global.set $global$7 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -209,18 +220,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -228,7 +239,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $4 (param $0 i64) (result i32) (i32.eq @@ -259,6 +270,7 @@ (i64.or (i64.extend_i32_u (call $3 + (i32.const 1) (i32.const 12) ) ) @@ -303,13 +315,37 @@ (i64.const 8589934592) ) (global.set $global$1 - (i32.const 15) + (i32.const 4) ) (global.set $global$2 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$3 + (i32.sub + (global.get $global$2) + (i32.const 1) + ) + ) + (global.set $global$4 + (i32.const 1073741824) + ) + (global.set $global$5 (i32.const 65536) ) + (global.set $global$6 + (i32.and + (i32.add + (global.get $global$3) + (i32.const 65536) + ) + (i32.xor + (global.get $global$3) + (i32.const -1) + ) + ) + ) + (global.set $global$7 + (global.get $global$6) + ) ) ) diff --git a/test/fixtures/compiler/0-struct.lys.wast b/test/fixtures/compiler/0-struct.lys.wast index 8361e45..784a20b 100644 --- a/test/fixtures/compiler/0-struct.lys.wast +++ b/test/fixtures/compiler/0-struct.lys.wast @@ -165,23 +165,23 @@ ) ) ) - (data 0 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_63 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_90 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_123 (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_150 (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_183 (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_218 (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_259 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_294 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_335 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_370 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_411 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_446 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_487 (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_514 (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_547 (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_574 (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_607 (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/0-wast.lys.optimized.wast b/test/fixtures/compiler/0-wast.lys.optimized.wast index ffc46e7..daadb10 100644 --- a/test/fixtures/compiler/0-wast.lys.optimized.wast +++ b/test/fixtures/compiler/0-wast.lys.optimized.wast @@ -4,6 +4,10 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) (memory $0 1) (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") @@ -14,7 +18,7 @@ (export "main" (func $1)) (start $2) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) (func $1 (result i32) (local $0 i32) @@ -22,7 +26,7 @@ (local $2 i32) (if (i32.eqz - (global.get $global$1) + (global.get $global$3) ) (then (unreachable) @@ -33,16 +37,16 @@ (local.tee $1 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (local.tee $0 - (global.get $global$2) + (global.get $global$6) ) (i32.const 32) ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) @@ -83,20 +87,44 @@ ) ) ) - (global.set $global$2 + (global.set $global$6 (local.get $1) ) (i32.const 9) ) (func $2 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 + (i32.sub + (global.get $global$1) + (i32.const 1) + ) + ) + (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 (i32.const 65536) ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) ) ) diff --git a/test/fixtures/compiler/0-wast.lys.wast b/test/fixtures/compiler/0-wast.lys.wast index bd217a3..9cf0ee3 100644 --- a/test/fixtures/compiler/0-wast.lys.wast +++ b/test/fixtures/compiler/0-wast.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast b/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast index 999d4ca..004ef74 100644 --- a/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast +++ b/test/fixtures/compiler/1-wast-sha3.lys.optimized.wast @@ -1,8 +1,8 @@ (module - (type $0 (func (param i32 i32))) + (type $0 (func (param i32 i32 i32))) (type $1 (func (result i32))) (type $2 (func (param i32) (result i32))) - (type $3 (func (param i32 i32 i32))) + (type $3 (func (param i32 i32))) (type $4 (func (param i32))) (type $5 (func (param i32) (result i64))) (type $6 (func (param i64) (result i64))) @@ -10,7 +10,11 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") @@ -21,7 +25,7 @@ (export "keccak" (func $7)) (start $8) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) (func $1 (param $0 i32) (result i32) (local $1 i32) @@ -37,7 +41,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -46,17 +50,11 @@ ) (if (i32.gt_u - (local.tee $0 + (local.tee $1 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add - (i32.add - (local.tee $1 - (global.get $global$2) - ) - (i32.const 16) - ) (select (i32.const 16) (local.get $0) @@ -65,10 +63,16 @@ (i32.const 16) ) ) + (i32.add + (local.tee $0 + (global.get $global$6) + ) + (i32.const 16) + ) ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) @@ -90,8 +94,8 @@ (i32.and (i32.add (i32.sub - (local.get $0) (local.get $1) + (local.get $0) ) (i32.const 65535) ) @@ -109,11 +113,11 @@ ) ) ) - (global.set $global$2 - (local.get $0) + (global.set $global$6 + (local.get $1) ) (i32.add - (local.get $1) + (local.get $0) (i32.const 16) ) ) @@ -165,24 +169,26 @@ ) ) ) - (func $3 (param $0 i32) (param $1 i32) - (local.set $1 + (func $3 (param $0 i32) (param $1 i32) (param $2 i32) + (local.set $2 (i32.add (local.get $0) - (local.get $1) + (local.get $2) ) ) (loop $label (if - (i32.ne - (local.get $0) - (local.get $1) + (i32.eqz + (i32.eq + (local.get $0) + (local.get $2) + ) ) (then (i32.store8 (local.get $0) (i32.load8_u - (i32.const 0) + (local.get $1) ) ) (local.set $0 @@ -234,8 +240,10 @@ (i64.store (i32.wrap_i64 (local.tee $27 - (i64.extend_i32_s - (local.get $1) + (local.tee $26 + (i64.extend_i32_s + (local.get $1) + ) ) ) ) @@ -249,7 +257,7 @@ ) (i64.load (i32.wrap_i64 - (local.tee $26 + (local.tee $27 (i64.extend_i32_s (local.get $0) ) @@ -273,7 +281,7 @@ (i32.add (local.tee $0 (i32.wrap_i64 - (local.get $26) + (local.get $27) ) ) (i32.const 8) @@ -582,6 +590,9 @@ ) ) ) + (local.set $27 + (local.get $26) + ) (local.set $3 (i32.const 0) ) @@ -595,7 +606,7 @@ (local.set $28 (i64.xor (i64.load - (local.tee $25 + (local.tee $1 (i32.add (local.tee $0 (i32.wrap_i64 @@ -608,7 +619,7 @@ ) (i64.xor (i64.load - (local.tee $1 + (local.tee $2 (i32.add (local.get $0) (i32.const 120) @@ -617,7 +628,7 @@ ) (i64.xor (i64.load - (local.tee $2 + (local.tee $4 (i32.add (local.get $0) (i32.const 80) @@ -631,7 +642,7 @@ ) ) (i64.load - (local.tee $4 + (local.tee $5 (i32.add (local.get $0) (i32.const 40) @@ -646,7 +657,7 @@ (local.set $29 (i64.xor (i64.load - (local.tee $5 + (local.tee $6 (i32.add (local.get $0) (i32.const 176) @@ -655,7 +666,7 @@ ) (i64.xor (i64.load - (local.tee $6 + (local.tee $7 (i32.add (local.get $0) (i32.const 136) @@ -664,7 +675,7 @@ ) (i64.xor (i64.load - (local.tee $7 + (local.tee $8 (i32.add (local.get $0) (i32.const 96) @@ -673,7 +684,7 @@ ) (i64.xor (i64.load - (local.tee $8 + (local.tee $9 (i32.add (local.get $0) (i32.const 16) @@ -681,7 +692,7 @@ ) ) (i64.load - (local.tee $9 + (local.tee $10 (i32.add (local.get $0) (i32.const 56) @@ -696,7 +707,7 @@ (local.set $30 (i64.xor (i64.load - (local.tee $10 + (local.tee $11 (i32.add (local.get $0) (i32.const 184) @@ -705,7 +716,7 @@ ) (i64.xor (i64.load - (local.tee $11 + (local.tee $12 (i32.add (local.get $0) (i32.const 144) @@ -714,7 +725,7 @@ ) (i64.xor (i64.load - (local.tee $12 + (local.tee $13 (i32.add (local.get $0) (i32.const 104) @@ -723,7 +734,7 @@ ) (i64.xor (i64.load - (local.tee $13 + (local.tee $14 (i32.add (local.get $0) (i32.const 24) @@ -731,7 +742,7 @@ ) ) (i64.load - (local.tee $14 + (local.tee $15 (i32.sub (local.get $0) (i32.const -64) @@ -752,7 +763,7 @@ (local.tee $34 (i64.xor (i64.load - (local.tee $15 + (local.tee $16 (i32.add (local.get $0) (i32.const 192) @@ -761,7 +772,7 @@ ) (i64.xor (i64.load - (local.tee $16 + (local.tee $17 (i32.add (local.get $0) (i32.const 152) @@ -770,7 +781,7 @@ ) (i64.xor (i64.load - (local.tee $17 + (local.tee $18 (i32.add (local.get $0) (i32.const 112) @@ -779,7 +790,7 @@ ) (i64.xor (i64.load - (local.tee $18 + (local.tee $19 (i32.add (local.get $0) (i32.const 32) @@ -787,7 +798,7 @@ ) ) (i64.load - (local.tee $19 + (local.tee $20 (i32.add (local.get $0) (i32.const 72) @@ -803,7 +814,7 @@ (local.tee $35 (i64.xor (i64.load - (local.tee $20 + (local.tee $21 (i32.add (local.get $0) (i32.const 168) @@ -812,7 +823,7 @@ ) (i64.xor (i64.load - (local.tee $21 + (local.tee $22 (i32.add (local.get $0) (i32.const 128) @@ -821,7 +832,7 @@ ) (i64.xor (i64.load - (local.tee $22 + (local.tee $23 (i32.add (local.get $0) (i32.const 88) @@ -830,7 +841,7 @@ ) (i64.xor (i64.load - (local.tee $23 + (local.tee $24 (i32.add (local.get $0) (i32.const 8) @@ -838,7 +849,7 @@ ) ) (i64.load - (local.tee $24 + (local.tee $25 (i32.add (local.get $0) (i32.const 48) @@ -857,34 +868,34 @@ ) ) (i64.store - (local.get $4) + (local.get $5) (i64.xor (local.get $26) (i64.load - (local.get $4) + (local.get $5) ) ) ) (i64.store - (local.get $2) + (local.get $4) (i64.xor (local.get $26) (i64.load - (local.get $2) + (local.get $4) ) ) ) (i64.store - (local.get $1) + (local.get $2) (i64.xor (local.get $26) (i64.load - (local.get $1) + (local.get $2) ) ) ) (i64.store - (local.get $25) + (local.get $1) (i64.xor (local.get $26) (i64.load @@ -896,7 +907,7 @@ ) ) (i64.store - (local.get $23) + (local.get $24) (i64.xor (local.tee $26 (i64.xor @@ -908,48 +919,48 @@ ) ) (i64.load - (local.get $23) + (local.get $24) ) ) ) (i64.store - (local.get $24) + (local.get $25) (i64.xor (local.get $26) (i64.load - (local.get $24) + (local.get $25) ) ) ) (i64.store - (local.get $22) + (local.get $23) (i64.xor (local.get $26) (i64.load - (local.get $22) + (local.get $23) ) ) ) (i64.store - (local.get $21) + (local.get $22) (i64.xor (local.get $26) (i64.load - (local.get $21) + (local.get $22) ) ) ) (i64.store - (local.get $20) + (local.get $21) (i64.xor (local.get $26) (i64.load - (local.get $20) + (local.get $21) ) ) ) (i64.store - (local.get $8) + (local.get $9) (i64.xor (local.tee $26 (i64.xor @@ -961,48 +972,48 @@ ) ) (i64.load - (local.get $8) + (local.get $9) ) ) ) (i64.store - (local.get $9) + (local.get $10) (i64.xor (local.get $26) (i64.load - (local.get $9) + (local.get $10) ) ) ) (i64.store - (local.get $7) + (local.get $8) (i64.xor (local.get $26) (i64.load - (local.get $7) + (local.get $8) ) ) ) (i64.store - (local.get $6) + (local.get $7) (i64.xor (local.get $26) (i64.load - (local.get $6) + (local.get $7) ) ) ) (i64.store - (local.get $5) + (local.get $6) (i64.xor (local.get $26) (i64.load - (local.get $5) + (local.get $6) ) ) ) (i64.store - (local.get $13) + (local.get $14) (i64.xor (local.tee $26 (i64.xor @@ -1014,48 +1025,48 @@ ) ) (i64.load - (local.get $13) + (local.get $14) ) ) ) (i64.store - (local.get $14) + (local.get $15) (i64.xor (local.get $26) (i64.load - (local.get $14) + (local.get $15) ) ) ) (i64.store - (local.get $12) + (local.get $13) (i64.xor (local.get $26) (i64.load - (local.get $12) + (local.get $13) ) ) ) (i64.store - (local.get $11) + (local.get $12) (i64.xor (local.get $26) (i64.load - (local.get $11) + (local.get $12) ) ) ) (i64.store - (local.get $10) + (local.get $11) (i64.xor (local.get $26) (i64.load - (local.get $10) + (local.get $11) ) ) ) (i64.store - (local.get $18) + (local.get $19) (i64.xor (local.tee $26 (i64.xor @@ -1067,43 +1078,43 @@ ) ) (i64.load - (local.get $18) + (local.get $19) ) ) ) (i64.store - (local.get $19) + (local.get $20) (i64.xor (local.get $26) (i64.load - (local.get $19) + (local.get $20) ) ) ) (i64.store - (local.get $17) + (local.get $18) (i64.xor (local.get $26) (i64.load - (local.get $17) + (local.get $18) ) ) ) (i64.store - (local.get $16) + (local.get $17) (i64.xor (local.get $26) (i64.load - (local.get $16) + (local.get $17) ) ) ) (i64.store - (local.get $15) + (local.get $16) (i64.xor (local.get $26) (i64.load - (local.get $15) + (local.get $16) ) ) ) @@ -1600,7 +1611,7 @@ (local.get $26) (i64.xor (i64.load - (local.tee $4 + (local.tee $1 (i32.add (local.get $1) (local.get $2) @@ -1613,12 +1624,14 @@ ) ) (i64.store - (local.get $4) + (local.get $1) (i64.xor (i64.load (i32.add - (local.get $1) (local.get $2) + (i32.wrap_i64 + (local.get $27) + ) ) ) (i64.and @@ -1679,6 +1692,7 @@ (local $2 i32) (call $3 (local.get $0) + (i32.const 0) (i32.const 616) ) (i64.store @@ -2094,6 +2108,7 @@ ) ) ) + (i32.const 0) (local.get $2) ) (i32.store @@ -2121,7 +2136,7 @@ (i32.wrap_i64 (i64.load (i32.wrap_i64 - (global.get $global$3) + (global.get $global$7) ) ) ) @@ -2150,7 +2165,7 @@ (i32.wrap_i64 (i64.load (i32.wrap_i64 - (global.get $global$3) + (global.get $global$7) ) ) ) @@ -2291,7 +2306,7 @@ (local.tee $1 (i32.wrap_i64 (local.tee $7 - (global.get $global$3) + (global.get $global$7) ) ) ) @@ -2333,6 +2348,7 @@ ) (local.get $5) ) + (i32.const 0) (i32.sub (i32.const 136) (local.get $1) @@ -2451,14 +2467,38 @@ (local $2 i64) (local $3 i32) (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 + (i32.sub + (global.get $global$1) + (i32.const 1) + ) + ) + (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 (i32.const 65536) ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) (local.set $0 (call $6 (i32.const 616) @@ -2483,6 +2523,7 @@ (i32.const 16) ) ) + (i32.const 0) (i32.const 16) ) (i64.store @@ -2507,7 +2548,7 @@ ) (local.get $2) ) - (global.set $global$3 + (global.set $global$7 (local.get $1) ) ) diff --git a/test/fixtures/compiler/1-wast-sha3.lys.wast b/test/fixtures/compiler/1-wast-sha3.lys.wast index c71a0fc..7e4147f 100644 --- a/test/fixtures/compiler/1-wast-sha3.lys.wast +++ b/test/fixtures/compiler/1-wast-sha3.lys.wast @@ -691,11 +691,11 @@ (call $system::core::i64::i64.store_2 (local.get $system::hash::keccak::outputRef) (call $system::core::i64::i64.load_2 (local.get $system::hash::keccak::contextRef_2) (call $system::core::i32::i32.as_4 (i32.const 24))) (call $system::core::i32::i32.as_4 (i32.const 24))) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/a.lys.wast b/test/fixtures/compiler/a.lys.wast index de881d5..013b77f 100644 --- a/test/fixtures/compiler/a.lys.wast +++ b/test/fixtures/compiler/a.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/b.lys.wast b/test/fixtures/compiler/b.lys.wast index aa6c4ca..603f297 100644 --- a/test/fixtures/compiler/b.lys.wast +++ b/test/fixtures/compiler/b.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/booleanLogic.lys.wast b/test/fixtures/compiler/booleanLogic.lys.wast index fec7bd2..90554bd 100644 --- a/test/fixtures/compiler/booleanLogic.lys.wast +++ b/test/fixtures/compiler/booleanLogic.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/bytes.lys.wast b/test/fixtures/compiler/bytes.lys.wast index e2058ca..cef210c 100644 --- a/test/fixtures/compiler/bytes.lys.wast +++ b/test/fixtures/compiler/bytes.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 54) "\00\00\00\00\00") - (data 0 (i32.const 59) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 72) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 87) "\02\00\00\000\00\00") - (data 0 (i32.const 94) "\02\00\00\000\00\00") + (data $mem_54 (i32.const 54) "\00\00\00\00\00") + (data $mem_59 (i32.const 59) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_72 (i32.const 72) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_87 (i32.const 87) "\02\00\00\000\00\00") + (data $mem_94 (i32.const 94) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -1719,8 +1719,8 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "\0c\00\00\00a\00s\00d\00a\00s\00d\00\00") - (data 0 (i32.const 33) "\10\00\00\00u\00t\00f\00 \00\ab\00\100\110\bb\00\00") + (data $mem_16 (i32.const 16) "\0c\00\00\00a\00s\00d\00a\00s\00d\00\00") + (data $mem_33 (i32.const 33) "\10\00\00\00u\00t\00f\00 \00\ab\00\100\110\bb\00\00") (global $test::fixtures::compiler::bytes::a (mut i64) (i64.const 0)) (global $test::fixtures::compiler::bytes::b (mut i64) (i64.const 0)) (export "main" (func $test::fixtures::compiler::bytes::main_1)) diff --git a/test/fixtures/compiler/c.lys.wast b/test/fixtures/compiler/c.lys.wast index 16cef82..e2ea016 100644 --- a/test/fixtures/compiler/c.lys.wast +++ b/test/fixtures/compiler/c.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/deconstruct.lys.wast b/test/fixtures/compiler/deconstruct.lys.wast index f06a4be..dcac85d 100644 --- a/test/fixtures/compiler/deconstruct.lys.wast +++ b/test/fixtures/compiler/deconstruct.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/dynamicLhsMatch.lys.wast b/test/fixtures/compiler/dynamicLhsMatch.lys.wast index 07990eb..cd7249e 100644 --- a/test/fixtures/compiler/dynamicLhsMatch.lys.wast +++ b/test/fixtures/compiler/dynamicLhsMatch.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/emptyFn.lys.wast b/test/fixtures/compiler/emptyFn.lys.wast index 65439db..5177a97 100644 --- a/test/fixtures/compiler/emptyFn.lys.wast +++ b/test/fixtures/compiler/emptyFn.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/extern.lys.wast b/test/fixtures/compiler/extern.lys.wast index 9dfdf18..04e572a 100644 --- a/test/fixtures/compiler/extern.lys.wast +++ b/test/fixtures/compiler/extern.lys.wast @@ -1311,11 +1311,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/fib1.lys.wast b/test/fixtures/compiler/fib1.lys.wast index d7002ed..eb034ab 100644 --- a/test/fixtures/compiler/fib1.lys.wast +++ b/test/fixtures/compiler/fib1.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/fib2.lys.wast b/test/fixtures/compiler/fib2.lys.wast index 59dc0fd..f8860a1 100644 --- a/test/fixtures/compiler/fib2.lys.wast +++ b/test/fixtures/compiler/fib2.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/fib3.lys.wast b/test/fixtures/compiler/fib3.lys.wast index 538ccc8..edee3a1 100644 --- a/test/fixtures/compiler/fib3.lys.wast +++ b/test/fixtures/compiler/fib3.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/getter.lys.wast b/test/fixtures/compiler/getter.lys.wast index 7104030..213ffe3 100644 --- a/test/fixtures/compiler/getter.lys.wast +++ b/test/fixtures/compiler/getter.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/globalMutability.lys.wast b/test/fixtures/compiler/globalMutability.lys.wast index 0260d8e..769eda4 100644 --- a/test/fixtures/compiler/globalMutability.lys.wast +++ b/test/fixtures/compiler/globalMutability.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/if.lys.wast b/test/fixtures/compiler/if.lys.wast index 87cad4c..61583e2 100644 --- a/test/fixtures/compiler/if.lys.wast +++ b/test/fixtures/compiler/if.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/if2.lys.wast b/test/fixtures/compiler/if2.lys.wast index 3624c9b..5a8ad18 100644 --- a/test/fixtures/compiler/if2.lys.wast +++ b/test/fixtures/compiler/if2.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/infix.lys.wast b/test/fixtures/compiler/infix.lys.wast index f2e4724..a58dabc 100644 --- a/test/fixtures/compiler/infix.lys.wast +++ b/test/fixtures/compiler/infix.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/is.lys.wast b/test/fixtures/compiler/is.lys.wast index a496dc6..93c2b2c 100644 --- a/test/fixtures/compiler/is.lys.wast +++ b/test/fixtures/compiler/is.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/iterator-loco.lys.optimized.wast b/test/fixtures/compiler/iterator-loco.lys.optimized.wast index bebd2ad..0e5b417 100644 --- a/test/fixtures/compiler/iterator-loco.lys.optimized.wast +++ b/test/fixtures/compiler/iterator-loco.lys.optimized.wast @@ -1,11 +1,14 @@ (module - (type $0 (func (result i32))) - (type $1 (func (param i32) (result i32))) - (type $2 (func (param i32 i32) (result i32))) - (type $3 (func)) + (type $0 (func (param i32 i32) (result i32))) + (type $1 (func (result i32))) + (type $2 (func)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) (memory $0 1) (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") @@ -16,16 +19,22 @@ (export "test" (func $2)) (start $3) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $1 (param $0 i32) (result i32) - (local $1 i32) + (func $1 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -33,7 +42,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -42,14 +51,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $1 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -64,13 +73,13 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -80,13 +89,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -97,22 +106,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$2 - (local.get $2) + (global.set $global$6 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -125,18 +134,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -144,7 +153,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $2 (param $0 i32) (param $1 i32) (result i32) (local $2 i64) @@ -156,6 +165,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 8) ) ) @@ -205,6 +215,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 4) ) ) @@ -254,13 +265,37 @@ ) (func $3 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 + (i32.sub + (global.get $global$1) + (i32.const 1) + ) + ) + (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 (i32.const 65536) ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) ) ) diff --git a/test/fixtures/compiler/iterator-loco.lys.wast b/test/fixtures/compiler/iterator-loco.lys.wast index 3834661..79ea659 100644 --- a/test/fixtures/compiler/iterator-loco.lys.wast +++ b/test/fixtures/compiler/iterator-loco.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/loops.lys.wast b/test/fixtures/compiler/loops.lys.wast index dc46ff0..80af0a0 100644 --- a/test/fixtures/compiler/loops.lys.wast +++ b/test/fixtures/compiler/loops.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/mutability.lys.wast b/test/fixtures/compiler/mutability.lys.wast index f94324a..adcb4d9 100644 --- a/test/fixtures/compiler/mutability.lys.wast +++ b/test/fixtures/compiler/mutability.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/nop.lys.wast b/test/fixtures/compiler/nop.lys.wast index 712c330..f0662ed 100644 --- a/test/fixtures/compiler/nop.lys.wast +++ b/test/fixtures/compiler/nop.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/panic-match.lys.wast b/test/fixtures/compiler/panic-match.lys.wast index 185a749..7224ac7 100644 --- a/test/fixtures/compiler/panic-match.lys.wast +++ b/test/fixtures/compiler/panic-match.lys.wast @@ -1309,11 +1309,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast b/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast index 4c3c566..ffdd40f 100644 --- a/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast +++ b/test/fixtures/compiler/patternMatchinIs.lys.optimized.wast @@ -4,16 +4,20 @@ (type $2 (func)) (type $3 (func (param i32 i32))) (type $4 (func (param i32))) - (type $5 (func (param i32) (result i32))) + (type $5 (func (param i32 i32) (result i32))) (type $6 (func (result i64))) (import "test" "registerAssertion" (func $fimport$0 (param i32 i32))) (global $global$0 (mut i64) (i64.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) (global $global$3 (mut i32) (i32.const 0)) - (global $global$4 (mut i64) (i64.const 0)) - (global $global$5 (mut i64) (i64.const 0)) - (global $global$6 (mut i64) (i64.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i32) (i32.const 0)) + (global $global$8 (mut i64) (i64.const 0)) + (global $global$9 (mut i64) (i64.const 0)) + (global $global$10 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -92,6 +96,7 @@ (i64.or (i64.extend_i32_u (call $3 + (i32.const 1) (i32.const 8) ) ) @@ -109,16 +114,22 @@ ) ) (func $2 (result i32) - (global.get $global$3) + (global.get $global$7) ) - (func $3 (param $0 i32) (result i32) - (local $1 i32) + (func $3 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -126,7 +137,7 @@ ) (if (i32.lt_u - (global.get $global$2) + (global.get $global$4) (local.get $0) ) (then @@ -135,14 +146,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$1) + (global.get $global$3) (i32.add (i32.add (local.tee $1 - (global.get $global$3) + (global.get $global$7) ) (i32.const 16) ) @@ -157,13 +168,13 @@ ) ) (i32.xor - (global.get $global$1) + (global.get $global$3) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -173,13 +184,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -190,22 +201,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$3 - (local.get $2) + (global.set $global$7 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -218,18 +229,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -237,7 +248,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $4 (result i64) (local $0 i64) @@ -247,6 +258,7 @@ (i64.or (i64.extend_i32_u (call $3 + (i32.const 1) (i32.const 4) ) ) @@ -393,7 +405,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -404,7 +416,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -417,7 +429,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -440,7 +452,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -451,7 +463,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -464,7 +476,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -487,7 +499,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -498,7 +510,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -511,7 +523,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -534,7 +546,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -614,21 +626,45 @@ (i64.const 8589934592) ) (global.set $global$1 - (i32.const 15) + (i32.const 4) ) (global.set $global$2 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$3 - (i32.const 65536) + (i32.sub + (global.get $global$2) + (i32.const 1) + ) ) (global.set $global$4 - (i64.const 4294967296) + (i32.const 1073741824) ) (global.set $global$5 - (i64.const 4294967296) + (i32.const 65536) ) (global.set $global$6 + (i32.and + (i32.add + (global.get $global$3) + (i32.const 65536) + ) + (i32.xor + (global.get $global$3) + (i32.const -1) + ) + ) + ) + (global.set $global$7 + (global.get $global$6) + ) + (global.set $global$8 + (i64.const 4294967296) + ) + (global.set $global$9 + (i64.const 4294967296) + ) + (global.set $global$10 (i64.const 4294967296) ) ) diff --git a/test/fixtures/compiler/patternMatchinIs.lys.wast b/test/fixtures/compiler/patternMatchinIs.lys.wast index 6e00bab..24d0d6b 100644 --- a/test/fixtures/compiler/patternMatchinIs.lys.wast +++ b/test/fixtures/compiler/patternMatchinIs.lys.wast @@ -165,23 +165,23 @@ ) ) ) - (data 0 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_63 (i32.const 63) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_90 (i32.const 90) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_123 (i32.const 123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_150 (i32.const 150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_183 (i32.const 183) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_218 (i32.const 218) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_259 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_294 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_335 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_370 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_411 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_446 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_487 (i32.const 487) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_514 (i32.const 514) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_547 (i32.const 547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_574 (i32.const 574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_607 (i32.const 607) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/compiler/patternMatching.lys.optimized.wast b/test/fixtures/compiler/patternMatching.lys.optimized.wast index 9081735..7e334e9 100644 --- a/test/fixtures/compiler/patternMatching.lys.optimized.wast +++ b/test/fixtures/compiler/patternMatching.lys.optimized.wast @@ -7,6 +7,10 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) (memory $0 1) (data $0 (i32.const 21) "\08\00\00\00t\00r\00u\00e") (data $1 (i32.const 34) "\n\00\00\00f\00a\00l\00s\00e") @@ -20,7 +24,7 @@ (export "test4" (func $4)) (start $5) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) (func $1 (param $0 i32) (result i32) (i32.eq @@ -167,156 +171,185 @@ (local $2 i32) (local $3 i32) (local $4 i32) - (if - (i32.ne - (local.tee $1 - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) + (block $block1 (result i64) + (if + (i32.ne + (local.tee $1 + (i32.wrap_i64 + (i64.shr_u + (local.get $0) + (i64.const 32) + ) ) ) + (i32.const 2) ) - (i32.const 2) - ) - (then - (block $block - (br_if $block - (i32.eq - (local.get $1) - (i32.const 1) + (then + (block $block + (br_if $block + (i32.eq + (local.get $1) + (i32.const 1) + ) ) ) - ) - (if - (i32.lt_u - (global.get $global$1) - (i32.const 4) - ) - (then - (unreachable) + (if + (i32.lt_u + (global.get $global$3) + (i32.const 4) + ) + (then + (unreachable) + ) ) - ) - (if - (i32.gt_u - (local.tee $2 - (i32.and - (i32.add - (global.get $global$0) + (if + (i32.gt_u + (local.tee $2 + (i32.and (i32.add - (local.tee $1 - (global.get $global$2) + (global.get $global$2) + (i32.add + (local.tee $1 + (global.get $global$6) + ) + (i32.const 32) ) - (i32.const 32) ) - ) - (i32.xor - (global.get $global$0) - (i32.const -1) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) ) ) - ) - (i32.shl - (local.tee $3 - (memory.size) + (i32.shl + (local.tee $3 + (memory.size) + ) + (i32.const 16) ) - (i32.const 16) ) - ) - (then - (drop - (memory.grow - (select - (local.get $3) - (local.tee $4 - (i32.shr_s - (i32.and - (i32.add - (i32.sub - (local.get $2) - (local.get $1) + (then + (drop + (memory.grow + (select + (local.get $3) + (local.tee $4 + (i32.shr_s + (i32.and + (i32.add + (i32.sub + (local.get $2) + (local.get $1) + ) + (i32.const 65535) ) - (i32.const 65535) + (i32.const -65536) ) - (i32.const -65536) + (i32.const 16) ) - (i32.const 16) ) - ) - (i32.gt_u - (local.get $3) - (local.get $4) + (i32.gt_u + (local.get $3) + (local.get $4) + ) ) ) ) ) ) - ) - (global.set $global$2 - (local.get $2) - ) - (local.set $3 - (i32.add - (local.tee $1 - (local.tee $2 - (i32.add - (local.get $1) - (i32.const 16) + (global.set $global$6 + (local.get $2) + ) + (local.set $3 + (i32.add + (local.tee $1 + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 16) + ) ) ) + (i32.const 4) ) - (i32.const 4) ) - ) - (loop $label - (if - (i32.ne - (local.get $1) - (local.get $3) - ) - (then - (i32.store8 + (loop $label + (if + (i32.ne (local.get $1) - (i32.load8_u - (i32.const 0) - ) + (local.get $3) ) - (local.set $1 - (i32.add + (then + (i32.store8 (local.get $1) - (i32.const 1) + (i32.load8_u + (i32.const 0) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) ) + (br $label) ) - (br $label) ) ) - ) - (i32.store - (i32.wrap_i64 - (local.tee $0 - (i64.or - (i64.extend_i32_u - (local.get $2) + (i32.store + (i32.wrap_i64 + (local.tee $0 + (i64.or + (i64.extend_i32_u + (local.get $2) + ) + (i64.const 8589934592) ) - (i64.const 8589934592) ) ) + (i32.const 0) + ) + (br $block1 + (local.get $0) ) - (i32.const 0) ) ) + (local.get $0) ) - (local.get $0) ) (func $5 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 + (i32.sub + (global.get $global$1) + (i32.const 1) + ) + ) + (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 (i32.const 65536) ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) ) ) diff --git a/test/fixtures/compiler/patternMatching.lys.wast b/test/fixtures/compiler/patternMatching.lys.wast index bc28d15..c6b3aec 100644 --- a/test/fixtures/compiler/patternMatching.lys.wast +++ b/test/fixtures/compiler/patternMatching.lys.wast @@ -238,11 +238,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 16) "\00\00\00\00\00") - (data 0 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 49) "\02\00\00\000\00\00") - (data 0 (i32.const 56) "\02\00\00\000\00\00") + (data $mem_16 (i32.const 16) "\00\00\00\00\00") + (data $mem_21 (i32.const 21) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_34 (i32.const 34) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_49 (i32.const 49) "\02\00\00\000\00\00") + (data $mem_56 (i32.const 56) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) diff --git a/test/fixtures/execution/fibo.lys.wast b/test/fixtures/execution/fibo.lys.wast index 6a6b683..d5362ab 100644 --- a/test/fixtures/execution/fibo.lys.wast +++ b/test/fixtures/execution/fibo.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 316) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 343) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 376) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 403) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 436) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 471) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 512) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 547) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 588) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 623) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 664) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 699) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 740) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 767) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 800) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 827) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 860) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_316 (i32.const 316) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_343 (i32.const 343) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_376 (i32.const 376) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_403 (i32.const 403) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_436 (i32.const 436) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_471 (i32.const 471) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_512 (i32.const 512) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_547 (i32.const 547) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_588 (i32.const 588) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_623 (i32.const 623) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_664 (i32.const 664) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_699 (i32.const 699) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_740 (i32.const 740) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_767 (i32.const 767) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_800 (i32.const 800) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_827 (i32.const 827) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_860 (i32.const 860) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ ) ) ) - (data 0 (i32.const 269) "\00\00\00\00\00") - (data 0 (i32.const 274) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 287) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 302) "\02\00\00\000\00\00") - (data 0 (i32.const 309) "\02\00\00\000\00\00") + (data $mem_269 (i32.const 269) "\00\00\00\00\00") + (data $mem_274 (i32.const 274) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_287 (i32.const 287) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_302 (i32.const 302) "\02\00\00\000\00\00") + (data $mem_309 (i32.const 309) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,11 +2087,11 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "\12\00\00\00f\00i\00b\00o\00n\00a\00c\00c\00i\00\00") - (data 0 (i32.const 39) "4\00\00\00f\00i\00b\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003\00\00") - (data 0 (i32.const 96) "R\00\00\00f\00i\00b\00P\00a\00t\00t\00e\00r\00n\00M\00a\00t\00c\00h\00i\00n\00g\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003\00\00") - (data 0 (i32.const 183) "\12\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l\00\00") - (data 0 (i32.const 206) ":\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l\00(\001\000\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \003\006\002\008\008\000\000\00\00") + (data $mem_16 (i32.const 16) "\12\00\00\00f\00i\00b\00o\00n\00a\00c\00c\00i\00\00") + (data $mem_39 (i32.const 39) "4\00\00\00f\00i\00b\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003\00\00") + (data $mem_96 (i32.const 96) "R\00\00\00f\00i\00b\00P\00a\00t\00t\00e\00r\00n\00M\00a\00t\00c\00h\00i\00n\00g\00(\004\006\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \001\008\003\006\003\001\001\009\000\003\00\00") + (data $mem_183 (i32.const 183) "\12\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l\00\00") + (data $mem_206 (i32.const 206) ":\00\00\00f\00a\00c\00t\00o\00r\00i\00a\00l\00(\001\000\00)\00 \00m\00u\00s\00t\00 \00b\00e\00 \003\006\002\008\008\000\000\00\00") (export "main" (func $test::fixtures::execution::fibo::main_1)) (func $test::fixtures::execution::fibo::fibo_1 (param $n i32) (param $x1 i32) (param $x2 i32) (result i32) (block $B1 (result i32) diff --git a/test/fixtures/execution/implicitCast.lys.optimized.wast b/test/fixtures/execution/implicitCast.lys.optimized.wast index af5dd2a..61c5182 100644 --- a/test/fixtures/execution/implicitCast.lys.optimized.wast +++ b/test/fixtures/execution/implicitCast.lys.optimized.wast @@ -3,7 +3,7 @@ (type $1 (func (result i32))) (type $2 (func (param i32))) (type $3 (func (param i32 i32))) - (type $4 (func (param i64))) + (type $4 (func (param i32 i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) @@ -72,11 +72,11 @@ ) ) ) - (func $2 (param $0 i64) + (func $2 (param $0 i32) (param $1 i64) (call $fimport$1 - (i32.const 1) + (local.get $0) (i32.wrap_i64 - (local.get $0) + (local.get $1) ) ) ) @@ -85,15 +85,19 @@ (i32.const 16) ) (call $2 + (i32.const 1) (i64.const 12884901955) ) (call $2 + (i32.const 1) (i64.const 12884901996) ) (call $2 + (i32.const 1) (i64.const 12884902015) ) (call $2 + (i32.const 1) (i64.const 12884902034) ) (call $fimport$2) diff --git a/test/fixtures/execution/implicitCast.lys.wast b/test/fixtures/execution/implicitCast.lys.wast index 8e01c48..575c1a8 100644 --- a/test/fixtures/execution/implicitCast.lys.wast +++ b/test/fixtures/execution/implicitCast.lys.wast @@ -280,23 +280,23 @@ ) ) ) - (data 0 (i32.const 214) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 241) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 274) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 301) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 334) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 369) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 410) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 445) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 486) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 521) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 562) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 597) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 638) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 665) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 698) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 725) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 758) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_214 (i32.const 214) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_241 (i32.const 241) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_274 (i32.const 274) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_301 (i32.const 301) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_334 (i32.const 334) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_369 (i32.const 369) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_410 (i32.const 410) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_445 (i32.const 445) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_486 (i32.const 486) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_521 (i32.const 521) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_562 (i32.const 562) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_597 (i32.const 597) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_638 (i32.const 638) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_665 (i32.const 665) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_698 (i32.const 698) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_725 (i32.const 725) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_758 (i32.const 758) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 167) "\00\00\00\00\00") - (data 0 (i32.const 172) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 185) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 200) "\02\00\00\000\00\00") - (data 0 (i32.const 207) "\02\00\00\000\00\00") + (data $mem_167 (i32.const 167) "\00\00\00\00\00") + (data $mem_172 (i32.const 172) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_185 (i32.const 185) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_200 (i32.const 200) "\02\00\00\000\00\00") + (data $mem_207 (i32.const 207) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,11 +2087,11 @@ ) ) ) - (data 0 (i32.const 16) ".\00\00\00I\00m\00p\00l\00i\00c\00i\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00a\00s\00t\00i\00n\00g\00\00") - (data 0 (i32.const 67) "$\00\00\00e\00q\00(\001\000\00_\00u\001\006\00,\00 \001\000\00_\00i\003\002\00)\00\00") - (data 0 (i32.const 108) "\0e\00\00\00m\00a\00t\00c\00h\00 \000\00\00") - (data 0 (i32.const 127) "\0e\00\00\00m\00a\00t\00c\00h\00 \001\00\00") - (data 0 (i32.const 146) "\10\00\00\000\00.\000\00 \00=\00=\00 \000\00\00") + (data $mem_16 (i32.const 16) ".\00\00\00I\00m\00p\00l\00i\00c\00i\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00a\00s\00t\00i\00n\00g\00\00") + (data $mem_67 (i32.const 67) "$\00\00\00e\00q\00(\001\000\00_\00u\001\006\00,\00 \001\000\00_\00i\003\002\00)\00\00") + (data $mem_108 (i32.const 108) "\0e\00\00\00m\00a\00t\00c\00h\00 \000\00\00") + (data $mem_127 (i32.const 127) "\0e\00\00\00m\00a\00t\00c\00h\00 \001\00\00") + (data $mem_146 (i32.const 146) "\10\00\00\000\00.\000\00 \00=\00=\00 \000\00\00") (export "main" (func $test::fixtures::execution::implicitCast::main_1)) (func $test::fixtures::execution::implicitCast::testMatchWithDifferentTypes_1 (param $input i32) (result i32) (local $var$1 i32) diff --git a/test/fixtures/execution/indirect-smoke.lys.optimized.wast b/test/fixtures/execution/indirect-smoke.lys.optimized.wast index cd8aaa1..212199c 100644 --- a/test/fixtures/execution/indirect-smoke.lys.optimized.wast +++ b/test/fixtures/execution/indirect-smoke.lys.optimized.wast @@ -1,11 +1,12 @@ (module - (type $0 (func)) - (type $1 (func (param i32 i32))) - (type $2 (func (result i32))) - (type $3 (func (param i32))) - (type $4 (func (param i64 i32))) - (type $5 (func (param i32 i32 i64))) - (type $6 (func (param i64))) + (type $0 (func (result i32))) + (type $1 (func)) + (type $2 (func (param i32 i32))) + (type $3 (func (param i32) (result i32))) + (type $4 (func (param i32))) + (type $5 (func (param i64 i32))) + (type $6 (func (param i32 i32 i64))) + (type $7 (func (param i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) @@ -40,11 +41,13 @@ (data $24 (i32.const 107) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00o\00n\00e\00 \00a\00r\00g\00u\00m\00e\00n\00t") (data $25 (i32.const 184) "\02\00\00\00A") (data $26 (i32.const 191) "\02\00\00\00B") + (table $0 4 funcref) + (elem $0 (i32.const 0) $5 $7 $6 $8) (export "memory" (memory $0)) (export "test_getMaxMemory" (func $1)) (export "test_getLastErrorMessage" (func $3)) - (export "main" (func $5)) - (start $6) + (export "main" (func $9)) + (start $10) (func $0 (param $0 i64) (param $1 i32) (call $fimport$3 (i32.wrap_i64 @@ -118,17 +121,35 @@ ) ) ) - (func $5 + (func $5 (result i32) + (i32.const 1) + ) + (func $6 (param $0 i32) (result i32) + (i32.add + (local.get $0) + (i32.const 1) + ) + ) + (func $7 (result i32) + (i32.const 2) + ) + (func $8 (param $0 i32) (result i32) + (i32.add + (local.get $0) + (i32.const 2) + ) + ) + (func $9 (call $4 (i64.const 12884901904) ) (call $2 - (i32.const 1) + (call $5) (i32.const 1) (i64.const 12884901981) ) (call $2 - (i32.const 2) + (call $7) (i32.const 2) (i64.const 12884901988) ) @@ -137,18 +158,22 @@ (i64.const 12884901995) ) (call $2 - (i32.const 2) + (call $6 + (i32.const 1) + ) (i32.const 2) (i64.const 12884902072) ) (call $2 - (i32.const 3) + (call $8 + (i32.const 1) + ) (i32.const 3) (i64.const 12884902079) ) (call $fimport$2) ) - (func $6 + (func $10 (global.set $global$0 (i32.const 65536) ) diff --git a/test/fixtures/execution/indirect-smoke.lys.wast b/test/fixtures/execution/indirect-smoke.lys.wast index ec7e7c7..ecdf824 100644 --- a/test/fixtures/execution/indirect-smoke.lys.wast +++ b/test/fixtures/execution/indirect-smoke.lys.wast @@ -21,7 +21,7 @@ (type $lys::->i32 (func (result i32))) (type $lys::i32->i32 (func (param i32) (result i32))) (table $lys::internal-functions 4 funcref) - (elem 0 (offset (i32.const 0)) $test::fixtures::execution::indirect-smoke::a_1 $test::fixtures::execution::indirect-smoke::b_1 $test::fixtures::execution::indirect-smoke::a_2 $test::fixtures::execution::indirect-smoke::b_2) + (elem $elem_table_0 (offset (i32.const 0)) $test::fixtures::execution::indirect-smoke::a_1 $test::fixtures::execution::indirect-smoke::b_1 $test::fixtures::execution::indirect-smoke::a_2 $test::fixtures::execution::indirect-smoke::b_2) (memory $mem 1) (export "memory" (memory $mem)) (func $support::env::printf_8 (param $str i64) (param $extra i32) @@ -283,23 +283,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 245) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 272) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 305) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 332) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 365) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 400) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 441) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 476) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 517) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 552) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 593) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 628) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 789) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_245 (i32.const 245) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_272 (i32.const 272) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_305 (i32.const 305) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_332 (i32.const 332) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_365 (i32.const 365) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_400 (i32.const 400) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_441 (i32.const 441) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_476 (i32.const 476) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_517 (i32.const 517) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_552 (i32.const 552) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_593 (i32.const 593) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_628 (i32.const 628) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_669 (i32.const 669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_696 (i32.const 696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_729 (i32.const 729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_756 (i32.const 756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_789 (i32.const 789) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -609,11 +609,11 @@ ) ) ) - (data 0 (i32.const 198) "\00\00\00\00\00") - (data 0 (i32.const 203) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 216) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 231) "\02\00\00\000\00\00") - (data 0 (i32.const 238) "\02\00\00\000\00\00") + (data $mem_198 (i32.const 198) "\00\00\00\00\00") + (data $mem_203 (i32.const 203) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_216 (i32.const 216) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_231 (i32.const 231) "\02\00\00\000\00\00") + (data $mem_238 (i32.const 238) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2090,12 +2090,12 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00n\00o\00 \00a\00r\00g\00u\00m\00e\00n\00t\00s\00\00") - (data 0 (i32.const 93) "\02\00\00\00A\00\00") - (data 0 (i32.const 100) "\02\00\00\00B\00\00") - (data 0 (i32.const 107) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00o\00n\00e\00 \00a\00r\00g\00u\00m\00e\00n\00t\00\00") - (data 0 (i32.const 184) "\02\00\00\00A\00\00") - (data 0 (i32.const 191) "\02\00\00\00B\00\00") + (data $mem_16 (i32.const 16) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00n\00o\00 \00a\00r\00g\00u\00m\00e\00n\00t\00s\00\00") + (data $mem_93 (i32.const 93) "\02\00\00\00A\00\00") + (data $mem_100 (i32.const 100) "\02\00\00\00B\00\00") + (data $mem_107 (i32.const 107) "H\00\00\00T\00e\00s\00t\00 \00i\00n\00d\00i\00r\00e\00c\00t\00 \00c\00a\00l\00l\00 \00w\00i\00t\00h\00 \00o\00n\00e\00 \00a\00r\00g\00u\00m\00e\00n\00t\00\00") + (data $mem_184 (i32.const 184) "\02\00\00\00A\00\00") + (data $mem_191 (i32.const 191) "\02\00\00\00B\00\00") (export "main" (func $test::fixtures::execution::indirect-smoke::main_1)) (func $test::fixtures::execution::indirect-smoke::a_1 (result i32) (i32.const 1) diff --git a/test/fixtures/execution/is.lys.optimized.wast b/test/fixtures/execution/is.lys.optimized.wast index c8ece01..52ce759 100644 --- a/test/fixtures/execution/is.lys.optimized.wast +++ b/test/fixtures/execution/is.lys.optimized.wast @@ -3,7 +3,7 @@ (type $1 (func (param i32))) (type $2 (func (result i32))) (type $3 (func (param i32 i32))) - (type $4 (func (param i32) (result i32))) + (type $4 (func (param i32 i32) (result i32))) (type $5 (func (result i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) @@ -11,10 +11,14 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) - (global $global$4 (mut i64) (i64.const 0)) - (global $global$5 (mut i64) (i64.const 0)) - (global $global$6 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) + (global $global$8 (mut i64) (i64.const 0)) + (global $global$9 (mut i64) (i64.const 0)) + (global $global$10 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 100) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 127) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -44,16 +48,22 @@ (export "main" (func $5)) (start $6) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $1 (param $0 i32) (result i32) - (local $1 i32) + (func $1 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -61,7 +71,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -70,14 +80,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $1 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -92,13 +102,13 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -108,13 +118,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -125,22 +135,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$2 - (local.get $2) + (global.set $global$6 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -153,18 +163,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -172,7 +182,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $2 (result i32) (local $0 i64) @@ -181,7 +191,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -219,6 +229,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 8) ) ) @@ -228,7 +239,7 @@ ) (i64.const 12884902532) ) - (global.set $global$3 + (global.set $global$7 (local.get $1) ) (unreachable) @@ -243,6 +254,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 4) ) ) @@ -290,7 +302,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -301,7 +313,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -314,7 +326,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -337,7 +349,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -348,7 +360,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -361,7 +373,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -384,7 +396,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -395,7 +407,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -408,7 +420,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -431,7 +443,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -509,24 +521,48 @@ ) (func $6 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 - (i64.const 8589934592) + (i32.const 1073741824) ) (global.set $global$4 - (i64.const 4294967296) + (i32.const 65536) ) (global.set $global$5 - (i64.const 4294967296) + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) ) (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 + (i64.const 8589934592) + ) + (global.set $global$8 + (i64.const 4294967296) + ) + (global.set $global$9 + (i64.const 4294967296) + ) + (global.set $global$10 (i64.const 4294967296) ) ) diff --git a/test/fixtures/execution/is.lys.wast b/test/fixtures/execution/is.lys.wast index 078d753..aa4e8a4 100644 --- a/test/fixtures/execution/is.lys.wast +++ b/test/fixtures/execution/is.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 100) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 127) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 160) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 187) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 220) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 255) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 296) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 331) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 372) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 407) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 448) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 483) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 524) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 551) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 584) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 611) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 644) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_100 (i32.const 100) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_127 (i32.const 127) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_160 (i32.const 160) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_187 (i32.const 187) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_220 (i32.const 220) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_255 (i32.const 255) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_296 (i32.const 296) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_331 (i32.const 331) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_372 (i32.const 372) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_407 (i32.const 407) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_448 (i32.const 448) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_483 (i32.const 483) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_524 (i32.const 524) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_551 (i32.const 551) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_584 (i32.const 584) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_611 (i32.const 611) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_644 (i32.const 644) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 53) "\00\00\00\00\00") - (data 0 (i32.const 58) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 71) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 86) "\02\00\00\000\00\00") - (data 0 (i32.const 93) "\02\00\00\000\00\00") + (data $mem_53 (i32.const 53) "\00\00\00\00\00") + (data $mem_58 (i32.const 58) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_71 (i32.const 71) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_86 (i32.const 86) "\02\00\00\000\00\00") + (data $mem_93 (i32.const 93) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,7 +2087,7 @@ ) ) ) - (data 0 (i32.const 16) " \00\00\00<\00e\00x\00p\00r\00>\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>\00\00") + (data $mem_16 (i32.const 16) " \00\00\00<\00e\00x\00p\00r\00>\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>\00\00") (global $test::fixtures::execution::is::value1 (mut i64) (i64.const 0)) (global $test::fixtures::execution::is::value2 (mut i64) (i64.const 0)) (global $test::fixtures::execution::is::value3 (mut i64) (i64.const 0)) diff --git a/test/fixtures/execution/isPatternMatching.lys.optimized.wast b/test/fixtures/execution/isPatternMatching.lys.optimized.wast index a238e0c..78f2269 100644 --- a/test/fixtures/execution/isPatternMatching.lys.optimized.wast +++ b/test/fixtures/execution/isPatternMatching.lys.optimized.wast @@ -3,7 +3,7 @@ (type $1 (func (param i32))) (type $2 (func (result i32))) (type $3 (func (param i32 i32))) - (type $4 (func (param i32) (result i32))) + (type $4 (func (param i32 i32) (result i32))) (type $5 (func (result i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) @@ -11,10 +11,14 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) - (global $global$4 (mut i64) (i64.const 0)) - (global $global$5 (mut i64) (i64.const 0)) - (global $global$6 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) + (global $global$8 (mut i64) (i64.const 0)) + (global $global$9 (mut i64) (i64.const 0)) + (global $global$10 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 114) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 141) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -44,16 +48,22 @@ (export "main" (func $5)) (start $6) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $1 (param $0 i32) (result i32) - (local $1 i32) + (func $1 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -61,7 +71,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -70,14 +80,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $1 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -92,13 +102,13 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -108,13 +118,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -125,22 +135,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$2 - (local.get $2) + (global.set $global$6 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -153,18 +163,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -172,7 +182,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $2 (result i32) (local $0 i64) @@ -181,7 +191,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -219,6 +229,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 8) ) ) @@ -228,7 +239,7 @@ ) (i64.const 12884902546) ) - (global.set $global$3 + (global.set $global$7 (local.get $1) ) (unreachable) @@ -243,6 +254,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 4) ) ) @@ -290,7 +302,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -301,7 +313,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -314,7 +326,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$4) + (global.get $global$8) (i64.const 32) ) ) @@ -337,7 +349,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -348,7 +360,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -361,7 +373,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$5) + (global.get $global$9) (i64.const 32) ) ) @@ -384,7 +396,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -395,7 +407,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -408,7 +420,7 @@ (local.tee $0 (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -431,7 +443,7 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (global.get $global$6) + (global.get $global$10) (i64.const 32) ) ) @@ -509,24 +521,48 @@ ) (func $6 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 - (i64.const 8589934592) + (i32.const 1073741824) ) (global.set $global$4 - (i64.const 4294967296) + (i32.const 65536) ) (global.set $global$5 - (i64.const 4294967296) + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) ) (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 + (i64.const 8589934592) + ) + (global.set $global$8 + (i64.const 4294967296) + ) + (global.set $global$9 + (i64.const 4294967296) + ) + (global.set $global$10 (i64.const 4294967296) ) ) diff --git a/test/fixtures/execution/isPatternMatching.lys.wast b/test/fixtures/execution/isPatternMatching.lys.wast index 45f0df4..de22ea3 100644 --- a/test/fixtures/execution/isPatternMatching.lys.wast +++ b/test/fixtures/execution/isPatternMatching.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 114) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 141) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 174) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 201) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 234) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 269) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 310) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 345) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 538) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 565) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 598) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 625) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 658) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_114 (i32.const 114) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_141 (i32.const 141) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_174 (i32.const 174) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_201 (i32.const 201) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_234 (i32.const 234) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_269 (i32.const 269) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_310 (i32.const 310) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_345 (i32.const 345) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_386 (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_421 (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_462 (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_497 (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_538 (i32.const 538) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_565 (i32.const 565) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_598 (i32.const 598) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_625 (i32.const 625) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_658 (i32.const 658) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ ) ) ) - (data 0 (i32.const 67) "\00\00\00\00\00") - (data 0 (i32.const 72) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 85) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 100) "\02\00\00\000\00\00") - (data 0 (i32.const 107) "\02\00\00\000\00\00") + (data $mem_67 (i32.const 67) "\00\00\00\00\00") + (data $mem_72 (i32.const 72) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_85 (i32.const 85) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_100 (i32.const 100) "\02\00\00\000\00\00") + (data $mem_107 (i32.const 107) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,7 +2087,7 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) ".\00\00\00i\00s\00 \00w\00i\00t\00h\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00\00") + (data $mem_16 (i32.const 16) ".\00\00\00i\00s\00 \00w\00i\00t\00h\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00\00") (global $test::fixtures::execution::isPatternMatching::value1 (mut i64) (i64.const 0)) (global $test::fixtures::execution::isPatternMatching::value2 (mut i64) (i64.const 0)) (global $test::fixtures::execution::isPatternMatching::value3 (mut i64) (i64.const 0)) diff --git a/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast b/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast index c1efc0b..323bd04 100644 --- a/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast +++ b/test/fixtures/execution/isPatternMatchingVariable.lys.optimized.wast @@ -10,7 +10,8 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 168) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 195) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -40,7 +41,7 @@ (export "main" (func $4)) (start $5) (func $0 (result i32) - (global.get $global$2) + (global.get $global$3) ) (func $1 (result i32) (local $0 i64) @@ -49,7 +50,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$4) ) (i64.const 32) ) @@ -101,7 +102,7 @@ (global.get $global$0) (i32.add (local.tee $0 - (global.get $global$2) + (global.get $global$3) ) (i32.const 32) ) @@ -148,7 +149,7 @@ ) ) ) - (global.set $global$2 + (global.set $global$3 (local.get $1) ) (local.set $2 @@ -200,7 +201,7 @@ ) (i64.const 12884902600) ) - (global.set $global$3 + (global.set $global$4 (local.get $4) ) (unreachable) @@ -343,6 +344,9 @@ (i32.const 65536) ) (global.set $global$3 + (i32.const 65536) + ) + (global.set $global$4 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/isPatternMatchingVariable.lys.wast b/test/fixtures/execution/isPatternMatchingVariable.lys.wast index 1d8a223..7ac4acb 100644 --- a/test/fixtures/execution/isPatternMatchingVariable.lys.wast +++ b/test/fixtures/execution/isPatternMatchingVariable.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 168) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 195) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 228) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 255) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 288) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 323) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 364) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 399) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 440) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 475) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 516) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 551) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 592) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 619) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 652) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 679) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 712) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_168 (i32.const 168) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_195 (i32.const 195) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_228 (i32.const 228) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_255 (i32.const 255) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_288 (i32.const 288) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_323 (i32.const 323) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_364 (i32.const 364) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_399 (i32.const 399) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_440 (i32.const 440) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_475 (i32.const 475) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_516 (i32.const 516) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_551 (i32.const 551) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_592 (i32.const 592) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_619 (i32.const 619) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_652 (i32.const 652) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_679 (i32.const 679) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_712 (i32.const 712) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 121) "\00\00\00\00\00") - (data 0 (i32.const 126) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 139) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 154) "\02\00\00\000\00\00") - (data 0 (i32.const 161) "\02\00\00\000\00\00") + (data $mem_121 (i32.const 121) "\00\00\00\00\00") + (data $mem_126 (i32.const 126) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_139 (i32.const 139) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_154 (i32.const 154) "\02\00\00\000\00\00") + (data $mem_161 (i32.const 161) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,7 +2087,7 @@ ) ) ) - (data 0 (i32.const 16) "d\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00'\00c\00a\00s\00e\00 \00X\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>\00'\00 \00s\00e\00t\00t\00i\00n\00g\00 \00X\00\00") + (data $mem_16 (i32.const 16) "d\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00'\00c\00a\00s\00e\00 \00X\00 \00i\00s\00 \00<\00t\00y\00p\00e\00>\00'\00 \00s\00e\00t\00t\00i\00n\00g\00 \00X\00\00") (global $test::fixtures::execution::isPatternMatchingVariable::value1 (mut i64) (i64.const 0)) (global $test::fixtures::execution::isPatternMatchingVariable::value2 (mut i64) (i64.const 0)) (global $test::fixtures::execution::isPatternMatchingVariable::value3 (mut i64) (i64.const 0)) diff --git a/test/fixtures/execution/numberOps.lys.optimized.wast b/test/fixtures/execution/numberOps.lys.optimized.wast index c221190..85cf443 100644 --- a/test/fixtures/execution/numberOps.lys.optimized.wast +++ b/test/fixtures/execution/numberOps.lys.optimized.wast @@ -3,7 +3,7 @@ (type $1 (func (result i32))) (type $2 (func (param i32))) (type $3 (func (param i32 i32))) - (type $4 (func (param i64))) + (type $4 (func (param i32 i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) @@ -86,11 +86,11 @@ ) ) ) - (func $2 (param $0 i64) + (func $2 (param $0 i32) (param $1 i64) (call $fimport$1 - (i32.const 1) + (local.get $0) (i32.wrap_i64 - (local.get $0) + (local.get $1) ) ) ) @@ -99,57 +99,75 @@ (i32.const 16) ) (call $2 + (i32.const 1) (i64.const 12884901949) ) (call $2 + (i32.const 1) (i64.const 12884901956) ) (call $2 + (i32.const 1) (i64.const 12884901973) ) (call $2 + (i32.const 1) (i64.const 12884901992) ) (call $2 + (i32.const 1) (i64.const 12884902013) ) (call $2 + (i32.const 1) (i64.const 12884902020) ) (call $2 + (i32.const 1) (i64.const 12884902065) ) (call $2 + (i32.const 1) (i64.const 12884902110) ) (call $2 + (i32.const 1) (i64.const 12884902155) ) (call $2 + (i32.const 1) (i64.const 12884902162) ) (call $2 + (i32.const 1) (i64.const 12884902169) ) (call $2 + (i32.const 1) (i64.const 12884902176) ) (call $2 + (i32.const 1) (i64.const 12884902183) ) (call $2 + (i32.const 1) (i64.const 12884902190) ) (call $2 + (i32.const 1) (i64.const 12884902197) ) (call $2 + (i32.const 1) (i64.const 12884902204) ) (call $2 + (i32.const 1) (i64.const 12884902213) ) (call $2 + (i32.const 1) (i64.const 12884902232) ) (call $fimport$2) diff --git a/test/fixtures/execution/numberOps.lys.wast b/test/fixtures/execution/numberOps.lys.wast index 8598a32..1798ce3 100644 --- a/test/fixtures/execution/numberOps.lys.wast +++ b/test/fixtures/execution/numberOps.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 410) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 437) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 470) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 497) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 530) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 565) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 606) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 641) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 682) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 717) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 758) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 793) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 834) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 861) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 894) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 921) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 954) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_410 (i32.const 410) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_437 (i32.const 437) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_470 (i32.const 470) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_497 (i32.const 497) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_530 (i32.const 530) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_565 (i32.const 565) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_606 (i32.const 606) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_641 (i32.const 641) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_682 (i32.const 682) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_717 (i32.const 717) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_758 (i32.const 758) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_793 (i32.const 793) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_834 (i32.const 834) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_861 (i32.const 861) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_894 (i32.const 894) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_921 (i32.const 921) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_954 (i32.const 954) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ ) ) ) - (data 0 (i32.const 363) "\00\00\00\00\00") - (data 0 (i32.const 368) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 381) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 396) "\02\00\00\000\00\00") - (data 0 (i32.const 403) "\02\00\00\000\00\00") + (data $mem_363 (i32.const 363) "\00\00\00\00\00") + (data $mem_368 (i32.const 368) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_381 (i32.const 381) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_396 (i32.const 396) "\02\00\00\000\00\00") + (data $mem_403 (i32.const 403) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,25 +2087,25 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "(\00\00\00N\00u\00m\00b\00e\00r\00 \00s\00a\00n\00i\00t\00y\00 \00c\00h\00e\00c\00k\00s\00\00") - (data 0 (i32.const 61) "\02\00\00\001\00\00") - (data 0 (i32.const 68) "\0c\00\00\000\00 \00/\00 \001\000\00\00") - (data 0 (i32.const 85) "\0e\00\00\001\000\00 \00/\00 \001\000\00\00") - (data 0 (i32.const 104) "\10\00\00\001\000\00 \00/\00 \001\000\000\00\00") - (data 0 (i32.const 125) "\02\00\00\002\00\00") - (data 0 (i32.const 132) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002\00\00") - (data 0 (i32.const 177) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002\00\00") - (data 0 (i32.const 222) "(\00\00\000\00x\008\000\000\000\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002\00\00") - (data 0 (i32.const 267) "\02\00\00\003\00\00") - (data 0 (i32.const 274) "\02\00\00\004\00\00") - (data 0 (i32.const 281) "\02\00\00\005\00\00") - (data 0 (i32.const 288) "\02\00\00\006\00\00") - (data 0 (i32.const 295) "\02\00\00\007\00\00") - (data 0 (i32.const 302) "\02\00\00\008\00\00") - (data 0 (i32.const 309) "\02\00\00\009\00\00") - (data 0 (i32.const 316) "\04\00\00\001\000\00\00") - (data 0 (i32.const 325) "\0e\00\00\00s\00q\00r\00t\00(\001\00)\00\00") - (data 0 (i32.const 344) "\0e\00\00\00s\00q\00r\00t\00(\004\00)\00\00") + (data $mem_16 (i32.const 16) "(\00\00\00N\00u\00m\00b\00e\00r\00 \00s\00a\00n\00i\00t\00y\00 \00c\00h\00e\00c\00k\00s\00\00") + (data $mem_61 (i32.const 61) "\02\00\00\001\00\00") + (data $mem_68 (i32.const 68) "\0c\00\00\000\00 \00/\00 \001\000\00\00") + (data $mem_85 (i32.const 85) "\0e\00\00\001\000\00 \00/\00 \001\000\00\00") + (data $mem_104 (i32.const 104) "\10\00\00\001\000\00 \00/\00 \001\000\000\00\00") + (data $mem_125 (i32.const 125) "\02\00\00\002\00\00") + (data $mem_132 (i32.const 132) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002\00\00") + (data $mem_177 (i32.const 177) "(\00\00\000\00x\00F\00F\00F\00F\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002\00\00") + (data $mem_222 (i32.const 222) "(\00\00\000\00x\008\000\000\000\00 \00a\00s\00 \00i\001\006\00 \00a\00s\00 \00i\003\002\00\00") + (data $mem_267 (i32.const 267) "\02\00\00\003\00\00") + (data $mem_274 (i32.const 274) "\02\00\00\004\00\00") + (data $mem_281 (i32.const 281) "\02\00\00\005\00\00") + (data $mem_288 (i32.const 288) "\02\00\00\006\00\00") + (data $mem_295 (i32.const 295) "\02\00\00\007\00\00") + (data $mem_302 (i32.const 302) "\02\00\00\008\00\00") + (data $mem_309 (i32.const 309) "\02\00\00\009\00\00") + (data $mem_316 (i32.const 316) "\04\00\00\001\000\00\00") + (data $mem_325 (i32.const 325) "\0e\00\00\00s\00q\00r\00t\00(\001\00)\00\00") + (data $mem_344 (i32.const 344) "\0e\00\00\00s\00q\00r\00t\00(\004\00)\00\00") (export "main" (func $test::fixtures::execution::numberOps::main_1)) (func $test::fixtures::execution::numberOps::maxI64_1 (result i64) (i64.const 0xFFFFFFFFFFFF) diff --git a/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast b/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast index 509bad2..782b81a 100644 --- a/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast +++ b/test/fixtures/execution/patternMatchingDeconstruct.lys.optimized.wast @@ -12,7 +12,11 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 358) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 385) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -48,7 +52,7 @@ (export "main" (func $5)) (start $6) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) (func $1 (param $0 i32) (param $1 i32) (param $2 i64) (call $fimport$1 @@ -72,7 +76,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -101,7 +105,7 @@ (local $7 i64) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (i32.const 12) ) (then @@ -113,16 +117,16 @@ (local.tee $4 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (local.tee $3 - (global.get $global$2) + (global.get $global$6) ) (i32.const 32) ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) @@ -163,7 +167,7 @@ ) ) ) - (global.set $global$2 + (global.set $global$6 (local.get $4) ) (local.set $5 @@ -359,15 +363,39 @@ ) (func $6 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 + (i32.const 65536) + ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/patternMatchingDeconstruct.lys.wast b/test/fixtures/execution/patternMatchingDeconstruct.lys.wast index 835fe0d..50ee79a 100644 --- a/test/fixtures/execution/patternMatchingDeconstruct.lys.wast +++ b/test/fixtures/execution/patternMatchingDeconstruct.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 358) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 385) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 418) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 445) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 478) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 513) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 554) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 589) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 630) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 665) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 706) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 741) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 782) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 809) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 842) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 869) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 902) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_358 (i32.const 358) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_385 (i32.const 385) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_418 (i32.const 418) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_445 (i32.const 445) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_478 (i32.const 478) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_513 (i32.const 513) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_554 (i32.const 554) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_589 (i32.const 589) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_630 (i32.const 630) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_665 (i32.const 665) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_706 (i32.const 706) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_741 (i32.const 741) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_782 (i32.const 782) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_809 (i32.const 809) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_842 (i32.const 842) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_869 (i32.const 869) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_902 (i32.const 902) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 311) "\00\00\00\00\00") - (data 0 (i32.const 316) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 329) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 344) "\02\00\00\000\00\00") - (data 0 (i32.const 351) "\02\00\00\000\00\00") + (data $mem_311 (i32.const 311) "\00\00\00\00\00") + (data $mem_316 (i32.const 316) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_329 (i32.const 329) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_344 (i32.const 344) "\02\00\00\000\00\00") + (data $mem_351 (i32.const 351) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,13 +2087,13 @@ ) ) ) - (data 0 (i32.const 16) "B\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00d\00e\00c\00o\00n\00s\00t\00r\00u\00c\00t\00\00") - (data 0 (i32.const 87) "\14\00\00\00i\00s\00R\00e\00d\00(\00R\00e\00d\00)\00\00") - (data 0 (i32.const 112) "\18\00\00\00i\00s\00R\00e\00d\00(\00G\00r\00e\00e\00n\00)\00\00") - (data 0 (i32.const 141) "\16\00\00\00i\00s\00R\00e\00d\00(\00B\00l\00u\00e\00)\00\00") - (data 0 (i32.const 168) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\000\00,\000\00)\00)\00\00") - (data 0 (i32.const 217) "(\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\000\00,\001\00,\003\00)\00)\00\00") - (data 0 (i32.const 262) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\001\00,\003\00)\00)\00\00") + (data $mem_16 (i32.const 16) "B\00\00\00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00 \00w\00i\00t\00h\00 \00d\00e\00c\00o\00n\00s\00t\00r\00u\00c\00t\00\00") + (data $mem_87 (i32.const 87) "\14\00\00\00i\00s\00R\00e\00d\00(\00R\00e\00d\00)\00\00") + (data $mem_112 (i32.const 112) "\18\00\00\00i\00s\00R\00e\00d\00(\00G\00r\00e\00e\00n\00)\00\00") + (data $mem_141 (i32.const 141) "\16\00\00\00i\00s\00R\00e\00d\00(\00B\00l\00u\00e\00)\00\00") + (data $mem_168 (i32.const 168) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\000\00,\000\00)\00)\00\00") + (data $mem_217 (i32.const 217) "(\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\000\00,\001\00,\003\00)\00)\00\00") + (data $mem_262 (i32.const 262) ",\00\00\00i\00s\00R\00e\00d\00(\00C\00u\00s\00t\00o\00m\00(\002\005\005\00,\001\00,\003\00)\00)\00\00") (export "main" (func $test::fixtures::execution::patternMatchingDeconstruct::main_1)) (func $test::fixtures::execution::patternMatchingDeconstruct::Color.is_1 (param $self i64) (result i32) (block $B1 (result i32) diff --git a/test/fixtures/execution/recursiveStruct.lys.optimized.wast b/test/fixtures/execution/recursiveStruct.lys.optimized.wast index 0277d72..70d699b 100644 --- a/test/fixtures/execution/recursiveStruct.lys.optimized.wast +++ b/test/fixtures/execution/recursiveStruct.lys.optimized.wast @@ -4,14 +4,19 @@ (type $2 (func (param i64) (result i64))) (type $3 (func (param i32))) (type $4 (func (param i32 i32))) - (type $5 (func (param i32 i64))) + (type $5 (func (param i32) (result i32))) + (type $6 (func (param i32 i64))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 246) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 273) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -47,17 +52,32 @@ (export "main" (func $6)) (start $7) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $1 (result i32) - (local $0 i32) + (func $1 (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) + (local $4 i32) + (if + (i32.eqz + (local.tee $0 + (local.tee $4 + (i32.shl + (local.get $0) + (i32.const 3) + ) + ) + ) + ) + (then + (unreachable) + ) + ) (if (i32.lt_u - (global.get $global$1) - (i32.const 8) + (global.get $global$3) + (local.get $0) ) (then (unreachable) @@ -65,19 +85,29 @@ ) (if (i32.gt_u - (local.tee $1 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add - (local.tee $0 - (global.get $global$2) + (i32.add + (local.tee $1 + (global.get $global$6) + ) + (i32.const 16) + ) + (select + (i32.const 16) + (local.get $0) + (i32.le_u + (local.get $0) + (i32.const 16) + ) ) - (i32.const 32) ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) @@ -99,8 +129,8 @@ (i32.and (i32.add (i32.sub - (local.get $1) (local.get $0) + (local.get $1) ) (i32.const 65535) ) @@ -118,20 +148,20 @@ ) ) ) - (global.set $global$2 - (local.get $1) + (global.set $global$6 + (local.get $0) ) (local.set $2 (i32.add + (local.get $4) (local.tee $0 (local.tee $1 (i32.add - (local.get $0) + (local.get $1) (i32.const 16) ) ) ) - (i32.const 8) ) ) (loop $label @@ -166,7 +196,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -202,7 +232,9 @@ (local.tee $1 (i64.or (i64.extend_i32_u - (call $1) + (call $1 + (i32.const 1) + ) ) (i64.const 8589934592) ) @@ -219,7 +251,9 @@ (local.tee $1 (i64.or (i64.extend_i32_u - (call $1) + (call $1 + (i32.const 1) + ) ) (i64.const 17179869184) ) @@ -330,15 +364,39 @@ ) (func $7 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 + (i32.const 65536) + ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/recursiveStruct.lys.wast b/test/fixtures/execution/recursiveStruct.lys.wast index 574572c..0b09086 100644 --- a/test/fixtures/execution/recursiveStruct.lys.wast +++ b/test/fixtures/execution/recursiveStruct.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 246) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 273) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 306) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 333) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 366) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 401) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 442) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 477) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 518) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 553) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 594) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 629) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 670) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 697) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 730) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 757) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 790) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_246 (i32.const 246) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_273 (i32.const 273) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_306 (i32.const 306) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_333 (i32.const 333) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_366 (i32.const 366) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_401 (i32.const 401) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_442 (i32.const 442) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_477 (i32.const 477) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_518 (i32.const 518) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_553 (i32.const 553) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_594 (i32.const 594) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_629 (i32.const 629) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_670 (i32.const 670) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_697 (i32.const 697) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_730 (i32.const 730) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_757 (i32.const 757) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_790 (i32.const 790) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ ) ) ) - (data 0 (i32.const 199) "\00\00\00\00\00") - (data 0 (i32.const 204) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 217) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 232) "\02\00\00\000\00\00") - (data 0 (i32.const 239) "\02\00\00\000\00\00") + (data $mem_199 (i32.const 199) "\00\00\00\00\00") + (data $mem_204 (i32.const 204) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_217 (i32.const 217) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_232 (i32.const 232) "\02\00\00\000\00\00") + (data $mem_239 (i32.const 239) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,13 +2087,13 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "&\00\00\00F\00o\00r\00e\00s\00t\00 \00&\00 \00T\00r\00e\00e\00 \00t\00e\00s\00t\00s\00\00") - (data 0 (i32.const 59) "\10\00\00\00a\00 \00i\00s\00 \00N\00i\00l\00\00") - (data 0 (i32.const 80) "\14\00\00\00a\00 \00i\00s\00 \00F\00o\00r\00e\00s\00\00") - (data 0 (i32.const 105) "\14\00\00\00b\00 \00i\00s\00 \00F\00o\00r\00e\00s\00\00") - (data 0 (i32.const 130) "\12\00\00\00c\00 \00i\00s\00 \00C\00o\00n\00s\00\00") - (data 0 (i32.const 153) "\12\00\00\00e\00 \00i\00s\00 \00N\00o\00d\00e\00\00") - (data 0 (i32.const 176) "\12\00\00\00e\00 \00i\00s\00 \00T\00r\00e\00e\00\00") + (data $mem_16 (i32.const 16) "&\00\00\00F\00o\00r\00e\00s\00t\00 \00&\00 \00T\00r\00e\00e\00 \00t\00e\00s\00t\00s\00\00") + (data $mem_59 (i32.const 59) "\10\00\00\00a\00 \00i\00s\00 \00N\00i\00l\00\00") + (data $mem_80 (i32.const 80) "\14\00\00\00a\00 \00i\00s\00 \00F\00o\00r\00e\00s\00\00") + (data $mem_105 (i32.const 105) "\14\00\00\00b\00 \00i\00s\00 \00F\00o\00r\00e\00s\00\00") + (data $mem_130 (i32.const 130) "\12\00\00\00c\00 \00i\00s\00 \00C\00o\00n\00s\00\00") + (data $mem_153 (i32.const 153) "\12\00\00\00e\00 \00i\00s\00 \00N\00o\00d\00e\00\00") + (data $mem_176 (i32.const 176) "\12\00\00\00e\00 \00i\00s\00 \00T\00r\00e\00e\00\00") (export "main" (func $test::fixtures::execution::recursiveStruct::main_1)) (func $test::fixtures::execution::recursiveStruct::Tree.is_1 (param $self i64) (result i32) (block $B1 (result i32) diff --git a/test/fixtures/execution/setStructValues.lys.optimized.wast b/test/fixtures/execution/setStructValues.lys.optimized.wast index 425e889..5b148c7 100644 --- a/test/fixtures/execution/setStructValues.lys.optimized.wast +++ b/test/fixtures/execution/setStructValues.lys.optimized.wast @@ -2,10 +2,10 @@ (type $0 (func (param i32 i32))) (type $1 (func)) (type $2 (func (result i32))) - (type $3 (func (param i32 i32 i64))) - (type $4 (func (param i32))) - (type $5 (func (param i32) (result i32))) - (type $6 (func (param i64 i32))) + (type $3 (func (param i64 i32))) + (type $4 (func (param i32 i32 i64))) + (type $5 (func (param i32))) + (type $6 (func (param i32 i32) (result i32))) (type $7 (func (param i64 i64 i64))) (type $8 (func (param i64))) (type $9 (func (param i32 i64))) @@ -18,9 +18,13 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) - (global $global$4 (mut i64) (i64.const 0)) - (global $global$5 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) + (global $global$8 (mut i64) (i64.const 0)) + (global $global$9 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 1669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 1696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -85,20 +89,26 @@ (data $60 (i32.const 1543) "J\00\00\00a\00.\00f\00 \00i\00s\00 \00n\00o\00t\00 \00C\00u\00s\00t\00o\00m\00 \00i\00n\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test_getLastErrorMessage" (func $6)) - (export "main" (func $10)) - (start $11) + (export "test_getLastErrorMessage" (func $7)) + (export "main" (func $11)) + (start $12) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $1 (param $0 i32) (result i32) - (local $1 i32) + (func $1 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -106,7 +116,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -115,14 +125,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $1 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -137,13 +147,13 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -153,13 +163,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -170,22 +180,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$2 - (local.get $2) + (global.set $global$6 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -198,18 +208,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -217,7 +227,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $2 (param $0 i64) (param $1 i32) (call $fimport$4 @@ -227,8 +237,16 @@ (local.get $1) ) ) - (func $3 (param $0 i64) (param $1 i64) (param $2 i64) - (call $8 + (func $3 (param $0 i64) (param $1 i32) + (call $fimport$4 + (i32.wrap_i64 + (local.get $0) + ) + (local.get $1) + ) + ) + (func $4 (param $0 i64) (param $1 i64) (param $2 i64) + (call $9 (i64.eq (local.get $0) (local.get $1) @@ -241,7 +259,7 @@ (local.get $1) ) (then - (call $2 + (call $3 (i64.const 12884903829) (i32.wrap_i64 (i64.shr_s @@ -250,7 +268,7 @@ ) ) ) - (call $2 + (call $3 (i64.const 12884903864) (i32.wrap_i64 (i64.shr_s @@ -259,13 +277,13 @@ ) ) ) - (call $2 + (call $3 (i64.const 12884903905) (i32.wrap_i64 (local.get $0) ) ) - (call $2 + (call $3 (i64.const 12884903940) (i32.wrap_i64 (local.get $1) @@ -274,8 +292,8 @@ ) ) ) - (func $4 (param $0 i32) (param $1 i32) (param $2 i64) - (call $8 + (func $5 (param $0 i32) (param $1 i32) (param $2 i64) + (call $9 (i32.eq (local.get $0) (local.get $1) @@ -288,19 +306,19 @@ (local.get $1) ) (then - (call $2 + (call $3 (i64.const 12884903981) (local.get $0) ) - (call $2 + (call $3 (i64.const 12884904008) (local.get $1) ) ) ) ) - (func $5 (param $0 i32) (param $1 i32) (param $2 i64) - (call $8 + (func $6 (param $0 i32) (param $1 i32) (param $2 i64) + (call $9 (i32.eq (local.get $0) (local.get $1) @@ -324,14 +342,14 @@ ) ) ) - (func $6 (result i32) + (func $7 (result i32) (local $0 i64) (if (result i32) (i32.eq (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -352,14 +370,14 @@ ) ) ) - (func $7 (param $0 i64) + (func $8 (param $0 i64) (call $fimport$1 (i32.wrap_i64 (local.get $0) ) ) ) - (func $8 (param $0 i32) (param $1 i64) + (func $9 (param $0 i32) (param $1 i64) (call $fimport$2 (local.get $0) (i32.wrap_i64 @@ -367,7 +385,7 @@ ) ) ) - (func $9 (result i64) + (func $10 (result i64) (local $0 i64) (i32.store (i32.wrap_i64 @@ -375,6 +393,7 @@ (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 8) ) ) @@ -395,23 +414,23 @@ ) (local.get $0) ) - (func $10 - (local $0 i32) - (local $1 i32) - (local $2 i32) + (func $11 + (local $0 i64) + (local $1 i64) + (local $2 i64) (local $3 i32) - (local $4 i64) - (local $5 i64) - (local $6 i64) - (call $7 + (local $4 i32) + (local $5 i32) + (call $8 (i64.const 12884902790) ) (i64.store (i32.wrap_i64 - (local.tee $4 + (local.tee $0 (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 16) ) ) @@ -422,30 +441,28 @@ (i64.const 8589934592) ) (i64.store - (local.tee $3 - (i32.add - (local.tee $0 - (i32.wrap_i64 - (local.get $4) - ) - ) - (i32.const 8) + (i32.add + (i32.wrap_i64 + (local.get $0) ) + (i32.const 8) ) (i64.const 4294967296) ) (call $fimport$0 - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) (i32.const 16) ) - (call $7 + (call $8 (i64.const 12884902835) ) - (call $8 + (call $9 (i32.eq (i32.wrap_i64 (i64.shr_u - (local.get $4) + (local.get $0) (i64.const 32) ) ) @@ -453,14 +470,18 @@ ) (i64.const 12884902892) ) - (call $8 + (call $9 (i32.or (i32.eq - (local.tee $1 + (local.tee $4 (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $0) + (local.tee $3 + (i32.wrap_i64 + (local.get $0) + ) + ) ) (i64.const 32) ) @@ -470,27 +491,27 @@ ) (i32.or (i32.eq - (local.get $1) + (local.get $4) (i32.const 1) ) (i32.eq - (local.get $1) + (local.get $4) (i32.const 2) ) ) ) (i64.const 12884902919) ) - (call $8 + (call $9 (i32.or (i32.eq - (local.tee $2 + (local.tee $4 (i32.wrap_i64 (i64.shr_u (i64.load - (local.tee $1 + (local.tee $5 (i32.add - (local.get $0) + (local.get $3) (i32.const 8) ) ) @@ -503,23 +524,25 @@ ) (i32.or (i32.eq - (local.get $2) + (local.get $4) (i32.const 1) ) (i32.eq - (local.get $2) + (local.get $4) (i32.const 2) ) ) ) (i64.const 12884902948) ) - (call $8 + (call $9 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) (i64.const 32) ) @@ -528,12 +551,17 @@ ) (i64.const 12884902977) ) - (call $8 + (call $9 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $3) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 8) + ) ) (i64.const 32) ) @@ -543,15 +571,16 @@ (i64.const 12884903002) ) (call $fimport$3) - (call $7 + (call $8 (i64.const 12884903027) ) (i32.store (i32.wrap_i64 - (local.tee $5 + (local.tee $1 (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 4) ) ) @@ -561,11 +590,11 @@ ) (i32.const -1430532899) ) - (call $8 + (call $9 (i32.eq (i32.load (i32.wrap_i64 - (local.get $5) + (local.get $1) ) ) (i32.const -1430532899) @@ -573,52 +602,63 @@ (i64.const 12884903046) ) (i64.store - (local.get $0) - (local.get $5) + (local.get $3) + (local.get $1) ) - (call $8 + (call $9 (i32.const 1) (i64.const 12884903089) ) - (call $8 + (call $9 (i64.eq - (local.get $5) - (local.tee $6 + (local.get $1) + (local.tee $2 (i64.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) ) ) (i64.const 12884903106) ) - (call $8 + (call $9 (i64.eq - (local.get $5) + (local.get $1) (i64.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) ) (i64.const 12884903127) ) - (call $8 + (call $9 (i64.eq - (local.get $6) + (local.get $2) (i64.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) ) (i64.const 12884903148) ) (i64.store - (local.get $1) + (local.get $5) (i64.const 8589934592) ) - (call $8 + (call $9 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 8) + ) ) (i64.const 32) ) @@ -628,15 +668,17 @@ (i64.const 12884903173) ) (call $fimport$3) - (call $7 + (call $8 (i64.const 12884903198) ) - (call $8 + (call $9 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) (i64.const 32) ) @@ -645,12 +687,17 @@ ) (i64.const 12884903235) ) - (call $8 + (call $9 (i32.eq (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 8) + ) ) (i64.const 32) ) @@ -659,14 +706,16 @@ ) (i64.const 12884903266) ) - (call $8 + (call $9 (i32.or (i32.eq - (local.tee $0 + (local.tee $3 (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) (i64.const 32) ) @@ -676,25 +725,30 @@ ) (i32.or (i32.eq - (local.get $0) + (local.get $3) (i32.const 1) ) (i32.eq - (local.get $0) + (local.get $3) (i32.const 2) ) ) ) (i64.const 12884903291) ) - (call $8 + (call $9 (i32.or (i32.eq - (local.tee $0 + (local.tee $3 (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 8) + ) ) (i64.const 32) ) @@ -704,11 +758,11 @@ ) (i32.or (i32.eq - (local.get $0) + (local.get $3) (i32.const 1) ) (i32.eq - (local.get $0) + (local.get $3) (i32.const 2) ) ) @@ -720,10 +774,10 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (local.tee $4 + (local.tee $0 (i64.load (i32.wrap_i64 - (local.get $4) + (local.get $0) ) ) ) @@ -733,19 +787,19 @@ (i32.const 3) ) (then - (call $8 + (call $9 (i32.const 0) (i64.const 12884903431) ) (br $block) ) ) - (call $8 + (call $9 (i32.eq - (local.tee $0 + (local.tee $3 (i32.load (i32.wrap_i64 - (local.get $4) + (local.get $0) ) ) ) @@ -753,70 +807,70 @@ ) (i64.const 12884903349) ) - (call $8 + (call $9 (i32.eq - (local.get $0) + (local.get $3) (i32.const -1430532899) ) (i64.const 12884903392) ) ) (call $fimport$3) - (call $7 + (call $8 (i64.const 12884902022) ) - (call $5 + (call $6 (i32.const -1) (i32.const -1) (i64.const 12884902049) ) - (call $4 + (call $5 (i32.const -1) (i32.const -1) (i64.const 12884902086) ) - (call $7 + (call $8 (i64.const 12884901904) ) - (call $5 + (call $6 (i32.load (i32.wrap_i64 - (global.get $global$4) + (global.get $global$8) ) ) (i32.const 0) (i64.const 12884901925) ) - (call $5 + (call $6 (i32.load (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i32.const 0) (i64.const 12884901962) ) (call $fimport$3) - (call $7 + (call $8 (i64.const 12884901999) ) (i32.store (i32.wrap_i64 - (global.get $global$4) + (global.get $global$8) ) (i32.const 3) ) (i32.store - (local.tee $0 + (local.tee $3 (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i32.const -1412567295) ) (i32.store (i32.add - (local.get $0) + (local.get $3) (i32.const 5) ) (i32.const 5) @@ -826,7 +880,7 @@ (i64.const 12884902151) (i32.load (i32.wrap_i64 - (global.get $global$4) + (global.get $global$8) ) ) ) @@ -834,66 +888,66 @@ (i64.const 12884902184) (i32.load (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) ) - (call $3 + (call $4 (i64.const 2882400001) (i64.const 2882400001) (i64.const 12884902217) ) - (call $5 + (call $6 (i32.load (i32.wrap_i64 - (global.get $global$4) + (global.get $global$8) ) ) (i32.const 3) (i64.const 12884902298) ) - (call $4 + (call $5 (i32.load (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i32.const -1412567295) (i64.const 12884902335) ) - (call $5 + (call $6 (i32.load (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i32.const -1412567295) (i64.const 12884902404) ) - (call $3 + (call $4 (i64.load32_s (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i64.const -1412567295) (i64.const 12884902473) ) - (call $3 + (call $4 (i64.load32_s (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i64.const -1412567295) (i64.const 12884902500) ) - (call $8 + (call $9 (i64.eq - (local.tee $4 + (local.tee $0 (i64.load32_s (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) ) @@ -903,49 +957,49 @@ ) (if (i64.ne - (local.get $4) + (local.get $0) (i64.const -1412567295) ) (then - (call $2 + (call $3 (i64.const 12884903677) (i32.wrap_i64 (i64.shr_s - (local.get $4) + (local.get $0) (i64.const 32) ) ) ) - (call $2 + (call $3 (i64.const 12884903712) (i32.const -1) ) - (call $2 + (call $3 (i64.const 12884903753) (i32.wrap_i64 - (local.get $4) + (local.get $0) ) ) - (call $2 + (call $3 (i64.const 12884903788) (i32.const -1412567295) ) ) ) - (call $5 + (call $6 (i32.load8_u (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) ) (i32.const 1) (i64.const 12884902666) ) - (call $5 + (call $6 (i32.load8_u (i32.add (i32.wrap_i64 - (global.get $global$5) + (global.get $global$9) ) (i32.const 5) ) @@ -956,24 +1010,48 @@ (call $fimport$3) (call $fimport$3) ) - (func $11 + (func $12 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 - (i64.const 8589934592) + (i32.const 1073741824) ) (global.set $global$4 - (call $9) + (i32.const 65536) ) (global.set $global$5 - (call $9) + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 + (i64.const 8589934592) + ) + (global.set $global$8 + (call $10) + ) + (global.set $global$9 + (call $10) ) ) ) diff --git a/test/fixtures/execution/setStructValues.lys.wast b/test/fixtures/execution/setStructValues.lys.wast index a2e73b9..85a0543 100644 --- a/test/fixtures/execution/setStructValues.lys.wast +++ b/test/fixtures/execution/setStructValues.lys.wast @@ -280,23 +280,23 @@ (func $support::env::printf_15 (param $str i64) (call $support::env::printf_8 (local.get $str) (i32.const 0)) ) - (data 0 (i32.const 1669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1789) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1824) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1865) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1900) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1941) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1976) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 2017) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 2052) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 2093) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 2120) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 2153) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 2180) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 2213) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_1669 (i32.const 1669) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_1696 (i32.const 1696) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_1729 (i32.const 1729) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_1756 (i32.const 1756) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_1789 (i32.const 1789) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1824 (i32.const 1824) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1865 (i32.const 1865) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1900 (i32.const 1900) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1941 (i32.const 1941) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1976 (i32.const 1976) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_2017 (i32.const 2017) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_2052 (i32.const 2052) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_2093 (i32.const 2093) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_2120 (i32.const 2120) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_2153 (i32.const 2153) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_2180 (i32.const 2180) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_2213 (i32.const 2213) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 1622) "\00\00\00\00\00") - (data 0 (i32.const 1627) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 1640) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 1655) "\02\00\00\000\00\00") - (data 0 (i32.const 1662) "\02\00\00\000\00\00") + (data $mem_1622 (i32.const 1622) "\00\00\00\00\00") + (data $mem_1627 (i32.const 1627) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_1640 (i32.const 1640) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_1655 (i32.const 1655) "\02\00\00\000\00\00") + (data $mem_1662 (i32.const 1662) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,46 +2087,46 @@ ) ) ) - (data 0 (i32.const 16) "\10\00\00\00t\00e\00s\00t\00L\00o\00a\00d\00\00") - (data 0 (i32.const 37) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \000\00\00") - (data 0 (i32.const 74) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000\00\00") - (data 0 (i32.const 111) "\12\00\00\00t\00e\00s\00t\00S\00t\00o\00r\00e\00\00") - (data 0 (i32.const 134) "\16\00\00\00t\00e\00s\00t\00N\00u\00m\00b\00e\00r\00s\00\00") - (data 0 (i32.const 161) " \00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00=\00=\00 \00-\001\00\00") - (data 0 (i32.const 198) "<\00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \00-\001\00 \00a\00s\00 \00u\003\002\00\00") - (data 0 (i32.const 263) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00%\00X\00\00") - (data 0 (i32.const 296) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00%\00X\00\00") - (data 0 (i32.const 329) "L\00\00\000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00\00") - (data 0 (i32.const 410) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \003\00\00") - (data 0 (i32.const 447) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00\00") - (data 0 (i32.const 516) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\003\002\00\00") - (data 0 (i32.const 585) "\16\00\00\00V\00A\00R\00 \00=\00=\00 \00V\00A\00R\002\00\00") - (data 0 (i32.const 612) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00\00") - (data 0 (i32.const 695) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00u\006\004\00\00") - (data 0 (i32.const 778) "2\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \000\00x\000\001\00\00") - (data 0 (i32.const 833) "@\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00,\00 \005\00 \00a\00s\00 \00u\003\002\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \005\00\00") - (data 0 (i32.const 902) "(\00\00\00s\00e\00t\00 \00v\00a\00l\00u\00e\00s\00 \00i\00n\00 \00s\00t\00r\00u\00c\00t\00\00") - (data 0 (i32.const 947) "4\00\00\00g\00e\00t\00t\00e\00r\00s\00 \00o\00f\00 \00t\00h\00e\00 \00c\00o\00n\00s\00t\00r\00u\00c\00t\00o\00r\00\00") - (data 0 (i32.const 1004) "\16\00\00\00a\00 \00i\00s\00 \00C\00a\00t\00B\00a\00g\00\00") - (data 0 (i32.const 1031) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") - (data 0 (i32.const 1060) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") - (data 0 (i32.const 1089) "\14\00\00\00a\00.\00f\00 \00i\00s\00 \00R\00e\00d\00\00") - (data 0 (i32.const 1114) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d\00\00") - (data 0 (i32.const 1139) "\0e\00\00\00s\00e\00t\00t\00e\00r\00s\00\00") - (data 0 (i32.const 1158) "&\00\00\00y\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D\00\00") - (data 0 (i32.const 1201) "\0c\00\00\00y\00 \00=\00=\00 \00y\00\00") - (data 0 (i32.const 1218) "\10\00\00\00t\00m\00p\00 \00=\00=\00 \00y\00\00") - (data 0 (i32.const 1239) "\10\00\00\00a\00.\00f\00 \00=\00=\00 \00y\00\00") - (data 0 (i32.const 1260) "\14\00\00\00a\00.\00f\00 \00=\00=\00 \00t\00m\00p\00\00") - (data 0 (i32.const 1285) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d\00\00") - (data 0 (i32.const 1310) " \00\00\00v\00a\00l\00i\00d\00a\00t\00e\00 \00s\00e\00t\00t\00e\00r\00s\00\00") - (data 0 (i32.const 1347) "\1a\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00u\00s\00t\00o\00m\00\00") - (data 0 (i32.const 1378) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d\00\00") - (data 0 (i32.const 1403) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") - (data 0 (i32.const 1432) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") - (data 0 (i32.const 1461) "&\00\00\00x\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D\00\00") - (data 0 (i32.const 1504) "\22\00\00\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D\00\00") - (data 0 (i32.const 1543) "J\00\00\00a\00.\00f\00 \00i\00s\00 \00n\00o\00t\00 \00C\00u\00s\00t\00o\00m\00 \00i\00n\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00\00") + (data $mem_16 (i32.const 16) "\10\00\00\00t\00e\00s\00t\00L\00o\00a\00d\00\00") + (data $mem_37 (i32.const 37) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \000\00\00") + (data $mem_74 (i32.const 74) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000\00\00") + (data $mem_111 (i32.const 111) "\12\00\00\00t\00e\00s\00t\00S\00t\00o\00r\00e\00\00") + (data $mem_134 (i32.const 134) "\16\00\00\00t\00e\00s\00t\00N\00u\00m\00b\00e\00r\00s\00\00") + (data $mem_161 (i32.const 161) " \00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00=\00=\00 \00-\001\00\00") + (data $mem_198 (i32.const 198) "<\00\00\000\00x\00F\00F\00F\00F\00F\00F\00F\00F\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \00-\001\00 \00a\00s\00 \00u\003\002\00\00") + (data $mem_263 (i32.const 263) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00%\00X\00\00") + (data $mem_296 (i32.const 296) "\1c\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00%\00X\00\00") + (data $mem_329 (i32.const 329) "L\00\00\000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00\00") + (data $mem_410 (i32.const 410) " \00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00x\00)\00 \00=\00=\00 \003\00\00") + (data $mem_447 (i32.const 447) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\003\002\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00\00") + (data $mem_516 (i32.const 516) "@\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\003\002\00\00") + (data $mem_585 (i32.const 585) "\16\00\00\00V\00A\00R\00 \00=\00=\00 \00V\00A\00R\002\00\00") + (data $mem_612 (i32.const 612) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00i\006\004\00\00") + (data $mem_695 (i32.const 695) "N\00\00\00i\003\002\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00u\006\004\00 \00=\00=\00 \000\00x\00A\00B\00C\00D\00E\00F\000\001\00 \00a\00s\00 \00u\006\004\00\00") + (data $mem_778 (i32.const 778) "2\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \000\00x\000\001\00\00") + (data $mem_833 (i32.const 833) "@\00\00\00u\008\00.\00l\00o\00a\00d\00(\00y\00,\00 \005\00 \00a\00s\00 \00u\003\002\00)\00 \00a\00s\00 \00i\003\002\00 \00=\00=\00 \005\00\00") + (data $mem_902 (i32.const 902) "(\00\00\00s\00e\00t\00 \00v\00a\00l\00u\00e\00s\00 \00i\00n\00 \00s\00t\00r\00u\00c\00t\00\00") + (data $mem_947 (i32.const 947) "4\00\00\00g\00e\00t\00t\00e\00r\00s\00 \00o\00f\00 \00t\00h\00e\00 \00c\00o\00n\00s\00t\00r\00u\00c\00t\00o\00r\00\00") + (data $mem_1004 (i32.const 1004) "\16\00\00\00a\00 \00i\00s\00 \00C\00a\00t\00B\00a\00g\00\00") + (data $mem_1031 (i32.const 1031) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") + (data $mem_1060 (i32.const 1060) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") + (data $mem_1089 (i32.const 1089) "\14\00\00\00a\00.\00f\00 \00i\00s\00 \00R\00e\00d\00\00") + (data $mem_1114 (i32.const 1114) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d\00\00") + (data $mem_1139 (i32.const 1139) "\0e\00\00\00s\00e\00t\00t\00e\00r\00s\00\00") + (data $mem_1158 (i32.const 1158) "&\00\00\00y\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D\00\00") + (data $mem_1201 (i32.const 1201) "\0c\00\00\00y\00 \00=\00=\00 \00y\00\00") + (data $mem_1218 (i32.const 1218) "\10\00\00\00t\00m\00p\00 \00=\00=\00 \00y\00\00") + (data $mem_1239 (i32.const 1239) "\10\00\00\00a\00.\00f\00 \00=\00=\00 \00y\00\00") + (data $mem_1260 (i32.const 1260) "\14\00\00\00a\00.\00f\00 \00=\00=\00 \00t\00m\00p\00\00") + (data $mem_1285 (i32.const 1285) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d\00\00") + (data $mem_1310 (i32.const 1310) " \00\00\00v\00a\00l\00i\00d\00a\00t\00e\00 \00s\00e\00t\00t\00e\00r\00s\00\00") + (data $mem_1347 (i32.const 1347) "\1a\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00u\00s\00t\00o\00m\00\00") + (data $mem_1378 (i32.const 1378) "\14\00\00\00a\00.\00g\00 \00i\00s\00 \00R\00e\00d\00\00") + (data $mem_1403 (i32.const 1403) "\18\00\00\00a\00.\00f\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") + (data $mem_1432 (i32.const 1432) "\18\00\00\00a\00.\00g\00 \00i\00s\00 \00C\00o\00l\00o\00r\00\00") + (data $mem_1461 (i32.const 1461) "&\00\00\00x\00.\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D\00\00") + (data $mem_1504 (i32.const 1504) "\22\00\00\00h\00e\00x\00 \00=\00=\00 \000\00x\00A\00A\00B\00B\00C\00C\00D\00D\00\00") + (data $mem_1543 (i32.const 1543) "J\00\00\00a\00.\00f\00 \00i\00s\00 \00n\00o\00t\00 \00C\00u\00s\00t\00o\00m\00 \00i\00n\00 \00p\00a\00t\00t\00e\00r\00n\00 \00m\00a\00t\00c\00h\00i\00n\00g\00\00") (global $test::fixtures::execution::setStructValues::x (mut i64) (i64.const 0)) (global $test::fixtures::execution::setStructValues::y (mut i64) (i64.const 0)) (export "main" (func $test::fixtures::execution::setStructValues::main_1)) diff --git a/test/fixtures/execution/simpleIterator.lys.optimized.wast b/test/fixtures/execution/simpleIterator.lys.optimized.wast index 8be35aa..d1f2a76 100644 --- a/test/fixtures/execution/simpleIterator.lys.optimized.wast +++ b/test/fixtures/execution/simpleIterator.lys.optimized.wast @@ -4,7 +4,7 @@ (type $2 (func (result i32))) (type $3 (func (param i32))) (type $4 (func (param i64 i32))) - (type $5 (func (param i32) (result i32))) + (type $5 (func (param i32 i32) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) (import "test" "popTest" (func $fimport$2)) @@ -12,7 +12,11 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 121) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 148) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -51,16 +55,22 @@ ) ) (func $1 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $2 (param $0 i32) (result i32) - (local $1 i32) + (func $2 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -68,7 +78,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -77,14 +87,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $1 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -99,13 +109,13 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -115,13 +125,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -132,22 +142,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$2 - (local.get $2) + (global.set $global$6 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -160,18 +170,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -179,7 +189,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $3 (result i32) (local $0 i64) @@ -188,7 +198,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -224,6 +234,7 @@ (i64.or (i64.extend_i32_u (call $2 + (i32.const 1) (i32.const 8) ) ) @@ -273,6 +284,7 @@ (i64.or (i64.extend_i32_u (call $2 + (i32.const 1) (i32.const 4) ) ) @@ -345,15 +357,39 @@ ) (func $5 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 + (i32.const 65536) + ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/simpleIterator.lys.wast b/test/fixtures/execution/simpleIterator.lys.wast index 9173e37..8fc18f3 100644 --- a/test/fixtures/execution/simpleIterator.lys.wast +++ b/test/fixtures/execution/simpleIterator.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 121) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 148) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 181) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 208) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 241) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 276) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 317) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 352) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 393) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 428) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 469) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 504) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 545) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 572) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 605) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 632) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 665) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_121 (i32.const 121) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_148 (i32.const 148) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_181 (i32.const 181) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_208 (i32.const 208) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_241 (i32.const 241) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_276 (i32.const 276) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_317 (i32.const 317) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_352 (i32.const 352) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_393 (i32.const 393) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_428 (i32.const 428) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_469 (i32.const 469) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_504 (i32.const 504) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_545 (i32.const 545) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_572 (i32.const 572) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_605 (i32.const 605) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_632 (i32.const 632) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_665 (i32.const 665) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ ) ) ) - (data 0 (i32.const 74) "\00\00\00\00\00") - (data 0 (i32.const 79) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 92) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 107) "\02\00\00\000\00\00") - (data 0 (i32.const 114) "\02\00\00\000\00\00") + (data $mem_74 (i32.const 74) "\00\00\00\00\00") + (data $mem_79 (i32.const 79) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_92 (i32.const 92) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_107 (i32.const 107) "\02\00\00\000\00\00") + (data $mem_114 (i32.const 114) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,8 +2087,8 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "\1a\00\00\00I\00t\00e\00r\00a\00t\00o\00r\00 \00t\00e\00s\00t\00\00") - (data 0 (i32.const 47) "\16\00\00\00s\00p\00e\00c\00 \00t\00e\00s\00t\00 \001\00\00") + (data $mem_16 (i32.const 16) "\1a\00\00\00I\00t\00e\00r\00a\00t\00o\00r\00 \00t\00e\00s\00t\00\00") + (data $mem_47 (i32.const 47) "\16\00\00\00s\00p\00e\00c\00 \00t\00e\00s\00t\00 \001\00\00") (export "main" (func $test::fixtures::execution::simpleIterator::main_1)) (func $test::fixtures::execution::simpleIterator::Iterator.is_1 (param $a i64) (result i32) (local $test::fixtures::execution::simpleIterator::discriminant i32) diff --git a/test/fixtures/execution/strConcat.lys.optimized.wast b/test/fixtures/execution/strConcat.lys.optimized.wast index 2c2a155..7f172a5 100644 --- a/test/fixtures/execution/strConcat.lys.optimized.wast +++ b/test/fixtures/execution/strConcat.lys.optimized.wast @@ -22,7 +22,11 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 1123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 1150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -109,7 +113,7 @@ ) ) (func $3 (result i32) - (global.get $global$2) + (global.get $global$6) ) (func $4 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -245,7 +249,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -331,7 +335,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $2) ) (then @@ -343,11 +347,11 @@ (local.tee $2 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $3 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -362,7 +366,7 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) @@ -403,7 +407,7 @@ ) ) ) - (global.set $global$2 + (global.set $global$6 (local.get $2) ) (local.set $4 @@ -490,12 +494,11 @@ (func $12 (param $0 i64) (param $1 i64) (result i32) (local $2 i32) (local $3 i32) - (local $4 i32) (if (result i32) (i32.eq (i32.shr_u (i32.load - (local.tee $2 + (local.tee $3 (i32.wrap_i64 (local.get $0) ) @@ -505,7 +508,7 @@ ) (i32.shr_u (i32.load - (local.tee $3 + (local.tee $2 (i32.wrap_i64 (local.get $1) ) @@ -585,29 +588,30 @@ (i32.ne (i32.load16_u (i32.add - (local.tee $4 - (i32.shl - (local.get $2) - (i32.const 1) - ) - ) (i32.add (i32.wrap_i64 (local.get $0) ) (i32.const 4) ) + (i32.shl + (local.get $2) + (i32.const 1) + ) ) ) (i32.load16_u (i32.add - (local.get $4) (i32.add (i32.wrap_i64 (local.get $1) ) (i32.const 4) ) + (i32.shl + (local.get $2) + (i32.const 1) + ) ) ) ) @@ -1044,15 +1048,39 @@ ) (func $14 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 + (i32.const 65536) + ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/strConcat.lys.wast b/test/fixtures/execution/strConcat.lys.wast index f4b6ea4..fde23c2 100644 --- a/test/fixtures/execution/strConcat.lys.wast +++ b/test/fixtures/execution/strConcat.lys.wast @@ -280,23 +280,23 @@ ) ) ) - (data 0 (i32.const 1123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1183) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1210) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1243) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1278) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1319) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1354) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1395) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1430) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1471) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1506) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1607) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1634) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1667) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_1123 (i32.const 1123) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_1150 (i32.const 1150) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_1183 (i32.const 1183) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_1210 (i32.const 1210) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_1243 (i32.const 1243) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1278 (i32.const 1278) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1319 (i32.const 1319) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1354 (i32.const 1354) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1395 (i32.const 1395) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1430 (i32.const 1430) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1471 (i32.const 1471) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1506 (i32.const 1506) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1547 (i32.const 1547) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_1574 (i32.const 1574) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_1607 (i32.const 1607) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_1634 (i32.const 1634) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_1667 (i32.const 1667) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 1076) "\00\00\00\00\00") - (data 0 (i32.const 1081) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 1094) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 1109) "\02\00\00\000\00\00") - (data 0 (i32.const 1116) "\02\00\00\000\00\00") + (data $mem_1076 (i32.const 1076) "\00\00\00\00\00") + (data $mem_1081 (i32.const 1081) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_1094 (i32.const 1094) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_1109 (i32.const 1109) "\02\00\00\000\00\00") + (data $mem_1116 (i32.const 1116) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,40 +2087,40 @@ ) ) ) - (data 0 (i32.const 16) ".\00\00\00T\00e\00s\00t\00 \00b\00y\00t\00e\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00\00") - (data 0 (i32.const 67) "\06\00\00\00a\00b\00c\00\00") - (data 0 (i32.const 78) "\08\00\00\001\002\003\004\00\00") - (data 0 (i32.const 91) "\1a\00\00\00a\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \003\00\00") - (data 0 (i32.const 122) "\1a\00\00\00b\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \004\00\00") - (data 0 (i32.const 153) "\1a\00\00\00c\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \007\00\00") - (data 0 (i32.const 184) "\0e\00\00\00a\00b\00c\001\002\003\004\00\00") - (data 0 (i32.const 203) "$\00\00\00c\00 \00=\00=\00 \00'\00a\00b\00c\001\002\003\004\00'\00 \00(\001\00)\00\00") - (data 0 (i32.const 244) "\0e\00\00\00a\00b\00c\001\002\003\004\00\00") - (data 0 (i32.const 263) "$\00\00\00c\00 \00=\00=\00 \00'\00a\00b\00c\001\002\003\004\00'\00 \00(\002\00)\00\00") - (data 0 (i32.const 304) "\1c\00\00\00d\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \002\008\00\00") - (data 0 (i32.const 337) "\1c\00\00\00a\00b\00c\001\002\003\004\00a\00b\00c\001\002\003\004\00\00") - (data 0 (i32.const 370) ",\00\00\00T\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00o\00p\00e\00r\00a\00t\00i\00o\00n\00s\00\00") - (data 0 (i32.const 419) "\0c\00\00\00a\00s\00d\00n'5\d8\11\dc\00") - (data 0 (i32.const 436) "\1e\00\00\00s\00t\00r\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \006\00\00") - (data 0 (i32.const 471) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \000\00\00") - (data 0 (i32.const 494) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \001\00\00") - (data 0 (i32.const 517) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \002\00\00") - (data 0 (i32.const 540) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \003\00\00") - (data 0 (i32.const 563) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \004\00\00") - (data 0 (i32.const 586) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \005\00\00") - (data 0 (i32.const 609) "(\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00\00") - (data 0 (i32.const 654) "\04\00\00\00d\00s\00\00") - (data 0 (i32.const 663) "\04\00\00\00s\00a\00\00") - (data 0 (i32.const 672) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \004\00\00") - (data 0 (i32.const 723) "4\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00 \00U\00T\00F\001\006\00\00") - (data 0 (i32.const 780) "\04\00\00\00a\00b\00\00") - (data 0 (i32.const 789) "\06\00\00\00\b5\00\9c&\0e\fe\00") - (data 0 (i32.const 800) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \005\00\00") - (data 0 (i32.const 851) "$\00\00\00a\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") - (data 0 (i32.const 892) "$\00\00\00b\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") - (data 0 (i32.const 933) "$\00\00\00\b5\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") - (data 0 (i32.const 974) ".\00\00\000\00x\002\006\009\00C\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") - (data 0 (i32.const 1025) ".\00\00\000\00x\00F\00E\000\00E\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") + (data $mem_16 (i32.const 16) ".\00\00\00T\00e\00s\00t\00 \00b\00y\00t\00e\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00\00") + (data $mem_67 (i32.const 67) "\06\00\00\00a\00b\00c\00\00") + (data $mem_78 (i32.const 78) "\08\00\00\001\002\003\004\00\00") + (data $mem_91 (i32.const 91) "\1a\00\00\00a\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \003\00\00") + (data $mem_122 (i32.const 122) "\1a\00\00\00b\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \004\00\00") + (data $mem_153 (i32.const 153) "\1a\00\00\00c\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \007\00\00") + (data $mem_184 (i32.const 184) "\0e\00\00\00a\00b\00c\001\002\003\004\00\00") + (data $mem_203 (i32.const 203) "$\00\00\00c\00 \00=\00=\00 \00'\00a\00b\00c\001\002\003\004\00'\00 \00(\001\00)\00\00") + (data $mem_244 (i32.const 244) "\0e\00\00\00a\00b\00c\001\002\003\004\00\00") + (data $mem_263 (i32.const 263) "$\00\00\00c\00 \00=\00=\00 \00'\00a\00b\00c\001\002\003\004\00'\00 \00(\002\00)\00\00") + (data $mem_304 (i32.const 304) "\1c\00\00\00d\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \002\008\00\00") + (data $mem_337 (i32.const 337) "\1c\00\00\00a\00b\00c\001\002\003\004\00a\00b\00c\001\002\003\004\00\00") + (data $mem_370 (i32.const 370) ",\00\00\00T\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00o\00p\00e\00r\00a\00t\00i\00o\00n\00s\00\00") + (data $mem_419 (i32.const 419) "\0c\00\00\00a\00s\00d\00n'5\d8\11\dc\00") + (data $mem_436 (i32.const 436) "\1e\00\00\00s\00t\00r\00.\00l\00e\00n\00g\00t\00h\00 \00=\00=\00 \006\00\00") + (data $mem_471 (i32.const 471) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \000\00\00") + (data $mem_494 (i32.const 494) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \001\00\00") + (data $mem_517 (i32.const 517) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \002\00\00") + (data $mem_540 (i32.const 540) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \003\00\00") + (data $mem_563 (i32.const 563) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \004\00\00") + (data $mem_586 (i32.const 586) "\12\00\00\00c\00h\00a\00r\00 \00a\00t\00 \005\00\00") + (data $mem_609 (i32.const 609) "(\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00\00") + (data $mem_654 (i32.const 654) "\04\00\00\00d\00s\00\00") + (data $mem_663 (i32.const 663) "\04\00\00\00s\00a\00\00") + (data $mem_672 (i32.const 672) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \004\00\00") + (data $mem_723 (i32.const 723) "4\00\00\00S\00t\00r\00i\00n\00g\00 \00c\00o\00n\00c\00a\00t\00e\00n\00a\00t\00i\00o\00n\00 \00U\00T\00F\001\006\00\00") + (data $mem_780 (i32.const 780) "\04\00\00\00a\00b\00\00") + (data $mem_789 (i32.const 789) "\06\00\00\00\b5\00\9c&\0e\fe\00") + (data $mem_800 (i32.const 800) ".\00\00\00S\00t\00r\00i\00n\00g\00.\00l\00e\00n\00g\00t\00h\00 \00m\00u\00s\00t\00 \00b\00e\00 \005\00\00") + (data $mem_851 (i32.const 851) "$\00\00\00a\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") + (data $mem_892 (i32.const 892) "$\00\00\00b\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") + (data $mem_933 (i32.const 933) "$\00\00\00\b5\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") + (data $mem_974 (i32.const 974) ".\00\00\000\00x\002\006\009\00C\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") + (data $mem_1025 (i32.const 1025) ".\00\00\000\00x\00F\00E\000\00E\00 \00a\00s\00s\00e\00r\00t\00i\00o\00n\00 \00f\00a\00i\00l\00e\00d\00\00") (export "main" (func $test::fixtures::execution::strConcat::main_1)) (func $test::fixtures::execution::strConcat::main_1 (local $test::fixtures::execution::strConcat::a i64) diff --git a/test/fixtures/execution/stringifyNumbers.lys.optimized.wast b/test/fixtures/execution/stringifyNumbers.lys.optimized.wast index 1b63240..2fcb8ef 100644 --- a/test/fixtures/execution/stringifyNumbers.lys.optimized.wast +++ b/test/fixtures/execution/stringifyNumbers.lys.optimized.wast @@ -19,7 +19,11 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 692) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 719) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -73,7 +77,7 @@ (export "main" (func $15)) (start $16) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) (func $1 (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -142,7 +146,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -201,7 +205,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $1) ) (then @@ -213,11 +217,11 @@ (local.tee $1 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $2 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -232,7 +236,7 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) @@ -273,7 +277,7 @@ ) ) ) - (global.set $global$2 + (global.set $global$6 (local.get $1) ) (local.set $3 @@ -439,7 +443,19 @@ ) (func $9 (param $0 i64) (param $1 i64) (param $2 i32) (local $3 i32) + (local $4 i32) (loop $label + (local.set $3 + (i32.add + (i32.wrap_i64 + (i64.rem_u + (local.get $1) + (i64.const 10) + ) + ) + (i32.const 48) + ) + ) (if (i32.lt_u (i32.load @@ -448,7 +464,7 @@ ) ) (i32.add - (local.tee $3 + (local.tee $4 (i32.shl (local.tee $2 (i32.sub @@ -468,7 +484,7 @@ ) (i32.store16 (i32.add - (local.get $3) + (local.get $4) (i32.add (i32.wrap_i64 (local.get $0) @@ -476,15 +492,7 @@ (i32.const 4) ) ) - (i32.add - (i32.wrap_i64 - (i64.rem_u - (local.get $1) - (i64.const 10) - ) - ) - (i32.const 48) - ) + (local.get $3) ) (br_if $label (i64.ne @@ -1007,15 +1015,39 @@ ) (func $16 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 + (i32.const 65536) + ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/stringifyNumbers.lys.wast b/test/fixtures/execution/stringifyNumbers.lys.wast index b08f238..e2d9164 100644 --- a/test/fixtures/execution/stringifyNumbers.lys.wast +++ b/test/fixtures/execution/stringifyNumbers.lys.wast @@ -280,23 +280,23 @@ (func $support::env::printf_15 (param $str i64) (call $support::env::printf_8 (local.get $str) (i32.const 0)) ) - (data 0 (i32.const 692) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 719) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 752) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 779) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 812) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 847) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 888) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 923) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 964) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 999) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1040) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1075) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1116) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1143) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 1176) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1203) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 1236) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_692 (i32.const 692) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_719 (i32.const 719) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_752 (i32.const 752) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_779 (i32.const 779) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_812 (i32.const 812) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_847 (i32.const 847) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_888 (i32.const 888) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_923 (i32.const 923) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_964 (i32.const 964) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_999 (i32.const 999) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1040 (i32.const 1040) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1075 (i32.const 1075) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_1116 (i32.const 1116) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_1143 (i32.const 1143) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_1176 (i32.const 1176) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_1203 (i32.const 1203) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_1236 (i32.const 1236) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ ) ) ) - (data 0 (i32.const 645) "\00\00\00\00\00") - (data 0 (i32.const 650) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 663) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 678) "\02\00\00\000\00\00") - (data 0 (i32.const 685) "\02\00\00\000\00\00") + (data $mem_645 (i32.const 645) "\00\00\00\00\00") + (data $mem_650 (i32.const 650) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_663 (i32.const 663) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_678 (i32.const 678) "\02\00\00\000\00\00") + (data $mem_685 (i32.const 685) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,31 +2087,31 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "\1c\00\00\00 \00 \00 \00 \00n\00u\00m\00b\00e\00r\00:\00 \00%\00d\00\00") - (data 0 (i32.const 49) "\1c\00\00\00 \00 \00 \00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 82) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 115) "$\00\00\00a\00s\00s\00e\00r\00t\00N\00u\00m\00b\00e\00r\00L\00e\00n\00g\00t\00h\00\00") - (data 0 (i32.const 156) "\10\00\00\00G\00i\00v\00e\00n\00:\00 \00'\00\00") - (data 0 (i32.const 177) "\1a\00\00\00'\00 \00E\00x\00p\00e\00c\00t\00e\00d\00:\00 \00'\00\00") - (data 0 (i32.const 208) "\02\00\00\00'\00\00") - (data 0 (i32.const 215) "\0c\00\00\00g\00i\00v\00e\00n\00:\00\00") - (data 0 (i32.const 232) "\12\00\00\00e\00x\00p\00e\00c\00t\00e\00d\00:\00\00") - (data 0 (i32.const 255) "4\00\00\00s\00t\00r\00i\00n\00g\00i\00f\00y\00c\00a\00t\00i\00o\00n\00 \00o\00f\00 \00n\00u\00m\00b\00e\00r\00s\00\00") - (data 0 (i32.const 312) "(\00\00\00t\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00e\00q\00u\00a\00l\00i\00t\00y\00\00") - (data 0 (i32.const 357) "\08\00\00\00a\00b\00c\00d\00\00") - (data 0 (i32.const 370) "\08\00\00\00a\00b\00c\00d\00\00") - (data 0 (i32.const 383) "8\00\00\00g\00e\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00h\00a\00r\00a\00c\00t\00e\00r\00s\00 \00l\00e\00n\00g\00t\00h\00\00") - (data 0 (i32.const 444) "(\00\00\00n\00u\00m\00b\00e\00r\00 \00s\00e\00r\00i\00a\00l\00i\00z\00a\00t\00i\00o\00n\00\00") - (data 0 (i32.const 489) "\02\00\00\001\00\00") - (data 0 (i32.const 496) "\04\00\00\00-\001\00\00") - (data 0 (i32.const 505) "\0e\00\00\002\002\002\002\002\002\002\00\00") - (data 0 (i32.const 524) "\0e\00\00\003\003\003\003\003\003\003\00\00") - (data 0 (i32.const 543) "\0e\00\00\00-\004\004\004\004\004\004\00\00") - (data 0 (i32.const 562) "\12\00\00\001\002\003\004\005\006\007\008\009\00\00") - (data 0 (i32.const 585) "\0c\00\00\001\000\000\000\000\000\00\00") - (data 0 (i32.const 602) "\08\00\00\002\000\000\000\00\00") - (data 0 (i32.const 615) "\0c\00\00\003\000\000\000\000\000\00\00") - (data 0 (i32.const 632) "\08\00\00\004\000\000\000\00\00") + (data $mem_16 (i32.const 16) "\1c\00\00\00 \00 \00 \00 \00n\00u\00m\00b\00e\00r\00:\00 \00%\00d\00\00") + (data $mem_49 (i32.const 49) "\1c\00\00\00 \00 \00 \00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_82 (i32.const 82) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_115 (i32.const 115) "$\00\00\00a\00s\00s\00e\00r\00t\00N\00u\00m\00b\00e\00r\00L\00e\00n\00g\00t\00h\00\00") + (data $mem_156 (i32.const 156) "\10\00\00\00G\00i\00v\00e\00n\00:\00 \00'\00\00") + (data $mem_177 (i32.const 177) "\1a\00\00\00'\00 \00E\00x\00p\00e\00c\00t\00e\00d\00:\00 \00'\00\00") + (data $mem_208 (i32.const 208) "\02\00\00\00'\00\00") + (data $mem_215 (i32.const 215) "\0c\00\00\00g\00i\00v\00e\00n\00:\00\00") + (data $mem_232 (i32.const 232) "\12\00\00\00e\00x\00p\00e\00c\00t\00e\00d\00:\00\00") + (data $mem_255 (i32.const 255) "4\00\00\00s\00t\00r\00i\00n\00g\00i\00f\00y\00c\00a\00t\00i\00o\00n\00 \00o\00f\00 \00n\00u\00m\00b\00e\00r\00s\00\00") + (data $mem_312 (i32.const 312) "(\00\00\00t\00e\00s\00t\00 \00s\00t\00r\00i\00n\00g\00 \00e\00q\00u\00a\00l\00i\00t\00y\00\00") + (data $mem_357 (i32.const 357) "\08\00\00\00a\00b\00c\00d\00\00") + (data $mem_370 (i32.const 370) "\08\00\00\00a\00b\00c\00d\00\00") + (data $mem_383 (i32.const 383) "8\00\00\00g\00e\00t\00 \00n\00u\00m\00b\00e\00r\00 \00c\00h\00a\00r\00a\00c\00t\00e\00r\00s\00 \00l\00e\00n\00g\00t\00h\00\00") + (data $mem_444 (i32.const 444) "(\00\00\00n\00u\00m\00b\00e\00r\00 \00s\00e\00r\00i\00a\00l\00i\00z\00a\00t\00i\00o\00n\00\00") + (data $mem_489 (i32.const 489) "\02\00\00\001\00\00") + (data $mem_496 (i32.const 496) "\04\00\00\00-\001\00\00") + (data $mem_505 (i32.const 505) "\0e\00\00\002\002\002\002\002\002\002\00\00") + (data $mem_524 (i32.const 524) "\0e\00\00\003\003\003\003\003\003\003\00\00") + (data $mem_543 (i32.const 543) "\0e\00\00\00-\004\004\004\004\004\004\00\00") + (data $mem_562 (i32.const 562) "\12\00\00\001\002\003\004\005\006\007\008\009\00\00") + (data $mem_585 (i32.const 585) "\0c\00\00\001\000\000\000\000\000\00\00") + (data $mem_602 (i32.const 602) "\08\00\00\002\000\000\000\00\00") + (data $mem_615 (i32.const 615) "\0c\00\00\003\000\000\000\000\000\00\00") + (data $mem_632 (i32.const 632) "\08\00\00\004\000\000\000\00\00") (export "main" (func $test::fixtures::execution::stringifyNumbers::main_1)) (func $test::fixtures::execution::stringifyNumbers::assertNumber_1 (param $numberToSerialize i64) (param $expected i64) (call $test::fixtures::execution::stringifyNumbers::assertEquals_1 (call $system::core::string::string.stringify_8 (local.get $numberToSerialize)) (local.get $expected)) diff --git a/test/fixtures/execution/structValuesExtended.lys.optimized.wast b/test/fixtures/execution/structValuesExtended.lys.optimized.wast index 77c7910..58903ae 100644 --- a/test/fixtures/execution/structValuesExtended.lys.optimized.wast +++ b/test/fixtures/execution/structValuesExtended.lys.optimized.wast @@ -4,7 +4,7 @@ (type $2 (func (result i32))) (type $3 (func (param f32))) (type $4 (func (param i32 i32))) - (type $5 (func (param i32) (result i32))) + (type $5 (func (param i32 i32) (result i32))) (type $6 (func (param i32 i64))) (type $7 (func (param i64) (result i32))) (import "test" "printNumber" (func $fimport$0 (param f32))) @@ -15,7 +15,11 @@ (global $global$0 (mut i32) (i32.const 0)) (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) - (global $global$3 (mut i64) (i64.const 0)) + (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i64) (i64.const 0)) (memory $0 1) (data $0 (i32.const 266) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 293) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -67,16 +71,22 @@ (export "main" (func $5)) (start $6) (func $0 (result i32) - (global.get $global$2) + (global.get $global$6) ) - (func $1 (param $0 i32) (result i32) - (local $1 i32) + (func $1 (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) (if (i32.eqz - (local.get $0) + (local.tee $0 + (local.tee $4 + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) ) (then (unreachable) @@ -84,7 +94,7 @@ ) (if (i32.lt_u - (global.get $global$1) + (global.get $global$3) (local.get $0) ) (then @@ -93,14 +103,14 @@ ) (if (i32.gt_u - (local.tee $2 + (local.tee $0 (i32.and (i32.add - (global.get $global$0) + (global.get $global$2) (i32.add (i32.add (local.tee $1 - (global.get $global$2) + (global.get $global$6) ) (i32.const 16) ) @@ -115,13 +125,13 @@ ) ) (i32.xor - (global.get $global$0) + (global.get $global$2) (i32.const -1) ) ) ) (i32.shl - (local.tee $3 + (local.tee $2 (memory.size) ) (i32.const 16) @@ -131,13 +141,13 @@ (drop (memory.grow (select - (local.get $3) - (local.tee $4 + (local.get $2) + (local.tee $3 (i32.shr_s (i32.and (i32.add (i32.sub - (local.get $2) + (local.get $0) (local.get $1) ) (i32.const 65535) @@ -148,22 +158,22 @@ ) ) (i32.gt_u + (local.get $2) (local.get $3) - (local.get $4) ) ) ) ) ) ) - (global.set $global$2 - (local.get $2) + (global.set $global$6 + (local.get $0) ) - (local.set $0 + (local.set $2 (i32.add - (local.get $0) - (local.tee $1 - (local.tee $2 + (local.get $4) + (local.tee $0 + (local.tee $1 (i32.add (local.get $1) (i32.const 16) @@ -176,18 +186,18 @@ (if (i32.ne (local.get $0) - (local.get $1) + (local.get $2) ) (then (i32.store8 - (local.get $1) + (local.get $0) (i32.load8_u (i32.const 0) ) ) - (local.set $1 + (local.set $0 (i32.add - (local.get $1) + (local.get $0) (i32.const 1) ) ) @@ -195,7 +205,7 @@ ) ) ) - (local.get $2) + (local.get $1) ) (func $2 (result i32) (local $0 i64) @@ -204,7 +214,7 @@ (i32.wrap_i64 (i64.shr_u (local.tee $0 - (global.get $global$3) + (global.get $global$7) ) (i64.const 32) ) @@ -272,23 +282,25 @@ ) ) (func $5 - (local $0 i32) - (local $1 i32) + (local $0 i64) + (local $1 i64) (local $2 i32) (local $3 i32) (local $4 i32) (local $5 i32) (local $6 i32) - (local $7 i64) + (local $7 i32) + (local $8 i32) (call $fimport$2 (i32.const 16) ) (i32.store (i32.wrap_i64 - (local.tee $7 + (local.tee $0 (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 41) ) ) @@ -300,9 +312,9 @@ ) (i32.store8 (i32.add - (local.tee $0 + (local.tee $2 (i32.wrap_i64 - (local.get $7) + (local.get $0) ) ) (i32.const 4) @@ -310,47 +322,37 @@ (i32.const 1) ) (f32.store - (local.tee $2 - (i32.add - (local.get $0) - (i32.const 5) - ) + (i32.add + (local.get $2) + (i32.const 5) ) (f32.const 3) ) (i64.store - (local.tee $4 - (i32.add - (local.get $0) - (i32.const 9) - ) + (i32.add + (local.get $2) + (i32.const 9) ) (i64.const 8) ) (f64.store - (local.tee $5 - (i32.add - (local.get $0) - (i32.const 17) - ) + (i32.add + (local.get $2) + (i32.const 17) ) (f64.const 0.4000000059604645) ) (i64.store - (local.tee $1 - (i32.add - (local.get $0) - (i32.const 25) - ) + (i32.add + (local.get $2) + (i32.const 25) ) (i64.const 8589934592) ) (i64.store - (local.tee $3 - (i32.add - (local.get $0) - (i32.const 33) - ) + (i32.add + (local.get $2) + (i32.const 33) ) (i64.const 8589934592) ) @@ -358,7 +360,7 @@ (i32.eq (i32.wrap_i64 (i64.shr_u - (local.get $7) + (local.get $0) (i64.const 32) ) ) @@ -369,7 +371,11 @@ (call $3 (i32.eq (i32.load - (local.get $0) + (local.tee $2 + (i32.wrap_i64 + (local.get $0) + ) + ) ) (i32.const 1) ) @@ -378,9 +384,9 @@ (call $3 (i32.ne (i32.load8_u - (local.tee $6 + (local.tee $3 (i32.add - (local.get $0) + (local.get $2) (i32.const 4) ) ) @@ -392,7 +398,12 @@ (call $3 (f32.eq (f32.load - (local.get $2) + (local.tee $4 + (i32.add + (local.get $2) + (i32.const 5) + ) + ) ) (f32.const 3) ) @@ -401,7 +412,12 @@ (call $3 (i64.eq (i64.load - (local.get $4) + (local.tee $5 + (i32.add + (local.get $2) + (i32.const 9) + ) + ) ) (i64.const 8) ) @@ -410,7 +426,12 @@ (call $3 (f64.eq (f64.load - (local.get $5) + (local.tee $6 + (i32.add + (local.get $2) + (i32.const 17) + ) + ) ) (f64.const 0.4000000059604645) ) @@ -421,7 +442,12 @@ (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $1) + (local.tee $7 + (i32.add + (local.get $2) + (i32.const 25) + ) + ) ) (i64.const 32) ) @@ -435,7 +461,12 @@ (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $3) + (local.tee $8 + (i32.add + (local.get $2) + (i32.const 33) + ) + ) ) (i64.const 32) ) @@ -447,7 +478,12 @@ (call $3 (call $4 (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 25) + ) ) ) (i64.const 12884902009) @@ -455,42 +491,53 @@ (call $3 (call $4 (i64.load - (local.get $3) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 33) + ) ) ) (i64.const 12884902016) ) (i32.store - (local.get $0) + (local.get $2) (i32.const 5) ) (i32.store8 - (local.get $6) + (local.get $3) (i32.const 0) ) (f32.store - (local.get $2) + (local.get $4) (f32.const -999) ) (i64.store - (local.get $4) + (local.get $5) (i64.const 3735928559) ) (f64.store - (local.get $5) + (local.get $6) (f64.const 608000000925854355947520) ) (call $fimport$0 (f32.load - (local.get $2) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 5) + ) ) ) (i32.store (i32.wrap_i64 - (local.tee $7 + (local.tee $1 (i64.or (i64.extend_i32_u (call $1 + (i32.const 1) (i32.const 4) ) ) @@ -501,16 +548,21 @@ (i32.const 333) ) (i64.store - (local.get $1) (local.get $7) + (local.get $1) ) (call $fimport$0 (f32.load - (local.get $2) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 5) + ) ) ) (i64.store - (local.get $3) + (local.get $8) (i64.const 4294967296) ) (call $fimport$1 @@ -518,13 +570,17 @@ ) (call $fimport$1 (i32.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) ) (call $3 (i32.eq (i32.load - (local.get $0) + (i32.wrap_i64 + (local.get $0) + ) ) (i32.const 5) ) @@ -533,7 +589,12 @@ (call $fimport$1 (i32.ne (i32.load8_u - (local.get $6) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 4) + ) ) (i32.const 0) ) @@ -541,20 +602,35 @@ (call $3 (i32.eqz (i32.load8_u - (local.get $6) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 4) + ) ) ) (i64.const 12884902030) ) (call $fimport$0 (f32.load - (local.get $2) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 5) + ) ) ) (call $3 (f32.eq (f32.load - (local.get $2) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 5) + ) ) (f32.const -999) ) @@ -563,7 +639,12 @@ (call $3 (i64.eq (i64.load - (local.get $4) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 9) + ) ) (i64.const 3735928559) ) @@ -572,7 +653,12 @@ (call $3 (f64.eq (f64.load - (local.get $5) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 17) + ) ) (f64.const 608000000925854355947520) ) @@ -583,7 +669,12 @@ (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 25) + ) ) (i64.const 32) ) @@ -597,7 +688,12 @@ (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $3) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 33) + ) ) (i64.const 32) ) @@ -609,7 +705,12 @@ (call $3 (call $4 (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 25) + ) ) ) (i64.const 12884902072) @@ -617,7 +718,12 @@ (call $3 (call $4 (i64.load - (local.get $3) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 33) + ) ) ) (i64.const 12884902079) @@ -627,7 +733,12 @@ (i32.wrap_i64 (i64.shr_u (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 25) + ) ) (i64.const 32) ) @@ -641,9 +752,14 @@ (i32.ne (i32.wrap_i64 (i64.shr_u - (local.tee $7 + (local.tee $0 (i64.load - (local.get $1) + (i32.add + (i32.wrap_i64 + (local.get $0) + ) + (i32.const 25) + ) ) ) (i64.const 32) @@ -663,7 +779,7 @@ (i32.eq (i32.load (i32.wrap_i64 - (local.get $7) + (local.get $0) ) ) (i32.const 333) @@ -675,15 +791,39 @@ ) (func $6 (global.set $global$0 - (i32.const 15) + (i32.const 4) ) (global.set $global$1 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$2 - (i32.const 65536) + (i32.sub + (global.get $global$1) + (i32.const 1) + ) ) (global.set $global$3 + (i32.const 1073741824) + ) + (global.set $global$4 + (i32.const 65536) + ) + (global.set $global$5 + (i32.and + (i32.add + (global.get $global$2) + (i32.const 65536) + ) + (i32.xor + (global.get $global$2) + (i32.const -1) + ) + ) + ) + (global.set $global$6 + (global.get $global$5) + ) + (global.set $global$7 (i64.const 8589934592) ) ) diff --git a/test/fixtures/execution/structValuesExtended.lys.wast b/test/fixtures/execution/structValuesExtended.lys.wast index 64fb510..7c2a477 100644 --- a/test/fixtures/execution/structValuesExtended.lys.wast +++ b/test/fixtures/execution/structValuesExtended.lys.wast @@ -280,23 +280,23 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 266) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 293) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 326) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 353) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 538) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 573) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 614) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 649) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 690) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 717) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 750) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 777) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 810) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_266 (i32.const 266) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_293 (i32.const 293) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_326 (i32.const 326) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_353 (i32.const 353) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_386 (i32.const 386) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_421 (i32.const 421) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_462 (i32.const 462) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_497 (i32.const 497) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_538 (i32.const 538) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_573 (i32.const 573) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_614 (i32.const 614) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_649 (i32.const 649) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_690 (i32.const 690) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_717 (i32.const 717) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_750 (i32.const 750) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_777 (i32.const 777) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_810 (i32.const 810) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -1677,11 +1677,11 @@ ) ) ) - (data 0 (i32.const 219) "\00\00\00\00\00") - (data 0 (i32.const 224) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 237) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 252) "\02\00\00\000\00\00") - (data 0 (i32.const 259) "\02\00\00\000\00\00") + (data $mem_219 (i32.const 219) "\00\00\00\00\00") + (data $mem_224 (i32.const 224) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_237 (i32.const 237) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_252 (i32.const 252) "\02\00\00\000\00\00") + (data $mem_259 (i32.const 259) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,29 +2087,29 @@ ) ) ) - (data 0 (i32.const 16) ",\00\00\00s\00t\00r\00u\00c\00t\00 \00v\00a\00l\00u\00e\00s\00 \00e\00x\00t\00e\00n\00d\00e\00d\00\00") - (data 0 (i32.const 65) "\02\00\00\00A\00\00") - (data 0 (i32.const 72) "\02\00\00\00B\00\00") - (data 0 (i32.const 79) "\02\00\00\00C\00\00") - (data 0 (i32.const 86) "\02\00\00\00D\00\00") - (data 0 (i32.const 93) "\02\00\00\00E\00\00") - (data 0 (i32.const 100) "\02\00\00\00F\00\00") - (data 0 (i32.const 107) "\02\00\00\00G\00\00") - (data 0 (i32.const 114) "\02\00\00\00H\00\00") - (data 0 (i32.const 121) "\02\00\00\00I\00\00") - (data 0 (i32.const 128) "\02\00\00\00J\00\00") - (data 0 (i32.const 135) "\02\00\00\00K\00\00") - (data 0 (i32.const 142) "\02\00\00\00L\00\00") - (data 0 (i32.const 149) "\02\00\00\00M\00\00") - (data 0 (i32.const 156) "\02\00\00\00N\00\00") - (data 0 (i32.const 163) "\02\00\00\00\d1\00\00") - (data 0 (i32.const 170) "\02\00\00\00O\00\00") - (data 0 (i32.const 177) "\02\00\00\00P\00\00") - (data 0 (i32.const 184) "\02\00\00\00Q\00\00") - (data 0 (i32.const 191) "\02\00\00\00V\00\00") - (data 0 (i32.const 198) "\02\00\00\00W\00\00") - (data 0 (i32.const 205) "\02\00\00\00X\00\00") - (data 0 (i32.const 212) "\02\00\00\00Y\00\00") + (data $mem_16 (i32.const 16) ",\00\00\00s\00t\00r\00u\00c\00t\00 \00v\00a\00l\00u\00e\00s\00 \00e\00x\00t\00e\00n\00d\00e\00d\00\00") + (data $mem_65 (i32.const 65) "\02\00\00\00A\00\00") + (data $mem_72 (i32.const 72) "\02\00\00\00B\00\00") + (data $mem_79 (i32.const 79) "\02\00\00\00C\00\00") + (data $mem_86 (i32.const 86) "\02\00\00\00D\00\00") + (data $mem_93 (i32.const 93) "\02\00\00\00E\00\00") + (data $mem_100 (i32.const 100) "\02\00\00\00F\00\00") + (data $mem_107 (i32.const 107) "\02\00\00\00G\00\00") + (data $mem_114 (i32.const 114) "\02\00\00\00H\00\00") + (data $mem_121 (i32.const 121) "\02\00\00\00I\00\00") + (data $mem_128 (i32.const 128) "\02\00\00\00J\00\00") + (data $mem_135 (i32.const 135) "\02\00\00\00K\00\00") + (data $mem_142 (i32.const 142) "\02\00\00\00L\00\00") + (data $mem_149 (i32.const 149) "\02\00\00\00M\00\00") + (data $mem_156 (i32.const 156) "\02\00\00\00N\00\00") + (data $mem_163 (i32.const 163) "\02\00\00\00\d1\00\00") + (data $mem_170 (i32.const 170) "\02\00\00\00O\00\00") + (data $mem_177 (i32.const 177) "\02\00\00\00P\00\00") + (data $mem_184 (i32.const 184) "\02\00\00\00Q\00\00") + (data $mem_191 (i32.const 191) "\02\00\00\00V\00\00") + (data $mem_198 (i32.const 198) "\02\00\00\00W\00\00") + (data $mem_205 (i32.const 205) "\02\00\00\00X\00\00") + (data $mem_212 (i32.const 212) "\02\00\00\00Y\00\00") (export "main" (func $test::fixtures::execution::structValuesExtended::main_1)) (func $test::fixtures::execution::structValuesExtended::Color.is_1 (param $self i64) (result i32) (block $B1 (result i32) diff --git a/test/fixtures/execution/traverseTree.lys.optimized.wast b/test/fixtures/execution/traverseTree.lys.optimized.wast index 04e1139..8588a41 100644 --- a/test/fixtures/execution/traverseTree.lys.optimized.wast +++ b/test/fixtures/execution/traverseTree.lys.optimized.wast @@ -4,7 +4,7 @@ (type $2 (func (result i32))) (type $3 (func (param i32))) (type $4 (func (param i64 i32))) - (type $5 (func (param i32 i64) (result i64))) + (type $5 (func (param i32 i64 i64) (result i64))) (type $6 (func (param i64) (result i32))) (import "test" "pushTest" (func $fimport$0 (param i32))) (import "test" "registerAssertion" (func $fimport$1 (param i32 i32))) @@ -14,6 +14,10 @@ (global $global$1 (mut i32) (i32.const 0)) (global $global$2 (mut i32) (i32.const 0)) (global $global$3 (mut i32) (i32.const 0)) + (global $global$4 (mut i32) (i32.const 0)) + (global $global$5 (mut i32) (i32.const 0)) + (global $global$6 (mut i32) (i32.const 0)) + (global $global$7 (mut i32) (i32.const 0)) (memory $0 1) (data $0 (i32.const 139) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d") (data $1 (i32.const 166) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d") @@ -80,17 +84,17 @@ ) ) (func $2 (result i32) - (global.get $global$3) + (global.get $global$7) ) - (func $3 (param $0 i32) (param $1 i64) (result i64) - (local $2 i32) + (func $3 (param $0 i32) (param $1 i64) (param $2 i64) (result i64) (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i64) + (local $6 i32) + (local $7 i64) (if (i32.lt_u - (global.get $global$2) + (global.get $global$4) (i32.const 20) ) (then @@ -99,25 +103,25 @@ ) (if (i32.gt_u - (local.tee $3 + (local.tee $4 (i32.and (i32.add - (global.get $global$1) + (global.get $global$3) (i32.add - (local.tee $2 - (global.get $global$3) + (local.tee $3 + (global.get $global$7) ) (i32.const 36) ) ) (i32.xor - (global.get $global$1) + (global.get $global$3) (i32.const -1) ) ) ) (i32.shl - (local.tee $4 + (local.tee $5 (memory.size) ) (i32.const 16) @@ -127,14 +131,14 @@ (drop (memory.grow (select - (local.get $4) - (local.tee $5 + (local.get $5) + (local.tee $6 (i32.shr_s (i32.and (i32.add (i32.sub + (local.get $4) (local.get $3) - (local.get $2) ) (i32.const 65535) ) @@ -144,23 +148,23 @@ ) ) (i32.gt_u - (local.get $4) (local.get $5) + (local.get $6) ) ) ) ) ) ) - (global.set $global$3 - (local.get $3) + (global.set $global$7 + (local.get $4) ) - (local.set $4 + (local.set $5 (i32.add - (local.tee $2 - (local.tee $3 + (local.tee $3 + (local.tee $4 (i32.add - (local.get $2) + (local.get $3) (i32.const 16) ) ) @@ -171,19 +175,19 @@ (loop $label (if (i32.ne - (local.get $2) - (local.get $4) + (local.get $3) + (local.get $5) ) (then (i32.store8 - (local.get $2) + (local.get $3) (i32.load8_u (i32.const 0) ) ) - (local.set $2 + (local.set $3 (i32.add - (local.get $2) + (local.get $3) (i32.const 1) ) ) @@ -193,10 +197,10 @@ ) (i32.store (i32.wrap_i64 - (local.tee $6 + (local.tee $7 (i64.or (i64.extend_i32_u - (local.get $3) + (local.get $4) ) (i64.const 4294967296) ) @@ -208,7 +212,7 @@ (i32.add (local.tee $0 (i32.wrap_i64 - (local.get $6) + (local.get $7) ) ) (i32.const 4) @@ -220,9 +224,9 @@ (local.get $0) (i32.const 12) ) - (i64.const 8589934592) + (local.get $2) ) - (local.get $6) + (local.get $7) ) (func $4 (param $0 i64) (result i32) (local $1 i32) @@ -249,9 +253,9 @@ ) ) ) - (local.set $2 + (local.set $1 (i32.load - (local.tee $1 + (local.tee $2 (i32.wrap_i64 (local.get $0) ) @@ -261,7 +265,7 @@ (local.set $0 (i64.load (i32.add - (local.get $1) + (local.get $2) (i32.const 12) ) ) @@ -272,12 +276,12 @@ (call $4 (i64.load (i32.add - (local.get $1) + (local.get $2) (i32.const 4) ) ) ) - (local.get $2) + (local.get $1) ) (call $4 (local.get $0) @@ -303,7 +307,9 @@ (call $3 (i32.const 3) (i64.const 8589934592) + (i64.const 8589934592) ) + (i64.const 8589934592) ) ) ) @@ -334,13 +340,37 @@ (i64.const 8589934592) ) (global.set $global$1 - (i32.const 15) + (i32.const 4) ) (global.set $global$2 - (i32.const 1073741824) + (i32.const 16) ) (global.set $global$3 + (i32.sub + (global.get $global$2) + (i32.const 1) + ) + ) + (global.set $global$4 + (i32.const 1073741824) + ) + (global.set $global$5 (i32.const 65536) ) + (global.set $global$6 + (i32.and + (i32.add + (global.get $global$3) + (i32.const 65536) + ) + (i32.xor + (global.get $global$3) + (i32.const -1) + ) + ) + ) + (global.set $global$7 + (global.get $global$6) + ) ) ) diff --git a/test/fixtures/execution/traverseTree.lys.wast b/test/fixtures/execution/traverseTree.lys.wast index 2948448..35b18c5 100644 --- a/test/fixtures/execution/traverseTree.lys.wast +++ b/test/fixtures/execution/traverseTree.lys.wast @@ -165,23 +165,23 @@ ) ) ) - (data 0 (i32.const 139) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 166) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 199) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 226) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 487) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 522) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") - (data 0 (i32.const 563) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") - (data 0 (i32.const 590) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") - (data 0 (i32.const 623) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") - (data 0 (i32.const 650) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") - (data 0 (i32.const 683) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") + (data $mem_139 (i32.const 139) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_166 (i32.const 166) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_199 (i32.const 199) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_226 (i32.const 226) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_259 (i32.const 259) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_294 (i32.const 294) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_335 (i32.const 335) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_370 (i32.const 370) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_411 (i32.const 411) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_446 (i32.const 446) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00L\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_487 (i32.const 487) "\1e\00\00\00 \00 \00g\00i\00v\00e\00n\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_522 (i32.const 522) "$\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00 \00M\00S\00B\00:\00 \00%\00X\00\00") + (data $mem_563 (i32.const 563) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00X\00\00") + (data $mem_590 (i32.const 590) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00X\00\00") + (data $mem_623 (i32.const 623) "\16\00\00\00 \00 \00g\00i\00v\00e\00n\00:\00 \00%\00d\00\00") + (data $mem_650 (i32.const 650) "\1c\00\00\00 \00 \00e\00x\00p\00e\00c\00t\00e\00d\00:\00 \00%\00d\00\00") + (data $mem_683 (i32.const 683) "\1a\00\00\00a\00s\00s\00e\00r\00t\00(\00f\00a\00l\00s\00e\00)\00\00") (global $support::test::lastErrorMessage (mut i64) (i64.const 0)) (export "test_getLastErrorMessage" (func $support::test::getLastErrorMessage_1)) (func $support::test::TestStruct.is_1 (param $a i64) (result i32) @@ -606,11 +606,11 @@ (local.set $end (i32.add (local.get $ptr) (local.get $len))) (block $exit (loop $cont (br_if $exit (i32.eq (local.get $ptr) (local.get $end))) (i32.store8 (local.get $ptr) (i32.load8_u (local.get $content))) (local.set $ptr (i32.add (local.get $ptr) (i32.const 1))) (br $cont))) ) - (data 0 (i32.const 92) "\00\00\00\00\00") - (data 0 (i32.const 97) "\08\00\00\00t\00r\00u\00e\00\00") - (data 0 (i32.const 110) "\0a\00\00\00f\00a\00l\00s\00e\00\00") - (data 0 (i32.const 125) "\02\00\00\000\00\00") - (data 0 (i32.const 132) "\02\00\00\000\00\00") + (data $mem_92 (i32.const 92) "\00\00\00\00\00") + (data $mem_97 (i32.const 97) "\08\00\00\00t\00r\00u\00e\00\00") + (data $mem_110 (i32.const 110) "\0a\00\00\00f\00a\00l\00s\00e\00\00") + (data $mem_125 (i32.const 125) "\02\00\00\000\00\00") + (data $mem_132 (i32.const 132) "\02\00\00\000\00\00") (func $system::core::string::string.length_1 (param $self i64) (result i32) (call $system::core::u32::u32./_1 (call $system::core::u32::u32.load_1 (call $system::core::string::string.as_1 (local.get $self))) (call $system::core::i32::i32.as_4 (i32.const 2))) ) @@ -2087,8 +2087,8 @@ (func $system::core::native::ref.load_2 (param $lhs i64) (param $offset i32) (result i64) (i64.load (i32.add (local.get $offset) (call $system::core::native::addressFromRef_1 (local.get $lhs)))) ) - (data 0 (i32.const 16) "\1a\00\00\00T\00r\00a\00v\00e\00r\00s\00e\00 \00t\00r\00e\00e\00\00") - (data 0 (i32.const 47) "(\00\00\00s\00u\00m\00(\00t\00r\00e\00e\00)\00 \00r\00e\00t\00u\00r\00n\00s\00 \004\005\00\00") + (data $mem_16 (i32.const 16) "\1a\00\00\00T\00r\00a\00v\00e\00r\00s\00e\00 \00t\00r\00e\00e\00\00") + (data $mem_47 (i32.const 47) "(\00\00\00s\00u\00m\00(\00t\00r\00e\00e\00)\00 \00r\00e\00t\00u\00r\00n\00s\00 \004\005\00\00") (export "main" (func $test::fixtures::execution::traverseTree::main_1)) (func $test::fixtures::execution::traverseTree::Tree.is_1 (param $self i64) (result i32) (block $B1 (result i32) From b3e38a658cbf85edf7a4ff37526635c3f50a85f7 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 11:29:52 -0300 Subject: [PATCH 4/8] update golden file --- test/fixtures/compiler/a.lys.optimized.wast | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/fixtures/compiler/a.lys.optimized.wast b/test/fixtures/compiler/a.lys.optimized.wast index 543f3fa..3c34031 100644 --- a/test/fixtures/compiler/a.lys.optimized.wast +++ b/test/fixtures/compiler/a.lys.optimized.wast @@ -13,9 +13,9 @@ (data $3 (i32.const 56) "\02\00\00\000") (export "memory" (memory $0)) (export "test_getMaxMemory" (func $0)) - (export "test" (func $2)) - (export "test0" (func $2)) - (export "testa" (func $1)) + (export "test" (func $1)) + (export "test0" (func $1)) + (export "testa" (func $2)) (export "floatingPoints" (func $3)) (export "addFloat" (func $4)) (export "addInts" (func $5)) @@ -24,12 +24,12 @@ (func $0 (result i32) (global.get $global$0) ) - (func $1 (param $0 i32) (result i32) - (local.get $0) - ) - (func $2 (result i32) + (func $1 (result i32) (i32.const 1) ) + (func $2 (param $0 i32) (result i32) + (local.get $0) + ) (func $3 (param $0 f32) (param $1 f64) (result f32) (local.get $0) ) From 358e98db2c8451f3c0003ae9cffaa6228513a29a Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 11:37:02 -0300 Subject: [PATCH 5/8] build lys-compiler on CI --- .github/workflows/push.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index acc7b3c..0ba9376 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -27,6 +27,16 @@ jobs: run: npm install - name: make test run: make test + - name: Checkout lys-compiler + uses: actions/checkout@v4 + with: + repository: lys-lang/lys-compiler + path: lys-compiler + - name: Build and test lys-compiler + working-directory: ./lys-compiler + run: | + make build LYS=../lys/dist/bin.js + lint: runs-on: ubuntu-latest steps: From 186ffde5813e798c4687eeef8959bf64c0b28d44 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 11:39:50 -0300 Subject: [PATCH 6/8] build lys-compiler on CI --- .github/workflows/push.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 0ba9376..08cadaa 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -27,6 +27,18 @@ jobs: run: npm install - name: make test run: make test + + lys-compiler: + name: lys-compiler build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Use Node.js 22.x + uses: actions/setup-node@v1 + with: + node-version: 22.x + - name: make test + run: make build - name: Checkout lys-compiler uses: actions/checkout@v4 with: @@ -35,8 +47,7 @@ jobs: - name: Build and test lys-compiler working-directory: ./lys-compiler run: | - make build LYS=../lys/dist/bin.js - + make build LYS=../dist/bin.js lint: runs-on: ubuntu-latest steps: From d2320efca17f41b1afa7bcd1a2b16df8bfb81774 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 11:40:44 -0300 Subject: [PATCH 7/8] build lys-compiler on CI --- .github/workflows/push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 08cadaa..0856168 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -37,6 +37,8 @@ jobs: uses: actions/setup-node@v1 with: node-version: 22.x + - name: npm install + run: npm install - name: make test run: make build - name: Checkout lys-compiler From d6da03534a481111e39cf25793ff6a82150d4420 Mon Sep 17 00:00:00 2001 From: menduz Date: Fri, 24 Jan 2025 11:41:34 -0300 Subject: [PATCH 8/8] build lys-compiler on CI --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 0856168..20883b2 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -39,7 +39,7 @@ jobs: node-version: 22.x - name: npm install run: npm install - - name: make test + - name: make build run: make build - name: Checkout lys-compiler uses: actions/checkout@v4