Add offsetof<T> builtin; Put a function's trampoline into the function table if a it has optional parameters; TypedArray scaffolding

This commit is contained in:
dcodeIO 2018-03-24 00:38:49 +01:00
parent ec5bb7ad51
commit 664f2a1c0d
17 changed files with 1301 additions and 612 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

@ -16,7 +16,11 @@ import {
import {
Node,
Expression
NodeKind,
Expression,
LiteralKind,
LiteralExpression,
StringLiteralExpression
} from "./ast";
import {
@ -37,10 +41,10 @@ import {
import {
ElementKind,
Global,
Local,
FunctionPrototype,
Class,
ClassPrototype
ClassPrototype,
Field
} from "./program";
/** Compiles a get of a built-in global. */
@ -94,12 +98,6 @@ export function compileCall(
arg2: ExpressionRef,
ret: ExpressionRef;
var tempLocal0: Local,
tempLocal1: Local;
var type: Type,
offset: i32;
// NOTE that some implementations below make use of the select expression where straight-forward.
// whether worth or not should probably be tested once/ it's known if/how embedders handle it.
// search: createSelect
@ -124,7 +122,7 @@ export function compileCall(
return module.createUnreachable();
}
compiler.compileExpressionRetainType(operands[0], Type.i32, false);
type = compiler.currentType;
let type = compiler.currentType;
compiler.currentType = Type.bool;
return type.is(TypeFlags.INTEGER) && !type.is(TypeFlags.REFERENCE)
? module.createI32(1)
@ -146,7 +144,7 @@ export function compileCall(
return module.createUnreachable();
}
compiler.compileExpressionRetainType(operands[0], Type.i32, false);
type = compiler.currentType;
let type = compiler.currentType;
compiler.currentType = Type.bool;
return type.is(TypeFlags.FLOAT)
? module.createI32(1)
@ -168,7 +166,7 @@ export function compileCall(
return module.createUnreachable();
}
compiler.compileExpressionRetainType(operands[0], Type.i32, false);
type = compiler.currentType;
let type = compiler.currentType;
compiler.currentType = Type.bool;
return type.is(TypeFlags.REFERENCE)
? module.createI32(1)
@ -190,7 +188,7 @@ export function compileCall(
return module.createUnreachable();
}
compiler.compileExpressionRetainType(operands[0], Type.i32, false);
type = compiler.currentType;
let type = compiler.currentType;
compiler.currentType = Type.bool;
let classType = type.classReference;
if (classType) {
@ -222,7 +220,7 @@ export function compileCall(
return module.createUnreachable();
}
compiler.compileExpressionRetainType(operands[0], Type.i32, false);
type = compiler.currentType;
let type = compiler.currentType;
compiler.currentType = Type.bool;
let classType = type.classReference;
return classType != null && classType.prototype.fnIndexedGet != null
@ -262,18 +260,18 @@ export function compileCall(
switch (compiler.currentType.kind) {
case TypeKind.F32: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.f32);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.f32);
ret = module.createBinary(BinaryOp.NeF32,
module.createTeeLocal(tempLocal0.index, arg0),
module.createGetLocal(tempLocal0.index, NativeType.F32)
module.createTeeLocal(tempLocal.index, arg0),
module.createGetLocal(tempLocal.index, NativeType.F32)
);
break;
}
case TypeKind.F64: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.f64);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.f64);
ret = module.createBinary(BinaryOp.NeF64,
module.createTeeLocal(tempLocal0.index, arg0),
module.createGetLocal(tempLocal0.index, NativeType.F64)
module.createTeeLocal(tempLocal.index, arg0),
module.createGetLocal(tempLocal.index, NativeType.F64)
);
break;
}
@ -322,35 +320,35 @@ export function compileCall(
}
switch (compiler.currentType.kind) {
case TypeKind.F32: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.f32);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.f32);
ret = module.createSelect(
module.createBinary(BinaryOp.NeF32,
module.createUnary(UnaryOp.AbsF32,
module.createTeeLocal(tempLocal0.index, arg0)
module.createTeeLocal(tempLocal.index, arg0)
),
module.createF32(Infinity)
),
module.createI32(0),
module.createBinary(BinaryOp.EqF32,
module.createGetLocal(tempLocal0.index, NativeType.F32),
module.createGetLocal(tempLocal0.index, NativeType.F32)
module.createGetLocal(tempLocal.index, NativeType.F32),
module.createGetLocal(tempLocal.index, NativeType.F32)
)
);
break;
}
case TypeKind.F64: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.f64);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.f64);
ret = module.createSelect(
module.createBinary(BinaryOp.NeF64,
module.createUnary(UnaryOp.AbsF64,
module.createTeeLocal(tempLocal0.index, arg0)
module.createTeeLocal(tempLocal.index, arg0)
),
module.createF64(Infinity)
),
module.createI32(0),
module.createBinary(BinaryOp.EqF64,
module.createGetLocal(tempLocal0.index, NativeType.F64),
module.createGetLocal(tempLocal0.index, NativeType.F64)
module.createGetLocal(tempLocal.index, NativeType.F64),
module.createGetLocal(tempLocal.index, NativeType.F64)
)
);
break;
@ -798,51 +796,51 @@ export function compileCall(
// doesn't need sign-extension here because ifFalse below is either positive
// or MIN_VALUE (-MIN_VALUE == MIN_VALUE) if selected
case TypeKind.I32: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
module.createTeeLocal(tempLocal.index, arg0),
module.createBinary(BinaryOp.SubI32, // ifFalse
module.createI32(0),
module.createGetLocal(tempLocal0.index, NativeType.I32)
module.createGetLocal(tempLocal.index, NativeType.I32)
),
module.createBinary(BinaryOp.GtI32,
module.createGetLocal(tempLocal0.index, NativeType.I32),
module.createGetLocal(tempLocal.index, NativeType.I32),
module.createI32(0)
)
);
break;
}
case TypeKind.ISIZE: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
module.createTeeLocal(tempLocal.index, arg0),
module.createBinary(
compiler.options.isWasm64
? BinaryOp.SubI64
: BinaryOp.SubI32,
compiler.options.usizeType.toNativeZero(module),
module.createGetLocal(tempLocal0.index, compiler.options.nativeSizeType)
module.createGetLocal(tempLocal.index, compiler.options.nativeSizeType)
),
module.createBinary(
compiler.options.isWasm64
? BinaryOp.GtI64
: BinaryOp.GtI32,
module.createGetLocal(tempLocal0.index, compiler.options.nativeSizeType),
module.createGetLocal(tempLocal.index, compiler.options.nativeSizeType),
compiler.options.usizeType.toNativeZero(module)
)
);
break;
}
case TypeKind.I64: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
module.createTeeLocal(tempLocal.index, arg0),
module.createBinary(BinaryOp.SubI64,
module.createI64(0, 0),
module.createGetLocal(tempLocal0.index, NativeType.I64),
module.createGetLocal(tempLocal.index, NativeType.I64),
),
module.createBinary(BinaryOp.GtI64,
module.createGetLocal(tempLocal0.index, NativeType.I64),
module.createGetLocal(tempLocal.index, NativeType.I64),
module.createI64(0, 0)
)
);
@ -925,8 +923,8 @@ export function compileCall(
case TypeKind.I8:
case TypeKind.I16:
case TypeKind.I32: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -942,8 +940,8 @@ export function compileCall(
case TypeKind.U16:
case TypeKind.U32:
case TypeKind.BOOL: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -956,8 +954,8 @@ export function compileCall(
break;
}
case TypeKind.I64: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -970,8 +968,8 @@ export function compileCall(
break;
}
case TypeKind.U64: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -984,8 +982,8 @@ export function compileCall(
break;
}
case TypeKind.ISIZE: {
tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
let tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1009,8 +1007,8 @@ export function compileCall(
ret = module.createUnreachable();
break;
}
tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
let tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1079,8 +1077,8 @@ export function compileCall(
case TypeKind.I8:
case TypeKind.I16:
case TypeKind.I32: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1096,8 +1094,8 @@ export function compileCall(
case TypeKind.U16:
case TypeKind.U32:
case TypeKind.BOOL: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i32);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1110,8 +1108,8 @@ export function compileCall(
break;
}
case TypeKind.I64: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1124,8 +1122,8 @@ export function compileCall(
break;
}
case TypeKind.U64: {
tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
let tempLocal0 = compiler.currentFunction.getTempLocal(Type.i64);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1138,8 +1136,8 @@ export function compileCall(
break;
}
case TypeKind.ISIZE: {
tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
let tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1163,8 +1161,8 @@ export function compileCall(
ret = module.createUnreachable();
break;
}
tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
let tempLocal0 = compiler.currentFunction.getTempLocal(compiler.options.usizeType);
let tempLocal1 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
compiler.currentFunction.freeTempLocal(tempLocal0);
ret = module.createSelect(
module.createTeeLocal(tempLocal0.index, arg0),
@ -1679,7 +1677,7 @@ export function compileCall(
return module.createUnreachable();
}
arg0 = compiler.compileExpression(operands[0], compiler.options.usizeType);
offset = operands.length == 2 ? evaluateConstantOffset(compiler, operands[1]) : 0; // reports
let offset = operands.length == 2 ? evaluateConstantOffset(compiler, operands[1]) : 0; // reports
if (offset < 0) { // reported in evaluateConstantOffset
return module.createUnreachable();
}
@ -1733,6 +1731,7 @@ export function compileCall(
? ConversionKind.NONE // wraps a larger integer type to a smaller one, i.e. i32.store8
: ConversionKind.IMPLICIT
);
let type: Type;
if (
compiler.currentType.is(TypeFlags.INTEGER) &&
typeArguments[0].is(TypeFlags.INTEGER) &&
@ -1748,7 +1747,7 @@ export function compileCall(
} else {
type = compiler.currentType;
}
offset = operands.length == 3 ? evaluateConstantOffset(compiler, operands[2]) : 0; // reports
let offset = operands.length == 3 ? evaluateConstantOffset(compiler, operands[2]) : 0; // reports
if (offset < 0) { // reported in evaluateConstantOffset
return module.createUnreachable();
}
@ -1770,26 +1769,105 @@ export function compileCall(
);
return module.createUnreachable();
}
if (typeArguments) {
if (typeArguments.length != 1) {
if (!(typeArguments && typeArguments.length == 1)) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
reportNode.range, "1", typeArguments ? typeArguments.length.toString(10) : "0"
);
return module.createUnreachable();
}
ret = compiler.options.isWasm64
? module.createI64(typeArguments[0].byteSize, 0)
: module.createI32(typeArguments[0].byteSize);
let byteSize = (<Type[]>typeArguments)[0].byteSize;
if (compiler.options.isWasm64) {
// implicitly wrap if contextual type is a 32-bit integer
if (contextualType.is(TypeFlags.INTEGER) && contextualType.size <= 32) {
compiler.currentType = Type.u32;
ret = module.createI32(byteSize);
} else {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", "0"
);
return module.createUnreachable();
ret = module.createI64(byteSize, 0);
}
} else {
// implicitly extend if contextual type is a 64-bit integer
if (contextualType.is(TypeFlags.INTEGER) && contextualType.size == 64) {
compiler.currentType = Type.u64;
ret = module.createI64(byteSize, 0);
} else {
ret = module.createI32(byteSize);
}
}
return ret;
}
case "offsetof": { // offsetof<T!>(fieldName?)
compiler.currentType = compiler.options.usizeType;
if (operands.length > 1) {
if (!(typeArguments && typeArguments.length == 1)) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments ? typeArguments.length.toString(10) : "0"
);
}
compiler.error(
DiagnosticCode.Expected_0_arguments_but_got_1,
reportNode.range, "1", operands.length.toString(10)
);
return module.createUnreachable();
}
if (!(typeArguments && typeArguments.length == 1)) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments ? typeArguments.length.toString(10) : "0"
);
return module.createUnreachable();
}
let classType = typeArguments[0].classReference;
if (!classType) {
compiler.error( // TODO: better error
DiagnosticCode.Operation_not_supported,
reportNode.range
);
return module.createUnreachable();
}
let offset: i32;
if (operands.length) {
if (
operands[0].kind != NodeKind.LITERAL ||
(<LiteralExpression>operands[0]).literalKind != LiteralKind.STRING
) {
compiler.error(
DiagnosticCode.String_literal_expected,
operands[0].range
);
return module.createUnreachable();
}
let fieldName = (<StringLiteralExpression>operands[0]).value;
let field = classType.members ? classType.members.get(fieldName) : null;
if (!(field && field.kind == ElementKind.FIELD)) {
compiler.error(
DiagnosticCode.Type_0_has_no_property_1,
operands[0].range, classType.internalName, fieldName
);
return module.createUnreachable();
}
offset = (<Field>field).memoryOffset;
} else {
offset = classType.currentMemoryOffset;
}
if (compiler.options.isWasm64) {
// implicitly wrap if contextual type is a 32-bit integer
if (contextualType.is(TypeFlags.INTEGER) && contextualType.size <= 32) {
compiler.currentType = Type.u32;
return module.createI32(offset);
} else {
return module.createI64(offset);
}
} else {
// implicitly extend if contextual type is a 64-bit integer
if (contextualType.is(TypeFlags.INTEGER) && contextualType.size == 64) {
compiler.currentType = Type.u64;
return module.createI64(offset);
} else {
return module.createI32(offset);
}
}
}
// control flow
@ -1823,7 +1901,8 @@ export function compileCall(
} else {
arg0 = compiler.compileExpression(operands[0], Type.i32, ConversionKind.NONE);
}
arg1 = compiler.compileExpression(operands[1], type = compiler.currentType);
let type = compiler.currentType;
arg1 = compiler.compileExpression(operands[1], type);
arg2 = compiler.compileExpression(operands[2], Type.bool);
compiler.currentType = type;
switch (compiler.currentType.kind) {
@ -2022,7 +2101,7 @@ export function compileCall(
arg0 = compiler.compileExpressionRetainType(operands[0], Type.i32);
}
type = compiler.currentType;
let type = compiler.currentType;
compiler.currentType = type.nonNullableType;
// just return ifTrueish if assertions are disabled, or simplify if dropped anyway
@ -2106,64 +2185,64 @@ export function compileCall(
} else {
switch (compiler.currentType.kind) {
default: { // any integer up to 32-bits incl. bool
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.i32);
ret = module.createIf(
module.createUnary(UnaryOp.EqzI32,
module.createTeeLocal(tempLocal0.index, arg0)
module.createTeeLocal(tempLocal.index, arg0)
),
abort,
module.createGetLocal(tempLocal0.index, NativeType.I32)
module.createGetLocal(tempLocal.index, NativeType.I32)
);
break;
}
case TypeKind.I64:
case TypeKind.U64: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.i64);
ret = module.createIf(
module.createUnary(UnaryOp.EqzI64,
module.createTeeLocal(tempLocal0.index, arg0)
module.createTeeLocal(tempLocal.index, arg0)
),
abort,
module.createGetLocal(tempLocal0.index, NativeType.I64)
module.createGetLocal(tempLocal.index, NativeType.I64)
);
break;
}
case TypeKind.ISIZE:
case TypeKind.USIZE: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(compiler.options.usizeType);
ret = module.createIf(
module.createUnary(
compiler.options.isWasm64
? UnaryOp.EqzI64
: UnaryOp.EqzI32,
module.createTeeLocal(tempLocal0.index, arg0)
module.createTeeLocal(tempLocal.index, arg0)
),
abort,
module.createGetLocal(tempLocal0.index, compiler.options.nativeSizeType)
module.createGetLocal(tempLocal.index, compiler.options.nativeSizeType)
);
break;
}
case TypeKind.F32: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.f32);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.f32);
ret = module.createIf(
module.createBinary(BinaryOp.EqF32,
module.createTeeLocal(tempLocal0.index, arg0),
module.createTeeLocal(tempLocal.index, arg0),
module.createF32(0)
),
abort,
module.createGetLocal(tempLocal0.index, NativeType.F32)
module.createGetLocal(tempLocal.index, NativeType.F32)
);
break;
}
case TypeKind.F64: {
tempLocal0 = compiler.currentFunction.getAndFreeTempLocal(Type.f64);
let tempLocal = compiler.currentFunction.getAndFreeTempLocal(Type.f64);
ret = module.createIf(
module.createBinary(BinaryOp.EqF64,
module.createTeeLocal(tempLocal0.index, arg0),
module.createTeeLocal(tempLocal.index, arg0),
module.createF64(0)
),
abort,
module.createGetLocal(tempLocal0.index, NativeType.F64)
module.createGetLocal(tempLocal.index, NativeType.F64)
);
break;
}

