Move some numeric builtins to stdlib; Minor refactoring

This commit is contained in:
dcodeIO 2018-04-17 02:50:38 +02:00
parent 6d0b5d92c2
commit 4929fca363
26 changed files with 1987 additions and 1746 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

@ -1767,23 +1767,17 @@ export class WhileStatement extends Statement {
statement: Statement;
}
/** Gets the first decorator by name within at set of decorators, if present. */
export function getFirstDecorator(name: string, decorators: DecoratorNode[] | null): DecoratorNode | null {
/** Tests if a specific decorator is present within the specified decorators. */
export function hasDecorator(name: string, decorators: DecoratorNode[] | null): bool {
if (decorators) {
for (let i = 0, k = decorators.length; i < k; ++i) {
let decorator = decorators[i];
let expression = decorator.name;
let expression = decorators[i].name;
if (expression.kind == NodeKind.IDENTIFIER && (<IdentifierExpression>expression).text == name) {
return decorator;
return true;
}
}
}
return null;
}
/** Tests if a specific decorator is present within the specified decorators. */
export function hasDecorator(name: string, decorators: DecoratorNode[] | null): bool {
return getFirstDecorator(name, decorators) != null;
return false;
}
/** Mangles a declaration's name to an internal name. */

View File

@ -54,22 +54,6 @@ export function compileGetConstant(
reportNode: Node
): ExpressionRef {
switch (global.internalName) {
case "NaN": { // context-sensitive
if (compiler.currentType == Type.f32) {
return compiler.module.createF32(NaN);
} else {
compiler.currentType = Type.f64;
return compiler.module.createF64(NaN);
}
}
case "Infinity": { // context-sensitive
if (compiler.currentType == Type.f32) {
return compiler.module.createF32(Infinity);
} else {
compiler.currentType = Type.f64;
return compiler.module.createF64(Infinity);
}
}
case "HEAP_BASE": { // never inlined for linking purposes
compiler.currentType = compiler.options.usizeType;
return compiler.module.createGetGlobal("HEAP_BASE", compiler.currentType.toNativeType());
@ -154,143 +138,6 @@ export function compileCall(
// math
case "isNaN": { // isNaN<T?>(value: T) -> bool
compiler.currentType = Type.bool;
if (operands.length != 1) {
if (typeArguments && typeArguments.length != 1) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
);
}
compiler.error(
DiagnosticCode.Expected_0_arguments_but_got_1,
reportNode.range, "1", operands.length.toString(10)
);
return module.createUnreachable();
}
if (typeArguments) {
if (typeArguments.length != 1) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
);
return module.createUnreachable();
}
arg0 = compiler.compileExpression(operands[0], typeArguments[0]);
} else {
arg0 = compiler.compileExpression(operands[0], Type.f64, ConversionKind.NONE);
}
switch (compiler.currentType.kind) {
case TypeKind.F32: {
ret = module.createBinary(
BinaryOp.GtU32,
module.createBinary(
BinaryOp.AndI32,
module.createUnary(UnaryOp.ReinterpretF32, arg0),
module.createI32(0x7FFFFFFF)
),
module.createI32(0x7F800000)
);
break;
}
case TypeKind.F64: {
ret = module.createBinary(
BinaryOp.GtU64,
module.createBinary(
BinaryOp.AndI64,
module.createUnary(UnaryOp.ReinterpretF64, arg0),
module.createI64(0xFFFFFFFF, 0x7FFFFFFF)
),
module.createI64(0, 0x7FF00000)
);
break;
}
case TypeKind.VOID: {
compiler.error(
DiagnosticCode.Operation_not_supported,
reportNode.range
);
ret = module.createUnreachable();
break;
}
default: { // every other type is never NaN
ret = module.createI32(0);
break;
}
}
compiler.currentType = Type.bool;
return ret;
}
case "isFinite": { // isFinite<T?>(value: T) -> bool
compiler.currentType = Type.bool;
if (operands.length != 1) {
if (typeArguments && typeArguments.length != 1) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
);
}
compiler.error(
DiagnosticCode.Expected_0_arguments_but_got_1,
reportNode.range, "1", operands.length.toString(10)
);
return module.createUnreachable();
}
if (typeArguments) {
if (typeArguments.length != 1) {
compiler.error(
DiagnosticCode.Expected_0_type_arguments_but_got_1,
reportNode.range, "1", typeArguments.length.toString(10)
);
return module.createUnreachable();
}
arg0 = compiler.compileExpression(operands[0], typeArguments[0]);
} else {
arg0 = compiler.compileExpression(operands[0], Type.f64, ConversionKind.NONE);
}
switch (compiler.currentType.kind) {
case TypeKind.F32: {
ret = module.createBinary(
BinaryOp.LtU32,
module.createBinary(
BinaryOp.AndI32,
module.createUnary(UnaryOp.ReinterpretF32, arg0),
module.createI32(0x7FFFFFFF)
),
module.createI32(0x7F800000)
);
break;
}
case TypeKind.F64: {
ret = module.createBinary(
BinaryOp.LtU64,
module.createBinary(
BinaryOp.AndI64,
module.createUnary(UnaryOp.ReinterpretF64, arg0),
module.createI64(0xFFFFFFFF, 0x7FFFFFFF)
),
module.createI64(0, 0x7FF00000)
);
break;
}
case TypeKind.VOID: {
compiler.error(
DiagnosticCode.Operation_not_supported,
reportNode.range
);
ret = module.createUnreachable();
break;
}
default: { // every other type is always finite
ret = module.createI32(1);
break;
}
}
compiler.currentType = Type.bool;
return ret;
}
case "clz": { // clz<T?>(value: T) -> T
if (operands.length != 1) {
if (typeArguments) {

View File

@ -266,12 +266,10 @@ export class Compiler extends DiagnosticEmitter {
this.startFunction = startFunctionInstance;
this.currentFunction = startFunctionInstance;
// compile entry file(s) while traversing to reachable elements
// compile entry file(s) while traversing reachable elements
var sources = program.sources;
for (let i = 0, k = sources.length; i < k; ++i) {
if (sources[i].isEntry) {
this.compileSource(sources[i]);
}
if (sources[i].isEntry) this.compileSource(sources[i]);
}
// compile the start function if not empty
@ -326,7 +324,7 @@ export class Compiler extends DiagnosticEmitter {
);
}
// import memory if requested
// import memory if requested (default memory is named '0' by Binaryen)
if (options.importMemory) module.addMemoryImport("0", "env", "memory");
// set up function table
@ -343,7 +341,7 @@ export class Compiler extends DiagnosticEmitter {
functionTableExported = true;
}
// import table if requested
// import table if requested (default table is named '0' by Binaryen)
if (options.importTable) {
module.addTableImport("0", "env", "table");
if (!functionTableExported) module.addTableExport("0", "table");
@ -354,6 +352,7 @@ export class Compiler extends DiagnosticEmitter {
// sources
/** Compiles a source by looking it up by path first. */
compileSourceByPath(normalizedPathWithoutExtension: string, reportNode: Node): void {
var source = this.program.lookupSourceByPath(normalizedPathWithoutExtension);
if (!source) {
@ -366,8 +365,9 @@ export class Compiler extends DiagnosticEmitter {
this.compileSource(source);
}
/** Compiles a source. */
compileSource(source: Source): void {
if (source.is(CommonFlags.COMPILED)) return;
if (source.is(CommonFlags.COMPILED)) return;
source.set(CommonFlags.COMPILED);
// compile top-level statements
@ -2098,12 +2098,16 @@ export class Compiler extends DiagnosticEmitter {
)
: this.module.createI64(0);
}
case TypeKind.F64: {
if (!(element.is(CommonFlags.BUILTIN) && contextualType == Type.f32)) {
return this.module.createF64((<VariableLikeElement>element).constantFloatValue);
}
// otherwise fall-through: basically precomputes f32.demote/f64 of NaN / Infinity
this.currentType = Type.f32;
}
case TypeKind.F32: {
return this.module.createF32((<VariableLikeElement>element).constantFloatValue);
}
case TypeKind.F64: {
return this.module.createF64((<VariableLikeElement>element).constantFloatValue);
}
default: {
assert(false);
return this.module.createUnreachable();
@ -2324,18 +2328,14 @@ export class Compiler extends DiagnosticEmitter {
expr = module.createUnary(UnaryOp.TruncF32ToI64, expr);
} else {
expr = module.createUnary(UnaryOp.TruncF32ToI32, expr);
if (toType.is(TypeFlags.SMALL)) {
expr = makeSmallIntegerWrap(expr, toType, module);
}
if (toType.is(TypeFlags.SHORT)) expr = makeSmallIntegerWrap(expr, toType, module);
}
} else {
if (toType.is(TypeFlags.LONG)) {
expr = module.createUnary(UnaryOp.TruncF32ToU64, expr);
} else {
expr = module.createUnary(UnaryOp.TruncF32ToU32, expr);
if (toType.is(TypeFlags.SMALL)) {
expr = makeSmallIntegerWrap(expr, toType, module);
}
if (toType.is(TypeFlags.SHORT)) expr = makeSmallIntegerWrap(expr, toType, module);
}
}
@ -2346,18 +2346,14 @@ export class Compiler extends DiagnosticEmitter {
expr = module.createUnary(UnaryOp.TruncF64ToI64, expr);
} else {
expr = module.createUnary(UnaryOp.TruncF64ToI32, expr);
if (toType.is(TypeFlags.SMALL)) {
expr = makeSmallIntegerWrap(expr, toType, module);
}
if (toType.is(TypeFlags.SHORT)) expr = makeSmallIntegerWrap(expr, toType, module);
}
} else {
if (toType.is(TypeFlags.LONG)) {
expr = module.createUnary(UnaryOp.TruncF64ToU64, expr);
} else {
expr = module.createUnary(UnaryOp.TruncF64ToU32, expr);
if (toType.is(TypeFlags.SMALL)) {
expr = makeSmallIntegerWrap(expr, toType, module);
}
if (toType.is(TypeFlags.SHORT)) expr = makeSmallIntegerWrap(expr, toType, module);
}
}
}
@ -2415,9 +2411,7 @@ export class Compiler extends DiagnosticEmitter {
// i64 to i32
if (!toType.is(TypeFlags.LONG)) {
expr = module.createUnary(UnaryOp.WrapI64, expr); // discards upper bits
if (toType.is(TypeFlags.SMALL)) {
expr = makeSmallIntegerWrap(expr, toType, module);
}
if (toType.is(TypeFlags.SHORT)) expr = makeSmallIntegerWrap(expr, toType, module);
}
// i32 to i64
@ -2426,7 +2420,7 @@ export class Compiler extends DiagnosticEmitter {
// i32 or smaller to even smaller or same size int with change of sign
} else if (
toType.is(TypeFlags.SMALL) &&
toType.is(TypeFlags.SHORT) &&
(
fromType.size > toType.size ||
(
@ -4097,7 +4091,7 @@ export class Compiler extends DiagnosticEmitter {
leftExpr = module.createTeeLocal(tempLocal.index, leftExpr);
}
possiblyOverflows = this.currentType.is(TypeFlags.SMALL | TypeFlags.INTEGER);
possiblyOverflows = this.currentType.is(TypeFlags.SHORT | TypeFlags.INTEGER);
condExpr = makeIsTrueish(leftExpr, this.currentType, module);
// simplify when cloning left without side effects was successful
@ -4143,7 +4137,7 @@ export class Compiler extends DiagnosticEmitter {
leftExpr = module.createTeeLocal(tempLocal.index, leftExpr);
}
possiblyOverflows = this.currentType.is(TypeFlags.SMALL | TypeFlags.INTEGER); // if right did
possiblyOverflows = this.currentType.is(TypeFlags.SHORT | TypeFlags.INTEGER); // if right did
condExpr = makeIsTrueish(leftExpr, this.currentType, module);
// simplify when cloning left without side effects was successful
@ -4179,7 +4173,7 @@ export class Compiler extends DiagnosticEmitter {
}
}
if (possiblyOverflows && wrapSmallIntegers) {
assert(this.currentType.is(TypeFlags.SMALL | TypeFlags.INTEGER)); // must be a small int
assert(this.currentType.is(TypeFlags.SHORT | TypeFlags.INTEGER)); // must be a small int
expr = makeSmallIntegerWrap(expr, this.currentType, module);
}
return compound
@ -6201,7 +6195,7 @@ export class Compiler extends DiagnosticEmitter {
}
if (possiblyOverflows) {
assert(currentType.is(TypeFlags.SMALL | TypeFlags.INTEGER));
assert(currentType.is(TypeFlags.SHORT | TypeFlags.INTEGER));
setValue = makeSmallIntegerWrap(setValue, currentType, module);
}
@ -6252,7 +6246,7 @@ export class Compiler extends DiagnosticEmitter {
false // wrapped below
);
currentType = this.currentType;
possiblyOverflows = currentType.is(TypeFlags.SMALL | TypeFlags.INTEGER); // if operand already did
possiblyOverflows = currentType.is(TypeFlags.SHORT | TypeFlags.INTEGER); // if operand already did
break;
}
case Token.MINUS: {
@ -6553,7 +6547,7 @@ export class Compiler extends DiagnosticEmitter {
}
}
if (possiblyOverflows && wrapSmallIntegers) {
assert(currentType.is(TypeFlags.SMALL | TypeFlags.INTEGER));
assert(currentType.is(TypeFlags.SHORT | TypeFlags.INTEGER));
expr = makeSmallIntegerWrap(expr, currentType, module);
}
return compound

View File

@ -36,17 +36,27 @@ abstract class ExportsWalker {
/** Program reference. */
program: Program;
/** Whether to include private members */
private includePrivate: bool;
/** Already seen elements. */
private seen: Set<Element> = new Set();
/** Constructs a new Element walker. */
constructor(program: Program) {
constructor(program: Program, includePrivate: bool = false) {
this.program = program;
this.includePrivate;
}
/** Walks all exports and calls the respective handlers. */
walk(): void {
for (let element of this.program.moduleLevelExports.values()) this.visitElement(element);
}
/** Visits an element.*/
visitElement(element: Element): void {
if (element.is(CommonFlags.PRIVATE) && !this.includePrivate) return;
if (this.seen.has(element)) return;
this.seen.add(element);
switch (element.kind) {
case ElementKind.GLOBAL: {
if (element.is(CommonFlags.COMPILED)) this.visitGlobal(<Global>element);
@ -57,11 +67,11 @@ abstract class ExportsWalker {
break;
}
case ElementKind.FUNCTION_PROTOTYPE: {
this.visitCompiledFunctions(<FunctionPrototype>element);
this.visitFunctionInstances(<FunctionPrototype>element);
break;
}
case ElementKind.CLASS_PROTOTYPE: {
this.visitCompiledClasses(<ClassPrototype>element);
this.visitClassInstances(<ClassPrototype>element);
break;
}
case ElementKind.FIELD: {
@ -71,26 +81,26 @@ abstract class ExportsWalker {
case ElementKind.PROPERTY: {
let prop = <Property>element;
let getter = prop.getterPrototype;
if (getter) this.visitCompiledFunctions(getter);
if (getter) this.visitFunctionInstances(getter);
let setter = prop.setterPrototype;
if (setter) this.visitCompiledFunctions(setter);
if (setter) this.visitFunctionInstances(setter);
break;
}
case ElementKind.NAMESPACE: {
if (hasCompiledMember(<Namespace>element)) this.visitNamespace(<Namespace>element);
if (hasCompiledMember(element)) this.visitNamespace(element);
break;
}
default: assert(false);
}
}
visitCompiledFunctions(element: FunctionPrototype): void {
private visitFunctionInstances(element: FunctionPrototype): void {
for (let instance of element.instances.values()) {
if (instance.is(CommonFlags.COMPILED)) this.visitFunction(<Function>instance);
}
}
visitCompiledClasses(element: ClassPrototype): void {
private visitClassInstances(element: ClassPrototype): void {
for (let instance of element.instances.values()) {
if (instance.is(CommonFlags.COMPILED)) this.visitClass(<Class>instance);
}
@ -114,17 +124,14 @@ export class IDLBuilder extends ExportsWalker {
}
private sb: string[] = [];
private seen: Set<Element> = new Set();
private indentLevel: i32 = 0;
/** Constructs a new WebIDL builder. */
constructor(program: Program) {
super(program);
constructor(program: Program, includePrivate: bool = false) {
super(program, includePrivate);
}
visitGlobal(element: Global): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
var isConst = element.is(CommonFlags.INLINED);
indent(sb, this.indentLevel);
@ -151,8 +158,6 @@ export class IDLBuilder extends ExportsWalker {
}
visitEnum(element: Enum): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
indent(sb, this.indentLevel++);
sb.push("interface ");
@ -184,8 +189,6 @@ export class IDLBuilder extends ExportsWalker {
}
visitFunction(element: Function): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
var signature = element.signature;
indent(sb, this.indentLevel);
@ -217,8 +220,6 @@ export class IDLBuilder extends ExportsWalker {
}
visitClass(element: Class): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
indent(sb, this.indentLevel++);
sb.push("interface ");
@ -238,8 +239,6 @@ export class IDLBuilder extends ExportsWalker {
}
visitNamespace(element: Namespace): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
indent(sb, this.indentLevel++);
sb.push("interface ");
@ -298,17 +297,14 @@ export class TSDBuilder extends ExportsWalker {
}
private sb: string[] = [];
private seen: Set<Element> = new Set();
private indentLevel: i32 = 0;
/** Constructs a new WebIDL builder. */
constructor(program: Program) {
super(program);
constructor(program: Program, includePrivate: bool = false) {
super(program, includePrivate);
}
visitGlobal(element: Global): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
var isConst = element.is(CommonFlags.INLINED);
indent(sb, this.indentLevel);
@ -327,8 +323,6 @@ export class TSDBuilder extends ExportsWalker {
}
visitEnum(element: Enum): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
indent(sb, this.indentLevel++);
sb.push("enum ");
@ -339,7 +333,6 @@ export class TSDBuilder extends ExportsWalker {
let numMembers = members.size;
for (let [name, member] of members) {
if (member.kind == ElementKind.ENUMVALUE) {
this.seen.add(member);
indent(sb, this.indentLevel);
sb.push(name);
if (member.is(CommonFlags.INLINED)) {
@ -357,8 +350,6 @@ export class TSDBuilder extends ExportsWalker {
}
visitFunction(element: Function): void {
if (this.seen.has(element)) return;
this.seen.add(element);
if (element.is(CommonFlags.PRIVATE)) return;
var sb = this.sb;
var signature = element.signature;
@ -397,8 +388,6 @@ export class TSDBuilder extends ExportsWalker {
}
visitClass(element: Class): void {
if (this.seen.has(element)) return;
this.seen.add(element);
var sb = this.sb;
var isInterface = element.kind == ElementKind.INTERFACE;
indent(sb, this.indentLevel++);
@ -530,8 +519,6 @@ export class TSDBuilder extends ExportsWalker {
}
}
// TODO: C bindings? or is this sufficiently covered by WebIDL and using a 3rd-party tool?
// helpers
/** Tests if a namespace-like element has at least one compiled member. */

View File

@ -2600,7 +2600,7 @@ export class FunctionPrototype extends Element {
if (isInstance) {
classInstance = assert(classPrototype).resolve(classTypeArguments, contextualTypeArguments); // reports
if (!classInstance) return null;
thisType = classInstance.type.asThis();
thisType = classInstance.type;
contextualTypeArguments.set("this", thisType);
}

View File

@ -69,20 +69,18 @@ export const enum TypeFlags {
INTEGER = 1 << 2,
/** Is a floating point type. */
FLOAT = 1 << 3,
/** Is a sized integer type with a target specific bit size. */
SIZE = 1 << 4,
/** Is a small type that is emulated in a larger type. */
SMALL = 1 << 5,
/** Is a long type larger than 32-bits. */
/** Is a pointer type. */
POINTER = 1 << 4,
/** Is smaller than 32-bits. */
SHORT = 1 << 5,
/** Is larger than 32-bits. */
LONG = 1 << 6,
/** Is a value type. */
VALUE = 1 << 7,
/** Is a reference type. */
REFERENCE = 1 << 8,
/** Is a nullable type. */
NULLABLE = 1 << 9,
/** Is the special 'this' type. */
THIS = 1 << 10
NULLABLE = 1 << 9
}
/** Represents a resolved type. */
@ -94,21 +92,19 @@ export class Type {
flags: TypeFlags;
/** Size in bits. */
size: u32;
/** Size in bytes. Ceiled to 8-bits. */
/** Size in bytes. */
byteSize: i32;
/** Underlying class reference, if a class type. */
classReference: Class | null;
/** Underlying function reference, if a function type. */
/** Underlying signature reference, if a function type. */
signatureReference: Signature | null;
/** Respective nullable type, if non-nullable. */
nullableType: Type | null = null;
/** Respective non-nullable type, if nullable. */
nonNullableType: Type;
/** Respective special 'this' type. */
thisType: Type | null = null;
/** Cached nullable type, if non-nullable. */
private cachedNullableType: Type | null = null;
/** Constructs a new resolved type. */
constructor(kind: TypeKind, flags: TypeFlags, size: i32) {
constructor(kind: TypeKind, flags: TypeFlags, size: u32) {
this.kind = kind;
this.flags = flags;
this.size = size;
@ -128,7 +124,7 @@ export class Type {
return ~0 >>> (targetType.size - this.size);
}
/** Tests if this type has the specified flags. */
/** Tests if this type has (all of) the specified flags. */
is(flags: TypeFlags): bool { return (this.flags & flags) == flags; }
/** Tests if this type has any of the specified flags. */
isAny(flags: TypeFlags): bool { return (this.flags & flags) != 0; }
@ -152,25 +148,13 @@ export class Type {
/** Composes the respective nullable type of this type. */
asNullable(): Type {
assert(this.is(TypeFlags.REFERENCE));
if (!this.nullableType) {
if (!this.cachedNullableType) {
assert(!this.is(TypeFlags.NULLABLE));
this.nullableType = new Type(this.kind, this.flags | TypeFlags.NULLABLE, this.size);
this.nullableType.classReference = this.classReference; // either a class reference
this.nullableType.signatureReference = this.signatureReference; // or a function reference
this.cachedNullableType = new Type(this.kind, this.flags | TypeFlags.NULLABLE, this.size);
this.cachedNullableType.classReference = this.classReference; // either a class reference
this.cachedNullableType.signatureReference = this.signatureReference; // or a function reference
}
return this.nullableType;
}
/** Composes the respective 'this' type of this type. */
asThis(): Type {
var thisType = this.thisType;
if (thisType) return thisType;
thisType = new Type(this.kind, this.flags | TypeFlags.THIS, this.size);
thisType.classReference = this.classReference;
thisType.nullableType = this.nullableType;
thisType.nonNullableType = this.nonNullableType;
this.thisType = thisType;
return thisType;
return this.cachedNullableType;
}
/** Tests if a value of this type is assignable to a target of the specified type. */
@ -213,11 +197,8 @@ export class Type {
/** Determines the common compatible type of two types, if any. */
static commonCompatible(left: Type, right: Type, signednessIsImportant: bool): Type | null {
if (right.isAssignableTo(left, signednessIsImportant)) {
return left;
} else if (left.isAssignableTo(right, signednessIsImportant)) {
return right;
}
if (right.isAssignableTo(left, signednessIsImportant)) return left;
else if (left.isAssignableTo(right, signednessIsImportant)) return right;
return null;
}
@ -233,16 +214,12 @@ export class Type {
case TypeKind.U16: return "u16";
case TypeKind.U32: {
let functionType = this.signatureReference;
return kindOnly || !functionType
? "u32"
: functionType.toString(true);
return kindOnly || !functionType ? "u32" : functionType.toString(true);
}
case TypeKind.U64: return "u64";
case TypeKind.USIZE: {
let classType = this.classReference;
return kindOnly || !classType
? "usize"
: classType.toString();
return kindOnly || !classType ? "usize" : classType.toString();
}
case TypeKind.BOOL: return "bool";
case TypeKind.F32: return "f32";
@ -332,7 +309,7 @@ export class Type {
/** An 8-bit signed integer. */
static readonly i8: Type = new Type(TypeKind.I8,
TypeFlags.SIGNED |
TypeFlags.SMALL |
TypeFlags.SHORT |
TypeFlags.INTEGER |
TypeFlags.VALUE, 8
);
@ -340,7 +317,7 @@ export class Type {
/** A 16-bit signed integer. */
static readonly i16: Type = new Type(TypeKind.I16,
TypeFlags.SIGNED |
TypeFlags.SMALL |
TypeFlags.SHORT |
TypeFlags.INTEGER |
TypeFlags.VALUE, 16
);
@ -363,8 +340,8 @@ export class Type {
/** A 32-bit signed size. WASM32 only. */
static readonly isize32: Type = new Type(TypeKind.ISIZE,
TypeFlags.SIGNED |
TypeFlags.SIZE |
TypeFlags.INTEGER |
TypeFlags.POINTER |
TypeFlags.VALUE, 32
);
@ -372,15 +349,15 @@ export class Type {
static readonly isize64: Type = new Type(TypeKind.ISIZE,
TypeFlags.SIGNED |
TypeFlags.LONG |
TypeFlags.SIZE |
TypeFlags.INTEGER |
TypeFlags.POINTER |
TypeFlags.VALUE, 64
);
/** An 8-bit unsigned integer. */
static readonly u8: Type = new Type(TypeKind.U8,
TypeFlags.UNSIGNED |
TypeFlags.SMALL |
TypeFlags.SHORT |
TypeFlags.INTEGER |
TypeFlags.VALUE, 8
);
@ -388,7 +365,7 @@ export class Type {
/** A 16-bit unsigned integer. */
static readonly u16: Type = new Type(TypeKind.U16,
TypeFlags.UNSIGNED |
TypeFlags.SMALL |
TypeFlags.SHORT |
TypeFlags.INTEGER |
TypeFlags.VALUE, 16
);
@ -411,8 +388,8 @@ export class Type {
/** A 32-bit unsigned size. WASM32 only. */
static readonly usize32: Type = new Type(TypeKind.USIZE,
TypeFlags.UNSIGNED |
TypeFlags.SIZE |
TypeFlags.INTEGER |
TypeFlags.POINTER |
TypeFlags.VALUE, 32
);
@ -420,15 +397,15 @@ export class Type {
static readonly usize64: Type = new Type(TypeKind.USIZE,
TypeFlags.UNSIGNED |
TypeFlags.LONG |
TypeFlags.SIZE |
TypeFlags.INTEGER |
TypeFlags.POINTER |
TypeFlags.VALUE, 64
);
/** A 1-bit unsigned integer. */
static readonly bool: Type = new Type(TypeKind.BOOL,
TypeFlags.UNSIGNED |
TypeFlags.SMALL |
TypeFlags.SHORT |
TypeFlags.INTEGER |
TypeFlags.VALUE, 1
);
@ -456,9 +433,7 @@ export class Type {
export function typesToNativeTypes(types: Type[]): NativeType[] {
var numTypes = types.length;
var ret = new Array<NativeType>(numTypes);
for (let i = 0; i < numTypes; ++i) {
ret[i] = types[i].toNativeType();
}
for (let i = 0; i < numTypes; ++i) ret[i] = types[i].toNativeType();
return ret;
}
@ -467,9 +442,7 @@ export function typesToString(types: Type[]): string {
var numTypes = types.length;
if (!numTypes) return "";
var sb = new Array<string>(numTypes);
for (let i = 0; i < numTypes; ++i) {
sb[i] = types[i].toString();
}
for (let i = 0; i < numTypes; ++i) sb[i] = types[i].toString();
return sb.join(",");
}
@ -524,31 +497,23 @@ export class Signature {
var thisThisType = this.thisType;
var targetThisType = target.thisType;
if (thisThisType) {
if (!(targetThisType && thisThisType.isAssignableTo(targetThisType))) {
return false;
}
if (!(targetThisType && thisThisType.isAssignableTo(targetThisType))) return false;
} else if (targetThisType) {
return false;
}
// check rest parameter
if (this.hasRest != target.hasRest) {
return false; // TODO
}
if (this.hasRest != target.hasRest) return false; // TODO
// check parameter types
var thisParameterTypes = this.parameterTypes;
var targetParameterTypes = target.parameterTypes;
var numParameters = thisParameterTypes.length;
if (numParameters != targetParameterTypes.length) {
return false;
}
if (numParameters != targetParameterTypes.length) return false;
for (let i = 0; i < numParameters; ++i) {
let thisParameterType = thisParameterTypes[i];
let targetParameterType = targetParameterTypes[i];
if (!thisParameterType.isAssignableTo(targetParameterType)) {
return false;
}
if (!thisParameterType.isAssignableTo(targetParameterType)) return false;
}
// check return type
@ -562,9 +527,7 @@ export class Signature {
var sb = [];
if (thisType) sb.push(thisType.toSignatureString());
if (parameterTypes) {
for (let i = 0, k = parameterTypes.length; i < k; ++i) {
sb.push(parameterTypes[i].toSignatureString());
}
for (let i = 0, k = parameterTypes.length; i < k; ++i) sb.push(parameterTypes[i].toSignatureString());
}
sb.push(returnType.toSignatureString());
return sb.join("");
@ -598,16 +561,10 @@ export class Signature {
for (let i = 0; i < numParameters; ++i, ++index) {
if (index) sb.push(", ");
if (i == restIndex) sb.push("...");
if (i < numNames) {
sb.push((<string[]>names)[i]);
} else {
sb.push(getGenericParameterName(i));
}
if (i >= optionalStart && i != restIndex) {
sb.push("?: ");
} else {
sb.push(": ");
}
if (i < numNames) sb.push((<string[]>names)[i]);
else sb.push(getGenericParameterName(i));
if (i >= optionalStart && i != restIndex) sb.push("?: ");
else sb.push(": ");
sb.push(parameters[i].toString());
}
}

View File

@ -8,27 +8,25 @@ export declare function isString<T>(value?: T): bool;
export declare function isArray<T>(value?: T): bool;
export declare const NaN: f64; // | f32
export const NaN: f64 = 0 / 0;
export declare const Infinity: f64; // | f32
export const Infinity: f64 = 1 / 0;
export declare function isNaN<T>(value: T): bool;
// export function isNaN<T>(value: T): bool {
// return isFloat(value)
// ? sizeof<T>() == 32
// ? (reinterpret<u32>(value) & -1 >>> 1) > 0xFF << 23
// : (reinterpret<u64>(value) & -1 >>> 1) > 0x7FF << 52
// : false;
// }
export function isNaN<T>(value: T): bool {
return isFloat(value)
? sizeof<T>() == 32
? (reinterpret<u32>(value) & -1 >>> 1) > 0xFF << 23
: (reinterpret<u64>(value) & -1 >>> 1) > 0x7FF << 52
: false;
}
export declare function isFinite<T>(value: T): bool;
// export function isFinite<T>(value: T): bool {
// return isFloat(value)
// ? sizeof<T>() == 32
// ? (reinterpret<u32>(value) & -1 >>> 1) < 0xFF << 23
// : (reinterpret<u64>(value) & -1 >>> 1) < 0x7FF << 52
// : true;
// }
export function isFinite<T>(value: T): bool {
return isFloat(value)
? sizeof<T>() == 32
? (reinterpret<u32>(value) & -1 >>> 1) < 0xFF << 23
: (reinterpret<u64>(value) & -1 >>> 1) < 0x7FF << 52
: true;
}
export declare function clz<T>(value: T): T;

View File

@ -2,7 +2,9 @@
(type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $fif (func (param f32 i32) (result f32)))
(type $Fi (func (param f64) (result i32)))
(type $v (func))
(global $binary/b (mut i32) (i32.const 0))
(global $binary/i (mut i32) (i32.const 0))
@ -1525,7 +1527,20 @@
(f64.const 1.e+300)
)
)
(func $~lib/math/NativeMathf.mod (; 2 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $isNaN<f32> (; 2 ;) (type $fi) (param $0 f32) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMathf.mod (; 3 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1574,14 +1589,8 @@
)
)
(get_local $3)
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
)
(i32.const 1)
@ -1879,7 +1888,7 @@
(get_local $0)
)
)
(func $~lib/math/NativeMathf.scalbn (; 3 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(func $~lib/math/NativeMathf.scalbn (; 4 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(local $2 f32)
(set_local $2
(get_local $0)
@ -1991,7 +2000,7 @@
)
)
)
(func $~lib/math/NativeMathf.pow (; 4 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $~lib/math/NativeMathf.pow (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 f32)
(local $3 f32)
(local $4 i32)
@ -3156,7 +3165,18 @@
(f32.const 1000000015047466219876688e6)
)
)
(func $~lib/math/NativeMath.mod (; 5 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $isNaN<f64> (; 6 ;) (type $Fi) (param $0 f64) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMath.mod (; 7 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i32)
(local $4 i64)
@ -3210,14 +3230,8 @@
)
)
(get_local $7)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(i32.const 1)
@ -3530,7 +3544,7 @@
(get_local $0)
)
)
(func $start (; 6 ;) (type $v)
(func $start (; 8 ;) (type $v)
(drop
(i32.rem_s
(get_global $binary/i)

View File

@ -3,11 +3,15 @@
(type $F (func (result f64)))
(type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $i (func (result i32)))
(type $f (func (result f32)))
(type $fif (func (param f32 i32) (result f32)))
(type $Fi (func (param f64) (result i32)))
(type $v (func))
(global $binary/b (mut i32) (i32.const 0))
(global $binary/i (mut i32) (i32.const 0))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $binary/I (mut i64) (i64.const 0))
(global $binary/f (mut f32) (f32.const 0))
(global $binary/F (mut f64) (f64.const 0))
@ -1715,7 +1719,28 @@
)
)
)
(func $~lib/math/NativeMathf.mod (; 2 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $isNaN<f32> (; 2 ;) (type $fi) (param $0 f32) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMathf.mod (; 3 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1773,14 +1798,8 @@
)
)
(get_local $7)
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
)
(i32.const 1)
@ -2153,7 +2172,7 @@
)
)
)
(func $~lib/math/NativeMathf.scalbn (; 3 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(func $~lib/math/NativeMathf.scalbn (; 4 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(local $2 f32)
(nop)
(set_local $2
@ -2272,7 +2291,7 @@
)
)
)
(func $~lib/math/NativeMathf.pow (; 4 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $~lib/math/NativeMathf.pow (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -3603,7 +3622,26 @@
)
)
)
(func $~lib/math/NativeMath.mod (; 5 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $isNaN<f64> (; 6 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMath.mod (; 7 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i64)
(local $4 i32)
@ -3667,14 +3705,8 @@
)
)
(get_local $7)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(i32.const 1)
@ -4060,7 +4092,7 @@
)
)
)
(func $start (; 6 ;) (type $v)
(func $start (; 8 ;) (type $v)
(drop
(i32.lt_s
(get_global $binary/i)

View File

@ -1,5 +1,7 @@
(module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $fi (func (param f32) (result i32)))
(type $Fi (func (param f64) (result i32)))
(type $v (func))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $builtins/b (mut i32) (i32.const 0))
@ -16,10 +18,58 @@
(export "test" (func $builtins/test))
(export "memory" (memory $0))
(start $start)
(func $builtins/test (; 1 ;) (type $v)
(func $isNaN<f32> (; 1 ;) (type $fi) (param $0 f32) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $isFinite<f32> (; 2 ;) (type $fi) (param $0 f32) (result i32)
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $isNaN<f64> (; 3 ;) (type $Fi) (param $0 f64) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $isFinite<f64> (; 4 ;) (type $Fi) (param $0 f64) (result i32)
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $builtins/test (; 5 ;) (type $v)
(nop)
)
(func $start (; 2 ;) (type $v)
(func $start (; 6 ;) (type $v)
(local $0 i32)
(local $1 i32)
(local $2 i64)
@ -234,6 +284,96 @@
(unreachable)
)
)
(if
(call $isNaN<f32>
(f32.const 1.25)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 80)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isNaN<f32>
(f32.const nan:0x400000)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 81)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isFinite<f32>
(f32.const 1.25)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 82)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 83)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const -inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 84)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const nan:0x400000)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 85)
(i32.const 0)
)
(unreachable)
)
)
(set_global $builtins/f
(f32.const nan:0x400000)
)
@ -268,10 +408,104 @@
(f32.const 1)
)
(set_global $builtins/b
(i32.const 0)
(call $isNaN<f32>
(f32.const 1.25)
)
)
(set_global $builtins/b
(i32.const 1)
(call $isFinite<f32>
(f32.const 1.25)
)
)
(if
(call $isNaN<f64>
(f64.const 1.25)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 116)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 117)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isFinite<f64>
(f64.const 1.25)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 118)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 119)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const -inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 120)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 121)
(i32.const 0)
)
(unreachable)
)
)
(set_global $builtins/F
(f64.const nan:0x8000000000000)
@ -307,10 +541,14 @@
(f64.const 1)
)
(set_global $builtins/b
(i32.const 0)
(call $isNaN<f64>
(f64.const 1.25)
)
)
(set_global $builtins/b
(i32.const 1)
(call $isFinite<f64>
(f64.const 1.25)
)
)
(set_global $builtins/i
(i32.load
@ -610,5 +848,130 @@
)
(unreachable)
)
(if
(i32.eqz
(call $isNaN<f32>
(f32.const nan:0x400000)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 261)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 262)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const nan:0x400000)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 263)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 264)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 265)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 266)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(call $isFinite<f32>
(f32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 267)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(call $isFinite<f64>
(f64.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 4)
(i32.const 268)
(i32.const 0)
)
(unreachable)
)
)
(drop
(call $isNaN<f64>
(f64.const 1)
)
)
)
)

View File

@ -1,14 +1,18 @@
(module
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $F (func (result f64)))
(type $fi (func (param f32) (result i32)))
(type $i (func (result i32)))
(type $Fi (func (param f64) (result i32)))
(type $v (func))
(type $f (func (result f32)))
(type $F (func (result f64)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $builtins/b (mut i32) (i32.const 0))
(global $builtins/i (mut i32) (i32.const 0))
(global $builtins/I (mut i64) (i64.const 0))
(global $builtins/f (mut f32) (f32.const 0))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $Infinity f64 (f64.const inf))
(global $builtins/F (mut f64) (f64.const 0))
(global $builtins/constantOffset i32 (i32.const 8))
(global $builtins/u (mut i32) (i32.const 0))
@ -21,9 +25,89 @@
(export "test" (func $builtins/test))
(export "memory" (memory $0))
(start $start)
(func $builtins/test (; 1 ;) (type $v)
(func $isNaN<f32> (; 1 ;) (type $fi) (param $0 f32) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $start (; 2 ;) (type $v)
(func $isFinite<f32> (; 2 ;) (type $fi) (param $0 f32) (result i32)
(return
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $isNaN<f64> (; 3 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $isFinite<f64> (; 4 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $builtins/test (; 5 ;) (type $v)
)
(func $start (; 6 ;) (type $v)
(local $0 i32)
(local $1 i32)
(local $2 i64)
@ -709,14 +793,8 @@
(if
(i32.eqz
(i32.eq
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const 1.25)
)
(i32.const 0)
)
@ -734,14 +812,8 @@
(if
(i32.eqz
(i32.eq
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const nan:0x400000)
)
(i32.const 1)
)
@ -759,14 +831,8 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const 1.25)
)
(i32.const 1)
)
@ -784,14 +850,8 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const inf)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const inf)
)
(i32.const 0)
)
@ -809,16 +869,10 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.neg
(f32.const inf)
)
)
(i32.const 2147483647)
(call $isFinite<f32>
(f32.neg
(f32.const inf)
)
(i32.const 2139095040)
)
(i32.const 0)
)
@ -836,14 +890,8 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const nan:0x400000)
)
(i32.const 0)
)
@ -913,25 +961,13 @@
)
)
(set_global $builtins/b
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const 1.25)
)
)
(set_global $builtins/b
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const 1.25)
)
)
(drop
@ -997,14 +1033,8 @@
(if
(i32.eqz
(i32.eq
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const 1.25)
)
(i32.const 0)
)
@ -1022,14 +1052,8 @@
(if
(i32.eqz
(i32.eq
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
(i32.const 1)
)
@ -1047,14 +1071,8 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const 1.25)
)
(i32.const 1)
)
@ -1072,14 +1090,8 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const inf)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const inf)
)
(i32.const 0)
)
@ -1097,16 +1109,10 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.neg
(f64.const inf)
)
)
(i64.const 9223372036854775807)
(call $isFinite<f64>
(f64.neg
(f64.const inf)
)
(i64.const 9218868437227405312)
)
(i32.const 0)
)
@ -1124,14 +1130,8 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
(i32.const 0)
)
@ -1201,25 +1201,13 @@
)
)
(set_global $builtins/b
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const 1.25)
)
)
(set_global $builtins/b
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const 1.25)
)
)
(set_global $builtins/i
@ -1908,14 +1896,8 @@
)
(if
(i32.eqz
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const nan:0x400000)
)
)
(block
@ -1930,14 +1912,8 @@
)
(if
(i32.eqz
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
)
(block
@ -1953,14 +1929,8 @@
(if
(i32.eqz
(i32.eqz
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const nan:0x400000)
)
)
)
@ -1977,14 +1947,8 @@
(if
(i32.eqz
(i32.eqz
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const inf)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const inf)
)
)
)
@ -2001,14 +1965,8 @@
(if
(i32.eqz
(i32.eqz
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
)
)
@ -2025,14 +1983,8 @@
(if
(i32.eqz
(i32.eqz
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const inf)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const inf)
)
)
)
@ -2048,14 +2000,8 @@
)
(if
(i32.eqz
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const 0)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const 0)
)
)
(block
@ -2070,14 +2016,8 @@
)
(if
(i32.eqz
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const 0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const 0)
)
)
(block
@ -2613,14 +2553,8 @@
)
)
(drop
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const 1)
)
)
)

