Update binaryen.js and enable tee optimizations

This commit is contained in:
dcodeIO 2017-12-29 04:38:39 +01:00
parent 4207f6460d
commit c67f87a988
15 changed files with 246 additions and 329 deletions

32
package-lock.json generated
View File

@ -33,7 +33,7 @@
"requires": { "requires": {
"@types/events": "1.1.0", "@types/events": "1.1.0",
"@types/minimatch": "3.0.2", "@types/minimatch": "3.0.2",
"@types/node": "8.5.1" "@types/node": "8.5.2"
} }
}, },
"@types/long": { "@types/long": {
@ -55,9 +55,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "8.5.1", "version": "8.5.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.5.2.tgz",
"integrity": "sha512-SrmAO+NhnsuG/6TychSl2VdxBZiw/d6V+8j+DFo8O3PwFi+QeYXWHhAw+b170aSc6zYab6/PjEWRZHIDN9mNUw==", "integrity": "sha512-KA4GKOpgXnrqEH2eCVhiv2CsxgXGQJgV1X0vsGlh+WCnxbeAE1GT44ZsTU1IN5dEeV/gDupKa7gWo08V5IxWVQ==",
"dev": true "dev": true
}, },
"@types/strip-bom": { "@types/strip-bom": {
@ -265,9 +265,9 @@
"dev": true "dev": true
}, },
"binaryen": { "binaryen": {
"version": "40.0.0-nightly.20171209", "version": "40.0.0-nightly.20171229",
"resolved": "https://registry.npmjs.org/binaryen/-/binaryen-40.0.0-nightly.20171209.tgz", "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-40.0.0-nightly.20171229.tgz",
"integrity": "sha512-ELe79ZuH6dPLo+j3tbTvGl9BagzUTtIuYlY3LWz1kj5JzgpqeZmUweay1vK6MZo7J/1IA7Sgda4J7vxUhNu03Q==" "integrity": "sha512-P9VXMphJKRZbdr0AAmkpgRPGVWbnDmcqt8NPuZ+W0eSeC1igGDLdreJteCdtHA7Z+qRQ4BWqtmKPZEJKRZk47w=="
}, },
"bn.js": { "bn.js": {
"version": "4.11.8", "version": "4.11.8",
@ -1314,9 +1314,9 @@
} }
}, },
"make-error": { "make-error": {
"version": "1.3.0", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.0.tgz", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.2.tgz",
"integrity": "sha1-Uq06M5zPEM5itAQLcI/nByRLi5Y=", "integrity": "sha512-l9ra35l5VWLF24y75Tg8XgfGLX0ueRhph118WKM6H5denx4bB5QF59+4UAm9oJ2qsPQZas/CQUDdtDdfvYHBdQ==",
"dev": true "dev": true
}, },
"md5.js": { "md5.js": {
@ -2006,6 +2006,7 @@
"version": "0.5.0", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.0.tgz", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.0.tgz",
"integrity": "sha512-vUoN3I7fHQe0R/SJLKRdKYuEdRGogsviXFkHHo17AWaTGv17VLnxw+CFXvqy+y4ORZ3doWLQcxRYfwKrsd/H7Q==", "integrity": "sha512-vUoN3I7fHQe0R/SJLKRdKYuEdRGogsviXFkHHo17AWaTGv17VLnxw+CFXvqy+y4ORZ3doWLQcxRYfwKrsd/H7Q==",
"dev": true,
"requires": { "requires": {
"source-map": "0.6.1" "source-map": "0.6.1"
}, },
@ -2013,7 +2014,8 @@
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
} }
} }
}, },
@ -2164,15 +2166,15 @@
} }
}, },
"ts-node": { "ts-node": {
"version": "4.0.2", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-4.0.2.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-4.1.0.tgz",
"integrity": "sha512-mg7l6ON8asjnfzkTi1LFWKaOGHl5Jf1+5ij0MQ502YfC6+4FBgh/idJgw9aN9kei1Rf4/pmFpNuFE1YbcQdOTA==", "integrity": "sha512-xcZH12oVg9PShKhy3UHyDmuDLV3y7iKwX25aMVPt1SIXSuAfWkFiGPEkg+th8R4YKW/QCxDoW7lJdb15lx6QWg==",
"dev": true, "dev": true,
"requires": { "requires": {
"arrify": "1.0.1", "arrify": "1.0.1",
"chalk": "2.3.0", "chalk": "2.3.0",
"diff": "3.4.0", "diff": "3.4.0",
"make-error": "1.3.0", "make-error": "1.3.2",
"minimist": "1.2.0", "minimist": "1.2.0",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",
"source-map-support": "0.5.0", "source-map-support": "0.5.0",

View File

@ -11,7 +11,7 @@
"url": "https://github.com/AssemblyScript/assemblyscript/issues" "url": "https://github.com/AssemblyScript/assemblyscript/issues"
}, },
"dependencies": { "dependencies": {
"binaryen": "40.0.0-nightly.20171209", "binaryen": "40.0.0-nightly.20171229",
"glob": "^7.1.2", "glob": "^7.1.2",
"minimist": "^1.2.0" "minimist": "^1.2.0"
}, },
@ -21,13 +21,13 @@
"@types/glob": "^5.0.34", "@types/glob": "^5.0.34",
"@types/long": "^3.0.32", "@types/long": "^3.0.32",
"@types/minimist": "^1.2.0", "@types/minimist": "^1.2.0",
"@types/node": "^8.5.1", "@types/node": "^8.5.2",
"chalk": "^2.3.0", "chalk": "^2.3.0",
"diff": "^3.4.0", "diff": "^3.4.0",
"long": "^3.2.0", "long": "^3.2.0",
"source-map-support": "^0.5.0", "source-map-support": "^0.5.0",
"ts-loader": "^3.2.0", "ts-loader": "^3.2.0",
"ts-node": "^4.0.2", "ts-node": "^4.1.0",
"tslint": "^5.8.0", "tslint": "^5.8.0",
"typescript": "^2.6.2", "typescript": "^2.6.2",
"webpack": "^3.10.0" "webpack": "^3.10.0"
@ -38,7 +38,7 @@
"asc": "bin/asc" "asc": "bin/asc"
}, },
"engines": { "engines": {
"node" : ">=8" "node": ">=8"
}, },
"scripts": { "scripts": {
"build": "webpack", "build": "webpack",

View File

@ -1028,7 +1028,7 @@ export class StringLiteralExpression extends LiteralExpression {
value: string; value: string;
serialize(sb: string[]): void { serialize(sb: string[]): void {
sb.push(escapeString(this.value)); sb.push(stringToLiteral(this.value));
} }
} }
@ -2181,19 +2181,93 @@ function builderEndsWith(sb: string[], code: CharCode): bool {
return false; return false;
} }
/** Escapes a string to a string literal. */ /** Converts a string to its literal representation including quotes. */
export function escapeString(str: string): string { export function stringToLiteral(str: string): string {
var k = str.length; var ret = new Array<string>();
var ret = new Array<string>(k); var off = 0;
for (var i = 0, c: string; i < k; ++i) { for (var i = 0, k = str.length; i < k;) {
switch (c = str.charAt(i)) { switch (str.charCodeAt(i)) {
case "\\": ret[i] = "\\\\"; break;
case "\"": ret[i] = "\\\""; break; case CharCode.NULL:
case "\r": ret[i] = "\\r"; break; if (i > off)
case "\n": ret[i] = "\\n"; break; ret.push(str.substring(off, off = i + 1));
case "\0": ret[i] = "\\0"; break; ret.push("\\0");
default: ret[i] = c; off = ++i;
break;
case CharCode.BACKSPACE:
if (i > off)
ret.push(str.substring(off, i));
off = ++i;
ret.push("\\b");
break;
case CharCode.TAB:
if (i > off)
ret.push(str.substring(off, i));
off = ++i;
ret.push("\\t");
break;
case CharCode.LINEFEED:
if (i > off)
ret.push(str.substring(off, i));
off = ++i;
ret.push("\\n");
break;
case CharCode.VERTICALTAB:
if (i > off)
ret.push(str.substring(off, i));
off = ++i;
ret.push("\\v");
break;
case CharCode.FORMFEED:
if (i > off)
ret.push(str.substring(off, i));
off = ++i;
ret.push("\\f");
break;
case CharCode.CARRIAGERETURN:
if (i > off)
ret.push(str.substring(off, i));
ret.push("\\r");
off = ++i;
break;
case CharCode.DOUBLEQUOTE:
if (i > off)
ret.push(str.substring(off, i));
ret.push("\\\"");
off = ++i;
break;
case CharCode.SINGLEQUOTE:
if (i > off)
ret.push(str.substring(off, i));
ret.push("\\'");
off = ++i;
break;
case CharCode.BACKSLASH:
if (i > off)
ret.push(str.substring(off, i));
ret.push("\\\\");
off = ++i;
break;
default:
++i;
break;
} }
} }
if (off == 0) {
assert(ret.length == 0);
return "\"" + str + "\"";
}
if (i > off)
ret.push(str.substring(off, i));
return "\"" + ret.join("") + "\""; return "\"" + ret.join("") + "\"";
} }