View File

@ -1192,6 +1192,10 @@ export class Compiler extends DiagnosticEmitter {
}
var functionTable = this.functionTable;
var index = functionTable.length;
if (func.signature.requiredParameters < func.signature.parameterTypes.length) {
// insert the trampoline if the function has optional parameters
func = this.ensureTrampoline(func);
}
functionTable.push(func);
func.functionTableIndex = index;
return index;

View File

@ -94,6 +94,7 @@ export enum DiagnosticCode {
Multiple_constructor_implementations_are_not_allowed = 2392,
Duplicate_function_implementation = 2393,
Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local = 2395,
Type_0_has_no_property_1 = 2460,
The_0_operator_cannot_be_applied_to_type_1 = 2469,
Export_declaration_conflicts_with_exported_declaration_of_0 = 2484,
Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property = 2540,
@ -197,6 +198,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
case 2392: return "Multiple constructor implementations are not allowed.";
case 2393: return "Duplicate function implementation.";
case 2395: return "Individual declarations in merged declaration '{0}' must be all exported or all local.";
case 2460: return "Type '{0}' has no property '{1}'.";
case 2469: return "The '{0}' operator cannot be applied to type '{1}'.";
case 2484: return "Export declaration conflicts with exported declaration of '{0}'.";
case 2540: return "Cannot assign to '{0}' because it is a constant or a read-only property.";

View File

@ -88,6 +88,7 @@
"Multiple constructor implementations are not allowed.": 2392,
"Duplicate function implementation.": 2393,
"Individual declarations in merged declaration '{0}' must be all exported or all local.": 2395,
"Type '{0}' has no property '{1}'.": 2460,
"The '{0}' operator cannot be applied to type '{1}'.": 2469,
"Export declaration conflicts with exported declaration of '{0}'.": 2484,
"Cannot assign to '{0}' because it is a constant or a read-only property.": 2540,

View File

@ -3012,7 +3012,7 @@ export class ClassPrototype extends Element {
}
}
}
instance.currentMemoryOffset = memoryOffset; // sizeof<this>() is its byte size in memory
instance.currentMemoryOffset = memoryOffset; // offsetof<this>() is the class' byte size in memory
return instance;
}

