Add a 'call_indirect' builtin to emit arbitrary calls (might trap at runtime); Optimize 'for' loop compilation a bit

This commit is contained in:
dcodeIO 2018-05-25 15:59:17 +02:00
parent 51ede113dd
commit 7ad13f9d65
47 changed files with 3311 additions and 22111 deletions

2
dist/asc.js vendored

File diff suppressed because one or more lines are too long

2
dist/asc.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2203,6 +2203,65 @@ export function compileCall(
flow.unset(FlowFlags.UNCHECKED_CONTEXT); flow.unset(FlowFlags.UNCHECKED_CONTEXT);
return ret; return ret;
} }
case "call_indirect": { // call_indirect<T?>(target: Function | u32, ...args: *[]) -> T
if (operands.length < 1) {
if (typeArguments) {
if (typeArguments.length) compiler.currentType = typeArguments[0];
if (typeArguments.length != 1) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
);
}
}
compiler.error(
DiagnosticCode.Expected_at_least_0_arguments_but_got_1,
reportNode.range, "1", operands.length.toString(10)
);
return module.createUnreachable();
}
let returnType: Type;
if (typeArguments) {
if (typeArguments.length != 1) {
if (typeArguments.length) compiler.currentType = typeArguments[0];
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
);
return module.createUnreachable();
}
returnType = typeArguments[0];
} else {
returnType = contextualType;
}
arg0 = compiler.compileExpressionRetainType(operands[0], Type.u32, WrapMode.NONE);
if (compiler.currentType.kind != TypeKind.U32) {
compiler.error(
DiagnosticCode.Operation_not_supported,
operands[0].range
);
return module.createUnreachable();
}
let numOperands = operands.length - 1;
let operandExprs = new Array<ExpressionRef>(numOperands);
let signatureParts = new Array<string>(numOperands + 1);
let nativeReturnType = returnType.toNativeType();
let nativeParamTypes = new Array<NativeType>(numOperands);
for (let i = 0; i < numOperands; ++i) {
operandExprs[i] = compiler.compileExpressionRetainType(operands[1 + i], Type.i32, WrapMode.NONE);
let operandType = compiler.currentType;
signatureParts[i] = operandType.toSignatureString();
nativeParamTypes[i] = operandType.toNativeType();
}
signatureParts[numOperands] = returnType.toSignatureString();
let typeName = signatureParts.join("");
let typeRef = module.getFunctionTypeBySignature(nativeReturnType, nativeParamTypes);
if (!typeRef) typeRef = module.addFunctionType(typeName, nativeReturnType, nativeParamTypes);
compiler.currentType = returnType;
// of course this can easily result in a 'RuntimeError: function signature mismatch' trap and
// thus must be used with care. it exists because it *might* be useful in specific scenarios.
return module.createCallIndirect(arg0, operandExprs, typeName);
}
// conversions // conversions

View File