View File

@ -1,9 +1,12 @@
(module
(type $F (func (result f64)))
(type $i (func (result i32)))
(type $iiv (func (param i32 i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(global $../../examples/i64-polyfill/assembly/i64/lo (mut i32) (i32.const 0))
(global $../../examples/i64-polyfill/assembly/i64/hi (mut i32) (i32.const 0))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $Infinity f64 (f64.const inf))
(global $HEAP_BASE i32 (i32.const 4))
(memory $0 1)
(export "getHi" (func $../../examples/i64-polyfill/assembly/i64/getHi))

View File

@ -2,7 +2,9 @@
(type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $fif (func (param f32 i32) (result f32)))
(type $Fi (func (param f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32)))
@ -1574,7 +1576,20 @@
(f64.const 1.e+300)
)
)
(func $~lib/math/NativeMathf.mod (; 3 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $isNaN<f32> (; 3 ;) (type $fi) (param $0 f32) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMathf.mod (; 4 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1623,14 +1638,8 @@
)
)
(get_local $3)
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
)
(i32.const 1)
@ -1928,7 +1937,7 @@
(get_local $0)
)
)
(func $~lib/math/NativeMathf.scalbn (; 4 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(func $~lib/math/NativeMathf.scalbn (; 5 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(local $2 f32)
(set_local $2
(get_local $0)
@ -2040,7 +2049,7 @@
)
)
)
(func $~lib/math/NativeMathf.pow (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $~lib/math/NativeMathf.pow (; 6 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 f32)
(local $3 f32)
(local $4 i32)
@ -3205,7 +3214,18 @@
(f32.const 1000000015047466219876688e6)
)
)
(func $~lib/math/NativeMath.mod (; 6 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $isNaN<f64> (; 7 ;) (type $Fi) (param $0 f64) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMath.mod (; 8 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i32)
(local $4 i64)
@ -3259,14 +3279,8 @@
)
)
(get_local $7)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(i32.const 1)
@ -3579,31 +3593,55 @@
(get_local $0)
)
)
(func $showcase/ANamespace.aNamespacedFunction (; 7 ;) (type $ii) (param $0 i32) (result i32)
(func $isFinite<f32> (; 9 ;) (type $fi) (param $0 f32) (result i32)
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $isFinite<f64> (; 10 ;) (type $Fi) (param $0 f64) (result i32)
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $showcase/ANamespace.aNamespacedFunction (; 11 ;) (type $ii) (param $0 i32) (result i32)
(get_local $0)
)
(func $showcase/addGeneric<i32> (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $showcase/addGeneric<i32> (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(i32.add
(get_local $0)
(get_local $1)
)
)
(func $showcase/addGeneric<f32> (; 9 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $showcase/addGeneric<f32> (; 13 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(f32.add
(get_local $0)
(get_local $1)
)
)
(func $showcase/addGeneric<f64> (; 10 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $showcase/addGeneric<f64> (; 14 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(f64.add
(get_local $0)
(get_local $1)
)
)
(func $showcase/anExportedFunction (; 11 ;) (type $v)
(func $showcase/anExportedFunction (; 15 ;) (type $v)
(nop)
)
(func $memcpy/memcpy (; 12 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $memcpy/memcpy (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@ -5186,18 +5224,18 @@
)
(get_local $5)
)
(func $showcase/ADerivedClass#set:aWildAccessorAppears (; 13 ;) (type $ifv) (param $0 i32) (param $1 f32)
(func $showcase/ADerivedClass#set:aWildAccessorAppears (; 17 ;) (type $ifv) (param $0 i32) (param $1 f32)
(f32.store offset=4
(get_local $0)
(get_local $1)
)
)
(func $showcase/ADerivedClass#get:aWildAccessorAppears (; 14 ;) (type $if) (param $0 i32) (result f32)
(func $showcase/ADerivedClass#get:aWildAccessorAppears (; 18 ;) (type $if) (param $0 i32) (result f32)
(f32.load offset=4
(get_local $0)
)
)
(func $start (; 15 ;) (type $v)
(func $start (; 19 ;) (type $v)
(local $0 i32)
(local $1 i64)
(local $2 i32)
@ -6493,6 +6531,96 @@
(unreachable)
)
)
(if
(call $isNaN<f32>
(f32.const 1.25)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 80)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isNaN<f32>
(f32.const nan:0x400000)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 81)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isFinite<f32>
(f32.const 1.25)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 82)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 83)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const -inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 84)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const nan:0x400000)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 85)
(i32.const 0)
)
(unreachable)
)
)
(set_global $builtins/f
(f32.const nan:0x400000)
)
@ -6527,10 +6655,104 @@
(f32.const 1)
)
(set_global $builtins/b
(i32.const 0)
(call $isNaN<f32>
(f32.const 1.25)
)
)
(set_global $builtins/b
(i32.const 1)
(call $isFinite<f32>
(f32.const 1.25)
)
)
(if
(call $isNaN<f64>
(f64.const 1.25)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 116)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 117)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.ne
(call $isFinite<f64>
(f64.const 1.25)
)
(i32.const 1)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 118)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 119)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const -inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 120)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 121)
(i32.const 0)
)
(unreachable)
)
)
(set_global $builtins/F
(f64.const nan:0x8000000000000)
@ -6566,10 +6788,14 @@
(f64.const 1)
)
(set_global $builtins/b
(i32.const 0)
(call $isNaN<f64>
(f64.const 1.25)
)
)
(set_global $builtins/b
(i32.const 1)
(call $isFinite<f64>
(f64.const 1.25)
)
)
(set_global $builtins/i
(i32.load
@ -6869,6 +7095,131 @@
)
(unreachable)
)
(if
(i32.eqz
(call $isNaN<f32>
(f32.const nan:0x400000)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 261)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 262)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const nan:0x400000)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 263)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f32>
(f32.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 264)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 265)
(i32.const 0)
)
(unreachable)
)
)
(if
(call $isFinite<f64>
(f64.const inf)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 266)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(call $isFinite<f32>
(f32.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 267)
(i32.const 0)
)
(unreachable)
)
)
(if
(i32.eqz
(call $isFinite<f64>
(f64.const 0)
)
)
(block
(call $abort
(i32.const 0)
(i32.const 28)
(i32.const 268)
(i32.const 0)
)
(unreachable)
)
)
(drop
(call $isNaN<f64>
(f64.const 1)
)
)
(if
(i32.ne
(call $showcase/ANamespace.aNamespacedFunction

View File

@ -3,10 +3,12 @@
(type $F (func (result f64)))
(type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $i (func (result i32)))
(type $f (func (result f32)))
(type $fif (func (param f32 i32) (result f32)))
(type $Fi (func (param f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32)))
(type $v (func))
@ -27,6 +29,7 @@
(global $unary/F (mut f64) (f64.const 0))
(global $binary/b (mut i32) (i32.const 0))
(global $binary/i (mut i32) (i32.const 0))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $binary/I (mut i64) (i64.const 0))
(global $binary/f (mut f32) (f32.const 0))
(global $binary/F (mut f64) (f64.const 0))
@ -38,6 +41,7 @@
(global $builtins/i (mut i32) (i32.const 0))
(global $builtins/I (mut i64) (i64.const 0))
(global $builtins/f (mut f32) (f32.const 0))
(global $Infinity f64 (f64.const inf))
(global $builtins/F (mut f64) (f64.const 0))
(global $builtins/constantOffset i32 (i32.const 8))
(global $builtins/u (mut i32) (i32.const 0))
@ -1771,7 +1775,28 @@
)
)
)
(func $~lib/math/NativeMathf.mod (; 3 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $isNaN<f32> (; 3 ;) (type $fi) (param $0 f32) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMathf.mod (; 4 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1829,14 +1854,8 @@
)
)
(get_local $7)
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
)
(i32.const 1)
@ -2209,7 +2228,7 @@
)
)
)
(func $~lib/math/NativeMathf.scalbn (; 4 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(func $~lib/math/NativeMathf.scalbn (; 5 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32)
(local $2 f32)
(nop)
(set_local $2
@ -2328,7 +2347,7 @@
)
)
)
(func $~lib/math/NativeMathf.pow (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $~lib/math/NativeMathf.pow (; 6 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -3659,7 +3678,26 @@
)
)
)
(func $~lib/math/NativeMath.mod (; 6 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $isNaN<f64> (; 7 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMath.mod (; 8 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i64)
(local $4 i32)
@ -3723,14 +3761,8 @@
)
)
(get_local $7)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(i32.const 1)
@ -4116,12 +4148,52 @@
)
)
)
(func $showcase/ANamespace.aNamespacedFunction (; 7 ;) (type $ii) (param $0 i32) (result i32)
(func $isFinite<f32> (; 9 ;) (type $fi) (param $0 f32) (result i32)
(return
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $isFinite<f64> (; 10 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $showcase/ANamespace.aNamespacedFunction (; 11 ;) (type $ii) (param $0 i32) (result i32)
(return
(get_local $0)
)
)
(func $showcase/addGeneric<i32> (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(func $showcase/addGeneric<i32> (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(return
(i32.add
(get_local $0)
@ -4129,7 +4201,7 @@
)
)
)
(func $showcase/addGeneric<f32> (; 9 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $showcase/addGeneric<f32> (; 13 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(return
(f32.add
(get_local $0)
@ -4137,7 +4209,7 @@
)
)
)
(func $showcase/addGeneric<f64> (; 10 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $showcase/addGeneric<f64> (; 14 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(f64.add
(get_local $0)
@ -4145,9 +4217,9 @@
)
)
)
(func $showcase/anExportedFunction (; 11 ;) (type $v)
(func $showcase/anExportedFunction (; 15 ;) (type $v)
)
(func $memcpy/memcpy (; 12 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $memcpy/memcpy (; 16 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
@ -5953,20 +6025,20 @@
(get_local $3)
)
)
(func $showcase/ADerivedClass#set:aWildAccessorAppears (; 13 ;) (type $ifv) (param $0 i32) (param $1 f32)
(func $showcase/ADerivedClass#set:aWildAccessorAppears (; 17 ;) (type $ifv) (param $0 i32) (param $1 f32)
(f32.store offset=4
(get_local $0)
(get_local $1)
)
)
(func $showcase/ADerivedClass#get:aWildAccessorAppears (; 14 ;) (type $if) (param $0 i32) (result f32)
(func $showcase/ADerivedClass#get:aWildAccessorAppears (; 18 ;) (type $if) (param $0 i32) (result f32)
(return
(f32.load offset=4
(get_local $0)
)
)
)
(func $start (; 15 ;) (type $v)
(func $start (; 19 ;) (type $v)
(local $0 i32)
(local $1 i64)
(local $2 f32)
@ -8369,14 +8441,8 @@
(if
(i32.eqz
(i32.eq
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const 1.25)
)
(i32.const 0)
)
@ -8394,14 +8460,8 @@
(if
(i32.eqz
(i32.eq
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const nan:0x400000)
)
(i32.const 1)
)
@ -8419,14 +8479,8 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const 1.25)
)
(i32.const 1)
)
@ -8444,14 +8498,8 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const inf)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const inf)
)
(i32.const 0)
)
@ -8469,16 +8517,10 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.neg
(f32.const inf)
)
)
(i32.const 2147483647)
(call $isFinite<f32>
(f32.neg
(f32.const inf)
)
(i32.const 2139095040)
)
(i32.const 0)
)
@ -8496,14 +8538,8 @@
(if
(i32.eqz
(i32.eq
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const nan:0x400000)
)
(i32.const 0)
)
@ -8573,25 +8609,13 @@
)
)
(set_global $builtins/b
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const 1.25)
)
)
(set_global $builtins/b
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const 1.25)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const 1.25)
)
)
(drop
@ -8657,14 +8681,8 @@
(if
(i32.eqz
(i32.eq
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const 1.25)
)
(i32.const 0)
)
@ -8682,14 +8700,8 @@
(if
(i32.eqz
(i32.eq
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
(i32.const 1)
)
@ -8707,14 +8719,8 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const 1.25)
)
(i32.const 1)
)
@ -8732,14 +8738,8 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const inf)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const inf)
)
(i32.const 0)
)
@ -8757,16 +8757,10 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.neg
(f64.const inf)
)
)
(i64.const 9223372036854775807)
(call $isFinite<f64>
(f64.neg
(f64.const inf)
)
(i64.const 9218868437227405312)
)
(i32.const 0)
)
@ -8784,14 +8778,8 @@
(if
(i32.eqz
(i32.eq
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
(i32.const 0)
)
@ -8861,25 +8849,13 @@
)
)
(set_global $builtins/b
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const 1.25)
)
)
(set_global $builtins/b
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1.25)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const 1.25)
)
)
(set_global $builtins/i
@ -9568,14 +9544,8 @@
)
(if
(i32.eqz
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(f32.const nan:0x400000)
)
)
(block
@ -9590,14 +9560,8 @@
)
(if
(i32.eqz
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const nan:0x8000000000000)
)
)
(block
@ -9613,14 +9577,8 @@
(if
(i32.eqz
(i32.eqz
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const nan:0x400000)
)
)
)
@ -9637,14 +9595,8 @@
(if
(i32.eqz
(i32.eqz
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const inf)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const inf)
)
)
)
@ -9661,14 +9613,8 @@
(if
(i32.eqz
(i32.eqz
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const nan:0x8000000000000)
)
)
)
@ -9685,14 +9631,8 @@
(if
(i32.eqz
(i32.eqz
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const inf)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const inf)
)
)
)
@ -9708,14 +9648,8 @@
)
(if
(i32.eqz
(i32.lt_u
(i32.and
(i32.reinterpret/f32
(f32.const 0)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isFinite<f32>
(f32.const 0)
)
)
(block
@ -9730,14 +9664,8 @@
)
(if
(i32.eqz
(i64.lt_u
(i64.and
(i64.reinterpret/f64
(f64.const 0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isFinite<f64>
(f64.const 0)
)
)
(block
@ -10273,14 +10201,8 @@
)
)
(drop
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.const 1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(f64.const 1)
)
)
(if

View File

@ -1,5 +1,6 @@
(module
(type $FF (func (param f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64)))
(type $Ff (func (param f64) (result f32)))
@ -1306,7 +1307,18 @@
(get_local $0)
)
)
(func $~lib/math/NativeMath.atan (; 12 ;) (type $FF) (param $0 f64) (result f64)
(func $isNaN<f64> (; 12 ;) (type $Fi) (param $0 f64) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMath.atan (; 13 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 f64)
(local $3 i32)
@ -1338,14 +1350,8 @@
)
(block
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
(return
(get_local $0)
@ -1669,12 +1675,12 @@
(get_local $4)
)
)
(func $std/libm/atan (; 13 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/atan (; 14 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.atan
(get_local $0)
)
)
(func $~lib/math/NativeMath.atanh (; 14 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.atanh (; 15 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i64)
(local $3 i64)
@ -1771,12 +1777,12 @@
)
)
)
(func $std/libm/atanh (; 15 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/atanh (; 16 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.atanh
(get_local $0)
)
)
(func $~lib/math/NativeMath.atan2 (; 16 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.atan2 (; 17 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -1788,25 +1794,13 @@
(i32.and
(if (result i32)
(tee_local $2
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(get_local $2)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
)
(i32.const 1)
@ -2123,13 +2117,13 @@
)
)
)
(func $std/libm/atan2 (; 17 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/atan2 (; 18 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(call $~lib/math/NativeMath.atan2
(get_local $0)
(get_local $1)
)
)
(func $~lib/math/NativeMath.cbrt (; 18 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.cbrt (; 19 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 f64)
(local $3 i32)
@ -2312,17 +2306,17 @@
)
)
)
(func $std/libm/cbrt (; 19 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/cbrt (; 20 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.cbrt
(get_local $0)
)
)
(func $std/libm/ceil (; 20 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/ceil (; 21 ;) (type $FF) (param $0 f64) (result f64)
(f64.ceil
(get_local $0)
)
)
(func $std/libm/clz32 (; 21 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/clz32 (; 22 ;) (type $FF) (param $0 f64) (result f64)
(f64.convert_s/i32
(i32.clz
(i32.trunc_s/f64
@ -2331,15 +2325,15 @@
)
)
)
(func $~lib/math/NativeMath.cos (; 22 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.cos (; 23 ;) (type $FF) (param $0 f64) (result f64)
(unreachable)
)
(func $std/libm/cos (; 23 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/cos (; 24 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.cos
(get_local $0)
)
)
(func $~lib/math/NativeMath.expm1 (; 24 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.expm1 (; 25 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 i32)
(local $3 f64)
@ -2378,14 +2372,8 @@
)
(block
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
(return
(get_local $0)
@ -2785,7 +2773,7 @@
)
)
)
(func $~lib/math/NativeMath.scalbn (; 25 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64)
(func $~lib/math/NativeMath.scalbn (; 26 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64)
(local $2 f64)
(set_local $2
(get_local $0)
@ -2899,7 +2887,7 @@
)
)
)
(func $~lib/math/NativeMath.exp (; 26 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.exp (; 27 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@ -2932,14 +2920,8 @@
)
(block
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
(return
(get_local $0)
@ -3109,7 +3091,7 @@
(get_local $2)
)
)
(func $~lib/math/expo2 (; 27 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/expo2 (; 28 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(f64.mul
(f64.mul
@ -3126,7 +3108,7 @@
(get_local $1)
)
)
(func $~lib/math/NativeMath.cosh (; 28 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.cosh (; 29 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i32)
(local $2 i64)
(set_local $0
@ -3213,32 +3195,32 @@
(get_local $0)
)
)
(func $std/libm/cosh (; 29 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/cosh (; 30 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.cosh
(get_local $0)
)
)
(func $std/libm/exp (; 30 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/exp (; 31 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.exp
(get_local $0)
)
)
(func $std/libm/expm1 (; 31 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/expm1 (; 32 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.expm1
(get_local $0)
)
)
(func $std/libm/floor (; 32 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/floor (; 33 ;) (type $FF) (param $0 f64) (result f64)
(f64.floor
(get_local $0)
)
)
(func $std/libm/fround (; 33 ;) (type $Ff) (param $0 f64) (result f32)
(func $std/libm/fround (; 34 ;) (type $Ff) (param $0 f64) (result f32)
(f32.demote/f64
(get_local $0)
)
)
(func $~lib/math/NativeMath.hypot (; 34 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.hypot (; 35 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 f64)
(local $3 f64)
(local $4 i64)
@ -3507,13 +3489,13 @@
)
)
)
(func $std/libm/hypot (; 35 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/hypot (; 36 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(call $~lib/math/NativeMath.hypot
(get_local $0)
(get_local $1)
)
)
(func $~lib/math/NativeMath.imul (; 36 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.imul (; 37 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(f64.convert_s/i32
(i32.mul
(i32.trunc_s/f64
@ -3525,18 +3507,18 @@
)
)
)
(func $std/libm/imul (; 37 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/imul (; 38 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(call $~lib/math/NativeMath.imul
(get_local $0)
(get_local $1)
)
)
(func $std/libm/log (; 38 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log (; 39 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.log
(get_local $0)
)
)
(func $~lib/math/NativeMath.log10 (; 39 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.log10 (; 40 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 i32)
(local $3 i32)
@ -3854,17 +3836,17 @@
(get_local $0)
)
)
(func $std/libm/log10 (; 40 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log10 (; 41 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.log10
(get_local $0)
)
)
(func $std/libm/log1p (; 41 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log1p (; 42 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.log1p
(get_local $0)
)
)
(func $~lib/math/NativeMath.log2 (; 42 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.log2 (; 43 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 i32)
(local $3 f64)
@ -4170,24 +4152,24 @@
(get_local $1)
)
)
(func $std/libm/log2 (; 43 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log2 (; 44 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.log2
(get_local $0)
)
)
(func $std/libm/max (; 44 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/max (; 45 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(f64.max
(get_local $0)
(get_local $1)
)
)
(func $std/libm/min (; 45 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/min (; 46 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(f64.min
(get_local $0)
(get_local $1)
)
)
(func $~lib/math/NativeMath.pow (; 46 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.pow (; 47 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 f64)
(local $3 f64)
(local $4 i32)
@ -5586,13 +5568,13 @@
(f64.const 1.e+300)
)
)
(func $std/libm/pow (; 47 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/pow (; 48 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(call $~lib/math/NativeMath.pow
(get_local $0)
(get_local $1)
)
)
(func $~lib/math/NativeMath.round (; 48 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.round (; 49 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 i64)
(local $3 i32)
@ -5725,12 +5707,12 @@
)
)
)
(func $std/libm/round (; 49 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/round (; 50 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.round
(get_local $0)
)
)
(func $std/libm/sign (; 50 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sign (; 51 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(select
(f64.copysign
@ -5748,7 +5730,7 @@
)
)
)
(func $~lib/math/NativeMath.sinh (; 51 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.sinh (; 52 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(local $2 f64)
(local $3 i64)
@ -5867,17 +5849,17 @@
)
)
)
(func $std/libm/sinh (; 52 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sinh (; 53 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.sinh
(get_local $0)
)
)
(func $std/libm/sqrt (; 53 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sqrt (; 54 ;) (type $FF) (param $0 f64) (result f64)
(f64.sqrt
(get_local $0)
)
)
(func $~lib/math/NativeMath.tanh (; 54 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.tanh (; 55 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 i32)
@ -6000,12 +5982,12 @@
(get_local $3)
)
)
(func $std/libm/tanh (; 55 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/tanh (; 56 ;) (type $FF) (param $0 f64) (result f64)
(call $~lib/math/NativeMath.tanh
(get_local $0)
)
)
(func $std/libm/trunc (; 56 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/trunc (; 57 ;) (type $FF) (param $0 f64) (result f64)
(f64.trunc
(get_local $0)
)

View File

@ -2,8 +2,9 @@
(type $F (func (result f64)))
(type $FF (func (param f64) (result f64)))
(type $f (func (result f32)))
(type $FFF (func (param f64 f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $i (func (result i32)))
(type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64)))
(type $Ff (func (param f64) (result f32)))
(global $std/libm/E f64 (f64.const 2.718281828459045))
@ -14,6 +15,7 @@
(global $std/libm/PI f64 (f64.const 3.141592653589793))
(global $std/libm/SQRT1_2 f64 (f64.const 0.7071067811865476))
(global $std/libm/SQRT2 f64 (f64.const 1.4142135623730951))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $HEAP_BASE i32 (i32.const 4))
(memory $0 1)
(export "E" (global $std/libm/E))
@ -1553,7 +1555,26 @@
)
)
)
(func $~lib/math/NativeMath.atan (; 12 ;) (type $FF) (param $0 f64) (result f64)
(func $isNaN<f64> (; 12 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMath.atan (; 13 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i32)
(local $2 i32)
(local $3 f64)
@ -1593,14 +1614,8 @@
)
(block
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
(return
(get_local $0)
@ -1970,14 +1985,14 @@
)
)
)
(func $std/libm/atan (; 13 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/atan (; 14 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.atan
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.atanh (; 14 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.atanh (; 15 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i64)
(local $3 i64)
@ -2087,14 +2102,14 @@
)
)
)
(func $std/libm/atanh (; 15 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/atanh (; 16 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.atanh
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.atan2 (; 16 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.atan2 (; 17 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i32)
(local $3 i64)
(local $4 i32)
@ -2108,25 +2123,13 @@
(i32.and
(if (result i32)
(tee_local $2
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(get_local $2)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
)
(i32.const 1)
@ -2586,7 +2589,7 @@
(f64.const 0)
)
)
(func $std/libm/atan2 (; 17 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/atan2 (; 18 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(call $~lib/math/NativeMath.atan2
(get_local $0)
@ -2594,7 +2597,7 @@
)
)
)
(func $~lib/math/NativeMath.cbrt (; 18 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.cbrt (; 19 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 f64)
@ -2813,14 +2816,14 @@
(get_local $3)
)
)
(func $std/libm/cbrt (; 19 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/cbrt (; 20 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.cbrt
(get_local $0)
)
)
)
(func $std/libm/ceil (; 20 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/ceil (; 21 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(return
(block $~lib/math/NativeMath.ceil|inlined.0 (result f64)
@ -2835,7 +2838,7 @@
)
)
)
(func $std/libm/clz32 (; 21 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/clz32 (; 22 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(return
(block $~lib/math/NativeMath.clz32|inlined.0 (result f64)
@ -2854,20 +2857,20 @@
)
)
)
(func $~lib/math/NativeMath.cos (; 22 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.cos (; 23 ;) (type $FF) (param $0 f64) (result f64)
(unreachable)
(return
(f64.const 0)
)
)
(func $std/libm/cos (; 23 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/cos (; 24 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.cos
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.expm1 (; 24 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.expm1 (; 25 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 i32)
@ -2920,14 +2923,8 @@
)
(block
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
(return
(get_local $0)
@ -3364,7 +3361,7 @@
(get_local $14)
)
)
(func $~lib/math/NativeMath.scalbn (; 25 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64)
(func $~lib/math/NativeMath.scalbn (; 26 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64)
(local $2 f64)
(nop)
(set_local $2
@ -3485,7 +3482,7 @@
)
)
)
(func $~lib/math/NativeMath.exp (; 26 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.exp (; 27 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i32)
(local $2 i32)
(local $3 f64)
@ -3524,14 +3521,8 @@
)
(block
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
(return
(get_local $0)
@ -3724,7 +3715,7 @@
)
)
)
(func $~lib/math/expo2 (; 27 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/expo2 (; 28 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(nop)
(set_local $1
@ -3761,7 +3752,7 @@
)
)
)
(func $~lib/math/NativeMath.cosh (; 28 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.cosh (; 29 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 f64)
@ -3870,28 +3861,28 @@
(get_local $3)
)
)
(func $std/libm/cosh (; 29 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/cosh (; 30 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.cosh
(get_local $0)
)
)
)
(func $std/libm/exp (; 30 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/exp (; 31 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.exp
(get_local $0)
)
)
)
(func $std/libm/expm1 (; 31 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/expm1 (; 32 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.expm1
(get_local $0)
)
)
)
(func $std/libm/floor (; 32 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/floor (; 33 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(return
(block $~lib/math/NativeMath.floor|inlined.0 (result f64)
@ -3906,7 +3897,7 @@
)
)
)
(func $std/libm/fround (; 33 ;) (type $Ff) (param $0 f64) (result f32)
(func $std/libm/fround (; 34 ;) (type $Ff) (param $0 f64) (result f32)
(local $1 f64)
(return
(block $~lib/math/NativeMath.fround|inlined.0 (result f32)
@ -3921,7 +3912,7 @@
)
)
)
(func $~lib/math/NativeMath.hypot (; 34 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.hypot (; 35 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i64)
(local $4 i64)
@ -4222,7 +4213,7 @@
)
)
)
(func $std/libm/hypot (; 35 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/hypot (; 36 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(call $~lib/math/NativeMath.hypot
(get_local $0)
@ -4230,7 +4221,7 @@
)
)
)
(func $~lib/math/NativeMath.imul (; 36 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.imul (; 37 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(f64.convert_s/i32
(i32.mul
@ -4244,7 +4235,7 @@
)
)
)
(func $std/libm/imul (; 37 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/imul (; 38 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(call $~lib/math/NativeMath.imul
(get_local $0)
@ -4252,14 +4243,14 @@
)
)
)
(func $std/libm/log (; 38 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log (; 39 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.log
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.log10 (; 39 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.log10 (; 40 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 i32)
@ -4648,21 +4639,21 @@
)
)
)
(func $std/libm/log10 (; 40 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log10 (; 41 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.log10
(get_local $0)
)
)
)
(func $std/libm/log1p (; 41 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log1p (; 42 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.log1p
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.log2 (; 42 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.log2 (; 43 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 i32)
@ -5038,14 +5029,14 @@
)
)
)
(func $std/libm/log2 (; 43 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/log2 (; 44 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.log2
(get_local $0)
)
)
)
(func $std/libm/max (; 44 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/max (; 45 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 f64)
(local $3 f64)
(return
@ -5065,7 +5056,7 @@
)
)
)
(func $std/libm/min (; 45 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/min (; 46 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 f64)
(local $3 f64)
(return
@ -5085,7 +5076,7 @@
)
)
)
(func $~lib/math/NativeMath.pow (; 46 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $~lib/math/NativeMath.pow (; 47 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i32)
(local $4 i32)
@ -6664,7 +6655,7 @@
)
)
)
(func $std/libm/pow (; 47 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $std/libm/pow (; 48 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(return
(call $~lib/math/NativeMath.pow
(get_local $0)
@ -6672,7 +6663,7 @@
)
)
)
(func $~lib/math/NativeMath.round (; 48 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.round (; 49 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 f64)
@ -6834,14 +6825,14 @@
(get_local $3)
)
)
(func $std/libm/round (; 49 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/round (; 50 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.round
(get_local $0)
)
)
)
(func $std/libm/sign (; 50 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sign (; 51 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(return
(block $~lib/math/NativeMath.sign|inlined.0 (result f64)
@ -6866,20 +6857,20 @@
)
)
)
(func $~lib/math/NativeMath.sin (; 51 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.sin (; 52 ;) (type $FF) (param $0 f64) (result f64)
(unreachable)
(return
(f64.const 0)
)
)
(func $std/libm/sin (; 52 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sin (; 53 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.sin
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.sinh (; 53 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.sinh (; 54 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 f64)
(local $3 f64)
@ -7014,14 +7005,14 @@
(get_local $5)
)
)
(func $std/libm/sinh (; 54 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sinh (; 55 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.sinh
(get_local $0)
)
)
)
(func $std/libm/sqrt (; 55 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/sqrt (; 56 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(return
(block $~lib/math/NativeMath.sqrt|inlined.0 (result f64)
@ -7036,20 +7027,20 @@
)
)
)
(func $~lib/math/NativeMath.tan (; 56 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.tan (; 57 ;) (type $FF) (param $0 f64) (result f64)
(unreachable)
(return
(f64.const 0)
)
)
(func $std/libm/tan (; 57 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/tan (; 58 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.tan
(get_local $0)
)
)
)
(func $~lib/math/NativeMath.tanh (; 58 ;) (type $FF) (param $0 f64) (result f64)
(func $~lib/math/NativeMath.tanh (; 59 ;) (type $FF) (param $0 f64) (result f64)
(local $1 i64)
(local $2 i32)
(local $3 i32)
@ -7195,14 +7186,14 @@
)
)
)
(func $std/libm/tanh (; 59 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/tanh (; 60 ;) (type $FF) (param $0 f64) (result f64)
(return
(call $~lib/math/NativeMath.tanh
(get_local $0)
)
)
)
(func $std/libm/trunc (; 60 ;) (type $FF) (param $0 f64) (result f64)
(func $std/libm/trunc (; 61 ;) (type $FF) (param $0 f64) (result f64)
(local $1 f64)
(return
(block $~lib/math/NativeMath.trunc|inlined.0 (result f64)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,12 @@
(module
(type $FFFi (func (param f64 f64 f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFi (func (param f64 f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $fffi (func (param f32 f32 f32) (result i32)))
(type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $ffi (func (param f32 f32) (result i32)))
(type $v (func))
(import "JSOp" "mod" (func $std/mod/JSOp.mod (param f64 f64) (result f64)))
@ -13,7 +15,18 @@
(data (i32.const 4) "\n\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s")
(export "memory" (memory $0))
(start $start)
(func $~lib/math/NativeMath.mod (; 2 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $isNaN<f64> (; 2 ;) (type $Fi) (param $0 f64) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMath.mod (; 3 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i32)
(local $4 i64)
@ -67,14 +80,8 @@
)
)
(get_local $7)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(i32.const 1)
@ -387,26 +394,14 @@
(get_local $0)
)
)
(func $std/mod/check<f64> (; 3 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32)
(func $std/mod/check<f64> (; 4 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32)
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
)
)
@ -433,7 +428,7 @@
(get_local $1)
)
)
(func $std/mod/test_fmod (; 4 ;) (type $FFFi) (param $0 f64) (param $1 f64) (param $2 f64) (result i32)
(func $std/mod/test_fmod (; 5 ;) (type $FFFi) (param $0 f64) (param $1 f64) (param $2 f64) (result i32)
(local $3 i32)
(i32.and
(if (result i32)
@ -464,7 +459,20 @@
(i32.const 1)
)
)
(func $~lib/math/NativeMathf.mod (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $isNaN<f32> (; 6 ;) (type $fi) (param $0 f32) (result i32)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
)
(func $~lib/math/NativeMathf.mod (; 7 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -513,14 +521,8 @@
)
)
(get_local $3)
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
)
(i32.const 1)
@ -818,26 +820,14 @@
(get_local $0)
)
)
(func $std/mod/check<f32> (; 6 ;) (type $ffi) (param $0 f32) (param $1 f32) (result i32)
(func $std/mod/check<f32> (; 8 ;) (type $ffi) (param $0 f32) (param $1 f32) (result i32)
(if
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
(return
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $0)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $0)
)
)
)
@ -864,7 +854,7 @@
(get_local $1)
)
)
(func $std/mod/test_fmodf (; 7 ;) (type $fffi) (param $0 f32) (param $1 f32) (param $2 f32) (result i32)
(func $std/mod/test_fmodf (; 9 ;) (type $fffi) (param $0 f32) (param $1 f32) (param $2 f32) (result i32)
(call $std/mod/check<f32>
(call $~lib/math/NativeMathf.mod
(get_local $0)
@ -873,7 +863,7 @@
(get_local $2)
)
)
(func $start (; 8 ;) (type $v)
(func $start (; 10 ;) (type $v)
(if
(i32.eqz
(call $std/mod/test_fmod

View File

@ -1,22 +1,46 @@
(module
(type $FFFi (func (param f64 f64 f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64)))
(type $FFi (func (param f64 f64) (result i32)))
(type $Fi (func (param f64) (result i32)))
(type $i (func (result i32)))
(type $FFi (func (param f64 f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32)))
(type $F (func (result f64)))
(type $fffi (func (param f32 f32 f32) (result i32)))
(type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $ffi (func (param f32 f32) (result i32)))
(type $v (func))
(import "JSOp" "mod" (func $std/mod/JSOp.mod (param f64 f64) (result f64)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $std/mod/js i32 (i32.const 1))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $Infinity f64 (f64.const inf))
(global $HEAP_BASE i32 (i32.const 28))
(memory $0 1)
(data (i32.const 4) "\n\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s\00")
(export "memory" (memory $0))
(start $start)
(func $~lib/math/NativeMath.mod (; 2 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(func $isNaN<f64> (; 2 ;) (type $Fi) (param $0 f64) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMath.mod (; 3 ;) (type $FFF) (param $0 f64) (param $1 f64) (result f64)
(local $2 i64)
(local $3 i64)
(local $4 i32)
@ -80,14 +104,8 @@
)
)
(get_local $7)
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
)
(i32.const 1)
@ -473,26 +491,14 @@
)
)
)
(func $std/mod/check<f64> (; 3 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32)
(func $std/mod/check<f64> (; 4 ;) (type $FFi) (param $0 f64) (param $1 f64) (result i32)
(if
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $1)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $1)
)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(get_local $0)
)
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
(call $isNaN<f64>
(get_local $0)
)
)
)
@ -523,7 +529,7 @@
)
)
)
(func $std/mod/test_fmod (; 4 ;) (type $FFFi) (param $0 f64) (param $1 f64) (param $2 f64) (result i32)
(func $std/mod/test_fmod (; 5 ;) (type $FFFi) (param $0 f64) (param $1 f64) (param $2 f64) (result i32)
(local $3 i32)
(return
(i32.and
@ -558,7 +564,28 @@
)
)
)
(func $~lib/math/NativeMathf.mod (; 5 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(func $isNaN<f32> (; 6 ;) (type $fi) (param $0 f32) (result i32)
(return
(i64.gt_u
(i64.and
(i64.reinterpret/f64
(f64.promote/f32
(get_local $0)
)
)
(i64.shr_u
(i64.const -1)
(i64.const 1)
)
)
(i64.shl
(i64.const 2047)
(i64.const 52)
)
)
)
)
(func $~lib/math/NativeMathf.mod (; 7 ;) (type $fff) (param $0 f32) (param $1 f32) (result f32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
@ -616,14 +643,8 @@
)
)
(get_local $7)
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
)
(i32.const 1)
@ -996,26 +1017,14 @@
)
)
)
(func $std/mod/check<f32> (; 6 ;) (type $ffi) (param $0 f32) (param $1 f32) (result i32)
(func $std/mod/check<f32> (; 8 ;) (type $ffi) (param $0 f32) (param $1 f32) (result i32)
(if
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $1)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $1)
)
(return
(i32.gt_u
(i32.and
(i32.reinterpret/f32
(get_local $0)
)
(i32.const 2147483647)
)
(i32.const 2139095040)
(call $isNaN<f32>
(get_local $0)
)
)
)
@ -1046,7 +1055,7 @@
)
)
)
(func $std/mod/test_fmodf (; 7 ;) (type $fffi) (param $0 f32) (param $1 f32) (param $2 f32) (result i32)
(func $std/mod/test_fmodf (; 9 ;) (type $fffi) (param $0 f32) (param $1 f32) (param $2 f32) (result i32)
(return
(call $std/mod/check<f32>
(call $~lib/math/NativeMathf.mod
@ -1057,7 +1066,7 @@
)
)
)
(func $start (; 8 ;) (type $v)
(func $start (; 10 ;) (type $v)
(if
(i32.eqz
(call $std/mod/test_fmod

View File

@ -32,6 +32,7 @@
(global $std/operator-overloading/f (mut i32) (i32.const 0))
(global $std/operator-overloading/p1 (mut i32) (i32.const 0))
(global $std/operator-overloading/p2 (mut i32) (i32.const 0))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $std/operator-overloading/p (mut i32) (i32.const 0))
(global $std/operator-overloading/n1 (mut i32) (i32.const 0))
(global $std/operator-overloading/n2 (mut i32) (i32.const 0))

View File

@ -4,6 +4,7 @@
(type $iii (func (param i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiF (func (param i32 i32) (result f64)))
(type $F (func (result f64)))
(type $iF (func (param i32) (result f64)))
(type $ii (func (param i32) (result i32)))
(type $iiiv (func (param i32 i32 i32)))
@ -20,6 +21,7 @@
(global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4))
(global $argumentCount (mut i32) (i32.const 0))
(global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $~lib/internal/string/CharCode.PLUS i32 (i32.const 43))
(global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45))
(global $~lib/internal/string/CharCode.DOT i32 (i32.const 46))