2
std/assembly.d.ts vendored
View File

@ -221,6 +221,8 @@ declare const Infinity: f32 | f64;
declare const HEAP_BASE: usize;
/** Determines the byte size of the specified core or class type. Compiles to a constant. */
declare function sizeof<T>(): usize;
/** Determines the offset of the specified field within the given class type. Returns the class type's end offset if field name has been omitted. Compiles to a constant. */
declare function offsetof<T>(fieldName?: string): usize;
/** Changes the type of any value of `usize` kind to another one of `usize` kind. Useful for casting class instances to their pointer values and vice-versa. Beware that this is unsafe.*/
declare function changetype<T>(value: any): T;
/** Tests if a 32-bit or 64-bit float is `NaN`. */

View File

@ -50,7 +50,9 @@ export declare function load<T>(offset: usize, constantOffset?: usize): T;
export declare function store<T>(offset: usize, value: void, constantOffset?: usize): T;
export declare function sizeof<T>(): usize;
export declare function sizeof<T>(): usize; // | u32 / u64
export declare function offsetof<T>(fieldName?: string): usize; // | u32 / u64
export declare function select<T>(ifTrue: T, ifFalse: T, condition: bool): T;

View File

@ -0,0 +1,78 @@
class TypedArray<T> {
readonly buffer: ArrayBuffer;
readonly byteOffset: i32;
readonly byteLength: i32;
get length(): i32 { return this.byteLength / sizeof<T>(); }
constructor(length: i32) {
var byteLength = length * sizeof<T>();
this.buffer = new ArrayBuffer(byteLength);
this.byteOffset = 0;
this.byteLength = byteLength;
}
@operator("[]")
private __get(index: i32): T {
var offset = this.byteOffset;
assert(<u32>index < <u32>this.byteLength / sizeof<T>());
return load<T>(changetype<usize>(this.buffer) + (offset + index) * sizeof<T>(), 4);
}
@operator("[]=")
private __set(index: i32, value: T): void {
var offset = this.byteOffset;
assert(<u32>index < <u32>(this.byteLength / sizeof<T>()));
store<T>(changetype<usize>(this.buffer) + (offset + index) * sizeof<T>(), value, 4);
}
}
// export class Int8Array extends TypedArray<i8> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i8>();
// static readonly name: string = "Int8Array";
// }
// export class Uint8Array extends TypedArray<u8> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u8>();
// static readonly name: string = "Uint8Array";
// }
// export class Int16Array extends TypedArray<i16> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i16>();
// static readonly name: string = "Int16Array";
// }
// export class Uint16Array extends TypedArray<u16> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u16>();
// static readonly name: string = "Uint16Array";
// }
// export class Int32Array extends TypedArray<i32> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i32>();
// static readonly name: string = "Int32Array";
// }
// export class Uint32Array extends TypedArray<u32> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u32>();
// static readonly name: string = "Uint32Array";
// }
// export class Int64Array extends TypedArray<i64> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<i64>();
// static readonly name: string = "Int64Array";
// }
// export class Uint64Array extends TypedArray<u64> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<u64>();
// static readonly name: string = "Uint64Array";
// }
// export class Float32Array extends TypedArray<f32> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<f32>();
// static readonly name: string = "Float32Array";
// }
// export class Float64Array extends TypedArray<f64> {
// static readonly BYTES_PER_ELEMENT: usize = sizeof<f64>();
// static readonly name: string = "Float64Array";
// }