@ -859,10 +859,10 @@ export class Compiler extends DiagnosticEmitter {
/** Compiles a readily resolved function instance. */ /** Compiles a readily resolved function instance. */
compileFunction(instance: Function): bool { compileFunction(instance: Function): bool {
if (instance.is(CommonFlags.COMPILED)) return true; if (instance.is(CommonFlags.COMPILED)) return true;
assert(!instance.is(CommonFlags.AMBIENT | CommonFlags.BUILTIN) || instance.internalName == "abort"); assert(!instance.is(CommonFlags.AMBIENT | CommonFlags.BUILTIN));
instance.set(CommonFlags.COMPILED); instance.set(CommonFlags.COMPILED);
// check that modifiers are matching but still compile as-is // check that modifiers are matching
var declaration = instance.prototype.declaration; var declaration = instance.prototype.declaration;
var body = declaration.body; var body = declaration.body;
if (body) { if (body) {
@ -1601,13 +1601,13 @@ export class Compiler extends DiagnosticEmitter {
flow.breakLabel = breakLabel; flow.breakLabel = breakLabel;
var continueLabel = "continue|" + label; var continueLabel = "continue|" + label;
flow.continueLabel = continueLabel; flow.continueLabel = continueLabel;
var loopLabel = "loop|" + label; var repeatLabel = "repeat|" + label;
// Compile in correct order // Compile in correct order
var module = this.module; var module = this.module;
var initExpr = statement.initializer var initExpr = statement.initializer
? this.compileStatement(<Statement>statement.initializer) ? this.compileStatement(<Statement>statement.initializer)
: module.createNop(); : 0;
var condExpr: ExpressionRef = 0; var condExpr: ExpressionRef = 0;
var alwaysTrue = true; var alwaysTrue = true;
if (statement.condition) { if (statement.condition) {
@ -1635,7 +1635,7 @@ export class Compiler extends DiagnosticEmitter {
} }
var incrExpr = statement.incrementor var incrExpr = statement.incrementor
? this.compileExpression(<Expression>statement.incrementor, Type.void, ConversionKind.IMPLICIT, WrapMode.NONE) ? this.compileExpression(<Expression>statement.incrementor, Type.void, ConversionKind.IMPLICIT, WrapMode.NONE)
: module.createNop(); : 0;
var bodyExpr = this.compileStatement(statement.statement); var bodyExpr = this.compileStatement(statement.statement);
// Switch back to the parent flow // Switch back to the parent flow
@ -1644,19 +1644,35 @@ export class Compiler extends DiagnosticEmitter {
currentFunction.flow = parentFlow; currentFunction.flow = parentFlow;
currentFunction.leaveBreakContext(); currentFunction.leaveBreakContext();
var expr = module.createBlock(breakLabel, [ var breakBlock = new Array<ExpressionRef>(); // outer 'break' block
initExpr, if (initExpr) breakBlock.push(initExpr);
module.createLoop(loopLabel,
module.createBlock(null, [ var repeatBlock = new Array<ExpressionRef>(); // block repeating the loop
module.createBlock(continueLabel, [ if (parentFlow.isAny(FlowFlags.CONTINUES | FlowFlags.CONDITIONALLY_CONTINUES)) {
module.createBreak(breakLabel, module.createUnary(UnaryOp.EqzI32, condExpr)), repeatBlock.push(
bodyExpr module.createBlock(continueLabel, [ // inner 'continue' block
], NativeType.None), module.createBreak(breakLabel, module.createUnary(UnaryOp.EqzI32, condExpr)),
incrExpr, bodyExpr
module.createBreak(loopLabel)
], NativeType.None) ], NativeType.None)
);
} else { // can omit the 'continue' block
repeatBlock.push(
module.createBreak(breakLabel, module.createUnary(UnaryOp.EqzI32, condExpr))
);
repeatBlock.push(bodyExpr);
}
if (incrExpr) repeatBlock.push(incrExpr);
repeatBlock.push(
module.createBreak(repeatLabel)
);
breakBlock.push(
module.createLoop(repeatLabel,
module.createBlock(null, repeatBlock, NativeType.None)
) )
], NativeType.None); );
var expr = module.createBlock(breakLabel, breakBlock, NativeType.None);
// If the loop is guaranteed to run and return, append a hint for Binaryen // If the loop is guaranteed to run and return, append a hint for Binaryen
if (flow.isAny(FlowFlags.RETURNS | FlowFlags.THROWS)) { if (flow.isAny(FlowFlags.RETURNS | FlowFlags.THROWS)) {

View File

@ -364,13 +364,6 @@ export class Parser extends DiagnosticEmitter {
var token = tn.next(); var token = tn.next();
var startPos = tn.tokenPos; var startPos = tn.tokenPos;
// 'void'
if (token == Token.VOID) {
return Node.createType(
Node.createIdentifierExpression("void", tn.range()), [], false, tn.range(startPos, tn.pos)
);
}
var type: CommonTypeNode; var type: CommonTypeNode;
// '(' ... // '(' ...
@ -437,6 +430,12 @@ export class Parser extends DiagnosticEmitter {
return null; return null;
} }
// 'void'
} else if (token == Token.VOID) {
type = Node.createType(
Node.createIdentifierExpression("void", tn.range()), [], false, tn.range(startPos, tn.pos)
);
// 'this' // 'this'
} else if (token == Token.THIS) { } else if (token == Token.THIS) {
type = Node.createType( type = Node.createType(

View File

@ -2318,7 +2318,9 @@ export enum CommonFlags {
/** Is scoped. */ /** Is scoped. */
SCOPED = 1 << 24, SCOPED = 1 << 24,
/** Is a trampoline. */ /** Is a trampoline. */
TRAMPOLINE = 1 << 25 TRAMPOLINE = 1 << 25,
/** Is a virtual method. */
VIRTUAL = 1 << 26
} }
export enum DecoratorFlags { export enum DecoratorFlags {

2
std/assembly.d.ts vendored
View File

@ -267,6 +267,8 @@ declare function offsetof<T>(fieldName?: string): usize;
declare function changetype<T>(value: any): T; declare function changetype<T>(value: any): T;
/** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */ /** Explicitly requests no bounds checks on the provided expression. Useful for array accesses. */
declare function unchecked<T>(value: T): T; declare function unchecked<T>(value: T): T;
/** Creates a `call_indirect` instruction, calling the specified target by index with the specified arguments. */
declare function call_indirect<T>(target: Function | u32, ...args: any[]): T;
/** Tests if a 32-bit or 64-bit float is `NaN`. */ /** Tests if a 32-bit or 64-bit float is `NaN`. */
declare function isNaN<T = f32 | f64>(value: T): bool; declare function isNaN<T = f32 | f64>(value: T): bool;
/** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */ /** Tests if a 32-bit or 64-bit float is finite, that is not `NaN` or +/-`Infinity`. */

View File

@ -80,6 +80,8 @@ export declare function assert<T>(isTrueish: T, message?: string): T;
export declare function unchecked<T>(expr: T): T; export declare function unchecked<T>(expr: T): T;
export declare function call_indirect<T>(target: void, ...args: void[]): T;
export declare function i8(value: void): i8; export declare function i8(value: void): i8;
export namespace i8 { export namespace i8 {
export const MIN_VALUE: i8 = -128; export const MIN_VALUE: i8 = -128;

View File

@ -1639,7 +1639,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.shr_u (i32.shr_u
(get_local $3) (get_local $3)
@ -1658,7 +1658,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i32.shl (i32.shl
@ -1689,7 +1689,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.shr_u (i32.shr_u
(get_local $3) (get_local $3)
@ -1708,7 +1708,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i32.shl (i32.shl
@ -1722,7 +1722,7 @@
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_local $4) (get_local $4)
@ -1764,7 +1764,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -1791,7 +1791,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.shr_u (i32.shr_u
(get_local $2) (get_local $2)
@ -1810,7 +1810,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(return (return
@ -3257,7 +3257,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -3280,7 +3280,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i64.shl (i64.shl
@ -3313,7 +3313,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -3336,7 +3336,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i64.shl (i64.shl
@ -3352,7 +3352,7 @@
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_local $3) (get_local $3)
@ -3394,7 +3394,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -3421,7 +3421,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -3444,7 +3444,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(return (return

View File

@ -1831,23 +1831,21 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.eqz
(i32.eqz (i32.shr_u
(i32.shr_u (get_local $8)
(get_local $8) (i32.const 31)
(i32.const 31)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -1856,7 +1854,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(set_local $2 (set_local $2
@ -1905,23 +1903,21 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i32.eqz
(i32.eqz (i32.shr_u
(i32.shr_u (get_local $8)
(get_local $8) (i32.const 31)
(i32.const 31)
)
) )
) )
) )
(set_local $5 )
(i32.sub (set_local $5
(get_local $5) (i32.sub
(i32.const 1) (get_local $5)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -1930,7 +1926,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(set_local $3 (set_local $3
@ -1968,53 +1964,50 @@
) )
) )
(block $break|2 (block $break|2
(nop) (loop $repeat|2
(loop $loop|2 (br_if $break|2
(block $continue|2 (i32.eqz
(br_if $break|2 (i32.gt_s
(get_local $4)
(get_local $5)
)
)
)
(block
(set_local $8
(i32.sub
(get_local $2)
(get_local $3)
)
)
(if
(i32.eqz (i32.eqz
(i32.gt_s (i32.shr_u
(get_local $4) (get_local $8)
(get_local $5) (i32.const 31)
)
)
(block
(if
(i32.eqz
(get_local $8)
)
(return
(f32.mul
(f32.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
) )
) )
) )
(block (set_local $2
(set_local $8 (i32.shl
(i32.sub (get_local $2)
(get_local $2) (i32.const 1)
(get_local $3)
)
)
(if
(i32.eqz
(i32.shr_u
(get_local $8)
(i32.const 31)
)
)
(block
(if
(i32.eqz
(get_local $8)
)
(return
(f32.mul
(f32.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
)
)
)
(set_local $2
(i32.shl
(get_local $2)
(i32.const 1)
)
) )
) )
) )
@ -2024,7 +2017,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(set_local $8 (set_local $8
@ -2058,24 +2051,21 @@
) )
) )
(block $break|3 (block $break|3
(nop) (loop $repeat|3
(loop $loop|3 (br_if $break|3
(block $continue|3 (i32.eqz
(br_if $break|3
(i32.eqz (i32.eqz
(i32.eqz (i32.shr_u
(i32.shr_u (get_local $2)
(get_local $2) (i32.const 23)
(i32.const 23)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $2 (set_local $2
@ -2084,7 +2074,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(if (if
@ -3713,23 +3703,21 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i64.eqz
(i64.eqz (i64.shr_u
(i64.shr_u (get_local $8)
(get_local $8) (i64.const 63)
(i64.const 63)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -3738,7 +3726,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(set_local $2 (set_local $2
@ -3789,23 +3777,21 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i64.eqz
(i64.eqz (i64.shr_u
(i64.shr_u (get_local $8)
(get_local $8) (i64.const 63)
(i64.const 63)
)
) )
) )
) )
(set_local $5 )
(i32.sub (set_local $5
(get_local $5) (i32.sub
(i32.const 1) (get_local $5)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -3814,7 +3800,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(set_local $3 (set_local $3
@ -3854,53 +3840,50 @@
) )
) )
(block $break|2 (block $break|2
(nop) (loop $repeat|2
(loop $loop|2 (br_if $break|2
(block $continue|2 (i32.eqz
(br_if $break|2 (i32.gt_s
(i32.eqz (get_local $4)
(i32.gt_s (get_local $5)
(get_local $4) )
(get_local $5) )
)
(block
(set_local $8
(i64.sub
(get_local $2)
(get_local $3)
)
)
(if
(i64.eqz
(i64.shr_u
(get_local $8)
(i64.const 63)
)
)
(block
(if
(i64.eqz
(get_local $8)
)
(return
(f64.mul
(f64.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
) )
) )
) )
(block (set_local $2
(set_local $8 (i64.shl
(i64.sub (get_local $2)
(get_local $2) (i64.const 1)
(get_local $3)
)
)
(if
(i64.eqz
(i64.shr_u
(get_local $8)
(i64.const 63)
)
)
(block
(if
(i64.eqz
(get_local $8)
)
(return
(f64.mul
(f64.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
)
)
)
(set_local $2
(i64.shl
(get_local $2)
(i64.const 1)
)
) )
) )
) )
@ -3910,7 +3893,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(set_local $8 (set_local $8
@ -3944,24 +3927,21 @@
) )
) )
(block $break|3 (block $break|3
(nop) (loop $repeat|3
(loop $loop|3 (br_if $break|3
(block $continue|3 (i32.eqz
(br_if $break|3 (i64.eqz
(i32.eqz (i64.shr_u
(i64.eqz (get_local $2)
(i64.shr_u (i64.const 52)
(get_local $2)
(i64.const 52)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $2 (set_local $2
@ -3970,7 +3950,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(if (if

View File

@ -2,6 +2,7 @@
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $fi (func (param f32) (result i32))) (type $fi (func (param f32) (result i32)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))
(type $iiv (func (param i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(global $builtins/b (mut i32) (i32.const 0)) (global $builtins/b (mut i32) (i32.const 0))
@ -12,11 +13,15 @@
(global $builtins/u (mut i32) (i32.const 0)) (global $builtins/u (mut i32) (i32.const 0))
(global $builtins/U (mut i64) (i64.const 0)) (global $builtins/U (mut i64) (i64.const 0))
(global $builtins/s (mut i32) (i32.const 0)) (global $builtins/s (mut i32) (i32.const 0))
(global $builtins/fn (mut i32) (i32.const 0))
(table 1 1 anyfunc)
(elem (i32.const 0) $start~anonymous|0)
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\0b\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s") (data (i32.const 8) "\0b\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s")
(data (i32.const 36) "\01\00\00\001") (data (i32.const 36) "\01\00\00\001")
(export "test" (func $builtins/test)) (export "test" (func $builtins/test))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "table" (table $0))
(start $start) (start $start)
(func $isNaN<f32> (; 1 ;) (type $fi) (param $0 f32) (result i32) (func $isNaN<f32> (; 1 ;) (type $fi) (param $0 f32) (result i32)
(f32.ne (f32.ne
@ -48,10 +53,13 @@
(f64.const 0) (f64.const 0)
) )
) )
(func $builtins/test (; 5 ;) (type $v) (func $start~anonymous|0 (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32)
(nop) (nop)
) )
(func $start (; 6 ;) (type $v) (func $builtins/test (; 6 ;) (type $v)
(nop)
)
(func $start (; 7 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 i32) (local $1 i32)
(local $2 i64) (local $2 i64)
@ -830,6 +838,11 @@
) )
(unreachable) (unreachable)
) )
(call_indirect (type $iiv)
(i32.const 1)
(i32.const 2)
(get_global $builtins/fn)
)
(if (if
(i32.eqz (i32.eqz
(call $isNaN<f32> (call $isNaN<f32>
@ -840,7 +853,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 261) (i32.const 264)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -856,7 +869,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 262) (i32.const 265)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -870,7 +883,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 263) (i32.const 266)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -884,7 +897,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 264) (i32.const 267)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -898,7 +911,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 265) (i32.const 268)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -912,7 +925,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 266) (i32.const 269)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -928,7 +941,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 267) (i32.const 270)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -944,7 +957,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 268) (i32.const 271)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)

View File

@ -232,6 +232,9 @@ F = select<f64>(12.5, 25.0, false);
if (!i) unreachable(); if (!i) unreachable();
var fn = function(a: i32, b: i32): void {}
call_indirect(fn, 1, 2);
// AS specific // AS specific
assert(sizeof<u8>() == 1); assert(sizeof<u8>() == 1);

View File

@ -2,6 +2,7 @@
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $fi (func (param f32) (result i32))) (type $fi (func (param f32) (result i32)))
(type $Fi (func (param f64) (result i32))) (type $Fi (func (param f64) (result i32)))
(type $iiv (func (param i32 i32)))
(type $v (func)) (type $v (func))
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
(global $builtins/b (mut i32) (i32.const 0)) (global $builtins/b (mut i32) (i32.const 0))
@ -15,12 +16,16 @@
(global $builtins/u (mut i32) (i32.const 0)) (global $builtins/u (mut i32) (i32.const 0))
(global $builtins/U (mut i64) (i64.const 0)) (global $builtins/U (mut i64) (i64.const 0))
(global $builtins/s (mut i32) (i32.const 0)) (global $builtins/s (mut i32) (i32.const 0))
(global $builtins/fn (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 44)) (global $HEAP_BASE i32 (i32.const 44))
(table 1 1 anyfunc)
(elem (i32.const 0) $start~anonymous|0)
(memory $0 1) (memory $0 1)
(data (i32.const 8) "\0b\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s\00") (data (i32.const 8) "\0b\00\00\00b\00u\00i\00l\00t\00i\00n\00s\00.\00t\00s\00")
(data (i32.const 36) "\01\00\00\001\00") (data (i32.const 36) "\01\00\00\001\00")
(export "test" (func $builtins/test)) (export "test" (func $builtins/test))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "table" (table $0))
(start $start) (start $start)
(func $isNaN<f32> (; 1 ;) (type $fi) (param $0 f32) (result i32) (func $isNaN<f32> (; 1 ;) (type $fi) (param $0 f32) (result i32)
(return (return
@ -60,10 +65,13 @@
) )
) )
) )
(func $builtins/test (; 5 ;) (type $v) (func $start~anonymous|0 (; 5 ;) (type $iiv) (param $0 i32) (param $1 i32)
(nop) (nop)
) )
(func $start (; 6 ;) (type $v) (func $builtins/test (; 6 ;) (type $v)
(nop)
)
(func $start (; 7 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 i32) (local $1 i32)
(local $2 i64) (local $2 i64)
@ -1538,6 +1546,11 @@
) )
(unreachable) (unreachable)
) )
(call_indirect (type $iiv)
(i32.const 1)
(i32.const 2)
(get_global $builtins/fn)
)
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
@ -1545,57 +1558,6 @@
(i32.const 1) (i32.const 1)
) )
) )
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 237)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 238)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 239)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block (block
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
@ -1606,14 +1568,28 @@
(unreachable) (unreachable)
) )
) )
(drop (if
(i32.const 4) (i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 241)
(i32.const 0)
)
(unreachable)
)
) )
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 1) (i32.const 4)
(i32.const 1) (i32.const 4)
) )
) )
(block (block
@ -1629,8 +1605,8 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 1) (i32.const 8)
(i32.const 1) (i32.const 8)
) )
) )
(block (block
@ -1643,28 +1619,14 @@
(unreachable) (unreachable)
) )
) )
(if (drop
(i32.eqz (i32.const 4)
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 244)
(i32.const 0)
)
(unreachable)
)
) )
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 4) (i32.const 1)
(i32.const 4) (i32.const 1)
) )
) )
(block (block
@ -1680,8 +1642,8 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 8) (i32.const 1)
(i32.const 8) (i32.const 1)
) )
) )
(block (block
@ -1694,8 +1656,22 @@
(unreachable) (unreachable)
) )
) )
(drop (if
(i32.const 4) (i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 247)
(i32.const 0)
)
(unreachable)
)
) )
(if (if
(i32.eqz (i32.eqz
@ -1731,12 +1707,32 @@
(unreachable) (unreachable)
) )
) )
(drop
(i32.const 4)
)
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8)
(i32.const 251)
(i32.const 0) (i32.const 0)
) )
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
) )
(block (block
(call $~lib/env/abort (call $~lib/env/abort
@ -1748,23 +1744,6 @@
(unreachable) (unreachable)
) )
) )
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 253)
(i32.const 0)
)
(unreachable)
)
)
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
@ -1772,23 +1751,6 @@
(i32.const 0) (i32.const 0)
) )
) )
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 254)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block (block
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
@ -1799,6 +1761,23 @@
(unreachable) (unreachable)
) )
) )
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 256)
(i32.const 0)
)
(unreachable)
)
)
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
@ -1816,6 +1795,40 @@
(unreachable) (unreachable)
) )
) )
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 258)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 260)
(i32.const 0)
)
(unreachable)
)
)
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
@ -1827,7 +1840,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 258) (i32.const 261)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1844,7 +1857,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 260) (i32.const 263)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1860,7 +1873,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 261) (i32.const 264)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1876,7 +1889,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 262) (i32.const 265)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1894,7 +1907,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 263) (i32.const 266)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1912,7 +1925,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 264) (i32.const 267)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1930,7 +1943,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 265) (i32.const 268)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1948,7 +1961,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 266) (i32.const 269)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1964,7 +1977,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 267) (i32.const 270)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -1980,7 +1993,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 268) (i32.const 271)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -2003,7 +2016,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 281) (i32.const 284)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -2020,7 +2033,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 282) (i32.const 285)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -2039,57 +2052,6 @@
) )
) )
) )
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 283)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 32767)
(i32.const 32767)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 284)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const -2147483648)
(i32.const -2147483648)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 285)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2147483647)
(i32.const 2147483647)
)
)
(block (block
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
@ -2102,9 +2064,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i64.eq (i32.eq
(i64.const -9223372036854775808) (i32.const 32767)
(i64.const -9223372036854775808) (i32.const 32767)
) )
) )
(block (block
@ -2119,9 +2081,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i64.eq (i32.eq
(i64.const 9223372036854775807) (i32.const -2147483648)
(i64.const 9223372036854775807) (i32.const -2147483648)
) )
) )
(block (block
@ -2137,9 +2099,26 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 2147483647)
(i32.const 2147483647)
)
)
(block
(call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8)
(i32.const 289)
(i32.const 0) (i32.const 0)
) )
(unreachable)
)
)
(if
(i32.eqz
(i64.eq
(i64.const -9223372036854775808)
(i64.const -9223372036854775808)
)
) )
(block (block
(call $~lib/env/abort (call $~lib/env/abort
@ -2153,9 +2132,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i32.eq (i64.eq
(i32.const 255) (i64.const 9223372036854775807)
(i32.const 255) (i64.const 9223372036854775807)
) )
) )
(block (block
@ -2175,23 +2154,6 @@
(i32.const 0) (i32.const 0)
) )
) )
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 292)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 65535)
(i32.const 65535)
)
)
(block (block
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
@ -2205,8 +2167,8 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 0) (i32.const 255)
(i32.const 0) (i32.const 255)
) )
) )
(block (block
@ -2222,8 +2184,8 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const -1) (i32.const 0)
(i32.const -1) (i32.const 0)
) )
) )
(block (block
@ -2238,9 +2200,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i64.eq (i32.eq
(i64.const 0) (i32.const 65535)
(i64.const 0) (i32.const 65535)
) )
) )
(block (block
@ -2255,9 +2217,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i64.eq (i32.eq
(i64.const -1) (i32.const 0)
(i64.const -1) (i32.const 0)
) )
) )
(block (block
@ -2273,8 +2235,8 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.const 0) (i32.const -1)
(i32.const 0) (i32.const -1)
) )
) )
(block (block
@ -2289,26 +2251,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i32.eq (i64.eq
(i32.const 0) (i64.const 0)
(i32.const 0) (i64.const 0)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 298)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
) )
) )
(block (block
@ -2323,26 +2268,26 @@
) )
(if (if
(i32.eqz (i32.eqz
(i32.eq (i64.eq
(i32.const 1) (i64.const -1)
(i32.const 1) (i64.const -1)
) )
) )
(block (block
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 299) (i32.const 300)
(i32.const 29) (i32.const 0)
) )
(unreachable) (unreachable)
) )
) )
(if (if
(i32.eqz (i32.eqz
(f32.eq (i32.eq
(f32.const -3402823466385288598117041e14) (i32.const 0)
(f32.const -3402823466385288598117041e14) (i32.const 0)
) )
) )
(block (block
@ -2357,9 +2302,26 @@
) )
(if (if
(i32.eqz (i32.eqz
(f32.eq (i32.eq
(f32.const 3402823466385288598117041e14) (i32.const 0)
(f32.const 3402823466385288598117041e14) (i32.const 0)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 301)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
) )
) )
(block (block
@ -2374,17 +2336,17 @@
) )
(if (if
(i32.eqz (i32.eqz
(f32.eq (i32.eq
(f32.const -16777215) (i32.const 1)
(f32.const -16777215) (i32.const 1)
) )
) )
(block (block
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 303) (i32.const 302)
(i32.const 0) (i32.const 29)
) )
(unreachable) (unreachable)
) )
@ -2392,8 +2354,8 @@
(if (if
(i32.eqz (i32.eqz
(f32.eq (f32.eq
(f32.const 16777215) (f32.const -3402823466385288598117041e14)
(f32.const 16777215) (f32.const -3402823466385288598117041e14)
) )
) )
(block (block
@ -2409,8 +2371,8 @@
(if (if
(i32.eqz (i32.eqz
(f32.eq (f32.eq
(f32.const 1.1920928955078125e-07) (f32.const 3402823466385288598117041e14)
(f32.const 1.1920928955078125e-07) (f32.const 3402823466385288598117041e14)
) )
) )
(block (block
@ -2425,9 +2387,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(f64.eq (f32.eq
(f64.const -1797693134862315708145274e284) (f32.const -16777215)
(f64.const -1797693134862315708145274e284) (f32.const -16777215)
) )
) )
(block (block
@ -2442,9 +2404,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(f64.eq (f32.eq
(f64.const 1797693134862315708145274e284) (f32.const 16777215)
(f64.const 1797693134862315708145274e284) (f32.const 16777215)
) )
) )
(block (block
@ -2459,9 +2421,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(f64.eq (f32.eq
(f64.const -9007199254740991) (f32.const 1.1920928955078125e-07)
(f64.const -9007199254740991) (f32.const 1.1920928955078125e-07)
) )
) )
(block (block
@ -2474,6 +2436,57 @@
(unreachable) (unreachable)
) )
) )
(if
(i32.eqz
(f64.eq
(f64.const -1797693134862315708145274e284)
(f64.const -1797693134862315708145274e284)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 309)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const 1797693134862315708145274e284)
(f64.const 1797693134862315708145274e284)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 310)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const -9007199254740991)
(f64.const -9007199254740991)
)
)
(block
(call $~lib/env/abort
(i32.const 0)
(i32.const 8)
(i32.const 311)
(i32.const 0)
)
(unreachable)
)
)
(if (if
(i32.eqz (i32.eqz
(f64.eq (f64.eq
@ -2485,7 +2498,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 309) (i32.const 312)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)
@ -2502,7 +2515,7 @@
(call $~lib/env/abort (call $~lib/env/abort
(i32.const 0) (i32.const 0)
(i32.const 8) (i32.const 8)
(i32.const 310) (i32.const 313)
(i32.const 0) (i32.const 0)
) )
(unreachable) (unreachable)

View File

@ -0,0 +1,21 @@
(module
(type $iv (func (param i32)))
(type $v (func))
(memory $0 1)
(export "test" (func $class-overloading/test))
(export "memory" (memory $0))
(start $start)
(func $class-overloading/Foo#baz (; 0 ;) (type $iv) (param $0 i32)
(nop)
)
(func $class-overloading/test (; 1 ;) (type $iv) (param $0 i32)
(call $class-overloading/Foo#baz
(get_local $0)
)
)
(func $start (; 2 ;) (type $v)
(call $class-overloading/test
(i32.const 0)
)
)
)

View File

@ -0,0 +1,12 @@
class Foo {
baz(): void {}
}
class Bar extends Foo {
baz(): void {}
}
export function test(foo: Foo): void {
foo.baz();
}
// FIXME: this results in a call to Foo.baz instead of Bar.baz above.
// ultimately, overloaded functions should implicitly become virtual.
test(changetype<Bar>(0));

View File

@ -0,0 +1,22 @@
(module
(type $iv (func (param i32)))
(type $v (func))
(global $HEAP_BASE i32 (i32.const 8))
(memory $0 1)
(export "test" (func $class-overloading/test))
(export "memory" (memory $0))
(start $start)
(func $class-overloading/Foo#baz (; 0 ;) (type $iv) (param $0 i32)
(nop)
)
(func $class-overloading/test (; 1 ;) (type $iv) (param $0 i32)
(call $class-overloading/Foo#baz
(get_local $0)
)
)
(func $start (; 2 ;) (type $v)
(call $class-overloading/test
(i32.const 0)
)
)
)

View File

@ -186,7 +186,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -205,7 +205,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(if (if

View File

@ -217,18 +217,16 @@
(set_local $1 (set_local $1
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_local $1)
(get_local $1) (get_global $comma/a)
(get_global $comma/a)
)
) )
) )
(nop)
) )
(nop)
(block (block
(set_global $comma/a (set_global $comma/a
(i32.sub (i32.sub
@ -243,7 +241,7 @@
) )
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(if (if

View File

@ -13,7 +13,7 @@
(set_global $for/i (set_global $for/i
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_global $for/i) (get_global $for/i)
@ -26,7 +26,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(if (if
@ -45,7 +45,7 @@
) )
) )
(block $break|1 (block $break|1
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -58,11 +58,11 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_global $for/i) (get_global $for/i)
@ -75,7 +75,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -91,7 +91,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.eq (i32.eq
(get_global $for/i) (get_global $for/i)
@ -104,17 +104,17 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(loop $loop|4 (loop $repeat|4
(set_global $for/i (set_global $for/i
(i32.sub (i32.sub
(get_global $for/i) (get_global $for/i)
(i32.const 1) (i32.const 1)
) )
) )
(br_if $loop|4 (br_if $repeat|4
(get_global $for/i) (get_global $for/i)
) )
) )
@ -122,7 +122,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|5 (loop $repeat|5
(br_if $break|5 (br_if $break|5
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -135,7 +135,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|5) (br $repeat|5)
) )
) )
(if (if

View File

@ -15,25 +15,23 @@
(set_global $for/i (set_global $for/i
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_global $for/i)
(get_global $for/i) (i32.const 10)
(i32.const 10)
)
) )
) )
(nop)
) )
(nop)
(set_global $for/i (set_global $for/i
(i32.add (i32.add
(get_global $for/i) (get_global $for/i)
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(if (if
@ -57,48 +55,43 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_local $0)
(get_local $0) (i32.const 10)
(i32.const 10)
)
) )
) )
(nop)
) )
(nop)
(set_local $0 (set_local $0
(i32.add (i32.add
(get_local $0) (get_local $0)
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(block $break|2 (block $break|2
(nop) (loop $repeat|2
(loop $loop|2 (br_if $break|2
(block $continue|2 (i32.eqz
(br_if $break|2 (i32.gt_s
(i32.eqz (get_global $for/i)
(i32.gt_s (i32.const 0)
(get_global $for/i)
(i32.const 0)
)
) )
) )
(nop)
) )
(nop)
(set_global $for/i (set_global $for/i
(i32.sub (i32.sub
(get_global $for/i) (get_global $for/i)
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -119,21 +112,18 @@
) )
) )
(block $break|3 (block $break|3
(nop) (loop $repeat|3
(loop $loop|3 (br_if $break|3
(block $continue|3 (i32.eqz
(br_if $break|3 (i32.const 1)
(i32.eqz
(i32.const 1)
)
) )
(if )
(i32.eq (if
(get_global $for/i) (i32.eq
(i32.const 10) (get_global $for/i)
) (i32.const 10)
(br $break|3)
) )
(br $break|3)
) )
(set_global $for/i (set_global $for/i
(i32.add (i32.add
@ -141,43 +131,39 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(block $break|4 (block $break|4
(nop) (loop $repeat|4
(loop $loop|4 (br_if $break|4
(block $continue|4 (i32.eqz
(br_if $break|4 (i32.const 1)
(i32.eqz
(i32.const 1)
)
)
(if
(i32.eq
(block (result i32)
(set_global $for/i
(i32.sub
(get_global $for/i)
(i32.const 1)
)
)
(get_global $for/i)
)
(i32.const 0)
)
(br $break|4)
) )
) )
(nop) (if
(br $loop|4) (i32.eq
(block (result i32)
(set_global $for/i
(i32.sub
(get_global $for/i)
(i32.const 1)
)
)
(get_global $for/i)
)
(i32.const 0)
)
(br $break|4)
)
(br $repeat|4)
) )
) )
(block $break|5 (block $break|5
(set_local $1 (set_local $1
(i32.const 0) (i32.const 0)
) )
(loop $loop|5 (loop $repeat|5
(block $continue|5 (block $continue|5
(br_if $break|5 (br_if $break|5
(i32.eqz (i32.eqz
@ -195,7 +181,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|5) (br $repeat|5)
) )
) )
(if (if

View File

@ -46,7 +46,7 @@
(set_local $1 (set_local $1
(i32.const 10) (i32.const 10)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -59,7 +59,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )

View File

@ -107,25 +107,23 @@
(i32.const 10) (i32.const 10)
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_local $0)
(get_local $0) (get_local $1)
(get_local $1)
)
) )
) )
(nop)
) )
(nop)
(set_local $0 (set_local $0
(i32.add (i32.add
(get_local $0) (get_local $0)
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )

View File

@ -339,7 +339,7 @@
(set_local $2 (set_local $2
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_u (i32.ge_u
(get_local $2) (get_local $2)
@ -434,7 +434,7 @@
) )
) )
) )
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.eqz (i32.eqz
(f64.lt (f64.lt
@ -481,7 +481,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(i32.store16 (i32.store16
@ -551,7 +551,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )

View File

@ -398,137 +398,65 @@
(set_local $8 (set_local $8
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_u
(i32.lt_u (get_local $8)
(get_local $8) (get_local $1)
(get_local $1) )
)
)
(block
(set_local $9
(f64.mul
(f64.sub
(f64.convert_u/i32
(get_local $8)
)
(get_local $4)
) )
(get_local $6)
) )
) )
(block (block
(set_local $9 (set_local $10
(f64.mul (f64.const 0)
(f64.sub
(f64.convert_u/i32
(get_local $8)
)
(get_local $4)
)
(get_local $6)
)
) )
(block (set_local $11
(set_local $10 (f64.const 0)
(f64.const 0)
)
(set_local $11
(f64.const 0)
)
) )
(set_local $14 )
(i32.const 0) (set_local $14
) (i32.const 0)
(block $break|1 )
(loop $continue|1 (block $break|1
(if (loop $continue|1
(f64.le (if
(f64.add (f64.le
(tee_local $12 (f64.add
(f64.mul (tee_local $12
(get_local $10) (f64.mul
(get_local $10) (get_local $10)
) (get_local $10)
) )
(tee_local $13 )
(f64.mul (tee_local $13
(get_local $11) (f64.mul
(get_local $11) (get_local $11)
) (get_local $11)
) )
) )
(f64.const 4)
) )
(f64.const 4)
)
(block
(block (block
(block (set_local $15
(set_local $15
(f64.add
(f64.sub
(get_local $12)
(get_local $13)
)
(get_local $9)
)
)
(set_local $11
(f64.add
(f64.mul
(f64.mul
(f64.const 2)
(get_local $10)
)
(get_local $11)
)
(get_local $7)
)
)
(set_local $10
(get_local $15)
)
(if
(i32.ge_u
(get_local $14)
(get_local $3)
)
(br $break|1)
)
(set_local $14
(i32.add
(get_local $14)
(i32.const 1)
)
)
)
(br $continue|1)
)
)
)
)
(block $break|2
(set_local $15
(f64.min
(f64.const 8)
(f64.convert_u/i32
(get_local $3)
)
)
)
(loop $loop|2
(block $continue|2
(br_if $break|2
(i32.eqz
(f64.lt
(f64.convert_u/i32
(get_local $14)
)
(get_local $15)
)
)
)
(block
(set_local $16
(f64.add (f64.add
(f64.sub (f64.sub
(f64.mul (get_local $12)
(get_local $10) (get_local $13)
(get_local $10)
)
(f64.mul
(get_local $11)
(get_local $11)
)
) )
(get_local $9) (get_local $9)
) )
@ -546,100 +474,168 @@
) )
) )
(set_local $10 (set_local $10
(get_local $16) (get_local $15)
) )
) (if
) (i32.ge_u
(set_local $14 (get_local $14)
(i32.add (get_local $3)
(get_local $14)
(i32.const 1)
)
)
(br $loop|2)
)
)
(set_local $15
(f64.div
(call $~lib/math/NativeMath.log
(call $~lib/math/NativeMath.log
(block $~lib/math/NativeMath.sqrt|inlined.0 (result f64)
(set_local $15
(f64.add
(f64.mul
(get_local $10)
(get_local $10)
)
(f64.mul
(get_local $11)
(get_local $11)
)
)
)
(br $~lib/math/NativeMath.sqrt|inlined.0
(f64.sqrt
(get_local $15)
)
) )
(br $break|1)
) )
) (set_local $14
) (i32.add
(f64.const 0.6931471805599453) (get_local $14)
)
)
(set_local $17
(if (result i32)
(call $isFinite<f64>
(get_local $15)
)
(i32.trunc_u/f64
(f64.mul
(f64.convert_s/i32
(i32.sub
(i32.const 2048)
(i32.const 1) (i32.const 1)
) )
) )
(call $../../examples/mandelbrot/assembly/index/clamp<f64> )
(f64.div (br $continue|1)
(f64.sub )
(f64.convert_u/i32 )
(i32.add )
(get_local $14) )
(i32.const 1) (block $break|2
) (set_local $15
) (f64.min
(get_local $15) (f64.const 8)
) (f64.convert_u/i32
(f64.convert_u/i32 (get_local $3)
(get_local $3) )
) )
) )
(f64.const 0) (loop $repeat|2
(f64.const 1) (br_if $break|2
(i32.eqz
(f64.lt
(f64.convert_u/i32
(get_local $14)
) )
(get_local $15)
) )
) )
(i32.sub )
(i32.const 2048) (block
(set_local $16
(f64.add
(f64.sub
(f64.mul
(get_local $10)
(get_local $10)
)
(f64.mul
(get_local $11)
(get_local $11)
)
)
(get_local $9)
)
)
(set_local $11
(f64.add
(f64.mul
(f64.mul
(f64.const 2)
(get_local $10)
)
(get_local $11)
)
(get_local $7)
)
)
(set_local $10
(get_local $16)
)
)
(set_local $14
(i32.add
(get_local $14)
(i32.const 1) (i32.const 1)
) )
) )
(br $repeat|2)
) )
(i32.store16 )
(i32.shl (set_local $15
(i32.add (f64.div
(i32.mul (call $~lib/math/NativeMath.log
(get_local $0) (call $~lib/math/NativeMath.log
(get_local $1) (block $~lib/math/NativeMath.sqrt|inlined.0 (result f64)
(set_local $15
(f64.add
(f64.mul
(get_local $10)
(get_local $10)
)
(f64.mul
(get_local $11)
(get_local $11)
)
)
)
(br $~lib/math/NativeMath.sqrt|inlined.0
(f64.sqrt
(get_local $15)
)
)
) )
(get_local $8)
) )
)
(f64.const 0.6931471805599453)
)
)
(set_local $17
(if (result i32)
(call $isFinite<f64>
(get_local $15)
)
(i32.trunc_u/f64
(f64.mul
(f64.convert_s/i32
(i32.sub
(i32.const 2048)
(i32.const 1)
)
)
(call $../../examples/mandelbrot/assembly/index/clamp<f64>
(f64.div
(f64.sub
(f64.convert_u/i32
(i32.add
(get_local $14)
(i32.const 1)
)
)
(get_local $15)
)
(f64.convert_u/i32
(get_local $3)
)
)
(f64.const 0)
(f64.const 1)
)
)
)
(i32.sub
(i32.const 2048)
(i32.const 1) (i32.const 1)
) )
(get_local $17)
) )
) )
(i32.store16
(i32.shl
(i32.add
(i32.mul
(get_local $0)
(get_local $1)
)
(get_local $8)
)
(i32.const 1)
)
(get_local $17)
)
) )
(set_local $8 (set_local $8
(i32.add (i32.add
@ -647,7 +643,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )

View File

@ -110,7 +110,7 @@
(set_local $0 (set_local $0
(i32.const -128) (i32.const -128)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.gt_s (i32.gt_s
(get_local $0) (get_local $0)
@ -171,7 +171,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(set_global $retain-i32/si (set_global $retain-i32/si

View File

@ -558,65 +558,63 @@
(set_local $0 (set_local $0
(i32.const -128) (i32.const -128)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.le_s
(i32.le_s (get_local $0)
(get_local $0) (i32.const 255)
(i32.const 255)
)
) )
) )
(block )
(call $retain-i32/test (block
(i32.const 0) (call $retain-i32/test
(get_local $0) (i32.const 0)
) (get_local $0)
(call $retain-i32/test )
(i32.const 1) (call $retain-i32/test
(get_local $0) (i32.const 1)
) (get_local $0)
(call $retain-i32/test )
(i32.const -1) (call $retain-i32/test
(get_local $0) (i32.const -1)
) (get_local $0)
(call $retain-i32/test )
(i32.const -128) (call $retain-i32/test
(get_local $0) (i32.const -128)
) (get_local $0)
(call $retain-i32/test )
(i32.const 127) (call $retain-i32/test
(get_local $0) (i32.const 127)
) (get_local $0)
(call $retain-i32/test )
(i32.const 255) (call $retain-i32/test
(get_local $0) (i32.const 255)
) (get_local $0)
(call $retain-i32/test )
(i32.const -32768) (call $retain-i32/test
(get_local $0) (i32.const -32768)
) (get_local $0)
(call $retain-i32/test )
(i32.const 32767) (call $retain-i32/test
(get_local $0) (i32.const 32767)
) (get_local $0)
(call $retain-i32/test )
(i32.const 65535) (call $retain-i32/test
(get_local $0) (i32.const 65535)
) (get_local $0)
(call $retain-i32/test )
(i32.const 2147483647) (call $retain-i32/test
(get_local $0) (i32.const 2147483647)
) (get_local $0)
(call $retain-i32/test )
(i32.const -2147483648) (call $retain-i32/test
(get_local $0) (i32.const -2147483648)
) (get_local $0)
(call $retain-i32/test )
(i32.const -1) (call $retain-i32/test
(get_local $0) (i32.const -1)
) (get_local $0)
) )
) )
(set_local $0 (set_local $0
@ -625,7 +623,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(set_global $retain-i32/si (set_global $retain-i32/si

View File

@ -10,7 +10,7 @@
(func $start (; 1 ;) (type $v) (func $start (; 1 ;) (type $v)
(local $0 i32) (local $0 i32)
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -23,14 +23,14 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(block $break|1 (block $break|1
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -43,7 +43,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(call $scoped/fn (call $scoped/fn

View File

@ -26,44 +26,40 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_local $0)
(get_local $0) (i32.const 1)
(i32.const 1)
)
) )
) )
(nop)
) )
(nop)
(set_local $0 (set_local $0
(i32.add (i32.add
(get_local $0) (get_local $0)
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(block $break|1 (block $break|1
(set_local $1 (set_local $1
(i32.const 0) (i32.const 0)
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_local $1)
(get_local $1) (i32.const 1)
(i32.const 1)
)
) )
) )
(drop )
(get_local $1) (drop
) (get_local $1)
) )
(set_local $1 (set_local $1
(i32.add (i32.add
@ -71,7 +67,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(block (block

File diff suppressed because it is too large Load Diff

View File

@ -1,126 +0,0 @@
// This test case compiles to WebAssembly today, highlights some of the features that have been
// implemented already and gives a quick outlook on the road ahead.
// Global variables can be constant
const aConstantGlobal: i32 = 42;
// Constant globals can be exported to JS from the entry file
export const anExportedConstantGlobal: f32 = 42.0;
// Global variables can be mutable
var aMutableGlobal: i32 = 42;
// Variables can infer their type
var anInferredI32 = 42; // infers i32 by default
var anInferredI64 = 0x100000000; // infers i64 because the value doesn't fit in 32 bits
var anInferredF64 = 42.0; // infers f64 because it is notated as a float
var anInferredF32 = <f32>42.0; // infers f32 by evaluating its initializer
// Unary expressions just work
import "./unary";
// Binary expressions just work
import "./binary";
// Logical expressions just work
import "./logical";
// Several WebAssembly and some common JavaScript built-ins are supported and compile to opcodes directly
import "./builtins";
// Speaking of imports: Exports and re-exports are supported as well
export { aConstantGlobal };
export { anExportedConstantGlobal as anAliasedConstantGlobal } from "./showcase";
// Elements can be arranged in namespaces
namespace ANamespace {
export var aNamespacedGlobal: i32 = 42;
export function aNamespacedFunction(a: i32): i32 { return a; } // functions just work
}
// The compiler supports built-in assertions (--noAssert disables them globally)
assert(ANamespace.aNamespacedFunction(ANamespace.aNamespacedGlobal) == 42);
// Enums become constant globals and thus can be exported from the entry file
export enum AnEnum {
ONE = 1, // values can use explicit initializers
TWO, // or assume the previous value + 1
// or be omitted
FOUR = AnEnum.TWO + 2, // or reference other values (and remain constant through precomputation)
FIVE, // and continue from there
FORTYTWO = aMutableGlobal, // or reference mutable values but then can't be exported
FORTYTHREE // and even continue from there without being exported (tsc doesn't allow this)
}
assert(AnEnum.ONE == 1);
assert(AnEnum.TWO == 2);
assert(AnEnum.FOUR == 4);
assert(AnEnum.FIVE == 5);
assert(AnEnum.FORTYTWO == 42);
assert(AnEnum.FORTYTHREE == 43);
// In fact, there are a couple of things asc just waves through where tsc refuses to
1, 2, 3; // for example not-so-useful comma expressions
function addGeneric<T>(left: T, right: T): T {
return left + right; // or maybe-useful generic math
}
// Speaking of generics: While there is no type inference yet, it just works
addGeneric<i32>(1, 2); // compiles and calls the i32 version
addGeneric<f32>(1, 2); // compiles and calls the f32 version
clz<i64>(0x8000); // most built-ins are generic as well
// Type aliases work but must be declared in the global scope for now
type double = f64;
addGeneric<double>(1, 2); // compiles and calls the f64 version
// Speaking of lazy compilation: Stuff that's not used is considered dead code and not compiled by default
function anUnusedFunction(): void { }
// That is, unless exported from the entry file, so it is considered reachable
export function anExportedFunction(): void { }
// Or, of course, `--noTreeShaking` is specified
// As you see, while classes, strings and arrays are still in the works, pretty much everything can
// be implemented already. Here are a few more sophisitcated examples of code that'll most likely
// make it into the standard library eventually:
import "./memcpy"; // until replaced by the proposed `move_memory` intrinsic (sic.)
// Speaking of classes: Some preliminary work has already been done, so while we can't properly
// instantiate them yet, we can point them at some raw memory
class AClass {
static aStaticField: AClass | null = null;
aField: i32;
}
class ADerivedClass extends AClass {
anotherField: f32;
get aWildAccessorAppears(): f32 { return this.anotherField; }
set aWildAccessorAppears(val: f32) { this.anotherField = val; }
}
var aClassInstance = changetype<ADerivedClass>(<usize>8);
aClassInstance.aField = 42;
aClassInstance.anotherField = 9000;
assert(load<i32>(8) == 42);
assert(load<f32>(12) == 9000);
aClassInstance.aWildAccessorAppears = 123;
assert(aClassInstance.aWildAccessorAppears == 123);
AClass.aStaticField = aClassInstance;
assert(ADerivedClass.aStaticField == aClassInstance);
// yet that's pretty much a work in progress, until...
// Speaking of the standard library:
// Ultimately, a memory manager should still be present regardless of the GC spec because making
// everything a GC-managed object impacts performance where GC isn't necessary. TLSF appears to
// be a viable candidate because it's relatively fast and small and an ARC-variant seems like a
// good internal alternative to a general-purpose GC if we can figure out reference cycles.
// With GC (and earlier: host-bindings) it will technically be possible to declare classes whose
// instances can cross the JS/WASM boundary natively, but then aren't stored in linear memory.
// Have a nice day!
// P.S: Interested in compilers? Nothing cooler to do with your spare time? Say hi!

File diff suppressed because it is too large Load Diff

View File

@ -2419,7 +2419,7 @@
(set_global $std/allocator_arena/i (set_global $std/allocator_arena/i
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_u (i32.ge_u
(get_global $std/allocator_arena/i) (get_global $std/allocator_arena/i)
@ -2452,7 +2452,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -2466,7 +2466,7 @@
(set_global $std/allocator_arena/i (set_global $std/allocator_arena/i
(i32.const 0) (i32.const 0)
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.ge_u (i32.ge_u
(get_global $std/allocator_arena/i) (get_global $std/allocator_arena/i)
@ -2499,7 +2499,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
) )

View File

@ -2729,37 +2729,35 @@
(set_global $std/allocator_arena/i (set_global $std/allocator_arena/i
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_u
(i32.lt_u (get_global $std/allocator_arena/i)
(get_global $std/allocator_arena/i) (i32.const 42)
(i32.const 42)
)
) )
) )
(if )
(i32.eqz (if
(i32.eq (i32.eqz
(i32.load8_u (i32.eq
(i32.add (i32.load8_u
(get_global $std/allocator_arena/ptr1) (i32.add
(get_global $std/allocator_arena/i) (get_global $std/allocator_arena/ptr1)
) (get_global $std/allocator_arena/i)
) )
(i32.const 18)
) )
(i32.const 18)
) )
(block )
(call $~lib/env/abort (block
(i32.const 0) (call $~lib/env/abort
(i32.const 8) (i32.const 0)
(i32.const 13) (i32.const 8)
(i32.const 2) (i32.const 13)
) (i32.const 2)
(unreachable)
) )
(unreachable)
) )
) )
(set_global $std/allocator_arena/i (set_global $std/allocator_arena/i
@ -2768,7 +2766,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(call $~lib/memory/move_memory (call $~lib/memory/move_memory
@ -2780,37 +2778,35 @@
(set_global $std/allocator_arena/i (set_global $std/allocator_arena/i
(i32.const 0) (i32.const 0)
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i32.lt_u
(i32.lt_u (get_global $std/allocator_arena/i)
(get_global $std/allocator_arena/i) (i32.const 42)
(i32.const 42)
)
) )
) )
(if )
(i32.eqz (if
(i32.eq (i32.eqz
(i32.load8_u (i32.eq
(i32.add (i32.load8_u
(get_global $std/allocator_arena/ptr2) (i32.add
(get_global $std/allocator_arena/i) (get_global $std/allocator_arena/ptr2)
) (get_global $std/allocator_arena/i)
) )
(i32.const 18)
) )
(i32.const 18)
) )
(block )
(call $~lib/env/abort (block
(i32.const 0) (call $~lib/env/abort
(i32.const 8) (i32.const 0)
(i32.const 18) (i32.const 8)
(i32.const 2) (i32.const 18)
) (i32.const 2)
(unreachable)
) )
(unreachable)
) )
) )
(set_global $std/allocator_arena/i (set_global $std/allocator_arena/i
@ -2819,7 +2815,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(if (if

View File

@ -2939,7 +2939,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $1) (get_local $1)
@ -2997,7 +2997,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $0) (get_local $0)
@ -3364,7 +3364,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -3417,7 +3417,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -3481,7 +3481,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -3506,29 +3506,24 @@
(set_global $~argc (set_global $~argc
(i32.const 3) (i32.const 3)
) )
(i32.eqz (i32.and
(i32.and (call_indirect (type $iiii)
(call_indirect (type $iiii) (i32.load offset=8
(i32.load offset=8 (i32.add
(i32.add (get_local $3)
(get_local $3) (i32.shl
(i32.shl (get_local $2)
(get_local $2) (i32.const 2)
(i32.const 2)
)
) )
) )
(get_local $2)
(get_local $0)
(get_local $1)
) )
(i32.const 1) (get_local $2)
(get_local $0)
(get_local $1)
) )
(i32.const 1)
) )
) )
(return
(i32.const 0)
)
(block (block
(set_local $2 (set_local $2
(i32.add (i32.add
@ -3536,7 +3531,10 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
)
(return
(i32.const 0)
) )
) )
) )
@ -3600,7 +3598,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -3653,7 +3651,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -3719,7 +3717,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -3762,7 +3760,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -3825,7 +3823,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -3877,7 +3875,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $5) (get_local $5)
@ -3952,7 +3950,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -4004,7 +4002,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $5) (get_local $5)
@ -4061,7 +4059,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -4120,7 +4118,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $4) (get_local $4)
@ -4194,7 +4192,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(if (result i32) (if (result i32)
@ -4240,7 +4238,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $2) (get_local $2)
@ -4311,7 +4309,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.lt_s (i32.lt_s
(get_local $3) (get_local $3)
@ -4344,7 +4342,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $2) (get_local $2)
@ -4421,7 +4419,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -4449,7 +4447,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $1) (get_local $1)
@ -4532,7 +4530,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $1) (get_local $1)
@ -4561,7 +4559,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $0) (get_local $0)
@ -4597,7 +4595,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $2) (get_local $2)
@ -4698,7 +4696,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $0) (get_local $0)
@ -4750,7 +4748,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.le_s (i32.le_s
(get_local $4) (get_local $4)
@ -4906,7 +4904,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(block $break|2 (block $break|2
@ -4916,7 +4914,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.lt_s (i32.lt_s
(get_local $4) (get_local $4)
@ -5098,7 +5096,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(call $~lib/allocator/arena/free_memory (call $~lib/allocator/arena/free_memory
@ -5228,7 +5226,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $2) (get_local $2)
@ -5268,7 +5266,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -5331,7 +5329,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $3) (get_local $3)
@ -5359,7 +5357,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -5390,7 +5388,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -5429,7 +5427,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $1) (get_local $1)
@ -5577,7 +5575,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -5608,7 +5606,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $1) (get_local $1)
@ -5946,7 +5944,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $3) (get_local $3)
@ -5974,7 +5972,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -6178,7 +6176,7 @@
(i32.const 544) (i32.const 544)
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $2) (get_local $2)
@ -6211,7 +6209,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $1) (get_local $1)
@ -6228,7 +6226,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $0) (get_local $0)
@ -6255,7 +6253,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $1) (get_local $1)

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_u (i32.ge_u
(get_local $1) (get_local $1)
@ -53,7 +53,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $2) (get_local $2)

View File

@ -44,29 +44,27 @@
) )
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_u
(i32.lt_u (get_local $2)
(get_local $2) (get_local $3)
(get_local $3)
)
) )
) )
(set_local $1 )
(i32.mul (set_local $1
(i32.xor (i32.mul
(get_local $1) (i32.xor
(i32.load8_u offset=4 (get_local $1)
(i32.add (i32.load8_u offset=4
(get_local $0) (i32.add
(get_local $2) (get_local $0)
) (get_local $2)
) )
) )
(i32.const 16777619)
) )
(i32.const 16777619)
) )
) )
(set_local $2 (set_local $2
@ -75,7 +73,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(return (return

View File

@ -8607,7 +8607,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -8630,7 +8630,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i64.shl (i64.shl
@ -8663,7 +8663,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -8686,7 +8686,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i64.shl (i64.shl
@ -8702,7 +8702,7 @@
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_local $3) (get_local $3)
@ -8744,7 +8744,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -8771,7 +8771,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -8794,7 +8794,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(return (return
@ -9000,7 +9000,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.shr_u (i32.shr_u
(get_local $3) (get_local $3)
@ -9019,7 +9019,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i32.shl (i32.shl
@ -9050,7 +9050,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.shr_u (i32.shr_u
(get_local $3) (get_local $3)
@ -9069,7 +9069,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i32.shl (i32.shl
@ -9083,7 +9083,7 @@
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_local $4) (get_local $4)
@ -9125,7 +9125,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -9152,7 +9152,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.shr_u (i32.shr_u
(get_local $2) (get_local $2)
@ -9171,7 +9171,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(return (return
@ -12401,7 +12401,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i64.ne (i64.ne
(i64.shr_u (i64.shr_u
@ -12423,7 +12423,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i64.shl (i64.shl
@ -12464,7 +12464,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i64.ne (i64.ne
(i64.shr_u (i64.shr_u
@ -12486,7 +12486,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i64.shl (i64.shl
@ -12531,7 +12531,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.le_s (i32.le_s
(get_local $2) (get_local $2)
@ -12581,7 +12581,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(if (if
@ -12618,7 +12618,7 @@
(i32.const -60) (i32.const -60)
) )
(block $break|4 (block $break|4
(loop $loop|4 (loop $repeat|4
(br_if $break|4 (br_if $break|4
(i64.ne (i64.ne
(i64.shr_u (i64.shr_u
@ -12640,7 +12640,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|4) (br $repeat|4)
) )
) )
) )
@ -12866,7 +12866,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.shr_u (i32.shr_u
(get_local $2) (get_local $2)
@ -12885,7 +12885,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i32.shl (i32.shl
@ -12922,7 +12922,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.shr_u (i32.shr_u
(get_local $2) (get_local $2)
@ -12941,7 +12941,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i32.shl (i32.shl
@ -12985,7 +12985,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.le_s (i32.le_s
(get_local $3) (get_local $3)
@ -13034,7 +13034,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(if (if
@ -13064,7 +13064,7 @@
(if (if
(get_local $4) (get_local $4)
(block $break|4 (block $break|4
(loop $loop|4 (loop $repeat|4
(br_if $break|4 (br_if $break|4
(i32.shr_u (i32.shr_u
(get_local $4) (get_local $4)
@ -13083,7 +13083,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|4) (br $repeat|4)
) )
) )
(set_local $3 (set_local $3
@ -44238,7 +44238,7 @@
) )
) )
(block $break|0 (block $break|0
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(f64.lt (f64.lt
@ -44272,7 +44272,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
(block (block
(call $~lib/env/abort (call $~lib/env/abort
@ -44295,7 +44295,7 @@
(set_local $0 (set_local $0
(i32.const 0) (i32.const 0)
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.eqz (i32.eqz
(f64.lt (f64.lt
@ -44329,7 +44329,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
(block (block
(call $~lib/env/abort (call $~lib/env/abort

File diff suppressed because it is too large Load Diff

View File

@ -152,7 +152,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -175,7 +175,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i64.shl (i64.shl
@ -208,7 +208,7 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -231,7 +231,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i64.shl (i64.shl
@ -247,7 +247,7 @@
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_local $3) (get_local $3)
@ -289,7 +289,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -316,7 +316,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.eqz (i32.eqz
(i64.eqz (i64.eqz
@ -339,7 +339,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(return (return
@ -581,7 +581,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.shr_u (i32.shr_u
(get_local $3) (get_local $3)
@ -600,7 +600,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(i32.shl (i32.shl
@ -631,7 +631,7 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|1 (loop $repeat|1
(br_if $break|1 (br_if $break|1
(i32.shr_u (i32.shr_u
(get_local $3) (get_local $3)
@ -650,7 +650,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(i32.shl (i32.shl
@ -664,7 +664,7 @@
) )
) )
(block $break|2 (block $break|2
(loop $loop|2 (loop $repeat|2
(br_if $break|2 (br_if $break|2
(i32.le_s (i32.le_s
(get_local $4) (get_local $4)
@ -706,7 +706,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(if (if
@ -733,7 +733,7 @@
) )
) )
(block $break|3 (block $break|3
(loop $loop|3 (loop $repeat|3
(br_if $break|3 (br_if $break|3
(i32.shr_u (i32.shr_u
(get_local $2) (get_local $2)
@ -752,7 +752,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(return (return

View File

@ -160,23 +160,21 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i64.eqz
(i64.eqz (i64.shr_u
(i64.shr_u (get_local $8)
(get_local $8) (i64.const 63)
(i64.const 63)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -185,7 +183,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(set_local $2 (set_local $2
@ -236,23 +234,21 @@
(i64.const 12) (i64.const 12)
) )
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i64.eqz
(i64.eqz (i64.shr_u
(i64.shr_u (get_local $8)
(get_local $8) (i64.const 63)
(i64.const 63)
)
) )
) )
) )
(set_local $5 )
(i32.sub (set_local $5
(get_local $5) (i32.sub
(i32.const 1) (get_local $5)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -261,7 +257,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(set_local $3 (set_local $3
@ -301,53 +297,50 @@
) )
) )
(block $break|2 (block $break|2
(nop) (loop $repeat|2
(loop $loop|2 (br_if $break|2
(block $continue|2 (i32.eqz
(br_if $break|2 (i32.gt_s
(i32.eqz (get_local $4)
(i32.gt_s (get_local $5)
(get_local $4) )
(get_local $5) )
)
(block
(set_local $8
(i64.sub
(get_local $2)
(get_local $3)
)
)
(if
(i64.eqz
(i64.shr_u
(get_local $8)
(i64.const 63)
)
)
(block
(if
(i64.eqz
(get_local $8)
)
(return
(f64.mul
(f64.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
) )
) )
) )
(block (set_local $2
(set_local $8 (i64.shl
(i64.sub (get_local $2)
(get_local $2) (i64.const 1)
(get_local $3)
)
)
(if
(i64.eqz
(i64.shr_u
(get_local $8)
(i64.const 63)
)
)
(block
(if
(i64.eqz
(get_local $8)
)
(return
(f64.mul
(f64.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
)
)
)
(set_local $2
(i64.shl
(get_local $2)
(i64.const 1)
)
) )
) )
) )
@ -357,7 +350,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(set_local $8 (set_local $8
@ -391,24 +384,21 @@
) )
) )
(block $break|3 (block $break|3
(nop) (loop $repeat|3
(loop $loop|3 (br_if $break|3
(block $continue|3 (i32.eqz
(br_if $break|3 (i64.eqz
(i32.eqz (i64.shr_u
(i64.eqz (get_local $2)
(i64.shr_u (i64.const 52)
(get_local $2)
(i64.const 52)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $2 (set_local $2
@ -417,7 +407,7 @@
(i64.const 1) (i64.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(if (if
@ -684,23 +674,21 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.eqz
(i32.eqz (i32.shr_u
(i32.shr_u (get_local $8)
(get_local $8) (i32.const 31)
(i32.const 31)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -709,7 +697,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(set_local $2 (set_local $2
@ -758,23 +746,21 @@
(i32.const 9) (i32.const 9)
) )
) )
(loop $loop|1 (loop $repeat|1
(block $continue|1 (br_if $break|1
(br_if $break|1 (i32.eqz
(i32.eqz (i32.eqz
(i32.eqz (i32.shr_u
(i32.shr_u (get_local $8)
(get_local $8) (i32.const 31)
(i32.const 31)
)
) )
) )
) )
(set_local $5 )
(i32.sub (set_local $5
(get_local $5) (i32.sub
(i32.const 1) (get_local $5)
) (i32.const 1)
) )
) )
(set_local $8 (set_local $8
@ -783,7 +769,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|1) (br $repeat|1)
) )
) )
(set_local $3 (set_local $3
@ -821,53 +807,50 @@
) )
) )
(block $break|2 (block $break|2
(nop) (loop $repeat|2
(loop $loop|2 (br_if $break|2
(block $continue|2 (i32.eqz
(br_if $break|2 (i32.gt_s
(get_local $4)
(get_local $5)
)
)
)
(block
(set_local $8
(i32.sub
(get_local $2)
(get_local $3)
)
)
(if
(i32.eqz (i32.eqz
(i32.gt_s (i32.shr_u
(get_local $4) (get_local $8)
(get_local $5) (i32.const 31)
)
)
(block
(if
(i32.eqz
(get_local $8)
)
(return
(f32.mul
(f32.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
) )
) )
) )
(block (set_local $2
(set_local $8 (i32.shl
(i32.sub (get_local $2)
(get_local $2) (i32.const 1)
(get_local $3)
)
)
(if
(i32.eqz
(i32.shr_u
(get_local $8)
(i32.const 31)
)
)
(block
(if
(i32.eqz
(get_local $8)
)
(return
(f32.mul
(f32.const 0)
(get_local $0)
)
)
)
(set_local $2
(get_local $8)
)
)
)
(set_local $2
(i32.shl
(get_local $2)
(i32.const 1)
)
) )
) )
) )
@ -877,7 +860,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|2) (br $repeat|2)
) )
) )
(set_local $8 (set_local $8
@ -911,24 +894,21 @@
) )
) )
(block $break|3 (block $break|3
(nop) (loop $repeat|3
(loop $loop|3 (br_if $break|3
(block $continue|3 (i32.eqz
(br_if $break|3
(i32.eqz (i32.eqz
(i32.eqz (i32.shr_u
(i32.shr_u (get_local $2)
(get_local $2) (i32.const 23)
(i32.const 23)
)
) )
) )
) )
(set_local $4 )
(i32.sub (set_local $4
(get_local $4) (i32.sub
(i32.const 1) (get_local $4)
) (i32.const 1)
) )
) )
(set_local $2 (set_local $2
@ -937,7 +917,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|3) (br $repeat|3)
) )
) )
(if (if

View File

@ -2110,7 +2110,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_u (i32.ge_u
(get_local $2) (get_local $2)
@ -2142,7 +2142,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )
@ -2172,7 +2172,7 @@
(get_local $0) (get_local $0)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_u (i32.ge_u
(get_local $2) (get_local $2)
@ -2254,7 +2254,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
) )

View File

@ -2408,34 +2408,32 @@
) )
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_u
(i32.lt_u (get_local $2)
(get_local $2) (get_local $3)
(get_local $3)
)
) )
) )
(if )
(i32.eq (if
(i32.load (i32.eq
(i32.add (i32.load
(i32.load (i32.add
(get_local $0) (i32.load
) (get_local $0)
(i32.mul )
(get_local $2) (i32.mul
(i32.const 4) (get_local $2)
) (i32.const 4)
) )
) )
(get_local $1)
)
(return
(i32.const 1)
) )
(get_local $1)
)
(return
(i32.const 1)
) )
) )
(set_local $2 (set_local $2
@ -2444,7 +2442,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(return (return
@ -2482,19 +2480,40 @@
) )
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_u
(i32.lt_u (get_local $2)
(get_local $2) (get_local $3)
(get_local $3)
)
) )
) )
(if )
(i32.eq (if
(i32.load (i32.eq
(i32.load
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $2)
(i32.const 4)
)
)
)
(get_local $1)
)
(block
(if
(i32.lt_u
(i32.add
(get_local $2)
(i32.const 1)
)
(get_local $3)
)
(call $~lib/memory/move_memory
(i32.add (i32.add
(i32.load (i32.load
(get_local $0) (get_local $0)
@ -2504,62 +2523,39 @@
(i32.const 4) (i32.const 4)
) )
) )
) (i32.add
(get_local $1) (i32.load
)
(block
(if
(i32.lt_u
(i32.add
(get_local $2)
(i32.const 1)
)
(get_local $3)
)
(call $~lib/memory/move_memory
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(get_local $2)
(i32.const 4)
)
)
(i32.add
(i32.load
(get_local $0)
)
(i32.mul
(i32.add
(get_local $2)
(i32.const 1)
)
(i32.const 4)
)
)
(i32.sub
(i32.sub
(get_local $3)
(get_local $2)
)
(i32.const 1)
)
)
)
(i32.store offset=8
(get_local $0)
(i32.sub
(i32.load offset=8
(get_local $0) (get_local $0)
) )
(i32.mul
(i32.add
(get_local $2)
(i32.const 1)
)
(i32.const 4)
)
)
(i32.sub
(i32.sub
(get_local $3)
(get_local $2)
)
(i32.const 1) (i32.const 1)
) )
) )
(return )
(i32.store offset=8
(get_local $0)
(i32.sub
(i32.load offset=8
(get_local $0)
)
(i32.const 1) (i32.const 1)
) )
) )
(return
(i32.const 1)
)
) )
) )
(set_local $2 (set_local $2
@ -2568,7 +2564,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(return (return

View File

@ -403,7 +403,7 @@
) )
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.gt_s (i32.gt_s
(i32.add (i32.add
@ -441,7 +441,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
(return (return
(get_local $2) (get_local $2)
@ -3644,7 +3644,7 @@
(get_local $1) (get_local $1)
) )
) )
(loop $loop|0 (loop $repeat|0
(br_if $break|0 (br_if $break|0
(i32.ge_s (i32.ge_s
(get_local $2) (get_local $2)
@ -3671,7 +3671,7 @@
(get_local $3) (get_local $3)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(get_local $4) (get_local $4)

View File

@ -504,45 +504,43 @@
(set_local $5 (set_local $5
(get_local $7) (get_local $7)
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.le_s
(i32.le_s (i32.add
(i32.add (get_local $5)
(get_local $5) (get_local $8)
(get_local $8)
)
(get_local $4)
) )
(get_local $4)
) )
) )
(if )
(i32.eqz (if
(call $~lib/memory/compare_memory (i32.eqz
(call $~lib/memory/compare_memory
(i32.add
(i32.add (i32.add
(i32.add (get_local $0)
(get_local $0)
(i32.const 4)
)
(i32.shl
(get_local $5)
(i32.const 1)
)
)
(i32.add
(get_local $1)
(i32.const 4) (i32.const 4)
) )
(i32.shl (i32.shl
(get_local $8) (get_local $5)
(i32.const 1) (i32.const 1)
) )
) )
(i32.add
(get_local $1)
(i32.const 4)
)
(i32.shl
(get_local $8)
(i32.const 1)
)
) )
(return )
(get_local $5) (return
) (get_local $5)
) )
) )
(set_local $5 (set_local $5
@ -551,7 +549,7 @@
(i32.const 1) (i32.const 1)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(return (return
@ -4208,30 +4206,28 @@
) )
) )
) )
(loop $loop|0 (loop $repeat|0
(block $continue|0 (br_if $break|0
(br_if $break|0 (i32.eqz
(i32.eqz (i32.lt_s
(i32.lt_s (get_local $3)
(get_local $3) (get_local $6)
(get_local $6)
)
) )
) )
(call $~lib/memory/move_memory )
(call $~lib/memory/move_memory
(i32.add
(i32.add (i32.add
(i32.add (get_local $4)
(get_local $4)
(i32.const 4)
)
(get_local $3)
)
(i32.add
(get_local $0)
(i32.const 4) (i32.const 4)
) )
(get_local $5) (get_local $3)
) )
(i32.add
(get_local $0)
(i32.const 4)
)
(get_local $5)
) )
(set_local $3 (set_local $3
(i32.add (i32.add
@ -4239,7 +4235,7 @@
(get_local $5) (get_local $5)
) )
) )
(br $loop|0) (br $repeat|0)
) )
) )
(return (return