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; 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 {
if (decorators) {
for (let i = 0, k = decorators.length; i < k; ++i) {
let decorator = decorators[i];
let expression = decorator.name;
if (expression.kind == NodeKind.IDENTIFIER && (<IdentifierExpression>expression).text == name) {
return decorator;
}
}
}
return null;
}
/** Tests if a specific decorator is present within the specified decorators. */ /** Tests if a specific decorator is present within the specified decorators. */
export function hasDecorator(name: string, decorators: DecoratorNode[] | null): bool { export function hasDecorator(name: string, decorators: DecoratorNode[] | null): bool {
return getFirstDecorator(name, decorators) != null; if (decorators) {
for (let i = 0, k = decorators.length; i < k; ++i) {
let expression = decorators[i].name;
if (expression.kind == NodeKind.IDENTIFIER && (<IdentifierExpression>expression).text == name) {
return true;
}
}
}
return false;
} }
/** Mangles a declaration's name to an internal name. */ /** Mangles a declaration's name to an internal name. */

View File

@ -54,22 +54,6 @@ export function compileGetConstant(
reportNode: Node reportNode: Node
): ExpressionRef { ): ExpressionRef {
switch (global.internalName) { 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 case "HEAP_BASE": { // never inlined for linking purposes
compiler.currentType = compiler.options.usizeType; compiler.currentType = compiler.options.usizeType;
return compiler.module.createGetGlobal("HEAP_BASE", compiler.currentType.toNativeType()); return compiler.module.createGetGlobal("HEAP_BASE", compiler.currentType.toNativeType());
@ -154,143 +138,6 @@ export function compileCall(
// math // 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 case "clz": { // clz<T?>(value: T) -> T
if (operands.length != 1) { if (operands.length != 1) {
if (typeArguments) { if (typeArguments) {

View File

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

View File

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

View File

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

View File

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

View File

@ -3,11 +3,15 @@
(type $F (func (result f64))) (type $F (func (result f64)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32))) (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 $f (func (result f32)))
(type $fif (func (param f32 i32) (result f32))) (type $fif (func (param f32 i32) (result f32)))
(type $Fi (func (param f64) (result i32)))
(type $v (func)) (type $v (func))
(global $binary/b (mut i32) (i32.const 0)) (global $binary/b (mut i32) (i32.const 0))
(global $binary/i (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/I (mut i64) (i64.const 0))
(global $binary/f (mut f32) (f32.const 0)) (global $binary/f (mut f32) (f32.const 0))
(global $binary/F (mut f64) (f64.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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -1773,15 +1798,9 @@
) )
) )
(get_local $7) (get_local $7)
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(i32.const 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) (local $2 f32)
(nop) (nop)
(set_local $2 (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 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 $2 i64)
(local $3 i64) (local $3 i64)
(local $4 i32) (local $4 i32)
@ -3667,15 +3705,9 @@
) )
) )
(get_local $7) (get_local $7)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -4060,7 +4092,7 @@
) )
) )
) )
(func $start (; 6 ;) (type $v) (func $start (; 8 ;) (type $v)
(drop (drop
(i32.lt_s (i32.lt_s
(get_global $binary/i) (get_global $binary/i)

View File

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

View File

@ -1,9 +1,12 @@
(module (module
(type $F (func (result f64)))
(type $i (func (result i32))) (type $i (func (result i32)))
(type $iiv (func (param i32 i32))) (type $iiv (func (param i32 i32)))
(type $iiiiv (func (param i32 i32 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/lo (mut i32) (i32.const 0))
(global $../../examples/i64-polyfill/assembly/i64/hi (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)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
(export "getHi" (func $../../examples/i64-polyfill/assembly/i64/getHi)) (export "getHi" (func $../../examples/i64-polyfill/assembly/i64/getHi))

View File

@ -2,7 +2,9 @@
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $fif (func (param f32 i32) (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 $iiiiv (func (param i32 i32 i32 i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
@ -1574,7 +1576,20 @@
(f64.const 1.e+300) (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -1623,15 +1638,9 @@
) )
) )
(get_local $3) (get_local $3)
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -1928,7 +1937,7 @@
(get_local $0) (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) (local $2 f32)
(set_local $2 (set_local $2
(get_local $0) (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 $2 f32)
(local $3 f32) (local $3 f32)
(local $4 i32) (local $4 i32)
@ -3205,7 +3214,18 @@
(f32.const 1000000015047466219876688e6) (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 $2 i64)
(local $3 i32) (local $3 i32)
(local $4 i64) (local $4 i64)
@ -3259,15 +3279,9 @@
) )
) )
(get_local $7) (get_local $7)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -3579,31 +3593,55 @@
(get_local $0) (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) (get_local $0)
) )
(func $showcase/addGeneric<i32> (; 8 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) )
(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> (; 12 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32)
(i32.add (i32.add
(get_local $0) (get_local $0)
(get_local $1) (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 (f32.add
(get_local $0) (get_local $0)
(get_local $1) (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 (f64.add
(get_local $0) (get_local $0)
(get_local $1) (get_local $1)
) )
) )
(func $showcase/anExportedFunction (; 11 ;) (type $v) (func $showcase/anExportedFunction (; 15 ;) (type $v)
(nop) (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 $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
@ -5186,18 +5224,18 @@
) )
(get_local $5) (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 (f32.store offset=4
(get_local $0) (get_local $0)
(get_local $1) (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 (f32.load offset=4
(get_local $0) (get_local $0)
) )
) )
(func $start (; 15 ;) (type $v) (func $start (; 19 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 i64) (local $1 i64)
(local $2 i32) (local $2 i32)
@ -6493,6 +6531,96 @@
(unreachable) (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 (set_global $builtins/f
(f32.const nan:0x400000) (f32.const nan:0x400000)
) )
@ -6527,11 +6655,105 @@
(f32.const 1) (f32.const 1)
) )
(set_global $builtins/b (set_global $builtins/b
(i32.const 0) (call $isNaN<f32>
(f32.const 1.25)
)
) )
(set_global $builtins/b (set_global $builtins/b
(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) (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 (set_global $builtins/F
(f64.const nan:0x8000000000000) (f64.const nan:0x8000000000000)
) )
@ -6566,10 +6788,14 @@
(f64.const 1) (f64.const 1)
) )
(set_global $builtins/b (set_global $builtins/b
(i32.const 0) (call $isNaN<f64>
(f64.const 1.25)
)
) )
(set_global $builtins/b (set_global $builtins/b
(i32.const 1) (call $isFinite<f64>
(f64.const 1.25)
)
) )
(set_global $builtins/i (set_global $builtins/i
(i32.load (i32.load
@ -6869,6 +7095,131 @@
) )
(unreachable) (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 (if
(i32.ne (i32.ne
(call $showcase/ANamespace.aNamespacedFunction (call $showcase/ANamespace.aNamespacedFunction

View File

@ -3,10 +3,12 @@
(type $F (func (result f64))) (type $F (func (result f64)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $fff (func (param f32 f32) (result f32))) (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 $f (func (result f32)))
(type $fif (func (param f32 i32) (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 $iiiiv (func (param i32 i32 i32 i32)))
(type $i (func (result i32)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iii (func (param i32 i32) (result i32))) (type $iii (func (param i32 i32) (result i32)))
(type $v (func)) (type $v (func))
@ -27,6 +29,7 @@
(global $unary/F (mut f64) (f64.const 0)) (global $unary/F (mut f64) (f64.const 0))
(global $binary/b (mut i32) (i32.const 0)) (global $binary/b (mut i32) (i32.const 0))
(global $binary/i (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/I (mut i64) (i64.const 0))
(global $binary/f (mut f32) (f32.const 0)) (global $binary/f (mut f32) (f32.const 0))
(global $binary/F (mut f64) (f64.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 i32) (i32.const 0))
(global $builtins/I (mut i64) (i64.const 0)) (global $builtins/I (mut i64) (i64.const 0))
(global $builtins/f (mut f32) (f32.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/F (mut f64) (f64.const 0))
(global $builtins/constantOffset i32 (i32.const 8)) (global $builtins/constantOffset i32 (i32.const 8))
(global $builtins/u (mut i32) (i32.const 0)) (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -1829,15 +1854,9 @@
) )
) )
(get_local $7) (get_local $7)
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(i32.const 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) (local $2 f32)
(nop) (nop)
(set_local $2 (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 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 $2 i64)
(local $3 i64) (local $3 i64)
(local $4 i32) (local $4 i32)
@ -3723,15 +3761,9 @@
) )
) )
(get_local $7) (get_local $7)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 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 (return
(get_local $0) (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 (return
(i32.add (i32.add
(get_local $0) (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 (return
(f32.add (f32.add
(get_local $0) (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 (return
(f64.add (f64.add
(get_local $0) (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 $3 i32)
(local $4 i32) (local $4 i32)
(local $5 i32) (local $5 i32)
@ -5953,20 +6025,20 @@
(get_local $3) (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 (f32.store offset=4
(get_local $0) (get_local $0)
(get_local $1) (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 (return
(f32.load offset=4 (f32.load offset=4
(get_local $0) (get_local $0)
) )
) )
) )
(func $start (; 15 ;) (type $v) (func $start (; 19 ;) (type $v)
(local $0 i32) (local $0 i32)
(local $1 i64) (local $1 i64)
(local $2 f32) (local $2 f32)
@ -8369,15 +8441,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(f32.const 1.25) (f32.const 1.25)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8394,15 +8460,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000) (f32.const nan:0x400000)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(i32.const 1) (i32.const 1)
) )
) )
@ -8419,15 +8479,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const 1.25) (f32.const 1.25)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(i32.const 1) (i32.const 1)
) )
) )
@ -8444,15 +8498,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const inf) (f32.const inf)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8469,17 +8517,11 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.neg (f32.neg
(f32.const inf) (f32.const inf)
) )
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8496,15 +8538,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000) (f32.const nan:0x400000)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8573,26 +8609,14 @@
) )
) )
(set_global $builtins/b (set_global $builtins/b
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(f32.const 1.25) (f32.const 1.25)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(set_global $builtins/b (set_global $builtins/b
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const 1.25) (f32.const 1.25)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(drop (drop
(f64.const nan:0x8000000000000) (f64.const nan:0x8000000000000)
@ -8657,15 +8681,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(f64.const 1.25) (f64.const 1.25)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8682,15 +8700,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000) (f64.const nan:0x8000000000000)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(i32.const 1) (i32.const 1)
) )
) )
@ -8707,15 +8719,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const 1.25) (f64.const 1.25)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(i32.const 1) (i32.const 1)
) )
) )
@ -8732,15 +8738,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const inf) (f64.const inf)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8757,17 +8757,11 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.neg (f64.neg
(f64.const inf) (f64.const inf)
) )
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8784,15 +8778,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eq (i32.eq
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000) (f64.const nan:0x8000000000000)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(i32.const 0) (i32.const 0)
) )
) )
@ -8861,26 +8849,14 @@
) )
) )
(set_global $builtins/b (set_global $builtins/b
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(f64.const 1.25) (f64.const 1.25)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(set_global $builtins/b (set_global $builtins/b
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const 1.25) (f64.const 1.25)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(set_global $builtins/i (set_global $builtins/i
(i32.load (i32.load
@ -9568,15 +9544,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000) (f32.const nan:0x400000)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(block (block
(call $abort (call $abort
@ -9590,15 +9560,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000) (f64.const nan:0x8000000000000)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(block (block
(call $abort (call $abort
@ -9613,15 +9577,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eqz (i32.eqz
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const nan:0x400000) (f32.const nan:0x400000)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
) )
(block (block
@ -9637,15 +9595,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eqz (i32.eqz
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const inf) (f32.const inf)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
) )
(block (block
@ -9661,15 +9613,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eqz (i32.eqz
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const nan:0x8000000000000) (f64.const nan:0x8000000000000)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
) )
(block (block
@ -9685,15 +9631,9 @@
(if (if
(i32.eqz (i32.eqz
(i32.eqz (i32.eqz
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const inf) (f64.const inf)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
) )
(block (block
@ -9708,15 +9648,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i32.lt_u (call $isFinite<f32>
(i32.and
(i32.reinterpret/f32
(f32.const 0) (f32.const 0)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(block (block
(call $abort (call $abort
@ -9730,15 +9664,9 @@
) )
(if (if
(i32.eqz (i32.eqz
(i64.lt_u (call $isFinite<f64>
(i64.and
(i64.reinterpret/f64
(f64.const 0) (f64.const 0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(block (block
(call $abort (call $abort
@ -10273,15 +10201,9 @@
) )
) )
(drop (drop
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(f64.const 1) (f64.const 1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(if (if
(i32.eqz (i32.eqz

View File

@ -1,5 +1,6 @@
(module (module
(type $FF (func (param f64) (result f64))) (type $FF (func (param f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $Ff (func (param f64) (result f32))) (type $Ff (func (param f64) (result f32)))
@ -1306,7 +1307,18 @@
(get_local $0) (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 $1 f64)
(local $2 f64) (local $2 f64)
(local $3 i32) (local $3 i32)
@ -1338,15 +1350,9 @@
) )
(block (block
(if (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(get_local $0) (get_local $0)
) )
@ -1669,12 +1675,12 @@
(get_local $4) (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 (call $~lib/math/NativeMath.atan
(get_local $0) (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 $1 i64)
(local $2 i64) (local $2 i64)
(local $3 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 (call $~lib/math/NativeMath.atanh
(get_local $0) (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -1788,26 +1794,14 @@
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $2 (tee_local $2
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(get_local $2) (get_local $2)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 1) (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 (call $~lib/math/NativeMath.atan2
(get_local $0) (get_local $0)
(get_local $1) (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 $1 f64)
(local $2 f64) (local $2 f64)
(local $3 i32) (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 (call $~lib/math/NativeMath.cbrt
(get_local $0) (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 (f64.ceil
(get_local $0) (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 (f64.convert_s/i32
(i32.clz (i32.clz
(i32.trunc_s/f64 (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) (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 (call $~lib/math/NativeMath.cos
(get_local $0) (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 $1 f64)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -2378,15 +2372,9 @@
) )
(block (block
(if (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(get_local $0) (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) (local $2 f64)
(set_local $2 (set_local $2
(get_local $0) (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 $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -2932,15 +2920,9 @@
) )
(block (block
(if (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(get_local $0) (get_local $0)
) )
@ -3109,7 +3091,7 @@
(get_local $2) (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) (local $1 f64)
(f64.mul (f64.mul
(f64.mul (f64.mul
@ -3126,7 +3108,7 @@
(get_local $1) (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 $1 i32)
(local $2 i64) (local $2 i64)
(set_local $0 (set_local $0
@ -3213,32 +3195,32 @@
(get_local $0) (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 (call $~lib/math/NativeMath.cosh
(get_local $0) (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 (call $~lib/math/NativeMath.exp
(get_local $0) (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 (call $~lib/math/NativeMath.expm1
(get_local $0) (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 (f64.floor
(get_local $0) (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 (f32.demote/f64
(get_local $0) (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 $2 f64)
(local $3 f64) (local $3 f64)
(local $4 i64) (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 (call $~lib/math/NativeMath.hypot
(get_local $0) (get_local $0)
(get_local $1) (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 (f64.convert_s/i32
(i32.mul (i32.mul
(i32.trunc_s/f64 (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 (call $~lib/math/NativeMath.imul
(get_local $0) (get_local $0)
(get_local $1) (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 (call $~lib/math/NativeMath.log
(get_local $0) (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 $1 f64)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -3854,17 +3836,17 @@
(get_local $0) (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 (call $~lib/math/NativeMath.log10
(get_local $0) (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 (call $~lib/math/NativeMath.log1p
(get_local $0) (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 $1 f64)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -4170,24 +4152,24 @@
(get_local $1) (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 (call $~lib/math/NativeMath.log2
(get_local $0) (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 (f64.max
(get_local $0) (get_local $0)
(get_local $1) (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 (f64.min
(get_local $0) (get_local $0)
(get_local $1) (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 $2 f64)
(local $3 f64) (local $3 f64)
(local $4 i32) (local $4 i32)
@ -5586,13 +5568,13 @@
(f64.const 1.e+300) (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 (call $~lib/math/NativeMath.pow
(get_local $0) (get_local $0)
(get_local $1) (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 $1 f64)
(local $2 i64) (local $2 i64)
(local $3 i32) (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 (call $~lib/math/NativeMath.round
(get_local $0) (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) (local $1 f64)
(select (select
(f64.copysign (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 $1 f64)
(local $2 f64) (local $2 f64)
(local $3 i64) (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 (call $~lib/math/NativeMath.sinh
(get_local $0) (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 (f64.sqrt
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -6000,12 +5982,12 @@
(get_local $3) (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 (call $~lib/math/NativeMath.tanh
(get_local $0) (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 (f64.trunc
(get_local $0) (get_local $0)
) )

View File

@ -2,8 +2,9 @@
(type $F (func (result f64))) (type $F (func (result f64)))
(type $FF (func (param f64) (result f64))) (type $FF (func (param f64) (result f64)))
(type $f (func (result f32))) (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 $i (func (result i32)))
(type $FFF (func (param f64 f64) (result f64)))
(type $FiF (func (param f64 i32) (result f64))) (type $FiF (func (param f64 i32) (result f64)))
(type $Ff (func (param f64) (result f32))) (type $Ff (func (param f64) (result f32)))
(global $std/libm/E f64 (f64.const 2.718281828459045)) (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/PI f64 (f64.const 3.141592653589793))
(global $std/libm/SQRT1_2 f64 (f64.const 0.7071067811865476)) (global $std/libm/SQRT1_2 f64 (f64.const 0.7071067811865476))
(global $std/libm/SQRT2 f64 (f64.const 1.4142135623730951)) (global $std/libm/SQRT2 f64 (f64.const 1.4142135623730951))
(global $NaN f64 (f64.const nan:0x8000000000000))
(global $HEAP_BASE i32 (i32.const 4)) (global $HEAP_BASE i32 (i32.const 4))
(memory $0 1) (memory $0 1)
(export "E" (global $std/libm/E)) (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 $1 i32)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -1593,15 +1614,9 @@
) )
(block (block
(if (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(get_local $0) (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 (return
(call $~lib/math/NativeMath.atan (call $~lib/math/NativeMath.atan
(get_local $0) (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 $1 i64)
(local $2 i64) (local $2 i64)
(local $3 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 (return
(call $~lib/math/NativeMath.atanh (call $~lib/math/NativeMath.atanh
(get_local $0) (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 $2 i32)
(local $3 i64) (local $3 i64)
(local $4 i32) (local $4 i32)
@ -2108,26 +2123,14 @@
(i32.and (i32.and
(if (result i32) (if (result i32)
(tee_local $2 (tee_local $2
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(get_local $2) (get_local $2)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -2586,7 +2589,7 @@
(f64.const 0) (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 (return
(call $~lib/math/NativeMath.atan2 (call $~lib/math/NativeMath.atan2
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -2813,14 +2816,14 @@
(get_local $3) (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 (return
(call $~lib/math/NativeMath.cbrt (call $~lib/math/NativeMath.cbrt
(get_local $0) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.ceil|inlined.0 (result f64) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.clz32|inlined.0 (result f64) (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) (unreachable)
(return (return
(f64.const 0) (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 (return
(call $~lib/math/NativeMath.cos (call $~lib/math/NativeMath.cos
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -2920,15 +2923,9 @@
) )
(block (block
(if (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(get_local $0) (get_local $0)
) )
@ -3364,7 +3361,7 @@
(get_local $14) (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) (local $2 f64)
(nop) (nop)
(set_local $2 (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 $1 i32)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -3524,15 +3521,9 @@
) )
(block (block
(if (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(get_local $0) (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) (local $1 f64)
(nop) (nop)
(set_local $1 (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -3870,28 +3861,28 @@
(get_local $3) (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 (return
(call $~lib/math/NativeMath.cosh (call $~lib/math/NativeMath.cosh
(get_local $0) (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 (return
(call $~lib/math/NativeMath.exp (call $~lib/math/NativeMath.exp
(get_local $0) (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 (return
(call $~lib/math/NativeMath.expm1 (call $~lib/math/NativeMath.expm1
(get_local $0) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.floor|inlined.0 (result f64) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.fround|inlined.0 (result f32) (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 $2 i64)
(local $3 i64) (local $3 i64)
(local $4 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 (return
(call $~lib/math/NativeMath.hypot (call $~lib/math/NativeMath.hypot
(get_local $0) (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 (return
(f64.convert_s/i32 (f64.convert_s/i32
(i32.mul (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 (return
(call $~lib/math/NativeMath.imul (call $~lib/math/NativeMath.imul
(get_local $0) (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 (return
(call $~lib/math/NativeMath.log (call $~lib/math/NativeMath.log
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 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 (return
(call $~lib/math/NativeMath.log10 (call $~lib/math/NativeMath.log10
(get_local $0) (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 (return
(call $~lib/math/NativeMath.log1p (call $~lib/math/NativeMath.log1p
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 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 (return
(call $~lib/math/NativeMath.log2 (call $~lib/math/NativeMath.log2
(get_local $0) (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 $2 f64)
(local $3 f64) (local $3 f64)
(return (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 $2 f64)
(local $3 f64) (local $3 f64)
(return (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 $2 i64)
(local $3 i32) (local $3 i32)
(local $4 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 (return
(call $~lib/math/NativeMath.pow (call $~lib/math/NativeMath.pow
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 f64) (local $3 f64)
@ -6834,14 +6825,14 @@
(get_local $3) (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 (return
(call $~lib/math/NativeMath.round (call $~lib/math/NativeMath.round
(get_local $0) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.sign|inlined.0 (result f64) (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) (unreachable)
(return (return
(f64.const 0) (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 (return
(call $~lib/math/NativeMath.sin (call $~lib/math/NativeMath.sin
(get_local $0) (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 $1 i64)
(local $2 f64) (local $2 f64)
(local $3 f64) (local $3 f64)
@ -7014,14 +7005,14 @@
(get_local $5) (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 (return
(call $~lib/math/NativeMath.sinh (call $~lib/math/NativeMath.sinh
(get_local $0) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.sqrt|inlined.0 (result f64) (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) (unreachable)
(return (return
(f64.const 0) (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 (return
(call $~lib/math/NativeMath.tan (call $~lib/math/NativeMath.tan
(get_local $0) (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 $1 i64)
(local $2 i32) (local $2 i32)
(local $3 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 (return
(call $~lib/math/NativeMath.tanh (call $~lib/math/NativeMath.tanh
(get_local $0) (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) (local $1 f64)
(return (return
(block $~lib/math/NativeMath.trunc|inlined.0 (result f64) (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 (module
(type $FFFi (func (param f64 f64 f64) (result i32))) (type $FFFi (func (param f64 f64 f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64))) (type $FFF (func (param f64 f64) (result f64)))
(type $Fi (func (param f64) (result i32)))
(type $FFi (func (param f64 f64) (result i32))) (type $FFi (func (param f64 f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $fffi (func (param f32 f32 f32) (result i32))) (type $fffi (func (param f32 f32 f32) (result i32)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $ffi (func (param f32 f32) (result i32))) (type $ffi (func (param f32 f32) (result i32)))
(type $v (func)) (type $v (func))
(import "JSOp" "mod" (func $std/mod/JSOp.mod (param f64 f64) (result f64))) (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") (data (i32.const 4) "\n\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s")
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (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 $2 i64)
(local $3 i32) (local $3 i32)
(local $4 i64) (local $4 i64)
@ -67,15 +80,9 @@
) )
) )
(get_local $7) (get_local $7)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -387,27 +394,15 @@
(get_local $0) (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 (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
) )
(if (if
@ -433,7 +428,7 @@
(get_local $1) (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) (local $3 i32)
(i32.and (i32.and
(if (result i32) (if (result i32)
@ -464,7 +459,20 @@
(i32.const 1) (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -513,15 +521,9 @@
) )
) )
(get_local $3) (get_local $3)
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -818,27 +820,15 @@
(get_local $0) (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 (if
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(return (return
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $0) (get_local $0)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
) )
(if (if
@ -864,7 +854,7 @@
(get_local $1) (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 $std/mod/check<f32>
(call $~lib/math/NativeMathf.mod (call $~lib/math/NativeMathf.mod
(get_local $0) (get_local $0)
@ -873,7 +863,7 @@
(get_local $2) (get_local $2)
) )
) )
(func $start (; 8 ;) (type $v) (func $start (; 10 ;) (type $v)
(if (if
(i32.eqz (i32.eqz
(call $std/mod/test_fmod (call $std/mod/test_fmod

View File

@ -1,22 +1,46 @@
(module (module
(type $FFFi (func (param f64 f64 f64) (result i32))) (type $FFFi (func (param f64 f64 f64) (result i32)))
(type $FFF (func (param f64 f64) (result f64))) (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 $i (func (result i32)))
(type $FFi (func (param f64 f64) (result i32)))
(type $iiiiv (func (param i32 i32 i32 i32))) (type $iiiiv (func (param i32 i32 i32 i32)))
(type $F (func (result f64)))
(type $fffi (func (param f32 f32 f32) (result i32))) (type $fffi (func (param f32 f32 f32) (result i32)))
(type $fff (func (param f32 f32) (result f32))) (type $fff (func (param f32 f32) (result f32)))
(type $fi (func (param f32) (result i32)))
(type $ffi (func (param f32 f32) (result i32))) (type $ffi (func (param f32 f32) (result i32)))
(type $v (func)) (type $v (func))
(import "JSOp" "mod" (func $std/mod/JSOp.mod (param f64 f64) (result f64))) (import "JSOp" "mod" (func $std/mod/JSOp.mod (param f64 f64) (result f64)))
(import "env" "abort" (func $abort (param i32 i32 i32 i32))) (import "env" "abort" (func $abort (param i32 i32 i32 i32)))
(global $std/mod/js i32 (i32.const 1)) (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)) (global $HEAP_BASE i32 (i32.const 28))
(memory $0 1) (memory $0 1)
(data (i32.const 4) "\n\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s\00") (data (i32.const 4) "\n\00\00\00s\00t\00d\00/\00m\00o\00d\00.\00t\00s\00")
(export "memory" (memory $0)) (export "memory" (memory $0))
(start $start) (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 $2 i64)
(local $3 i64) (local $3 i64)
(local $4 i32) (local $4 i32)
@ -80,15 +104,9 @@
) )
) )
(get_local $7) (get_local $7)
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -473,27 +491,15 @@
) )
) )
) )
(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 (if
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $1) (get_local $1)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
(return (return
(i64.gt_u (call $isNaN<f64>
(i64.and
(i64.reinterpret/f64
(get_local $0) (get_local $0)
) )
(i64.const 9223372036854775807)
)
(i64.const 9218868437227405312)
)
) )
) )
(if (if
@ -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) (local $3 i32)
(return (return
(i32.and (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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -616,15 +643,9 @@
) )
) )
(get_local $7) (get_local $7)
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
(i32.const 1) (i32.const 1)
) )
@ -996,27 +1017,15 @@
) )
) )
) )
(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 (if
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $1) (get_local $1)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
(return (return
(i32.gt_u (call $isNaN<f32>
(i32.and
(i32.reinterpret/f32
(get_local $0) (get_local $0)
) )
(i32.const 2147483647)
)
(i32.const 2139095040)
)
) )
) )
(if (if
@ -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 (return
(call $std/mod/check<f32> (call $std/mod/check<f32>
(call $~lib/math/NativeMathf.mod (call $~lib/math/NativeMathf.mod
@ -1057,7 +1066,7 @@
) )
) )
) )
(func $start (; 8 ;) (type $v) (func $start (; 10 ;) (type $v)
(if (if
(i32.eqz (i32.eqz
(call $std/mod/test_fmod (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/f (mut i32) (i32.const 0))
(global $std/operator-overloading/p1 (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 $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/p (mut i32) (i32.const 0))
(global $std/operator-overloading/n1 (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)) (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 $iii (func (param i32 i32) (result i32)))
(type $iiii (func (param i32 i32 i32) (result i32))) (type $iiii (func (param i32 i32 i32) (result i32)))
(type $iiF (func (param i32 i32) (result f64))) (type $iiF (func (param i32 i32) (result f64)))
(type $F (func (result f64)))
(type $iF (func (param i32) (result f64))) (type $iF (func (param i32) (result f64)))
(type $ii (func (param i32) (result i32))) (type $ii (func (param i32) (result i32)))
(type $iiiv (func (param i32 i32 i32))) (type $iiiv (func (param i32 i32 i32)))
@ -20,6 +21,7 @@
(global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4)) (global $~lib/internal/string/HEADER_SIZE i32 (i32.const 4))
(global $argumentCount (mut i32) (i32.const 0)) (global $argumentCount (mut i32) (i32.const 0))
(global $~lib/internal/string/MAX_LENGTH i32 (i32.const 536870910)) (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.PLUS i32 (i32.const 43))
(global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45)) (global $~lib/internal/string/CharCode.MINUS i32 (i32.const 45))
(global $~lib/internal/string/CharCode.DOT i32 (i32.const 46)) (global $~lib/internal/string/CharCode.DOT i32 (i32.const 46))