View File

@ -1573,19 +1573,19 @@ export class Compiler extends DiagnosticEmitter {
left = this.compileExpression(expression.left, contextualType, ConversionKind.NONE); left = this.compileExpression(expression.left, contextualType, ConversionKind.NONE);
right = this.compileExpression(expression.right, this.currentType); right = this.compileExpression(expression.right, this.currentType);
// simplify if left is free of side effects while tolerating two levels of nesting, e.g., i32.load(i32.load(i32.const)) // simplify if left is free of side effects while tolerating one level of nesting, e.g., i32.load(i32.const)
// if (condition = this.module.cloneExpression(left, true, 2)) if (condition = this.module.cloneExpression(left, true, 1))
// return this.module.createIf( return this.module.createIf(
// this.currentType.isLongInteger this.currentType.isLongInteger
// ? this.module.createBinary(BinaryOp.NeI64, condition, this.module.createI64(0, 0)) ? this.module.createBinary(BinaryOp.NeI64, condition, this.module.createI64(0, 0))
// : this.currentType == Type.f64 : this.currentType == Type.f64
// ? this.module.createBinary(BinaryOp.NeF64, condition, this.module.createF64(0)) ? this.module.createBinary(BinaryOp.NeF64, condition, this.module.createF64(0))
// : this.currentType == Type.f32 : this.currentType == Type.f32
// ? this.module.createBinary(BinaryOp.NeF32, condition, this.module.createF32(0)) ? this.module.createBinary(BinaryOp.NeF32, condition, this.module.createF32(0))
// : condition, // usual case: saves one EQZ when not using EQZ above : condition, // usual case: saves one EQZ when not using EQZ above
// right, right,
// left left
// ); );
// otherwise use a temporary local for the intermediate value // otherwise use a temporary local for the intermediate value
tempLocal = this.currentFunction.getAndFreeTempLocal(this.currentType); tempLocal = this.currentFunction.getAndFreeTempLocal(this.currentType);
@ -1606,19 +1606,19 @@ export class Compiler extends DiagnosticEmitter {
left = this.compileExpression(expression.left, contextualType, ConversionKind.NONE); left = this.compileExpression(expression.left, contextualType, ConversionKind.NONE);
right = this.compileExpression(expression.right, this.currentType); right = this.compileExpression(expression.right, this.currentType);
// simplify if left is free of side effects while tolerating two levels of nesting // simplify if left is free of side effects while tolerating one level of nesting
// if (condition = this.module.cloneExpression(left, true, 2)) if (condition = this.module.cloneExpression(left, true, 1))
// return this.module.createIf( return this.module.createIf(
// this.currentType.isLongInteger this.currentType.isLongInteger
// ? this.module.createBinary(BinaryOp.NeI64, condition, this.module.createI64(0, 0)) ? this.module.createBinary(BinaryOp.NeI64, condition, this.module.createI64(0, 0))
// : this.currentType == Type.f64 : this.currentType == Type.f64
// ? this.module.createBinary(BinaryOp.NeF64, condition, this.module.createF64(0)) ? this.module.createBinary(BinaryOp.NeF64, condition, this.module.createF64(0))
// : this.currentType == Type.f32 : this.currentType == Type.f32
// ? this.module.createBinary(BinaryOp.NeF32, condition, this.module.createF32(0)) ? this.module.createBinary(BinaryOp.NeF32, condition, this.module.createF32(0))
// : condition, // usual case: saves one EQZ when not using EQZ above : condition, // usual case: saves one EQZ when not using EQZ above
// left, left,
// right right
// ); );
// otherwise use a temporary local for the intermediate value // otherwise use a temporary local for the intermediate value
tempLocal = this.currentFunction.getAndFreeTempLocal(this.currentType); tempLocal = this.currentFunction.getAndFreeTempLocal(this.currentType);

View File

@ -15,33 +15,15 @@ export type ImportRef = usize;
export type ExportRef = usize; export type ExportRef = usize;
export type Index = u32; export type Index = u32;
// snip... export enum NativeType {
declare function _BinaryenNone(): NativeType; None = _BinaryenTypeNone(),
declare function _BinaryenInt32(): NativeType; I32 = _BinaryenTypeInt32(),
declare function _BinaryenInt64(): NativeType; I64 = _BinaryenTypeInt64(),
declare function _BinaryenFloat32(): NativeType; F32 = _BinaryenTypeFloat32(),
declare function _BinaryenFloat64(): NativeType; F64 = _BinaryenTypeFloat64(),
declare function _BinaryenUndefined(): NativeType; Unreachable = _BinaryenTypeUnreachable(),
export enum NativeType { Auto = _BinaryenTypeAuto()
None = _BinaryenNone(),
I32 = _BinaryenInt32(),
I64 = _BinaryenInt64(),
F32 = _BinaryenFloat32(),
F64 = _BinaryenFloat64(),
Unreachable = 5,
Auto = _BinaryenUndefined()
} }
// ...snap, once binaryen is updated
// export enum NativeType {
// None = _BinaryenTypeNone(),
// I32 = _BinaryenTypeInt32(),
// I64 = _BinaryenTypeInt64(),
// F32 = _BinaryenTypeFloat32(),
// F64 = _BinaryenTypeFloat64(),
// Unreachable = _BinaryenTypeUnreachable(),
// Auto = _BinaryenTypeAuto()
// }
export enum ExpressionId { export enum ExpressionId {
Invalid = _BinaryenInvalidId(), Invalid = _BinaryenInvalidId(),
@ -828,28 +810,35 @@ export class Module {
case NativeType.I64: return this.createI64(_BinaryenConstGetValueI64Low(expr), _BinaryenConstGetValueI64High(expr)); case NativeType.I64: return this.createI64(_BinaryenConstGetValueI64Low(expr), _BinaryenConstGetValueI64High(expr));
case NativeType.F32: return this.createF32(_BinaryenConstGetValueF32(expr)); case NativeType.F32: return this.createF32(_BinaryenConstGetValueF32(expr));
case NativeType.F64: return this.createF64(_BinaryenConstGetValueF64(expr)); case NativeType.F64: return this.createF64(_BinaryenConstGetValueF64(expr));
default: throw new Error("unexpected constant type"); default: throw new Error("concrete type expected");
} }
case ExpressionId.GetLocal: case ExpressionId.GetLocal:
return _BinaryenGetLocal(this.ref, _BinaryenGetLocalGetIndex(expr), _BinaryenExpressionGetType(expr)); return _BinaryenGetLocal(this.ref, _BinaryenGetLocalGetIndex(expr), _BinaryenExpressionGetType(expr));
// case ExpressionId.GetGlobal: explodes if it doesn't have a name case ExpressionId.GetGlobal:
// return _BinaryenGetGlobal(this.ref, _BinaryenGetGlobalGetName(expr), _BinaryenExpressionGetType(expr)); var globalName = _BinaryenGetGlobalGetName(expr);
if (!globalName)
break;
return _BinaryenGetGlobal(this.ref, globalName, _BinaryenExpressionGetType(expr));
case ExpressionId.Load: case ExpressionId.Load:
if (!(nested1 = this.cloneExpression(_BinaryenLoadGetPtr(expr), noSideEffects, maxDepth - 1))) break; if (!(nested1 = this.cloneExpression(_BinaryenLoadGetPtr(expr), noSideEffects, maxDepth - 1)))
break;
return _BinaryenLoadIsAtomic(expr) return _BinaryenLoadIsAtomic(expr)
? _BinaryenAtomicLoad(this.ref, _BinaryenLoadGetBytes(expr), _BinaryenLoadGetOffset(expr), _BinaryenExpressionGetType(expr), nested1) ? _BinaryenAtomicLoad(this.ref, _BinaryenLoadGetBytes(expr), _BinaryenLoadGetOffset(expr), _BinaryenExpressionGetType(expr), nested1)
: _BinaryenLoad(this.ref, _BinaryenLoadGetBytes(expr), _BinaryenLoadIsSigned(expr) ? 1 : 0, _BinaryenLoadGetOffset(expr), _BinaryenLoadGetAlign(expr), _BinaryenExpressionGetType(expr), nested1); : _BinaryenLoad(this.ref, _BinaryenLoadGetBytes(expr), _BinaryenLoadIsSigned(expr) ? 1 : 0, _BinaryenLoadGetOffset(expr), _BinaryenLoadGetAlign(expr), _BinaryenExpressionGetType(expr), nested1);
case ExpressionId.Unary: case ExpressionId.Unary:
if (!(nested1 = this.cloneExpression(_BinaryenUnaryGetValue(expr), noSideEffects, maxDepth - 1))) break; if (!(nested1 = this.cloneExpression(_BinaryenUnaryGetValue(expr), noSideEffects, maxDepth - 1)))
break;
return _BinaryenUnary(this.ref, _BinaryenUnaryGetOp(expr), nested1); return _BinaryenUnary(this.ref, _BinaryenUnaryGetOp(expr), nested1);
case ExpressionId.Binary: case ExpressionId.Binary:
if (!(nested1 = this.cloneExpression(_BinaryenBinaryGetLeft(expr), noSideEffects, maxDepth - 1))) break; if (!(nested1 = this.cloneExpression(_BinaryenBinaryGetLeft(expr), noSideEffects, maxDepth - 1)))
if (!(nested2 = this.cloneExpression(_BinaryenBinaryGetRight(expr), noSideEffects, maxDepth - 1))) break; break;
if (!(nested2 = this.cloneExpression(_BinaryenBinaryGetRight(expr), noSideEffects, maxDepth - 1)))
break;
return _BinaryenBinary(this.ref, _BinaryenBinaryGetOp(expr), nested1, nested2); return _BinaryenBinary(this.ref, _BinaryenBinaryGetOp(expr), nested1, nested2);
} }
return 0; return 0;