View File

@ -657,7 +657,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 235)
(i32.const 244)
(i32.const 0)
)
(unreachable)
@ -674,7 +674,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 236)
(i32.const 245)
(i32.const 0)
)
(unreachable)
@ -700,7 +700,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 237)
(i32.const 246)
(i32.const 0)
)
(unreachable)
@ -726,7 +726,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 238)
(i32.const 247)
(i32.const 0)
)
(unreachable)
@ -752,7 +752,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 239)
(i32.const 248)
(i32.const 0)
)
(unreachable)
@ -778,7 +778,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 240)
(i32.const 249)
(i32.const 0)
)
(unreachable)
@ -806,7 +806,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 241)
(i32.const 250)
(i32.const 0)
)
(unreachable)
@ -834,7 +834,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 242)
(i32.const 251)
(i32.const 0)
)
(unreachable)

View File

@ -217,19 +217,28 @@ if (!i) unreachable();
// AS specific
sizeof<u8>();
sizeof<u16>();
sizeof<u32>();
sizeof<u64>();
assert(sizeof<u8>() == 1);
assert(sizeof<u16>() == 2);
assert(sizeof<u32>() == 4);
assert(sizeof<u64>() == 8);
sizeof<usize>();
sizeof<bool>();
sizeof<i8>();
sizeof<i16>();
sizeof<i32>();
sizeof<i64>();
assert(sizeof<bool>() == 1);
assert(sizeof<i8>() == 1);
assert(sizeof<i16>() == 2);
assert(sizeof<i32>() == 4);
assert(sizeof<i64>() == 8);
sizeof<isize>();
sizeof<f32>();
sizeof<f64>();
assert(sizeof<f32>() == 4);
assert(sizeof<f64>() == 8);
class Foo<T> { a: T; b: T; }
assert(offsetof<Foo<i32>>("a") == 0);
assert(offsetof<Foo<i32>>("b") == 4);
assert(offsetof<Foo<i16>>("a") == 0);
assert(offsetof<Foo<i16>>("b") == 2);
class Bar extends Foo<i64> {}
assert(offsetof<Bar>("a") == 0);
assert(offsetof<Bar>("b") == 8);
assert(NaN != NaN);
assert(isNaN<f32>(NaN));