View File

@ -31,13 +31,13 @@
(local $5 i32) (local $5 i32)
(local $6 i32) (local $6 i32)
(local $7 i32) (local $7 i32)
(set_local $6 (set_local $5
(i32.sub (i32.sub
(get_global $../../examples/game-of-life/assembly/game-of-life/h) (get_global $../../examples/game-of-life/assembly/game-of-life/h)
(i32.const 1) (i32.const 1)
) )
) )
(set_local $7 (set_local $6
(i32.sub (i32.sub
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
(i32.const 1) (i32.const 1)
@ -53,17 +53,17 @@
(get_global $../../examples/game-of-life/assembly/game-of-life/h) (get_global $../../examples/game-of-life/assembly/game-of-life/h)
) )
(block (block
(set_local $4 (set_local $3
(select (select
(i32.sub (i32.sub
(get_local $0) (get_local $0)
(i32.const 1) (i32.const 1)
) )
(get_local $6) (get_local $5)
(get_local $0) (get_local $0)
) )
) )
(set_local $5 (set_local $4
(select (select
(i32.const 0) (i32.const 0)
(i32.add (i32.add
@ -72,7 +72,7 @@
) )
(i32.eq (i32.eq
(get_local $0) (get_local $0)
(get_local $6) (get_local $5)
) )
) )
) )
@ -97,7 +97,7 @@
(i32.load8_u (i32.load8_u
(i32.add (i32.add
(i32.mul (i32.mul
(get_local $4) (get_local $3)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(tee_local $2 (tee_local $2
@ -106,7 +106,7 @@
(get_local $1) (get_local $1)
(i32.const 1) (i32.const 1)
) )
(get_local $7) (get_local $6)
(get_local $1) (get_local $1)
) )
) )
@ -115,7 +115,7 @@
(i32.load8_u (i32.load8_u
(i32.add (i32.add
(i32.mul (i32.mul
(get_local $4) (get_local $3)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(get_local $1) (get_local $1)
@ -125,10 +125,10 @@
(i32.load8_u (i32.load8_u
(i32.add (i32.add
(i32.mul (i32.mul
(get_local $4) (get_local $3)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(tee_local $3 (tee_local $7
(select (select
(i32.const 0) (i32.const 0)
(i32.add (i32.add
@ -137,7 +137,7 @@
) )
(i32.eq (i32.eq
(get_local $1) (get_local $1)
(get_local $7) (get_local $6)
) )
) )
) )
@ -160,14 +160,14 @@
(get_local $0) (get_local $0)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(get_local $3) (get_local $7)
) )
) )
) )
(i32.load8_u (i32.load8_u
(i32.add (i32.add
(i32.mul (i32.mul
(get_local $5) (get_local $4)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(get_local $2) (get_local $2)
@ -177,7 +177,7 @@
(i32.load8_u (i32.load8_u
(i32.add (i32.add
(i32.mul (i32.mul
(get_local $5) (get_local $4)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(get_local $1) (get_local $1)
@ -187,10 +187,10 @@
(i32.load8_u (i32.load8_u
(i32.add (i32.add
(i32.mul (i32.mul
(get_local $5) (get_local $4)
(get_global $../../examples/game-of-life/assembly/game-of-life/w) (get_global $../../examples/game-of-life/assembly/game-of-life/w)
) )
(get_local $3) (get_local $7)
) )
) )
) )
@ -207,13 +207,14 @@
) )
(if (if
(if (result i32) (if (result i32)
(tee_local $3 (i32.lt_u
(i32.lt_u (get_local $2)
(get_local $2) (i32.const 2)
(i32.const 2) )
) (i32.lt_u
(get_local $2)
(i32.const 2)
) )
(get_local $3)
(i32.gt_u (i32.gt_u
(get_local $2) (get_local $2)
(i32.const 3) (i32.const 3)

View File

@ -35,7 +35,6 @@
(local $8 i32) (local $8 i32)
(local $9 i32) (local $9 i32)
(local $10 i32) (local $10 i32)
(local $11 i32)
(nop) (nop)
(nop) (nop)
(block (block
@ -236,13 +235,14 @@
(get_local $9) (get_local $9)
(if (if
(if (result i32) (if (result i32)
(tee_local $11 (i32.lt_u
(i32.lt_u (get_local $8)
(get_local $8) (i32.const 2)
(i32.const 2) )
) (i32.lt_u
(get_local $8)
(i32.const 2)
) )
(get_local $11)
(i32.gt_u (i32.gt_u
(get_local $8) (get_local $8)
(i32.const 3) (i32.const 3)

View File

@ -10,27 +10,10 @@
(func $start (; 0 ;) (type $v) (func $start (; 0 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 f64) (local $1 f64)
(local $2 i64)
(local $3 f32)
(if
(tee_local $0
(i32.const 0)
)
(unreachable)
)
(if
(f64.ne
(tee_local $1
(f64.const 0)
)
(f64.const 0)
)
(unreachable)
)
(if (if
(i32.eqz (i32.eqz
(tee_local $0 (tee_local $0
(i32.const 1) (i32.const 2)
) )
) )
(unreachable) (unreachable)
@ -38,52 +21,14 @@
(if (if
(f64.eq (f64.eq
(tee_local $1 (tee_local $1
(f64.const 1) (f64.const 2)
)
(f64.const 0)
)
(unreachable)
)
(if
(i32.eqz
(if (result i32)
(tee_local $0
(i32.const 1)
)
(tee_local $0
(i32.const 2)
)
(get_local $0)
)
)
(unreachable)
)
(if
(f64.eq
(if (result f64)
(f64.ne
(tee_local $1
(f64.const 1)
)
(f64.const 0)
)
(tee_local $1
(f64.const 2)
)
(get_local $1)
) )
(f64.const 0) (f64.const 0)
) )
(unreachable) (unreachable)
) )
(set_global $logical/i (set_global $logical/i
(if (result i32) (i32.const 2)
(tee_local $0
(i32.const 1)
)
(i32.const 2)
(get_local $0)
)
) )
(if (if
(i32.ne (i32.ne
@ -93,13 +38,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/i (set_global $logical/i
(if (result i32) (i32.const 1)
(tee_local $0
(i32.const 0)
)
(get_local $0)
(i32.const 1)
)
) )
(if (if
(i32.ne (i32.ne
@ -109,16 +48,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/I (set_global $logical/I
(if (result i64) (i64.const 2)
(i64.ne
(tee_local $2
(i64.const 1)
)
(i64.const 0)
)
(i64.const 2)
(get_local $2)
)
) )
(if (if
(i64.ne (i64.ne
@ -128,16 +58,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/I (set_global $logical/I
(if (result i64) (i64.const 1)
(i64.ne
(tee_local $2
(i64.const 0)
)
(i64.const 0)
)
(get_local $2)
(i64.const 1)
)
) )
(if (if
(i64.ne (i64.ne
@ -147,16 +68,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/f (set_global $logical/f
(if (result f32) (f32.const 2)
(f32.ne
(tee_local $3
(f32.const 1)
)
(f32.const 0)
)
(f32.const 2)
(get_local $3)
)
) )
(if (if
(f32.ne (f32.ne
@ -166,16 +78,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/f (set_global $logical/f
(if (result f32) (f32.const 1)
(f32.ne
(tee_local $3
(f32.const 0)
)
(f32.const 0)
)
(get_local $3)
(f32.const 1)
)
) )
(if (if
(f32.ne (f32.ne
@ -185,16 +88,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/F (set_global $logical/F
(if (result f64) (f64.const 2)
(f64.ne
(tee_local $1
(f64.const 1)
)
(f64.const 0)
)
(f64.const 2)
(get_local $1)
)
) )
(if (if
(f64.ne (f64.ne
@ -204,16 +98,7 @@
(unreachable) (unreachable)
) )
(set_global $logical/F (set_global $logical/F
(if (result f64) (f64.const 1)
(f64.ne
(tee_local $1
(f64.const 0)
)
(f64.const 0)
)
(get_local $1)
(f64.const 1)
)
) )
(if (if
(f64.ne (f64.ne

View File

@ -11,47 +11,37 @@
(func $start (; 0 ;) (type $v) (func $start (; 0 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 f64) (local $1 f64)
(local $2 i64)
(local $3 f32)
(drop (drop
(if (result i32) (if (result i32)
(tee_local $0 (i32.const 0)
(i32.const 0)
)
(unreachable) (unreachable)
(get_local $0) (i32.const 0)
) )
) )
(drop (drop
(if (result f64) (if (result f64)
(f64.ne (f64.ne
(tee_local $1 (f64.const 0)
(f64.const 0)
)
(f64.const 0) (f64.const 0)
) )
(unreachable) (unreachable)
(get_local $1) (f64.const 0)
) )
) )
(drop (drop
(if (result i32) (if (result i32)
(tee_local $0 (i32.const 1)
(i32.const 1) (i32.const 1)
)
(get_local $0)
(unreachable) (unreachable)
) )
) )
(drop (drop
(if (result f64) (if (result f64)
(f64.ne (f64.ne
(tee_local $1 (f64.const 1)
(f64.const 1)
)
(f64.const 0) (f64.const 0)
) )
(get_local $1) (f64.const 1)
(unreachable) (unreachable)
) )
) )
@ -59,11 +49,9 @@
(if (result i32) (if (result i32)
(tee_local $0 (tee_local $0
(if (result i32) (if (result i32)
(tee_local $0 (i32.const 1)
(i32.const 1)
)
(i32.const 2) (i32.const 2)
(get_local $0) (i32.const 1)
) )
) )
(get_local $0) (get_local $0)
@ -76,13 +64,11 @@
(tee_local $1 (tee_local $1
(if (result f64) (if (result f64)
(f64.ne (f64.ne
(tee_local $1 (f64.const 1)
(f64.const 1)
)
(f64.const 0) (f64.const 0)
) )
(f64.const 2) (f64.const 2)
(get_local $1) (f64.const 1)
) )
) )
(f64.const 0) (f64.const 0)
@ -93,11 +79,9 @@
) )
(set_global $logical/i (set_global $logical/i
(if (result i32) (if (result i32)
(tee_local $0 (i32.const 1)
(i32.const 1)
)
(i32.const 2) (i32.const 2)
(get_local $0) (i32.const 1)
) )
) )
(if (if
@ -111,10 +95,8 @@
) )
(set_global $logical/i (set_global $logical/i
(if (result i32) (if (result i32)
(tee_local $0 (i32.const 0)
(i32.const 0) (i32.const 0)
)
(get_local $0)
(i32.const 1) (i32.const 1)
) )
) )
@ -130,13 +112,11 @@
(set_global $logical/I (set_global $logical/I
(if (result i64) (if (result i64)
(i64.ne (i64.ne
(tee_local $2 (i64.const 1)
(i64.const 1)
)
(i64.const 0) (i64.const 0)
) )
(i64.const 2) (i64.const 2)
(get_local $2) (i64.const 1)
) )
) )
(if (if
@ -151,12 +131,10 @@
(set_global $logical/I (set_global $logical/I
(if (result i64) (if (result i64)
(i64.ne (i64.ne
(tee_local $2 (i64.const 0)
(i64.const 0)
)
(i64.const 0) (i64.const 0)
) )
(get_local $2) (i64.const 0)
(i64.const 1) (i64.const 1)
) )
) )
@ -172,13 +150,11 @@
(set_global $logical/f (set_global $logical/f
(if (result f32) (if (result f32)
(f32.ne (f32.ne
(tee_local $3 (f32.const 1)
(f32.const 1)
)
(f32.const 0) (f32.const 0)
) )
(f32.const 2) (f32.const 2)
(get_local $3) (f32.const 1)
) )
) )
(if (if
@ -193,12 +169,10 @@
(set_global $logical/f (set_global $logical/f
(if (result f32) (if (result f32)
(f32.ne (f32.ne
(tee_local $3 (f32.const 0)
(f32.const 0)
)
(f32.const 0) (f32.const 0)
) )
(get_local $3) (f32.const 0)
(f32.const 1) (f32.const 1)
) )
) )
@ -214,13 +188,11 @@
(set_global $logical/F (set_global $logical/F
(if (result f64) (if (result f64)
(f64.ne (f64.ne
(tee_local $1 (f64.const 1)
(f64.const 1)
)
(f64.const 0) (f64.const 0)
) )
(f64.const 2) (f64.const 2)
(get_local $1) (f64.const 1)
) )
) )
(if (if
@ -235,12 +207,10 @@
(set_global $logical/F (set_global $logical/F
(if (result f64) (if (result f64)
(f64.ne (f64.ne
(tee_local $1 (f64.const 0)
(f64.const 0)
)
(f64.const 0) (f64.const 0)
) )
(get_local $1) (f64.const 0)
(f64.const 1) (f64.const 1)
) )
) )

View File

@ -19,14 +19,12 @@
(loop $continue|0 (loop $continue|0
(if (if
(if (result i32) (if (result i32)
(tee_local $1 (get_local $2)
(get_local $2)
)
(i32.rem_u (i32.rem_u
(get_local $3) (get_local $3)
(i32.const 4) (i32.const 4)
) )
(get_local $1) (get_local $2)
) )
(block (block
(set_local $4 (set_local $4

View File

@ -27,14 +27,12 @@
(loop $continue|0 (loop $continue|0
(if (if
(if (result i32) (if (result i32)
(tee_local $7 (get_local $2)
(get_local $2)
)
(i32.rem_u (i32.rem_u
(get_local $4) (get_local $4)
(i32.const 4) (i32.const 4)
) )
(get_local $7) (get_local $2)
) )
(block (block
(block (block

View File

@ -473,14 +473,12 @@
(loop $continue|0 (loop $continue|0
(if (if
(if (result i32) (if (result i32)
(tee_local $3 (get_local $2)
(get_local $2)
)
(i32.rem_u (i32.rem_u
(get_local $1) (get_local $1)
(i32.const 4) (i32.const 4)
) )
(get_local $3) (get_local $2)
) )
(block (block
(set_local $4 (set_local $4
@ -2049,7 +2047,6 @@
(get_local $0) (get_local $0)
) )
(func $std:heap/Heap.compare (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (func $std:heap/Heap.compare (; 3 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(if (if
(i32.eq (i32.eq
(get_local $0) (get_local $0)
@ -2062,9 +2059,7 @@
(loop $continue|0 (loop $continue|0
(if (if
(if (result i32) (if (result i32)
(tee_local $3 (get_local $2)
(get_local $2)
)
(i32.eq (i32.eq
(i32.load8_u (i32.load8_u
(get_local $0) (get_local $0)
@ -2073,7 +2068,7 @@
(get_local $1) (get_local $1)
) )
) )
(get_local $3) (get_local $2)
) )
(block (block
(set_local $2 (set_local $2

View File

@ -528,14 +528,12 @@
(loop $continue|0 (loop $continue|0
(if (if
(if (result i32) (if (result i32)
(tee_local $6 (get_local $2)
(get_local $2)
)
(i32.rem_u (i32.rem_u
(get_local $1) (get_local $1)
(i32.const 4) (i32.const 4)
) )
(get_local $6) (get_local $2)
) )
(block (block
(block (block
@ -2346,9 +2344,7 @@
(loop $continue|0 (loop $continue|0
(if (if
(if (result i32) (if (result i32)
(tee_local $3 (get_local $2)
(get_local $2)
)
(i32.eq (i32.eq
(i32.load8_u (i32.load8_u
(get_local $0) (get_local $0)
@ -2357,7 +2353,7 @@
(get_local $1) (get_local $1)
) )
) )
(get_local $3) (get_local $2)
) )
(block (block
(block (block

View File

@ -45,3 +45,8 @@
0b0; 0b0;
0b1; 0b1;
0b1111111111111111111111111111111; 0b1111111111111111111111111111111;
"123";
"1\"23";
"1\"2\\3";
"\0\n\\n\r";

View File

@ -45,3 +45,7 @@
0; 0;
1; 1;
2147483647; 2147483647;
"123";
"1\"23";
"1\"2\\3";
"\0\n\\n\r";