View File

@ -1226,57 +1226,18 @@
)
(unreachable)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 1)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(if
(i32.eqz
(f64.ne
(f64.const nan:0x8000000000000)
(f64.const nan:0x8000000000000)
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 234)
(i32.const 220)
(i32.const 0)
)
(unreachable)
@ -1284,11 +1245,185 @@
)
(if
(i32.eqz
(f32.ne
(tee_local $4
(f32.const nan:0x400000)
(i32.eq
(i32.const 2)
(i32.const 2)
)
(get_local $4)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 221)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 222)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 223)
(i32.const 0)
)
(unreachable)
)
)
(drop
(i32.const 4)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 225)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 226)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 227)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 228)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 229)
(i32.const 0)
)
(unreachable)
)
)
(drop
(i32.const 4)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 231)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 232)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -1301,6 +1436,127 @@
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 236)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 237)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 238)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 240)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 241)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.ne
(f64.const nan:0x8000000000000)
(f64.const nan:0x8000000000000)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 243)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.ne
(tee_local $4
(f32.const nan:0x400000)
)
(get_local $4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 244)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.ne
@ -1314,7 +1570,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 236)
(i32.const 245)
(i32.const 0)
)
(unreachable)
@ -1344,7 +1600,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 237)
(i32.const 246)
(i32.const 0)
)
(unreachable)
@ -1374,7 +1630,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 238)
(i32.const 247)
(i32.const 0)
)
(unreachable)
@ -1404,7 +1660,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 239)
(i32.const 248)
(i32.const 0)
)
(unreachable)
@ -1434,7 +1690,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 240)
(i32.const 249)
(i32.const 0)
)
(unreachable)
@ -1462,7 +1718,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 241)
(i32.const 250)
(i32.const 0)
)
(unreachable)
@ -1490,7 +1746,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 242)
(i32.const 251)
(i32.const 0)
)
(unreachable)
@ -1513,7 +1769,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 255)
(i32.const 264)
(i32.const 0)
)
(unreachable)
@ -1530,7 +1786,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 256)
(i32.const 265)
(i32.const 0)
)
(unreachable)
@ -1553,7 +1809,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 257)
(i32.const 266)
(i32.const 0)
)
(unreachable)
@ -1570,7 +1826,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 258)
(i32.const 267)
(i32.const 0)
)
(unreachable)
@ -1585,142 +1841,6 @@
)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 259)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2147483647)
(i32.const 2147483647)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 260)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i64.eq
(i64.const -9223372036854775808)
(i64.const -9223372036854775808)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 261)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i64.eq
(i64.const 9223372036854775807)
(i64.const 9223372036854775807)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 262)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 264)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 255)
(i32.const 255)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 265)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 266)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 65535)
(i32.const 65535)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 267)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
@ -1734,8 +1854,8 @@
(if
(i32.eqz
(i32.eq
(i32.const -1)
(i32.const -1)
(i32.const 2147483647)
(i32.const 2147483647)
)
)
(block
@ -1751,8 +1871,8 @@
(if
(i32.eqz
(i64.eq
(i64.const 0)
(i64.const 0)
(i64.const -9223372036854775808)
(i64.const -9223372036854775808)
)
)
(block
@ -1768,8 +1888,8 @@
(if
(i32.eqz
(i64.eq
(i64.const -1)
(i64.const -1)
(i64.const 9223372036854775807)
(i64.const 9223372036854775807)
)
)
(block
@ -1789,40 +1909,6 @@
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 272)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 272)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
@ -1836,25 +1922,25 @@
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
(i32.const 255)
(i32.const 255)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 273)
(i32.const 29)
(i32.const 274)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const -3402823466385288598117041e14)
(f32.const -3402823466385288598117041e14)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -1869,9 +1955,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const 3402823466385288598117041e14)
(f32.const 3402823466385288598117041e14)
(i32.eq
(i32.const 65535)
(i32.const 65535)
)
)
(block
@ -1886,9 +1972,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const -16777215)
(f32.const -16777215)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -1903,9 +1989,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const 16777215)
(f32.const 16777215)
(i32.eq
(i32.const -1)
(i32.const -1)
)
)
(block
@ -1920,9 +2006,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const 1.1920928955078125e-07)
(f32.const 1.1920928955078125e-07)
(i64.eq
(i64.const 0)
(i64.const 0)
)
)
(block
@ -1937,9 +2023,9 @@
)
(if
(i32.eqz
(f64.eq
(f64.const -1797693134862315708145274e284)
(f64.const -1797693134862315708145274e284)
(i64.eq
(i64.const -1)
(i64.const -1)
)
)
(block
@ -1954,9 +2040,9 @@
)
(if
(i32.eqz
(f64.eq
(f64.const 1797693134862315708145274e284)
(f64.const 1797693134862315708145274e284)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -1971,9 +2057,26 @@
)
(if
(i32.eqz
(f64.eq
(f64.const -9007199254740991)
(f64.const -9007199254740991)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 281)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
@ -1986,6 +2089,159 @@
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 282)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const -3402823466385288598117041e14)
(f32.const -3402823466385288598117041e14)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 284)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const 3402823466385288598117041e14)
(f32.const 3402823466385288598117041e14)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 285)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const -16777215)
(f32.const -16777215)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 286)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const 16777215)
(f32.const 16777215)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 287)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const 1.1920928955078125e-07)
(f32.const 1.1920928955078125e-07)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 288)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const -1797693134862315708145274e284)
(f64.const -1797693134862315708145274e284)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 289)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const 1797693134862315708145274e284)
(f64.const 1797693134862315708145274e284)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 290)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const -9007199254740991)
(f64.const -9007199254740991)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 291)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
@ -1997,7 +2253,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 283)
(i32.const 292)
(i32.const 0)
)
(unreachable)
@ -2014,7 +2270,7 @@
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 284)
(i32.const 293)
(i32.const 0)
)
(unreachable)

View File

@ -4083,7 +4083,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 235)
(i32.const 244)
(i32.const 0)
)
(unreachable)
@ -4100,7 +4100,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 236)
(i32.const 245)
(i32.const 0)
)
(unreachable)
@ -4126,7 +4126,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 237)
(i32.const 246)
(i32.const 0)
)
(unreachable)
@ -4152,7 +4152,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 238)
(i32.const 247)
(i32.const 0)
)
(unreachable)
@ -4178,7 +4178,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 239)
(i32.const 248)
(i32.const 0)
)
(unreachable)
@ -4204,7 +4204,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 240)
(i32.const 249)
(i32.const 0)
)
(unreachable)
@ -4232,7 +4232,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 241)
(i32.const 250)
(i32.const 0)
)
(unreachable)
@ -4260,7 +4260,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 242)
(i32.const 251)
(i32.const 0)
)
(unreachable)

View File

@ -5619,57 +5619,18 @@
)
(unreachable)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 1)
)
(drop
(i32.const 1)
)
(drop
(i32.const 2)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(drop
(i32.const 4)
)
(drop
(i32.const 4)
)
(drop
(i32.const 8)
)
(if
(i32.eqz
(f64.ne
(f64.const nan:0x8000000000000)
(f64.const nan:0x8000000000000)
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 234)
(i32.const 220)
(i32.const 0)
)
(unreachable)
@ -5677,11 +5638,185 @@
)
(if
(i32.eqz
(f32.ne
(tee_local $2
(f32.const nan:0x400000)
(i32.eq
(i32.const 2)
(i32.const 2)
)
(get_local $2)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 221)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 222)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 223)
(i32.const 0)
)
(unreachable)
)
)
(drop
(i32.const 4)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 225)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 226)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 227)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 228)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 229)
(i32.const 0)
)
(unreachable)
)
)
(drop
(i32.const 4)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 231)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 232)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -5694,6 +5829,127 @@
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 4)
(i32.const 4)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 236)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 237)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2)
(i32.const 2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 238)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 240)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 8)
(i32.const 8)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 241)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.ne
(f64.const nan:0x8000000000000)
(f64.const nan:0x8000000000000)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 243)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.ne
(tee_local $2
(f32.const nan:0x400000)
)
(get_local $2)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 244)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.ne
@ -5707,7 +5963,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 236)
(i32.const 245)
(i32.const 0)
)
(unreachable)
@ -5737,7 +5993,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 237)
(i32.const 246)
(i32.const 0)
)
(unreachable)
@ -5767,7 +6023,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 238)
(i32.const 247)
(i32.const 0)
)
(unreachable)
@ -5797,7 +6053,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 239)
(i32.const 248)
(i32.const 0)
)
(unreachable)
@ -5827,7 +6083,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 240)
(i32.const 249)
(i32.const 0)
)
(unreachable)
@ -5855,7 +6111,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 241)
(i32.const 250)
(i32.const 0)
)
(unreachable)
@ -5883,7 +6139,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 242)
(i32.const 251)
(i32.const 0)
)
(unreachable)
@ -5906,7 +6162,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 255)
(i32.const 264)
(i32.const 0)
)
(unreachable)
@ -5923,7 +6179,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 256)
(i32.const 265)
(i32.const 0)
)
(unreachable)
@ -5946,7 +6202,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 257)
(i32.const 266)
(i32.const 0)
)
(unreachable)
@ -5963,7 +6219,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 258)
(i32.const 267)
(i32.const 0)
)
(unreachable)
@ -5978,142 +6234,6 @@
)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 259)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 2147483647)
(i32.const 2147483647)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 260)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i64.eq
(i64.const -9223372036854775808)
(i64.const -9223372036854775808)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 261)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i64.eq
(i64.const 9223372036854775807)
(i64.const 9223372036854775807)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 262)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 264)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 255)
(i32.const 255)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 265)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 266)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 65535)
(i32.const 65535)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 267)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
@ -6127,8 +6247,8 @@
(if
(i32.eqz
(i32.eq
(i32.const -1)
(i32.const -1)
(i32.const 2147483647)
(i32.const 2147483647)
)
)
(block
@ -6144,8 +6264,8 @@
(if
(i32.eqz
(i64.eq
(i64.const 0)
(i64.const 0)
(i64.const -9223372036854775808)
(i64.const -9223372036854775808)
)
)
(block
@ -6161,8 +6281,8 @@
(if
(i32.eqz
(i64.eq
(i64.const -1)
(i64.const -1)
(i64.const 9223372036854775807)
(i64.const 9223372036854775807)
)
)
(block
@ -6182,40 +6302,6 @@
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 272)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 272)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
@ -6229,25 +6315,25 @@
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
(i32.const 255)
(i32.const 255)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 273)
(i32.const 29)
(i32.const 274)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const -3402823466385288598117041e14)
(f32.const -3402823466385288598117041e14)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -6262,9 +6348,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const 3402823466385288598117041e14)
(f32.const 3402823466385288598117041e14)
(i32.eq
(i32.const 65535)
(i32.const 65535)
)
)
(block
@ -6279,9 +6365,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const -16777215)
(f32.const -16777215)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -6296,9 +6382,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const 16777215)
(f32.const 16777215)
(i32.eq
(i32.const -1)
(i32.const -1)
)
)
(block
@ -6313,9 +6399,9 @@
)
(if
(i32.eqz
(f32.eq
(f32.const 1.1920928955078125e-07)
(f32.const 1.1920928955078125e-07)
(i64.eq
(i64.const 0)
(i64.const 0)
)
)
(block
@ -6330,9 +6416,9 @@
)
(if
(i32.eqz
(f64.eq
(f64.const -1797693134862315708145274e284)
(f64.const -1797693134862315708145274e284)
(i64.eq
(i64.const -1)
(i64.const -1)
)
)
(block
@ -6347,9 +6433,9 @@
)
(if
(i32.eqz
(f64.eq
(f64.const 1797693134862315708145274e284)
(f64.const 1797693134862315708145274e284)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
@ -6364,9 +6450,26 @@
)
(if
(i32.eqz
(f64.eq
(f64.const -9007199254740991)
(f64.const -9007199254740991)
(i32.eq
(i32.const 0)
(i32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 281)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
@ -6379,6 +6482,159 @@
(unreachable)
)
)
(if
(i32.eqz
(i32.eq
(i32.const 1)
(i32.const 1)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 282)
(i32.const 29)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const -3402823466385288598117041e14)
(f32.const -3402823466385288598117041e14)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 284)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const 3402823466385288598117041e14)
(f32.const 3402823466385288598117041e14)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 285)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const -16777215)
(f32.const -16777215)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 286)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const 16777215)
(f32.const 16777215)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 287)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f32.eq
(f32.const 1.1920928955078125e-07)
(f32.const 1.1920928955078125e-07)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 288)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const -1797693134862315708145274e284)
(f64.const -1797693134862315708145274e284)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 289)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const 1797693134862315708145274e284)
(f64.const 1797693134862315708145274e284)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 290)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
(f64.const -9007199254740991)
(f64.const -9007199254740991)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 291)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(f64.eq
@ -6390,7 +6646,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 283)
(i32.const 292)
(i32.const 0)
)
(unreachable)
@ -6407,7 +6663,7 @@
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 284)
(i32.const 293)
(i32.const 0)
)
(unreachable)