diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60f636a26a..1b494574a8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -121,14 +121,14 @@ jobs: - uses: dcodeIO/setup-node-nvm@master with: node-mirror: https://nodejs.org/download/v8-canary/ - node-version: "15.0.0-v8-canary202007077c53168ead" + node-version: "node" - name: Install dependencies run: npm ci --no-audit - name: Clean distribution files run: npm run clean - name: Test experimental features env: - ASC_FEATURES: mutable-globals,threads,reference-types,bigint-integration + ASC_FEATURES: mutable-globals,threads,reference-types,bigint-integration,gc run: | npm run test:compiler rt/flags features/js-bigint-integration features/reference-types features/threads test-runtimes: diff --git a/cli/asc.json b/cli/asc.json index b9de41a05a..948fdcc19e 100644 --- a/cli/asc.json +++ b/cli/asc.json @@ -192,13 +192,15 @@ " simd SIMD types and operations.", " threads Threading and atomic operations.", " reference-types Reference types and operations.", + " gc Garbage collection (anyref, WIP).", "" ], "TODO_doesNothingYet": [ " nontrapping-f2i Non-trapping float to integer ops.", " exception-handling Exception handling.", " tail-calls Tail call operations.", - " multi-value Multi value types." + " multi-value Multi value types.", + " memory64 Memory64 operations." ], "type": "S", "mutuallyExclusive": "disable" diff --git a/package-lock.json b/package-lock.json index 2ead3eb333..1cf7d8084d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1163,9 +1163,9 @@ "optional": true }, "binaryen": { - "version": "96.0.0-nightly.20200911", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-96.0.0-nightly.20200911.tgz", - "integrity": "sha512-/mFIOMaaGsKcWZcwcrCGVVAtqI5le0rySoZSuS1a+3W878co883NLHOtbV2owDjAT7QELnsmjeKEAh+5VC+gbQ==" + "version": "97.0.0-nightly.20200919", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-97.0.0-nightly.20200919.tgz", + "integrity": "sha512-BqKZxONTh53SVl2QUqVidoSo/nvL6FMKUG21SvB6V46M1Y6EbJrXES5Nt2c9XYveWpJjA297zIoxTUdI/PMDSA==" }, "bluebird": { "version": "3.7.2", diff --git a/package.json b/package.json index 8536556016..790cf11f27 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/AssemblyScript/assemblyscript/issues" }, "dependencies": { - "binaryen": "96.0.0-nightly.20200911", + "binaryen": "97.0.0-nightly.20200919", "long": "^4.0.0", "source-map-support": "^0.5.19", "ts-node": "^6.2.0" diff --git a/src/builtins.ts b/src/builtins.ts index 8c2feadc5c..7abdf6eb2e 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -53,7 +53,6 @@ import { import { BinaryOp, UnaryOp, - HostOp, AtomicRMWOp, SIMDExtractOp, SIMDReplaceOp, @@ -968,39 +967,16 @@ function builtin_nameof(ctx: BuiltinContext): ExpressionRef { return module.unreachable(); } var value: string; - if (resultType.isReference) { + if (resultType.isInternalReference) { let classReference = resultType.getClass(); if (classReference) { value = classReference.name; } else { - let signatureReference = resultType.getSignature(); - if (signatureReference) { - value = "Function"; - } else { - assert(resultType.isExternalReference); - value = "Externref"; - } + assert(resultType.getSignature()); + value = "Function"; } } else { - switch (resultType.kind) { - case TypeKind.BOOL: { value = "bool"; break; } - case TypeKind.I8: { value = "i8"; break; } - case TypeKind.U8: { value = "u8"; break; } - case TypeKind.I16: { value = "i16"; break; } - case TypeKind.U16: { value = "u16"; break; } - case TypeKind.I32: { value = "i32"; break; } - case TypeKind.U32: { value = "u32"; break; } - case TypeKind.F32: { value = "f32"; break; } - case TypeKind.I64: { value = "i64"; break; } - case TypeKind.U64: { value = "u64"; break; } - case TypeKind.F64: { value = "f64"; break; } - case TypeKind.ISIZE: { value = "isize"; break; } - case TypeKind.USIZE: { value = "usize"; break; } - case TypeKind.V128: { value = "v128"; break; } - case TypeKind.EXTERNREF: { value = "externref"; break; } - default: assert(false); - case TypeKind.VOID: { value = "void"; break; } - } + value = resultType.toString(); } return compiler.ensureStaticString(value); } @@ -2472,7 +2448,7 @@ function builtin_memory_size(ctx: BuiltinContext): ExpressionRef { checkTypeAbsent(ctx) | checkArgsRequired(ctx, 0) ) return module.unreachable(); - return module.host(HostOp.MemorySize); + return module.memory_size(); } builtins.set(BuiltinNames.memory_size, builtin_memory_size); @@ -2485,10 +2461,7 @@ function builtin_memory_grow(ctx: BuiltinContext): ExpressionRef { checkTypeAbsent(ctx) | checkArgsRequired(ctx, 1) ) return module.unreachable(); - var operands = ctx.operands; - return module.host(HostOp.MemoryGrow, null, [ - compiler.compileExpression(operands[0], Type.i32, Constraints.CONV_IMPLICIT) - ]); + return module.memory_grow(compiler.compileExpression(ctx.operands[0], Type.i32, Constraints.CONV_IMPLICIT)); } builtins.set(BuiltinNames.memory_grow, builtin_memory_grow); @@ -2775,6 +2748,11 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef { // TODO: also check for NaN in float assertions, as in `Boolean(NaN) -> false`? case TypeKind.F32: return module.if(module.binary(BinaryOp.EqF32, arg0, module.f32(0)), abort); case TypeKind.F64: return module.if(module.binary(BinaryOp.EqF64, arg0, module.f64(0)), abort); + case TypeKind.FUNCREF: + case TypeKind.EXTERNREF: + case TypeKind.EXNREF: + case TypeKind.ANYREF: return module.if(module.ref_is_null(arg0), abort); + } } else { compiler.currentType = type.nonNullableType; @@ -2852,6 +2830,21 @@ function builtin_assert(ctx: BuiltinContext): ExpressionRef { flow.freeTempLocal(temp); return ret; } + case TypeKind.FUNCREF: + case TypeKind.EXTERNREF: + case TypeKind.EXNREF: + case TypeKind.ANYREF: { + let temp = flow.getTempLocal(type); + let ret = module.if( + module.ref_is_null( + module.local_tee(temp.index, arg0) + ), + abort, + module.local_get(temp.index, NativeType.F64) + ); + flow.freeTempLocal(temp); + return ret; + } } } compiler.error( diff --git a/src/common.ts b/src/common.ts index 8f4373a4e0..5a8d66769b 100644 --- a/src/common.ts +++ b/src/common.ts @@ -123,7 +123,10 @@ export namespace CommonNames { export const f32 = "f32"; export const f64 = "f64"; export const v128 = "v128"; + export const funcref = "funcref"; export const externref = "externref"; + export const exnref = "exnref"; + export const anyref = "anyref"; export const i8x16 = "i8x16"; export const u8x16 = "u8x16"; export const i16x8 = "i16x8"; @@ -170,6 +173,8 @@ export namespace CommonNames { export const ASC_FEATURE_TAIL_CALLS = "ASC_FEATURE_TAIL_CALLS"; export const ASC_FEATURE_REFERENCE_TYPES = "ASC_FEATURE_REFERENCE_TYPES"; export const ASC_FEATURE_MULTI_VALUE = "ASC_FEATURE_MULTI_VALUE"; + export const ASC_FEATURE_GC = "ASC_FEATURE_GC"; + export const ASC_FEATURE_MEMORY64 = "ASC_FEATURE_MEMORY64"; // classes export const I8 = "I8"; export const I16 = "I16"; @@ -185,7 +190,10 @@ export namespace CommonNames { export const F32 = "F32"; export const F64 = "F64"; export const V128 = "V128"; + export const Funcref = "Funcref"; export const Externref = "Externref"; + export const Exnref = "Exnref"; + export const Anyref = "Anyref"; export const String = "String"; export const Array = "Array"; export const StaticArray = "StaticArray"; diff --git a/src/compiler.ts b/src/compiler.ts index e63e08361c..7063a56113 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -405,6 +405,8 @@ export class Compiler extends DiagnosticEmitter { if (options.hasFeature(Feature.TAIL_CALLS)) featureFlags |= FeatureFlags.TailCall; if (options.hasFeature(Feature.REFERENCE_TYPES)) featureFlags |= FeatureFlags.ReferenceTypes; if (options.hasFeature(Feature.MULTI_VALUE)) featureFlags |= FeatureFlags.MultiValue; + if (options.hasFeature(Feature.GC)) featureFlags |= FeatureFlags.GC; + if (options.hasFeature(Feature.MEMORY64)) featureFlags |= FeatureFlags.Memory64; module.setFeatures(featureFlags); // set up the main start function @@ -3624,12 +3626,21 @@ export class Compiler extends DiagnosticEmitter { fromType = fromType.nonNullableType; } if (fromType.isAssignableTo(toType)) { // downcast or same - assert(fromType.kind == toType.kind); + assert(toType.isExternalReference || fromType.kind == toType.kind); this.currentType = toType; return expr; } if (explicit && toType.nonNullableType.isAssignableTo(fromType)) { // upcast // (maybeCat) + if (toType.isExternalReference) { + this.error( + DiagnosticCode.Not_implemented_0, + reportNode.range, + "ref.cast" + ); + this.currentType = toType; + return module.unreachable(); + } assert(fromType.kind == toType.kind); if (!this.options.noAssert) { expr = this.makeRuntimeUpcastCheck(expr, fromType, toType, reportNode); @@ -4390,12 +4401,15 @@ export class Compiler extends DiagnosticEmitter { ); break; } - case TypeKind.EXTERNREF: { - // TODO: ref.eq + case TypeKind.FUNCREF: + case TypeKind.EXTERNREF: + case TypeKind.EXNREF: + case TypeKind.ANYREF: { this.error( - DiagnosticCode.Not_implemented_0, + DiagnosticCode.Operation_0_cannot_be_applied_to_type_1, expression.range, - "ref.eq instruction" + "ref.eq", + commonType.toString() ); expr = module.unreachable(); break; @@ -4491,12 +4505,15 @@ export class Compiler extends DiagnosticEmitter { ); break; } - case TypeKind.EXTERNREF: { - // TODO: !ref.eq + case TypeKind.FUNCREF: + case TypeKind.EXTERNREF: + case TypeKind.EXNREF: + case TypeKind.ANYREF: { this.error( - DiagnosticCode.Not_implemented_0, + DiagnosticCode.Operation_0_cannot_be_applied_to_type_1, expression.range, - "ref.eq instruction" + "ref.eq", + commonType.toString() ); expr = module.unreachable(); break; @@ -8311,13 +8328,7 @@ export class Compiler extends DiagnosticEmitter { this.currentType = signatureReference.type.asNullable(); return options.isWasm64 ? module.i64(0) : module.i32(0); } - // TODO: return null ref for externref or funcref - this.error( - DiagnosticCode.Not_implemented_0, - expression.range, - "ref.null" - ); - return module.unreachable(); + return this.makeZero(contextualType, expression); } this.currentType = options.usizeType; this.warning( @@ -8508,7 +8519,7 @@ export class Compiler extends DiagnosticEmitter { ); if (!functionInstance || !this.compileFunction(functionInstance)) return module.unreachable(); if (contextualType.isExternalReference) { - this.currentType = Type.externref; + this.currentType = Type.funcref; return module.ref_func(functionInstance.internalName); } let offset = this.ensureRuntimeFunction(functionInstance); @@ -10619,7 +10630,17 @@ export class Compiler extends DiagnosticEmitter { checkTypeSupported(type: Type, reportNode: Node): bool { switch (type.kind) { case TypeKind.V128: return this.checkFeatureEnabled(Feature.SIMD, reportNode); - case TypeKind.EXTERNREF: return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode); + case TypeKind.FUNCREF: + case TypeKind.EXTERNREF: + return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode); + case TypeKind.EXNREF: { + return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode) + && this.checkFeatureEnabled(Feature.EXCEPTION_HANDLING, reportNode); + } + case TypeKind.ANYREF: { + return this.checkFeatureEnabled(Feature.REFERENCE_TYPES, reportNode) + && this.checkFeatureEnabled(Feature.GC, reportNode); + } } let classReference = type.getClass(); if (classReference) { @@ -10712,14 +10733,11 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F32: return module.f32(0); case TypeKind.F64: return module.f64(0); case TypeKind.V128: return module.v128(v128_zero); + case TypeKind.FUNCREF: case TypeKind.EXTERNREF: - // TODO: return null ref for both externref as well as funcref - this.error( - DiagnosticCode.Not_implemented_0, - reportNode.range, - "ref.null" - ); - return module.unreachable(); + case TypeKind.EXNREF: + case TypeKind.ANYREF: + return module.ref_null(type.toNativeType()); } } @@ -10824,16 +10842,11 @@ export class Compiler extends DiagnosticEmitter { module.i64(0xFFFFFFFE, 0xFFDFFFFF) // (0x7FF0000000000000 - 1) << 1 ); } - case TypeKind.EXTERNREF: { - // TODO: non-null object might still be considered falseish - // i.e. a ref to Boolean(false), Number(0), String("") etc. - // TODO: return module.unary(UnaryOp.EqzI32, module.ref_is_null(expr)); - this.error( - DiagnosticCode.Not_implemented_0, - reportNode.range, - "ref.is_null" - ); - return module.unreachable(); + case TypeKind.FUNCREF: + case TypeKind.EXTERNREF: + case TypeKind.EXNREF: + case TypeKind.ANYREF:{ + return module.ref_is_null(expr); } default: { assert(false); diff --git a/src/flow.ts b/src/flow.ts index 94b21b82e6..f057c4426c 100644 --- a/src/flow.ts +++ b/src/flow.ts @@ -311,8 +311,10 @@ export class Flow { case NativeType.F32: { temps = parentFunction.tempF32s; break; } case NativeType.F64: { temps = parentFunction.tempF64s; break; } case NativeType.V128: { temps = parentFunction.tempV128s; break; } + case NativeType.Funcref: { temps = parentFunction.tempFuncrefs; break; } case NativeType.Externref: { temps = parentFunction.tempExternrefs; break; } case NativeType.Exnref: { temps = parentFunction.tempExnrefs; break; } + case NativeType.Anyref: { temps = parentFunction.tempAnyrefs; break; } default: throw new Error("concrete type expected"); } var local: Local; @@ -395,6 +397,12 @@ export class Flow { else parentFunction.tempV128s = temps = []; break; } + case NativeType.Funcref: { + let tempFuncrefs = parentFunction.tempFuncrefs; + if (tempFuncrefs) temps = tempFuncrefs; + else parentFunction.tempFuncrefs = temps = []; + break; + } case NativeType.Externref: { let tempExternrefs = parentFunction.tempExternrefs; if (tempExternrefs) temps = tempExternrefs; @@ -407,6 +415,12 @@ export class Flow { else parentFunction.tempExnrefs = temps = []; break; } + case NativeType.Anyref: { + let tempAnyrefs = parentFunction.tempAnyrefs; + if (tempAnyrefs) temps = tempAnyrefs; + else parentFunction.tempAnyrefs = temps = []; + break; + } default: throw new Error("concrete type expected"); } assert(local.index >= 0); diff --git a/src/glue/binaryen.d.ts b/src/glue/binaryen.d.ts index 9e703eb38a..84db410bd1 100644 --- a/src/glue/binaryen.d.ts +++ b/src/glue/binaryen.d.ts @@ -58,6 +58,7 @@ export declare function _BinaryenFeatureExceptionHandling(): BinaryenFeatureFlag export declare function _BinaryenFeatureTailCall(): BinaryenFeatureFlags; export declare function _BinaryenFeatureReferenceTypes(): BinaryenFeatureFlags; export declare function _BinaryenFeatureMultivalue(): BinaryenFeatureFlags; +export declare function _BinaryenFeatureGC(): BinaryenFeatureFlags; export declare function _BinaryenFeatureAll(): BinaryenFeatureFlags; type BinaryenExpressionId = i32; @@ -82,7 +83,8 @@ export declare function _BinaryenBinaryId(): BinaryenExpressionId; export declare function _BinaryenSelectId(): BinaryenExpressionId; export declare function _BinaryenDropId(): BinaryenExpressionId; export declare function _BinaryenReturnId(): BinaryenExpressionId; -export declare function _BinaryenHostId(): BinaryenExpressionId; +export declare function _BinaryenMemorySizeId(): BinaryenExpressionId; +export declare function _BinaryenMemoryGrowId(): BinaryenExpressionId; export declare function _BinaryenNopId(): BinaryenExpressionId; export declare function _BinaryenUnreachableId(): BinaryenExpressionId; export declare function _BinaryenAtomicCmpxchgId(): BinaryenExpressionId; @@ -266,9 +268,6 @@ export declare function _BinaryenLeFloat64(): BinaryenOp; export declare function _BinaryenGtFloat64(): BinaryenOp; export declare function _BinaryenGeFloat64(): BinaryenOp; -export declare function _BinaryenMemorySize(): BinaryenOp; -export declare function _BinaryenMemoryGrow(): BinaryenOp; - export declare function _BinaryenAtomicRMWAdd(): BinaryenOp; export declare function _BinaryenAtomicRMWSub(): BinaryenOp; export declare function _BinaryenAtomicRMWAnd(): BinaryenOp; @@ -568,17 +567,11 @@ export declare function _BinaryenGlobalSetSetName(expr: BinaryenExpressionRef, n export declare function _BinaryenGlobalSetGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; export declare function _BinaryenGlobalSetSetValue(expr: BinaryenExpressionRef, valueExpr: BinaryenExpressionRef): void; -export declare function _BinaryenHost(module: BinaryenModuleRef, op: BinaryenOp, nameOperand: BinaryenString, operandExprs: BinaryenArray, numOperands: BinaryenIndex): BinaryenExpressionRef; -export declare function _BinaryenHostGetOp(expr: BinaryenExpressionRef): BinaryenOp; -export declare function _BinaryenHostSetOp(expr: BinaryenExpressionRef, op: BinaryenOp): void; -export declare function _BinaryenHostGetNameOperand(expr: BinaryenExpressionRef): BinaryenString; -export declare function _BinaryenHostSetNameOperand(expr: BinaryenExpressionRef, nameOperand: BinaryenString): void; -export declare function _BinaryenHostGetNumOperands(expr: BinaryenExpressionRef): BinaryenIndex; -export declare function _BinaryenHostGetOperandAt(expr: BinaryenExpressionRef, index: BinaryenIndex): BinaryenExpressionRef; -export declare function _BinaryenHostSetOperandAt(expr: BinaryenExpressionRef, index: BinaryenIndex, operandExpr: BinaryenExpressionRef): void; -export declare function _BinaryenHostAppendOperand(expr: BinaryenExpressionRef, operandExpr: BinaryenExpressionRef): BinaryenIndex; -export declare function _BinaryenHostInsertOperandAt(expr: BinaryenExpressionRef, index: BinaryenIndex, operandExpr: BinaryenExpressionRef): void; -export declare function _BinaryenHostRemoveOperandAt(expr: BinaryenExpressionRef, index: BinaryenIndex): BinaryenExpressionRef; +export declare function _BinaryenMemorySize(module: BinaryenModuleRef): BinaryenExpressionRef; + +export declare function _BinaryenMemoryGrow(module: BinaryenModuleRef, delta: BinaryenExpressionRef): BinaryenExpressionRef; +export declare function _BinaryenMemoryGrowGetDelta(expr: BinaryenExpressionRef): BinaryenExpressionRef; +export declare function _BinaryenMemoryGrowSetDelta(expr: BinaryenExpressionRef, delta: BinaryenExpressionRef): void; export declare function _BinaryenLoad(module: BinaryenModuleRef, bytes: u32, signed: bool, offset: u32, align: u32, type: BinaryenType, ptrExpr: BinaryenExpressionRef): BinaryenExpressionRef; export declare function _BinaryenLoadIsAtomic(expr: BinaryenExpressionRef): bool; @@ -790,7 +783,7 @@ export declare function _BinaryenMemoryFillSetValue(expr: BinaryenExpressionRef, export declare function _BinaryenMemoryFillGetSize(expr: BinaryenExpressionRef): BinaryenExpressionRef; export declare function _BinaryenMemoryFillSetSize(expr: BinaryenExpressionRef, sizeExpr: BinaryenExpressionRef): void; -export declare function _BinaryenRefNull(module: BinaryenModuleRef): BinaryenExpressionRef; +export declare function _BinaryenRefNull(module: BinaryenModuleRef, type: BinaryenType): BinaryenExpressionRef; export declare function _BinaryenRefIsNull(module: BinaryenModuleRef, valueExpr: BinaryenExpressionRef): BinaryenExpressionRef; export declare function _BinaryenRefIsNullGetValue(expr: BinaryenExpressionRef): BinaryenExpressionRef; diff --git a/src/index.ts b/src/index.ts index 48cf27960f..6082cfc53c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -149,6 +149,10 @@ export const FEATURE_TAIL_CALLS = Feature.TAIL_CALLS; export const FEATURE_REFERENCE_TYPES = Feature.REFERENCE_TYPES; /** Multi value types. */ export const FEATURE_MULTI_VALUE = Feature.MULTI_VALUE; +/** Garbage collection. */ +export const FEATURE_GC = Feature.GC; +/** Memory64. */ +export const FEATURE_MEMORY64 = Feature.MEMORY64; /** Enables a specific feature. */ export function enableFeature(options: Options, feature: Feature): void { diff --git a/src/module.ts b/src/module.ts index a26d4b84d3..a265f28b20 100644 --- a/src/module.ts +++ b/src/module.ts @@ -39,8 +39,8 @@ export namespace NativeType { export const V128: NativeType = 6 /* _BinaryenTypeVec128 */; export const Funcref: NativeType = 7 /* _BinaryenTypeFuncref */; export const Externref: NativeType = 8 /* _BinaryenTypeExternref */; - export const Nullref: NativeType = 9 /* _BinaryenTypeNullref */; - export const Exnref: NativeType = 10 /* _BinaryenTypeExnref */; + export const Exnref: NativeType = 9 /* _BinaryenTypeExnref */; + export const Anyref: NativeType = 10 /* _BinaryenTypeAnyref */; export const Auto: NativeType = -1 /* _BinaryenTypeAuto */; } @@ -56,7 +56,9 @@ export enum FeatureFlags { TailCall = 128 /* _BinaryenFeatureTailCall */, ReferenceTypes = 256 /* _BinaryenFeatureReferenceTypes */, MultiValue = 512 /* _BinaryenFeatureMultivalue */, - All = 1023 /* _BinaryenFeatureAll */ + GC = 1024 /* _BinaryenFeatureGC */, + Memory64 = 2048, // TODO: missing in Binaryen API + All = 4095 /* _BinaryenFeatureAll */ } export enum ExpressionId { @@ -80,34 +82,35 @@ export enum ExpressionId { Select = 17 /* _BinaryenSelectId */, Drop = 18 /* _BinaryenDropId */, Return = 19 /* _BinaryenReturnId */, - Host = 20 /* _BinaryenHostId */, - Nop = 21 /* _BinaryenNopId */, - Unreachable = 22 /* _BinaryenUnreachableId */, - AtomicCmpxchg = 24 /* _BinaryenAtomicCmpxchgId */, - AtomicRMW = 23 /* _BinaryenAtomicRMWId */, - AtomicWait = 25 /* _BinaryenAtomicWaitId */, - AtomicNotify = 26 /* _BinaryenAtomicNotifyId */, - AtomicFence = 27 /* _BinaryenAtomicFenceId */, - SIMDExtract = 28 /* _BinaryenSIMDExtractId */, - SIMDReplace = 29 /* _BinaryenSIMDReplaceId */, - SIMDShuffle = 30 /* _BinaryenSIMDShuffleId */, - SIMDTernary = 31 /* _BinaryenSIMDTernaryId */, - SIMDShift = 32 /* _BinaryenSIMDShiftId */, - SIMDLoad = 33 /* _BinaryenSIMDLoadId */, - MemoryInit = 34 /* _BinaryenMemoryInitId */, - DataDrop = 35 /* _BinaryenDataDropId */, - MemoryCopy = 36 /* _BinaryenMemoryCopyId */, - MemoryFill = 37 /* _BinaryenMemoryFillId */, - Pop = 38 /* _BinaryenPopId */, - RefNull = 39 /* _BinaryenRefNullId */, - RefIsNull = 40 /* _BinaryenRefIsNullId */, - RefFunc = 41 /* _BinaryenRefFuncId */, - Try = 42 /* _BinaryenTryId */, - Throw = 43 /* _BinaryenThrowId */, - Rethrow = 44 /* _BinaryenRethrowId */, - BrOnExn = 45 /* _BinaryenBrOnExnId */, - TupleMake = 46 /* _BinaryenTupleMakeId */, - TupleExtract = 47 /* _BinaryenTupleExtractId */ + MemorySize = 20 /* _BinaryenMemorySizeId */, + MemoryGrow = 21 /* _BinaryenMemoryGrowId */, + Nop = 22 /* _BinaryenNopId */, + Unreachable = 23 /* _BinaryenUnreachableId */, + AtomicCmpxchg = 25 /* _BinaryenAtomicCmpxchgId */, + AtomicRMW = 24 /* _BinaryenAtomicRMWId */, + AtomicWait = 26 /* _BinaryenAtomicWaitId */, + AtomicNotify = 27 /* _BinaryenAtomicNotifyId */, + AtomicFence = 28 /* _BinaryenAtomicFenceId */, + SIMDExtract = 29 /* _BinaryenSIMDExtractId */, + SIMDReplace = 30 /* _BinaryenSIMDReplaceId */, + SIMDShuffle = 31 /* _BinaryenSIMDShuffleId */, + SIMDTernary = 32 /* _BinaryenSIMDTernaryId */, + SIMDShift = 33 /* _BinaryenSIMDShiftId */, + SIMDLoad = 34 /* _BinaryenSIMDLoadId */, + MemoryInit = 35 /* _BinaryenMemoryInitId */, + DataDrop = 36 /* _BinaryenDataDropId */, + MemoryCopy = 37 /* _BinaryenMemoryCopyId */, + MemoryFill = 38 /* _BinaryenMemoryFillId */, + Pop = 39 /* _BinaryenPopId */, + RefNull = 40 /* _BinaryenRefNullId */, + RefIsNull = 41 /* _BinaryenRefIsNullId */, + RefFunc = 42 /* _BinaryenRefFuncId */, + Try = 43 /* _BinaryenTryId */, + Throw = 44 /* _BinaryenThrowId */, + Rethrow = 45 /* _BinaryenRethrowId */, + BrOnExn = 46 /* _BinaryenBrOnExnId */, + TupleMake = 47 /* _BinaryenTupleMakeId */, + TupleExtract = 48 /* _BinaryenTupleExtractId */ } export enum UnaryOp { @@ -417,11 +420,6 @@ export enum BinaryOp { SwizzleV8x16 = 177 /* _BinaryenSwizzleVec8x16 */ } -export enum HostOp { - MemorySize = 0 /* _BinaryenMemorySize */, - MemoryGrow = 1 /* _BinaryenMemoryGrow */, -} - export enum AtomicRMWOp { Add = 0 /* _BinaryenAtomicRMWAdd */, Sub = 1 /* _BinaryenAtomicRMWSub */, @@ -559,8 +557,8 @@ export class Module { return binaryen._BinaryenConst(this.ref, out); } - ref_null(): ExpressionRef { - return binaryen._BinaryenRefNull(this.ref); + ref_null(type: NativeType): ExpressionRef { + return binaryen._BinaryenRefNull(this.ref, type); } // expressions @@ -580,18 +578,12 @@ export class Module { return binaryen._BinaryenBinary(this.ref, op, left, right); } - host( - op: HostOp, - name: string | null = null, - operands: ExpressionRef[] | null = null - ): ExpressionRef { - var cStr = this.allocStringCached(name); - var cArr = allocPtrArray(operands); - var ret = binaryen._BinaryenHost( - this.ref, op, cStr, cArr, operands ? (operands).length : 0 - ); - binaryen._free(cArr); - return ret; + memory_size(): ExpressionRef { + return binaryen._BinaryenMemorySize(this.ref); + } + + memory_grow(delta: ExpressionRef): ExpressionRef { + return binaryen._BinaryenMemoryGrow(this.ref, delta); } local_get( @@ -2090,20 +2082,8 @@ export function getCallOperandAt(expr: ExpressionRef, index: Index): ExpressionR return binaryen._BinaryenCallGetOperandAt(expr, index); } -export function getHostOp(expr: ExpressionRef): ExpressionRef { - return binaryen._BinaryenHostGetOp(expr); -} - -export function getHostOperandCount(expr: ExpressionRef): Index { - return binaryen._BinaryenHostGetNumOperands(expr); -} - -export function getHostOperandAt(expr: ExpressionRef, index: Index): ExpressionRef { - return binaryen._BinaryenHostGetOperandAt(expr, index); -} - -export function getHostName(expr: ExpressionRef): string | null { - return readString(binaryen._BinaryenHostGetNameOperand(expr)); +export function getMemoryGrowDelta(expr: ExpressionRef): ExpressionRef { + return binaryen._BinaryenMemoryGrowGetDelta(expr); } // functions @@ -2610,12 +2590,11 @@ export function traverse( visit(binaryen._BinaryenReturnGetValue(expr), data); break; } - case ExpressionId.Host: { - for (let i: Index = 0, n = binaryen._BinaryenHostGetNumOperands(expr); i < n; ++i) { - visit(binaryen._BinaryenHostGetOperandAt(expr, i), data); - } + case ExpressionId.MemorySize: + break; + case ExpressionId.MemoryGrow: + visit(binaryen._BinaryenMemoryGrowGetDelta(expr), data); break; - } case ExpressionId.Nop: { break; } diff --git a/src/program.ts b/src/program.ts index 05a020452c..c497a82243 100644 --- a/src/program.ts +++ b/src/program.ts @@ -901,7 +901,10 @@ export class Program extends DiagnosticEmitter { // compiler needs to check this condition whenever such a value is created // respectively stored or loaded. this.registerNativeType(CommonNames.v128, Type.v128); + this.registerNativeType(CommonNames.funcref, Type.funcref); this.registerNativeType(CommonNames.externref, Type.externref); + this.registerNativeType(CommonNames.exnref, Type.exnref); + this.registerNativeType(CommonNames.anyref, Type.anyref); // register compiler hints this.registerConstantInteger(CommonNames.ASC_TARGET, Type.i32, @@ -940,6 +943,10 @@ export class Program extends DiagnosticEmitter { i64_new(options.hasFeature(Feature.REFERENCE_TYPES) ? 1 : 0, 0)); this.registerConstantInteger(CommonNames.ASC_FEATURE_MULTI_VALUE, Type.bool, i64_new(options.hasFeature(Feature.MULTI_VALUE) ? 1 : 0, 0)); + this.registerConstantInteger(CommonNames.ASC_FEATURE_GC, Type.bool, + i64_new(options.hasFeature(Feature.GC) ? 1 : 0, 0)); + this.registerConstantInteger(CommonNames.ASC_FEATURE_MEMORY64, Type.bool, + i64_new(options.hasFeature(Feature.MEMORY64) ? 1 : 0, 0)); // remember deferred elements var queuedImports = new Array(); @@ -1151,7 +1158,16 @@ export class Program extends DiagnosticEmitter { this.registerWrapperClass(Type.f32, CommonNames.F32); this.registerWrapperClass(Type.f64, CommonNames.F64); if (options.hasFeature(Feature.SIMD)) this.registerWrapperClass(Type.v128, CommonNames.V128); - if (options.hasFeature(Feature.REFERENCE_TYPES)) this.registerWrapperClass(Type.externref, CommonNames.Externref); + if (options.hasFeature(Feature.REFERENCE_TYPES)) { + this.registerWrapperClass(Type.funcref, CommonNames.Funcref); + this.registerWrapperClass(Type.externref, CommonNames.Externref); + if (options.hasFeature(Feature.EXCEPTION_HANDLING)) { + this.registerWrapperClass(Type.exnref, CommonNames.Exnref); + } + if (options.hasFeature(Feature.GC)) { + this.registerWrapperClass(Type.anyref, CommonNames.Anyref); + } + } // resolve prototypes of extended classes or interfaces var resolver = this.resolver; @@ -3601,8 +3617,10 @@ export class Function extends TypedElement { tempF32s: Local[] | null = null; tempF64s: Local[] | null = null; tempV128s: Local[] | null = null; + tempFuncrefs: Local[] | null = null; tempExternrefs: Local[] | null = null; tempExnrefs: Local[] | null = null; + tempAnyrefs: Local[] | null = null; // used by flows to keep track of break labels nextBreakId: i32 = 0; diff --git a/src/resolver.ts b/src/resolver.ts index 2fcbe9e270..c3ffdf6695 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -1195,7 +1195,7 @@ export class Resolver extends DiagnosticEmitter { if (signatureReference) { return signatureReference.type.asNullable(); } else if (ctxType.isExternalReference) { - return Type.externref.asNullable(); + return ctxType; // TODO: nullable? } } return this.program.options.usizeType; diff --git a/src/types.ts b/src/types.ts index 671daec53a..d757e8bbff 100644 --- a/src/types.ts +++ b/src/types.ts @@ -59,8 +59,14 @@ export const enum TypeKind { // references - /** Any host reference. */ + /** Function reference. */ + FUNCREF, + /** External reference. */ EXTERNREF, + /** Exception reference. */ + EXNREF, + /** Any reference. */ + ANYREF, // other @@ -319,6 +325,9 @@ export class Type { /** Gets the corresponding non-nullable type. */ get nonNullableType(): Type { + if (this.isExternalReference) { + return this; // TODO + } return assert(this._nonNullableType); // set either in ctor or asNullable } @@ -387,7 +396,7 @@ export class Type { if (targetFunction = target.getSignature()) { return currentFunction.isAssignableTo(targetFunction); } - } else if (this.kind == TypeKind.EXTERNREF && target.kind == TypeKind.EXTERNREF) { + } else if (this.isExternalReference && (this.kind == target.kind || target.kind == TypeKind.ANYREF)) { return true; } } @@ -462,16 +471,14 @@ export class Type { return this.isNullableReference ? classReference.internalName + nullablePostfix : classReference.internalName; + } else { + let signatureReference = this.getSignature(); + if (signatureReference) { + return this.isNullableReference + ? "(" + signatureReference.toString(validWat) + ")" + nullablePostfix + : signatureReference.toString(validWat); + } } - let signatureReference = this.getSignature(); - if (signatureReference) { - return this.isNullableReference - ? "(" + signatureReference.toString(validWat) + ")" + nullablePostfix - : signatureReference.toString(validWat); - } - // TODO: Reflect.apply(value, "toString", []) ? - assert(this.kind == TypeKind.EXTERNREF); - return "externref"; } switch (this.kind) { case TypeKind.I8: return "i8"; @@ -488,7 +495,10 @@ export class Type { case TypeKind.F32: return "f32"; case TypeKind.F64: return "f64"; case TypeKind.V128: return "v128"; + case TypeKind.FUNCREF: return "funcref"; case TypeKind.EXTERNREF: return "externref"; + case TypeKind.EXNREF: return "exnref"; + case TypeKind.ANYREF: return "anyref"; default: assert(false); case TypeKind.VOID: return "void"; } @@ -514,7 +524,10 @@ export class Type { case TypeKind.F32: return NativeType.F32; case TypeKind.F64: return NativeType.F64; case TypeKind.V128: return NativeType.V128; + case TypeKind.FUNCREF: return NativeType.Funcref; case TypeKind.EXTERNREF: return NativeType.Externref; + case TypeKind.EXNREF: return NativeType.Exnref; + case TypeKind.ANYREF: return NativeType.Anyref; case TypeKind.VOID: return NativeType.None; } } @@ -646,9 +659,31 @@ export class Type { TypeFlags.VALUE, 128 ); - /** Any host reference. */ + /** Function reference. */ + static readonly funcref: Type = new Type(TypeKind.FUNCREF, + TypeFlags.EXTERNAL | + TypeFlags.NULLABLE | + TypeFlags.REFERENCE, 0 + ); + + /** External reference. */ static readonly externref: Type = new Type(TypeKind.EXTERNREF, TypeFlags.EXTERNAL | + TypeFlags.NULLABLE | + TypeFlags.REFERENCE, 0 + ); + + /** Exception reference. */ + static readonly exnref: Type = new Type(TypeKind.EXNREF, + TypeFlags.EXTERNAL | + TypeFlags.NULLABLE | + TypeFlags.REFERENCE, 0 + ); + + /** Any reference. */ + static readonly anyref: Type = new Type(TypeKind.ANYREF, + TypeFlags.EXTERNAL | + TypeFlags.NULLABLE | TypeFlags.REFERENCE, 0 ); diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index b022371b24..f281cfb769 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -35,8 +35,14 @@ declare type f32 = number; declare type f64 = number; /** A 128-bit vector. */ declare type v128 = object; -/** A host reference. */ -declare type externref = object; +/** Function reference. */ +declare type funcref = object | null; +/** External reference. */ +declare type externref = object | null; +/** Exception reference. */ +declare type exnref = object | null; +/** Any reference. */ +declare type anyref = object | null; // Compiler hints @@ -74,6 +80,10 @@ declare const ASC_FEATURE_TAIL_CALLS: bool; declare const ASC_FEATURE_REFERENCE_TYPES: bool; /** Whether the multi value types feature is enabled. */ declare const ASC_FEATURE_MULTI_VALUE: bool; +/** Whether the garbage collection feature is enabled. */ +declare const ASC_FEATURE_GC: bool; +/** Whether the memory64 feature is enabled. */ +declare const ASC_FEATURE_MEMORY64: bool; // Builtins diff --git a/std/assembly/reference.ts b/std/assembly/reference.ts index b45db14403..314ed5da09 100644 --- a/std/assembly/reference.ts +++ b/std/assembly/reference.ts @@ -1,4 +1,19 @@ -/** Host reference abstraction. */ +@unmanaged +abstract class Ref { +} + +@final @unmanaged +export abstract class Funcref extends Ref { +} + +@final @unmanaged +export abstract class Externref extends Ref { +} + +@final @unmanaged +export abstract class Exnref extends Ref { +} + @final @unmanaged -export abstract class Externref { +export abstract class Anyref extends Ref { } diff --git a/std/assembly/shared/feature.ts b/std/assembly/shared/feature.ts index 0e5dcc919a..0b36c644eb 100644 --- a/std/assembly/shared/feature.ts +++ b/std/assembly/shared/feature.ts @@ -23,7 +23,11 @@ export const enum Feature { /** Reference types. */ REFERENCE_TYPES = 1 << 8, // see: https://github.com/WebAssembly/reference-types /** Multi value types. */ - MULTI_VALUE = 1 << 9 // see: https://github.com/WebAssembly/multi-value + MULTI_VALUE = 1 << 9, // see: https://github.com/WebAssembly/multi-value + /** Garbage collection. */ + GC = 1 << 10, // see: https://github.com/WebAssembly/gc + /** Memory64. */ + MEMORY64 = 1 << 11 // see: https://github.com/WebAssembly/memory64 } /** Gets the name of the specified feature one would specify on the command line. */ @@ -39,6 +43,8 @@ export function featureToString(feature: Feature): string { case Feature.TAIL_CALLS: return "tail-calls"; case Feature.REFERENCE_TYPES: return "reference-types"; case Feature.MULTI_VALUE: return "multi-value"; + case Feature.GC: return "gc"; + case Feature.MEMORY64: return "memory64"; } assert(false); return ""; diff --git a/tests/compiler/asc-constants.ts b/tests/compiler/asc-constants.ts index c8b2b59eba..3b007986a3 100644 --- a/tests/compiler/asc-constants.ts +++ b/tests/compiler/asc-constants.ts @@ -14,3 +14,5 @@ ASC_FEATURE_EXCEPTION_HANDLING; ASC_FEATURE_TAIL_CALLS; ASC_FEATURE_REFERENCE_TYPES; ASC_FEATURE_MULTI_VALUE; +ASC_FEATURE_GC; +ASC_FEATURE_MEMORY64; diff --git a/tests/compiler/asc-constants.untouched.wat b/tests/compiler/asc-constants.untouched.wat index 0f74c055b8..e32d4d899e 100644 --- a/tests/compiler/asc-constants.untouched.wat +++ b/tests/compiler/asc-constants.untouched.wat @@ -17,6 +17,8 @@ (global $~lib/ASC_FEATURE_TAIL_CALLS i32 (i32.const 0)) (global $~lib/ASC_FEATURE_REFERENCE_TYPES i32 (i32.const 0)) (global $~lib/ASC_FEATURE_MULTI_VALUE i32 (i32.const 0)) + (global $~lib/ASC_FEATURE_GC i32 (i32.const 0)) + (global $~lib/ASC_FEATURE_MEMORY64 i32 (i32.const 0)) (export "memory" (memory $0)) (start $~start) (func $start:asc-constants @@ -50,6 +52,10 @@ drop i32.const 0 drop + i32.const 0 + drop + i32.const 0 + drop ) (func $~start call $start:asc-constants diff --git a/tests/compiler/features/reference-types.json b/tests/compiler/features/reference-types.json index 6492822f55..e63bf2973f 100644 --- a/tests/compiler/features/reference-types.json +++ b/tests/compiler/features/reference-types.json @@ -1,6 +1,8 @@ { "features": [ - "reference-types" + "reference-types", + "exception-handling", + "gc" ], "asc_flags": [ "--runtime none" diff --git a/tests/compiler/features/reference-types.optimized.wat b/tests/compiler/features/reference-types.optimized.wat index 8f9e7c11e3..420fa1e440 100644 --- a/tests/compiler/features/reference-types.optimized.wat +++ b/tests/compiler/features/reference-types.optimized.wat @@ -14,6 +14,7 @@ (import "reference-types" "external" (func $features/reference-types/external (param externref) (result externref))) (memory $0 1) (data (i32.const 1024) "6\00\00\00\01\00\00\00\01\00\00\006\00\00\00f\00e\00a\00t\00u\00r\00e\00s\00/\00r\00e\00f\00e\00r\00e\00n\00c\00e\00-\00t\00y\00p\00e\00s\00.\00t\00s") + (global $features/reference-types/funcGlobal (mut funcref) (ref.null func)) (export "memory" (memory $0)) (export "external" (func $features/reference-types/external)) (export "internal" (func $features/reference-types/internal)) @@ -45,4 +46,23 @@ global.get $features/reference-types/someKey call $~lib/bindings/Reflect/get call $~lib/bindings/console/log + global.get $features/reference-types/funcGlobal + ref.is_null + if + i32.const 0 + i32.const 1040 + i32.const 32 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null func + global.set $features/reference-types/funcGlobal + i32.const 0 + i32.const 1040 + i32.const 34 + i32.const 1 + call $~lib/builtins/abort + unreachable + ) ) diff --git a/tests/compiler/features/reference-types.ts b/tests/compiler/features/reference-types.ts index fa2fa17d89..9077879553 100644 --- a/tests/compiler/features/reference-types.ts +++ b/tests/compiler/features/reference-types.ts @@ -26,27 +26,66 @@ console.log(someObject); console.log(someKey); console.log(Reflect.get(someObject, someKey)); -// TODO: can represent and recognize 'null' for both externref and funcref -/* var nullGlobal: externref; -assert(!nullGlobal); -nullGlobal = null; -assert(!nullGlobal); -var nullGlobalInit: externref = null; -assert(!nullGlobalInit); -{ - let nullLocal: externref; - assert(!nullLocal); - nullLocal = null; - assert(!nullLocal); - let nullLocalInit: externref = null; - assert(!nullLocalInit); +// can represent and recognize 'null' + +var funcGlobal: funcref; +assert(!funcGlobal); +funcGlobal = null; +assert(!funcGlobal); +var funcGlobalInit: funcref = null; +assert(!funcGlobalInit); + +var externGlobal: externref; +assert(!externGlobal); +externGlobal = null; +assert(!externGlobal); +var externGlobalInit: externref = null; +assert(!externGlobalInit); + +var exnGlobal: exnref; +assert(!exnGlobal); +exnGlobal = null; +assert(!exnGlobal); +var exnGlobalInit: exnref = null; +assert(!exnGlobalInit); + +var anyGlobal: anyref; +assert(!anyGlobal); +anyGlobal = null; +assert(!anyGlobal); +var anyGlobalInit: anyref = null; +assert(!anyGlobalInit); + +function testLocal(): void { + let local: T; + assert(!local); + local = null; + assert(!local); + let localInit: T = null; + assert(!localInit); } +testLocal(); +testLocal(); +testLocal(); +testLocal(); // funcref can represent function references function someFunc(): void {} -var funcGlobal: externref = someFunc; +funcGlobal = someFunc; +assert(funcGlobalInit); +var otherFuncGlobal: funcref = someFunc; +assert(otherFuncGlobal); { - let funcLocal: externref = someFunc; + let funcLocal: funcref = someFunc; + assert(funcLocal); } -*/ \ No newline at end of file + +// can assign any reference type to anyref + +anyGlobal = funcGlobal; +anyGlobal = externGlobal; +anyGlobal = exnGlobal; + +// TODO: Not implemented: ref.cast +// exnGlobal = anyGlobal; diff --git a/tests/compiler/features/reference-types.untouched.wat b/tests/compiler/features/reference-types.untouched.wat index 0f9a373a7c..7aa89eed8b 100644 --- a/tests/compiler/features/reference-types.untouched.wat +++ b/tests/compiler/features/reference-types.untouched.wat @@ -15,11 +15,200 @@ (memory $0 1) (data (i32.const 16) "6\00\00\00\01\00\00\00\01\00\00\006\00\00\00f\00e\00a\00t\00u\00r\00e\00s\00/\00r\00e\00f\00e\00r\00e\00n\00c\00e\00-\00t\00y\00p\00e\00s\00.\00t\00s\00") (table $0 1 funcref) + (global $features/reference-types/funcGlobal (mut funcref) (ref.null func)) + (global $features/reference-types/funcGlobalInit (mut funcref) (ref.null func)) + (global $features/reference-types/externGlobal (mut externref) (ref.null extern)) + (global $features/reference-types/externGlobalInit (mut externref) (ref.null extern)) + (global $features/reference-types/exnGlobal (mut exnref) (ref.null exn)) + (global $features/reference-types/exnGlobalInit (mut exnref) (ref.null exn)) + (global $features/reference-types/anyGlobal (mut anyref) (ref.null any)) + (global $features/reference-types/anyGlobalInit (mut anyref) (ref.null any)) + (global $features/reference-types/otherFuncGlobal (mut funcref) (ref.null func)) (export "memory" (memory $0)) (export "external" (func $features/reference-types/external)) (export "internal" (func $features/reference-types/internal)) (start $~start) + (func $features/reference-types/testLocal + (local $0 funcref) + (local $1 funcref) + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 61 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null func + local.set $0 + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 63 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null func + local.set $1 + local.get $1 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 65 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ) + (func $features/reference-types/testLocal + (local $0 externref) + (local $1 externref) + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 61 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null extern + local.set $0 + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 63 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null extern + local.set $1 + local.get $1 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 65 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ) + (func $features/reference-types/testLocal + (local $0 exnref) + (local $1 exnref) + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 61 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null exn + local.set $0 + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 63 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null exn + local.set $1 + local.get $1 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 65 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ) + (func $features/reference-types/testLocal + (local $0 anyref) + (local $1 anyref) + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 61 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null any + local.set $0 + local.get $0 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 63 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ref.null any + local.set $1 + local.get $1 + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 65 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + ) + (func $features/reference-types/someFunc + nop + ) (func $start:features/reference-types + (local $0 funcref) global.get $features/reference-types/someObject global.get $features/reference-types/someKey call $~lib/bindings/Reflect/has @@ -42,6 +231,212 @@ global.get $features/reference-types/someKey call $~lib/bindings/Reflect/get call $~lib/bindings/console/log + global.get $features/reference-types/funcGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 32 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null func + global.set $features/reference-types/funcGlobal + global.get $features/reference-types/funcGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 34 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null func + global.set $features/reference-types/funcGlobalInit + global.get $features/reference-types/funcGlobalInit + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 36 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $features/reference-types/externGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 39 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null extern + global.set $features/reference-types/externGlobal + global.get $features/reference-types/externGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 41 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null extern + global.set $features/reference-types/externGlobalInit + global.get $features/reference-types/externGlobalInit + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 43 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $features/reference-types/exnGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 46 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null exn + global.set $features/reference-types/exnGlobal + global.get $features/reference-types/exnGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 48 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null exn + global.set $features/reference-types/exnGlobalInit + global.get $features/reference-types/exnGlobalInit + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 50 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $features/reference-types/anyGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 53 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null any + global.set $features/reference-types/anyGlobal + global.get $features/reference-types/anyGlobal + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 55 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.null any + global.set $features/reference-types/anyGlobalInit + global.get $features/reference-types/anyGlobalInit + ref.is_null + i32.eqz + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 57 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + call $features/reference-types/testLocal + call $features/reference-types/testLocal + call $features/reference-types/testLocal + call $features/reference-types/testLocal + ref.func $features/reference-types/someFunc + global.set $features/reference-types/funcGlobal + global.get $features/reference-types/funcGlobalInit + ref.is_null + if + i32.const 0 + i32.const 32 + i32.const 76 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.func $features/reference-types/someFunc + global.set $features/reference-types/otherFuncGlobal + global.get $features/reference-types/otherFuncGlobal + ref.is_null + if + i32.const 0 + i32.const 32 + i32.const 78 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ref.func $features/reference-types/someFunc + local.set $0 + local.get $0 + ref.is_null + if + i32.const 0 + i32.const 32 + i32.const 81 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + global.get $features/reference-types/funcGlobal + global.set $features/reference-types/anyGlobal + global.get $features/reference-types/externGlobal + global.set $features/reference-types/anyGlobal + global.get $features/reference-types/exnGlobal + global.set $features/reference-types/anyGlobal ) (func $features/reference-types/internal (param $0 externref) (result externref) (local $1 externref) diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index 91bd1ef485..6d8c3d16e2 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -1346,8 +1346,8 @@ ) (func $~lib/number/F32.isSafeInteger (param $0 f32) (result i32) local.get $0 - f32.trunc local.get $0 + f32.trunc f32.eq i32.const 0 local.get $0 @@ -1358,8 +1358,8 @@ ) (func $~lib/number/F32.isInteger (param $0 f32) (result i32) local.get $0 - f32.trunc local.get $0 + f32.trunc f32.eq i32.const 0 local.get $0 @@ -1371,8 +1371,8 @@ ) (func $~lib/number/F64.isSafeInteger (param $0 f64) (result i32) local.get $0 - f64.trunc local.get $0 + f64.trunc f64.eq i32.const 0 local.get $0 @@ -1383,8 +1383,8 @@ ) (func $~lib/number/F64.isInteger (param $0 f64) (result i32) local.get $0 - f64.trunc local.get $0 + f64.trunc f64.eq i32.const 0 local.get $0 diff --git a/tests/compiler/resolve-elementaccess.optimized.wat b/tests/compiler/resolve-elementaccess.optimized.wat index 7b40aaa0fe..b36e1a3f7a 100644 --- a/tests/compiler/resolve-elementaccess.optimized.wat +++ b/tests/compiler/resolve-elementaccess.optimized.wat @@ -1360,9 +1360,9 @@ local.tee $1 i32.trunc_f64_s local.tee $4 + local.get $1 local.get $4 f64.convert_i32_s - local.get $1 f64.ne i32.add i32.const 3 diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index afe414b4f6..feee7718d4 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -8403,9 +8403,9 @@ local.tee $1 i32.trunc_f64_s local.tee $4 + local.get $1 local.get $4 f64.convert_i32_s - local.get $1 f64.ne i32.add i32.const 3 @@ -15537,10 +15537,7 @@ i32.const 6080 i32.const 0 call $~lib/array/Array#reduce - i32.const 0 - i32.ne - i32.const 1 - i32.ne + i32.eqz if i32.const 0 i32.const 1296 @@ -15689,10 +15686,7 @@ i32.const 6304 i32.const 0 call $~lib/array/Array#reduceRight - i32.const 0 - i32.ne - i32.const 1 - i32.ne + i32.eqz if i32.const 0 i32.const 1296 diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index ca6ae81d81..117298a2c0 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -10527,9 +10527,9 @@ if (result i32) i32.const 0 else + local.get $1 local.get $0 f32.load - local.get $1 f32.eq end if @@ -11759,9 +11759,9 @@ if (result i32) i32.const 0 else + local.get $1 local.get $0 f64.load - local.get $1 f64.eq end if @@ -12353,9 +12353,9 @@ if (result i32) i32.const 0 else + local.get $1 local.get $3 f64.load - local.get $1 f64.eq end br_if $__inlined_func$~lib/map/Map#find diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index c28d5fba12..e482acfa7c 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -517,44 +517,44 @@ ) (func $~lib/math/R (param $0 f64) (result f64) local.get $0 - f64.const 0.16666666666666666 local.get $0 - f64.const -0.3255658186224009 local.get $0 - f64.const 0.20121253213486293 local.get $0 - f64.const -0.04005553450067941 local.get $0 - f64.const 7.915349942898145e-04 local.get $0 f64.const 3.479331075960212e-05 f64.mul + f64.const 7.915349942898145e-04 f64.add f64.mul + f64.const -0.04005553450067941 f64.add f64.mul + f64.const 0.20121253213486293 f64.add f64.mul + f64.const -0.3255658186224009 f64.add f64.mul + f64.const 0.16666666666666666 f64.add f64.mul - f64.const 1 local.get $0 - f64.const -2.403394911734414 local.get $0 - f64.const 2.0209457602335057 local.get $0 - f64.const -0.6882839716054533 local.get $0 f64.const 0.07703815055590194 f64.mul + f64.const -0.6882839716054533 f64.add f64.mul + f64.const 2.0209457602335057 f64.add f64.mul + f64.const -2.403394911734414 f64.add f64.mul + f64.const 1 f64.add f64.div ) @@ -630,12 +630,11 @@ i32.const 31 i32.shr_u if - f64.const 2 f64.const 1.5707963267948966 - f64.const 0.5 local.get $0 f64.const 0.5 f64.mul + f64.const 0.5 f64.add local.tee $0 f64.sqrt @@ -648,10 +647,10 @@ f64.sub f64.add f64.sub + f64.const 2 f64.mul return end - f64.const 2 f64.const 0.5 local.get $0 f64.const 0.5 @@ -680,6 +679,7 @@ f64.div f64.add f64.add + f64.const 2 f64.mul ) (func $std/math/test_acos (param $0 f64) (param $1 f64) (param $2 f64) (result i32) @@ -700,20 +700,20 @@ ) (func $~lib/math/Rf (param $0 f32) (result f32) local.get $0 - f32.const 0.16666586697101593 local.get $0 - f32.const -0.04274342209100723 local.get $0 f32.const -0.008656363002955914 f32.mul + f32.const -0.04274342209100723 f32.add f32.mul + f32.const 0.16666586697101593 f32.add f32.mul - f32.const 1 local.get $0 f32.const -0.7066296339035034 f32.mul + f32.const 1 f32.add f32.div ) @@ -781,12 +781,11 @@ i32.const 31 i32.shr_u if - f32.const 2 f32.const 1.570796251296997 - f32.const 0.5 local.get $0 f32.const 0.5 f32.mul + f32.const 0.5 f32.add local.tee $0 f32.sqrt @@ -799,10 +798,10 @@ f32.sub f32.add f32.sub + f32.const 2 f32.mul return end - f32.const 2 f32.const 0.5 local.get $0 f32.const 0.5 @@ -831,6 +830,7 @@ f32.div f32.add f32.add + f32.const 2 f32.mul ) (func $std/math/test_acosf (param $0 f32) (param $1 f32) (param $2 f32) (result i32) @@ -915,8 +915,8 @@ end local.get $3 if - f64.const 1 local.get $0 + f64.const 1 f64.add i64.reinterpret_f64 local.tee $5 @@ -974,8 +974,8 @@ local.set $1 end local.get $1 - f64.const 2 local.get $1 + f64.const 2 f64.add f64.div local.tee $4 @@ -986,36 +986,36 @@ f64.mul local.set $0 local.get $4 - f64.const 0.5 local.get $1 + f64.const 0.5 f64.mul local.get $1 f64.mul local.tee $4 local.get $7 - f64.const 0.6666666666666735 local.get $0 - f64.const 0.2857142874366239 local.get $0 - f64.const 0.1818357216161805 local.get $0 f64.const 0.14798198605116586 f64.mul + f64.const 0.1818357216161805 f64.add f64.mul + f64.const 0.2857142874366239 f64.add f64.mul + f64.const 0.6666666666666735 f64.add f64.mul local.get $0 - f64.const 0.3999999999940942 local.get $0 - f64.const 0.22222198432149784 local.get $0 f64.const 0.15313837699209373 f64.mul + f64.const 0.22222198432149784 f64.add f64.mul + f64.const 0.3999999999940942 f64.add f64.mul f64.add @@ -1135,8 +1135,8 @@ f64.const 1 f64.sub local.tee $3 - f64.const 2 local.get $3 + f64.const 2 f64.add f64.div local.tee $4 @@ -1144,39 +1144,39 @@ f64.mul local.set $0 local.get $4 - f64.const 0.5 local.get $3 + f64.const 0.5 f64.mul local.get $3 f64.mul local.tee $4 local.get $0 - f64.const 0.6666666666666735 local.get $0 local.get $0 f64.mul local.tee $0 - f64.const 0.2857142874366239 local.get $0 - f64.const 0.1818357216161805 local.get $0 f64.const 0.14798198605116586 f64.mul + f64.const 0.1818357216161805 f64.add f64.mul + f64.const 0.2857142874366239 f64.add f64.mul + f64.const 0.6666666666666735 f64.add f64.mul local.get $0 - f64.const 0.3999999999940942 local.get $0 - f64.const 0.22222198432149784 local.get $0 f64.const 0.15313837699209373 f64.mul + f64.const 0.22222198432149784 f64.add f64.mul + f64.const 0.3999999999940942 f64.add f64.mul f64.add @@ -1224,8 +1224,8 @@ local.get $3 local.get $3 f64.mul - f64.const 2 local.get $3 + f64.const 2 f64.mul f64.add f64.sqrt @@ -1237,8 +1237,8 @@ i64.const 1049 i64.lt_u if - f64.const 2 local.get $0 + f64.const 2 f64.mul f64.const 1 local.get $0 @@ -1343,8 +1343,8 @@ end local.get $3 if - f32.const 1 local.get $0 + f32.const 1 f32.add local.tee $1 i32.reinterpret_f32 @@ -1390,8 +1390,8 @@ local.set $1 end local.get $1 - f32.const 2 local.get $1 + f32.const 2 f32.add f32.div local.tee $4 @@ -1402,24 +1402,24 @@ f32.mul local.set $0 local.get $4 - f32.const 0.5 local.get $1 + f32.const 0.5 f32.mul local.get $1 f32.mul local.tee $4 local.get $6 - f32.const 0.6666666269302368 local.get $0 f32.const 0.2849878668785095 f32.mul + f32.const 0.6666666269302368 f32.add f32.mul local.get $0 - f32.const 0.40000972151756287 local.get $0 f32.const 0.24279078841209412 f32.mul + f32.const 0.40000972151756287 f32.add f32.mul f32.add @@ -1517,8 +1517,8 @@ f32.const 1 f32.sub local.tee $0 - f32.const 2 local.get $0 + f32.const 2 f32.add f32.div local.tee $3 @@ -1526,27 +1526,27 @@ f32.mul local.set $2 local.get $3 - f32.const 0.5 local.get $0 + f32.const 0.5 f32.mul local.get $0 f32.mul local.tee $3 local.get $2 - f32.const 0.6666666269302368 local.get $2 local.get $2 f32.mul local.tee $2 f32.const 0.2849878668785095 f32.mul + f32.const 0.6666666269302368 f32.add f32.mul local.get $2 - f32.const 0.40000972151756287 local.get $2 f32.const 0.24279078841209412 f32.mul + f32.const 0.40000972151756287 f32.add f32.mul f32.add @@ -1602,8 +1602,8 @@ i32.const 1166016512 i32.lt_u if - f32.const 2 local.get $0 + f32.const 2 f32.mul f32.const 1 local.get $0 @@ -1711,25 +1711,24 @@ i32.ge_u if (result f64) f64.const 1.5707963267948966 - f64.const 2 local.get $0 local.get $0 local.get $3 f64.mul f64.add + f64.const 2 f64.mul f64.const 6.123233995736766e-17 f64.sub f64.sub else f64.const 0.7853981633974483 - f64.const 2 local.get $0 + f64.const 2 f64.mul local.get $3 f64.mul f64.const 6.123233995736766e-17 - f64.const 2 local.get $1 local.get $0 i64.reinterpret_f64 @@ -1744,12 +1743,13 @@ local.get $1 f64.add f64.div + f64.const 2 f64.mul f64.sub f64.sub f64.const 0.7853981633974483 - f64.const 2 local.get $1 + f64.const 2 f64.mul f64.sub f64.sub @@ -1840,7 +1840,6 @@ return end f64.const 1.5707963705062866 - f64.const 2 f32.const 0.5 local.get $1 f32.abs @@ -1857,6 +1856,7 @@ f64.promote_f32 f64.mul f64.add + f64.const 2 f64.mul f64.sub f32.demote_f64 @@ -1899,8 +1899,8 @@ i64.const 1024 i64.ge_u if (result f64) - f64.const 2 local.get $0 + f64.const 2 f64.mul f64.const 1 local.get $0 @@ -1977,8 +1977,8 @@ i32.const 1073741824 i32.ge_u if (result f32) - f32.const 2 local.get $0 + f32.const 2 f32.mul f32.const 1 local.get $0 @@ -2078,13 +2078,13 @@ i32.const 1072037888 i32.lt_u if (result f64) - f64.const 2 local.get $0 + f64.const 2 f64.mul f64.const 1 f64.sub - f64.const 2 local.get $0 + f64.const 2 f64.add f64.div else @@ -2108,10 +2108,10 @@ local.get $0 f64.const 1.5 f64.sub - f64.const 1 - f64.const 1.5 local.get $0 + f64.const 1.5 f64.mul + f64.const 1 f64.add f64.div else @@ -2133,45 +2133,45 @@ local.set $2 local.get $0 local.get $5 - f64.const 0.3333333333333293 local.get $2 - f64.const 0.14285714272503466 local.get $2 - f64.const 0.09090887133436507 local.get $2 - f64.const 0.06661073137387531 local.get $2 - f64.const 0.049768779946159324 local.get $2 f64.const 0.016285820115365782 f64.mul + f64.const 0.049768779946159324 f64.add f64.mul + f64.const 0.06661073137387531 f64.add f64.mul + f64.const 0.09090887133436507 f64.add f64.mul + f64.const 0.14285714272503466 f64.add f64.mul + f64.const 0.3333333333333293 f64.add f64.mul local.get $2 - f64.const -0.19999999999876483 local.get $2 - f64.const -0.11111110405462356 local.get $2 - f64.const -0.0769187620504483 local.get $2 - f64.const -0.058335701337905735 local.get $2 f64.const -0.036531572744216916 f64.mul + f64.const -0.058335701337905735 f64.add f64.mul + f64.const -0.0769187620504483 f64.add f64.mul + f64.const -0.11111110405462356 f64.add f64.mul + f64.const -0.19999999999876483 f64.add f64.mul f64.add @@ -2310,13 +2310,13 @@ i32.const 1060110336 i32.lt_u if (result f32) - f32.const 2 local.get $0 + f32.const 2 f32.mul f32.const 1 f32.sub - f32.const 2 local.get $0 + f32.const 2 f32.add f32.div else @@ -2340,10 +2340,10 @@ local.get $0 f32.const 1.5 f32.sub - f32.const 1 - f32.const 1.5 local.get $0 + f32.const 1.5 f32.mul + f32.const 1 f32.add f32.div else @@ -2365,21 +2365,21 @@ local.set $2 local.get $0 local.get $5 - f32.const 0.333333283662796 local.get $2 - f32.const 0.14253635704517365 local.get $2 f32.const 0.06168760731816292 f32.mul + f32.const 0.14253635704517365 f32.add f32.mul + f32.const 0.333333283662796 f32.add f32.mul local.get $2 - f32.const -0.19999158382415771 local.get $2 f32.const -0.106480173766613 f32.mul + f32.const -0.19999158382415771 f32.add f32.mul f32.add @@ -2478,9 +2478,8 @@ i64.const 991 i64.ge_u if (result f64) - f64.const 0.5 - f64.const 2 local.get $0 + f64.const 2 f64.mul local.tee $5 local.get $5 @@ -2492,20 +2491,21 @@ f64.div f64.add call $~lib/math/NativeMath.log1p + f64.const 0.5 f64.mul else local.get $0 end else - f64.const 0.5 - f64.const 2 local.get $0 f64.const 1 local.get $0 f64.sub f64.div + f64.const 2 f64.mul call $~lib/math/NativeMath.log1p + f64.const 0.5 f64.mul end local.get $3 @@ -2540,33 +2540,33 @@ i32.const 796917760 i32.ge_u if (result f32) - f32.const 0.5 - f32.const 2 local.get $0 + f32.const 2 f32.mul - f32.const 1 local.get $0 f32.const 1 local.get $0 f32.sub f32.div + f32.const 1 f32.add f32.mul call $~lib/math/NativeMathf.log1p + f32.const 0.5 f32.mul else local.get $0 end else - f32.const 0.5 - f32.const 2 local.get $0 f32.const 1 local.get $0 f32.sub f32.div + f32.const 2 f32.mul call $~lib/math/NativeMathf.log1p + f32.const 0.5 f32.mul end local.get $3 @@ -3079,24 +3079,24 @@ local.set $1 local.get $0 local.get $3 - f64.const 1.87595182427177 local.get $1 - f64.const -1.8849797954337717 local.get $1 f64.const 1.6214297201053545 f64.mul + f64.const -1.8849797954337717 f64.add f64.mul + f64.const 1.87595182427177 f64.add local.get $1 local.get $1 f64.mul local.get $1 f64.mul - f64.const -0.758397934778766 local.get $1 f64.const 0.14599619288661245 f64.mul + f64.const -0.758397934778766 f64.add f64.mul f64.add @@ -3117,8 +3117,8 @@ local.get $1 local.get $0 f64.sub - f64.const 2 local.get $0 + f64.const 2 f64.mul local.get $1 f64.add @@ -3495,15 +3495,15 @@ i64.shl i64.add local.tee $3 - f64.const 3.753184150245214e-04 local.get $2 f64.convert_i64_u + f64.const 3.753184150245214e-04 f64.mul - f64.const 3.834951969714103e-04 local.get $5 local.get $4 i64.shl f64.convert_i64_u + f64.const 3.834951969714103e-04 f64.mul f64.add i64.trunc_f64_u @@ -3517,7 +3517,6 @@ i64.add f64.convert_i64_u global.set $~lib/math/rempio2_y0 - f64.const 5.421010862427522e-20 local.get $2 local.get $5 i64.const 53 @@ -3528,6 +3527,7 @@ i64.or i64.add f64.convert_i64_u + f64.const 5.421010862427522e-20 f64.mul global.set $~lib/math/rempio2_y1 global.get $~lib/math/rempio2_y0 @@ -3590,11 +3590,11 @@ return end f64.const 1 - f64.const 0.5 local.get $0 local.get $0 f64.mul local.tee $3 + f64.const 0.5 f64.mul local.tee $4 f64.sub @@ -3606,14 +3606,14 @@ f64.sub local.get $3 local.get $3 - f64.const 0.0416666666666666 local.get $3 - f64.const -0.001388888888887411 local.get $3 f64.const 2.480158728947673e-05 f64.mul + f64.const -0.001388888888887411 f64.add f64.mul + f64.const 0.0416666666666666 f64.add f64.mul local.get $3 @@ -3622,14 +3622,14 @@ local.tee $4 local.get $4 f64.mul - f64.const -2.7557314351390663e-07 local.get $3 - f64.const 2.087572321298175e-09 local.get $3 f64.const -1.1359647557788195e-11 f64.mul + f64.const 2.087572321298175e-09 f64.add f64.mul + f64.const -2.7557314351390663e-07 f64.add f64.mul f64.add @@ -3788,38 +3788,38 @@ local.get $0 f64.mul local.tee $1 - f64.const -0.16666666666666632 local.get $3 - f64.const 0.00833333333332249 local.get $3 - f64.const -1.984126982985795e-04 local.get $3 f64.const 2.7557313707070068e-06 f64.mul + f64.const -1.984126982985795e-04 f64.add f64.mul + f64.const 0.00833333333332249 f64.add local.get $3 local.get $3 local.get $3 f64.mul f64.mul - f64.const -2.5050760253406863e-08 local.get $3 f64.const 1.58969099521155e-10 f64.mul + f64.const -2.5050760253406863e-08 f64.add f64.mul f64.add local.tee $7 f64.mul + f64.const -0.16666666666666632 f64.add f64.mul drop local.get $0 local.get $3 - f64.const 0.5 local.get $4 + f64.const 0.5 f64.mul local.get $1 local.get $7 @@ -3835,11 +3835,11 @@ f64.sub else f64.const 1 - f64.const 0.5 local.get $0 local.get $0 f64.mul local.tee $3 + f64.const 0.5 f64.mul local.tee $1 f64.sub @@ -3851,14 +3851,14 @@ f64.sub local.get $3 local.get $3 - f64.const 0.0416666666666666 local.get $3 - f64.const -0.001388888888887411 local.get $3 f64.const 2.480158728947673e-05 f64.mul + f64.const -0.001388888888887411 f64.add f64.mul + f64.const 0.0416666666666666 f64.add f64.mul local.get $3 @@ -3867,14 +3867,14 @@ local.tee $1 local.get $1 f64.mul - f64.const -2.7557314351390663e-07 local.get $3 - f64.const 2.087572321298175e-09 local.get $3 f64.const -1.1359647557788195e-11 f64.mul + f64.const 2.087572321298175e-09 f64.add f64.mul + f64.const -2.7557314351390663e-07 f64.add f64.mul f64.add @@ -3953,10 +3953,10 @@ local.get $4 f64.mul local.set $3 - f64.const 1 local.get $4 f64.const -0.499999997251031 f64.mul + f64.const 1 f64.add local.get $3 f64.const 0.04166662332373906 @@ -3965,10 +3965,10 @@ local.get $3 local.get $4 f64.mul - f64.const -0.001388676377460993 local.get $4 f64.const 2.439044879627741e-05 f64.mul + f64.const -0.001388676377460993 f64.add f64.mul f64.add @@ -4119,10 +4119,10 @@ local.get $3 f64.mul local.tee $3 - f64.const -0.16666666641626524 local.get $4 f64.const 0.008333329385889463 f64.mul + f64.const -0.16666666641626524 f64.add f64.mul f64.add @@ -4131,10 +4131,10 @@ local.get $4 f64.mul f64.mul - f64.const -1.9839334836096632e-04 local.get $4 f64.const 2.718311493989822e-06 f64.mul + f64.const -1.9839334836096632e-04 f64.add f64.mul f64.add @@ -4147,10 +4147,10 @@ local.get $4 f64.mul local.set $3 - f64.const 1 local.get $4 f64.const -0.499999997251031 f64.mul + f64.const 1 f64.add local.get $3 f64.const 0.04166662332373906 @@ -4159,10 +4159,10 @@ local.get $3 local.get $4 f64.mul - f64.const -0.001388676377460993 local.get $4 f64.const 2.439044879627741e-05 f64.mul + f64.const -0.001388676377460993 f64.add f64.mul f64.add @@ -4243,8 +4243,8 @@ i32.const 1 i32.shl i32.sub - f64.const 1.4426950408889634 local.get $0 + f64.const 1.4426950408889634 f64.mul f64.const 0.5 local.get $0 @@ -4283,8 +4283,8 @@ end end local.get $0 - f64.const 0.5 local.get $0 + f64.const 0.5 f64.mul local.tee $4 f64.mul @@ -4293,22 +4293,22 @@ f64.mul local.set $1 f64.const 3 - f64.const 1 local.get $5 f64.const -0.03333333333333313 f64.mul + f64.const 1 f64.add local.get $1 - f64.const 1.5873015872548146e-03 local.get $5 f64.const -7.93650757867488e-05 f64.mul + f64.const 1.5873015872548146e-03 f64.add local.get $1 - f64.const 4.008217827329362e-06 local.get $5 f64.const -2.0109921818362437e-07 f64.mul + f64.const 4.008217827329362e-06 f64.add f64.mul f64.add @@ -4357,10 +4357,10 @@ i32.const -1 i32.eq if - f64.const 0.5 local.get $0 local.get $3 f64.sub + f64.const 0.5 f64.mul f64.const 0.5 f64.sub @@ -4374,21 +4374,21 @@ f64.const -0.25 f64.lt if - f64.const -2 local.get $3 local.get $0 f64.const 0.5 f64.add f64.sub + f64.const -2 f64.mul return end - f64.const 1 - f64.const 2 local.get $0 local.get $3 f64.sub + f64.const 2 f64.mul + f64.const 1 f64.add return end @@ -4513,8 +4513,8 @@ i32.const 1072734898 i32.ge_u if (result i32) - f64.const 1.4426950408889634 local.get $0 + f64.const 1.4426950408889634 f64.mul f64.const 0.5 local.get $0 @@ -4548,8 +4548,8 @@ if (result f64) local.get $0 else - f64.const 1 local.get $0 + f64.const 1 f64.add return end @@ -4562,23 +4562,22 @@ local.get $3 f64.mul local.set $5 - f64.const 1 local.get $0 local.get $0 local.get $3 f64.const 0.16666666666666602 f64.mul local.get $5 - f64.const -2.7777777777015593e-03 local.get $3 f64.const 6.613756321437934e-05 f64.mul + f64.const -2.7777777777015593e-03 f64.add local.get $5 - f64.const -1.6533902205465252e-06 local.get $3 f64.const 4.1381367970572385e-08 f64.mul + f64.const -1.6533902205465252e-06 f64.add f64.mul f64.add @@ -4595,6 +4594,7 @@ f64.sub local.get $1 f64.add + f64.const 1 f64.add local.set $0 local.get $4 @@ -4632,18 +4632,18 @@ i32.lt_u br_if $__inlined_func$~lib/math/NativeMath.cosh drop - f64.const 1 local.get $3 call $~lib/math/NativeMath.expm1 local.tee $3 local.get $3 f64.mul - f64.const 2 - f64.const 2 local.get $3 + f64.const 2 f64.mul + f64.const 2 f64.add f64.div + f64.const 1 f64.add br $__inlined_func$~lib/math/NativeMath.cosh end @@ -4651,7 +4651,6 @@ i32.const 1082535490 i32.lt_u if - f64.const 0.5 local.get $3 call $~lib/math/NativeMath.exp local.tee $3 @@ -4659,6 +4658,7 @@ local.get $3 f64.div f64.add + f64.const 0.5 f64.mul br $__inlined_func$~lib/math/NativeMath.cosh end @@ -4737,8 +4737,8 @@ i32.const 1 i32.shl i32.sub - f32.const 1.4426950216293335 local.get $0 + f32.const 1.4426950216293335 f32.mul f32.const 0.5 local.get $0 @@ -4777,20 +4777,20 @@ end end f32.const 3 - f32.const 1 local.get $0 - f32.const 0.5 local.get $0 + f32.const 0.5 f32.mul local.tee $2 f32.mul local.tee $1 - f32.const -0.03333321213722229 local.get $1 f32.const 1.5807170420885086e-03 f32.mul + f32.const -0.03333321213722229 f32.add f32.mul + f32.const 1 f32.add local.tee $7 local.get $2 @@ -4835,10 +4835,10 @@ i32.const -1 i32.eq if - f32.const 0.5 local.get $0 local.get $1 f32.sub + f32.const 0.5 f32.mul f32.const 0.5 f32.sub @@ -4852,21 +4852,21 @@ f32.const -0.25 f32.lt if - f32.const -2 local.get $1 local.get $0 f32.const 0.5 f32.add f32.sub + f32.const -2 f32.mul return end - f32.const 1 - f32.const 2 local.get $0 local.get $1 f32.sub + f32.const 2 f32.mul + f32.const 1 f32.add return end @@ -4988,8 +4988,8 @@ i32.const 1065686418 i32.gt_u if (result i32) - f32.const 1.4426950216293335 local.get $0 + f32.const 1.4426950216293335 f32.mul f32.const 0.5 local.get $0 @@ -5023,24 +5023,23 @@ if (result f32) local.get $0 else - f32.const 1 local.get $0 + f32.const 1 f32.add return end local.set $1 end - f32.const 1 local.get $0 local.get $0 local.get $0 local.get $0 f32.mul local.tee $0 - f32.const 0.16666625440120697 local.get $0 f32.const -2.7667332906275988e-03 f32.mul + f32.const 0.16666625440120697 f32.add f32.mul f32.sub @@ -5054,6 +5053,7 @@ f32.sub local.get $1 f32.add + f32.const 1 f32.add local.set $0 local.get $3 @@ -5085,18 +5085,18 @@ i32.lt_u br_if $__inlined_func$~lib/math/NativeMathf.cosh drop - f32.const 1 local.get $0 call $~lib/math/NativeMathf.expm1 local.tee $0 local.get $0 f32.mul - f32.const 2 - f32.const 2 local.get $0 + f32.const 2 f32.mul + f32.const 2 f32.add f32.div + f32.const 1 f32.add br $__inlined_func$~lib/math/NativeMathf.cosh end @@ -5104,10 +5104,10 @@ i32.const 1118925335 i32.lt_u if - f32.const 0.5 local.get $0 call $~lib/math/NativeMathf.exp local.tee $0 + f32.const 0.5 f32.mul f32.const 0.5 local.get $0 @@ -5216,8 +5216,8 @@ i64.eq br_if $~lib/util/math/exp2_lut|inlined.0 drop - f64.const 1 local.get $2 + f64.const 1 f64.add local.get $1 i32.const 2047 @@ -5287,20 +5287,20 @@ f64.mul f64.add local.get $2 - f64.const 0.24022650695909065 local.get $0 f64.const 0.0555041086686087 f64.mul + f64.const 0.24022650695909065 f64.add f64.mul f64.add local.get $2 local.get $2 f64.mul - f64.const 0.009618131975721055 local.get $0 f64.const 1.3332074570119598e-03 f64.mul + f64.const 0.009618131975721055 f64.add f64.mul f64.add @@ -5314,7 +5314,6 @@ i64.and i64.eqz if - f64.const 2 local.get $3 i64.const 4503599627370496 i64.sub @@ -5324,6 +5323,7 @@ f64.mul local.get $2 f64.add + f64.const 2 f64.mul br $~lib/util/math/specialcase2|inlined.0 end @@ -5340,8 +5340,8 @@ f64.const 1 f64.lt if (result f64) - f64.const 1 local.get $2 + f64.const 1 f64.add local.tee $7 f64.const 1 @@ -5444,7 +5444,6 @@ br_if $~lib/util/math/exp2f_lut|inlined.0 drop end - f64.const 0.6931471806916203 local.get $1 local.get $1 f64.const 211106232532992 @@ -5454,11 +5453,12 @@ f64.sub f64.sub local.tee $1 + f64.const 0.6931471806916203 f64.mul f64.const 1 f64.add - f64.const 0.05550361559341535 local.get $1 + f64.const 0.05550361559341535 f64.mul f64.const 0.2402284522445722 f64.add @@ -5655,8 +5655,8 @@ f64.mul local.tee $1 f64.sub - f64.const 2 local.get $8 + f64.const 2 f64.mul local.get $5 f64.add @@ -5671,8 +5671,8 @@ f64.mul local.tee $0 f64.sub - f64.const 2 local.get $7 + f64.const 2 f64.mul local.get $11 f64.add @@ -5934,8 +5934,8 @@ f64.const 1 f64.sub local.tee $0 - f64.const 2 local.get $0 + f64.const 2 f64.add f64.div local.tee $4 @@ -5955,8 +5955,8 @@ f64.mul local.tee $10 local.get $0 - f64.const 0.5 local.get $0 + f64.const 0.5 f64.mul local.get $0 f64.mul @@ -5983,32 +5983,32 @@ local.get $4 local.get $5 local.get $3 - f64.const 0.6666666666666735 local.get $3 local.get $3 f64.mul local.tee $0 - f64.const 0.2857142874366239 local.get $0 - f64.const 0.1818357216161805 local.get $0 f64.const 0.14798198605116586 f64.mul + f64.const 0.1818357216161805 f64.add f64.mul + f64.const 0.2857142874366239 f64.add f64.mul + f64.const 0.6666666666666735 f64.add f64.mul local.get $0 - f64.const 0.3999999999940942 local.get $0 - f64.const 0.22222198432149784 local.get $0 f64.const 0.15313837699209373 f64.mul + f64.const 0.22222198432149784 f64.add f64.mul + f64.const 0.3999999999940942 f64.add f64.mul f64.add @@ -6127,8 +6127,8 @@ f32.const 1 f32.sub local.tee $0 - f32.const 2 local.get $0 + f32.const 2 f32.add f32.div local.tee $3 @@ -6148,8 +6148,8 @@ f32.mul local.get $0 local.get $0 - f32.const 0.5 local.get $0 + f32.const 0.5 f32.mul local.get $0 f32.mul @@ -6166,20 +6166,20 @@ local.get $3 local.get $0 local.get $2 - f32.const 0.6666666269302368 local.get $2 local.get $2 f32.mul local.tee $0 f32.const 0.2849878668785095 f32.mul + f32.const 0.6666666269302368 f32.add f32.mul local.get $0 - f32.const 0.40000972151756287 local.get $0 f32.const 0.24279078841209412 f32.mul + f32.const 0.40000972151756287 f32.add f32.mul f32.add @@ -6337,8 +6337,8 @@ f64.const 1 f64.sub local.tee $0 - f64.const 2 local.get $0 + f64.const 2 f64.add f64.div local.tee $4 @@ -6355,8 +6355,8 @@ f64.convert_i32_s local.tee $9 local.get $0 - f64.const 0.5 local.get $0 + f64.const 0.5 f64.mul local.get $0 f64.mul @@ -6380,32 +6380,32 @@ local.get $4 local.get $5 local.get $3 - f64.const 0.6666666666666735 local.get $3 local.get $3 f64.mul local.tee $0 - f64.const 0.2857142874366239 local.get $0 - f64.const 0.1818357216161805 local.get $0 f64.const 0.14798198605116586 f64.mul + f64.const 0.1818357216161805 f64.add f64.mul + f64.const 0.2857142874366239 f64.add f64.mul + f64.const 0.6666666666666735 f64.add f64.mul local.get $0 - f64.const 0.3999999999940942 local.get $0 - f64.const 0.22222198432149784 local.get $0 f64.const 0.15313837699209373 f64.mul + f64.const 0.22222198432149784 f64.add f64.mul + f64.const 0.3999999999940942 f64.add f64.mul f64.add @@ -6522,8 +6522,8 @@ f32.const 1 f32.sub local.tee $0 - f32.const 2 local.get $0 + f32.const 2 f32.add f32.div local.tee $3 @@ -6532,8 +6532,8 @@ local.set $2 local.get $0 local.get $0 - f32.const 0.5 local.get $0 + f32.const 0.5 f32.mul local.get $0 f32.mul @@ -6550,20 +6550,20 @@ local.get $3 local.get $0 local.get $2 - f32.const 0.6666666269302368 local.get $2 local.get $2 f32.mul local.tee $0 f32.const 0.2849878668785095 f32.mul + f32.const 0.6666666269302368 f32.add f32.mul local.get $0 - f32.const 0.40000972151756287 local.get $0 f32.const 0.24279078841209412 f32.mul + f32.const 0.40000972151756287 f32.add f32.mul f32.add @@ -6859,8 +6859,8 @@ f64.reinterpret_i64 return end - f64.const 0 local.get $0 + f64.const 0 f64.mul ) (func $std/math/test_mod (param $0 f64) (param $1 f64) (param $2 f64) (result i32) @@ -7077,8 +7077,8 @@ f32.reinterpret_i32 return end - f32.const 0 local.get $0 + f32.const 0 f32.mul ) (func $std/math/test_modf (param $0 f32) (param $1 f32) (param $2 f32) (result i32) @@ -7514,11 +7514,11 @@ select return end - f64.const 1.4426950216293335 local.get $3 f64.const 1 f64.sub local.tee $0 + f64.const 1.4426950216293335 f64.mul local.tee $3 local.get $0 @@ -7608,7 +7608,6 @@ end end local.set $5 - f64.const 0.9617967009544373 local.get $3 i64.reinterpret_f64 i64.const 4294967295 @@ -7640,11 +7639,11 @@ i64.and f64.reinterpret_i64 local.tee $15 - f64.const 3 local.get $15 local.get $15 f64.mul local.tee $19 + f64.const 3 f64.add local.get $17 local.get $17 @@ -7652,26 +7651,26 @@ local.tee $13 local.get $13 f64.mul - f64.const 0.5999999999999946 local.get $13 - f64.const 0.4285714285785502 local.get $13 - f64.const 0.33333332981837743 local.get $13 - f64.const 0.272728123808534 local.get $13 - f64.const 0.23066074577556175 local.get $13 f64.const 0.20697501780033842 f64.mul + f64.const 0.23066074577556175 f64.add f64.mul + f64.const 0.272728123808534 f64.add f64.mul + f64.const 0.33333332981837743 f64.add f64.mul + f64.const 0.4285714285785502 f64.add f64.mul + f64.const 0.5999999999999946 f64.add f64.mul local.get $0 @@ -7739,10 +7738,11 @@ i64.and f64.reinterpret_i64 local.tee $2 + f64.const 0.9617967009544373 f64.mul local.tee $19 - f64.const -7.028461650952758e-09 local.get $2 + f64.const -7.028461650952758e-09 f64.mul local.get $0 local.get $2 @@ -7952,22 +7952,22 @@ local.get $2 local.get $2 local.get $0 - f64.const 0.16666666666666602 local.get $0 - f64.const -2.7777777777015593e-03 local.get $0 - f64.const 6.613756321437934e-05 local.get $0 - f64.const -1.6533902205465252e-06 local.get $0 f64.const 4.1381367970572385e-08 f64.mul + f64.const -1.6533902205465252e-06 f64.add f64.mul + f64.const 6.613756321437934e-05 f64.add f64.mul + f64.const -2.7777777777015593e-03 f64.add f64.mul + f64.const 0.16666666666666602 f64.add f64.mul f64.sub @@ -8143,8 +8143,8 @@ i32.and local.set $6 local.get $1 - f32.nearest local.get $1 + f32.nearest f32.eq i32.const 0 local.get $4 @@ -8159,8 +8159,8 @@ f32.const 0.5 f32.mul local.tee $8 - f32.nearest local.get $8 + f32.nearest f32.ne i32.const 31 i32.shl @@ -8234,20 +8234,19 @@ f64.const 0 local.get $1 f64.promote_f32 - f64.const 2.8853900817779268 local.get $3 local.get $3 local.get $2 f64.mul - f64.const 0.3333333282272823 - f64.const 0.20000167595436263 local.get $2 + f64.const 0.20000167595436263 f64.mul + f64.const 0.3333333282272823 f64.add - f64.const 0.14268654271188685 - f64.const 0.11791075649681414 local.get $2 + f64.const 0.11791075649681414 f64.mul + f64.const 0.14268654271188685 f64.add local.get $2 local.get $2 @@ -8256,6 +8255,7 @@ f64.add f64.mul f64.add + f64.const 2.8853900817779268 f64.mul local.get $7 f64.convert_i64_s @@ -8281,25 +8281,24 @@ local.get $2 f64.mul local.set $3 - f64.const 1 local.get $2 - f64.const 0.6931471880289533 - f64.const 0.24022651084211735 local.get $2 + f64.const 0.24022651084211735 f64.mul + f64.const 0.6931471880289533 f64.add - f64.const 0.055503571054988744 - f64.const 0.009618030771171498 local.get $2 + f64.const 0.009618030771171498 f64.mul + f64.const 0.055503571054988744 f64.add local.get $3 f64.mul f64.add - f64.const 0.001339086685300951 - f64.const 1.5469734999890288e-04 local.get $2 + f64.const 1.5469734999890288e-04 f64.mul + f64.const 0.001339086685300951 f64.add local.get $3 local.get $3 @@ -8307,6 +8306,7 @@ f64.mul f64.add f64.mul + f64.const 1 f64.add i64.reinterpret_f64 local.get $11 @@ -8690,6 +8690,9 @@ i32.const 1 i32.and i32.const 0 + local.get $1 + f64.abs + local.tee $1 local.get $2 i64.const 4503599627370496 i64.sub @@ -8713,9 +8716,6 @@ local.get $0 f64.add local.tee $8 - local.get $1 - f64.abs - local.tee $1 f64.eq select local.get $8 @@ -8939,6 +8939,9 @@ i32.const 1 i32.and i32.const 0 + local.get $1 + f32.abs + local.tee $1 local.get $2 i32.const 8388608 i32.sub @@ -8960,9 +8963,6 @@ local.get $0 f32.add local.tee $4 - local.get $1 - f32.abs - local.tee $1 f32.eq select local.get $4 @@ -9039,30 +9039,30 @@ local.tee $3 local.get $0 f64.mul - f64.const -0.16666666666666632 local.get $3 - f64.const 0.00833333333332249 local.get $3 - f64.const -1.984126982985795e-04 local.get $3 f64.const 2.7557313707070068e-06 f64.mul + f64.const -1.984126982985795e-04 f64.add f64.mul + f64.const 0.00833333333332249 f64.add local.get $3 local.get $3 local.get $3 f64.mul f64.mul - f64.const -2.5050760253406863e-08 local.get $3 f64.const 1.58969099521155e-10 f64.mul + f64.const -2.5050760253406863e-08 f64.add f64.mul f64.add f64.mul + f64.const -0.16666666666666632 f64.add f64.mul f64.add @@ -9208,11 +9208,11 @@ i32.and if (result f64) f64.const 1 - f64.const 0.5 local.get $0 local.get $0 f64.mul local.tee $3 + f64.const 0.5 f64.mul local.tee $1 f64.sub @@ -9224,14 +9224,14 @@ f64.sub local.get $3 local.get $3 - f64.const 0.0416666666666666 local.get $3 - f64.const -0.001388888888887411 local.get $3 f64.const 2.480158728947673e-05 f64.mul + f64.const -0.001388888888887411 f64.add f64.mul + f64.const 0.0416666666666666 f64.add f64.mul local.get $3 @@ -9240,14 +9240,14 @@ local.tee $1 local.get $1 f64.mul - f64.const -2.7557314351390663e-07 local.get $3 - f64.const 2.087572321298175e-09 local.get $3 f64.const -1.1359647557788195e-11 f64.mul + f64.const 2.087572321298175e-09 f64.add f64.mul + f64.const -2.7557314351390663e-07 f64.add f64.mul f64.add @@ -9266,38 +9266,38 @@ local.get $0 f64.mul local.tee $1 - f64.const -0.16666666666666632 local.get $3 - f64.const 0.00833333333332249 local.get $3 - f64.const -1.984126982985795e-04 local.get $3 f64.const 2.7557313707070068e-06 f64.mul + f64.const -1.984126982985795e-04 f64.add f64.mul + f64.const 0.00833333333332249 f64.add local.get $3 local.get $3 local.get $3 f64.mul f64.mul - f64.const -2.5050760253406863e-08 local.get $3 f64.const 1.58969099521155e-10 f64.mul + f64.const -2.5050760253406863e-08 f64.add f64.mul f64.add local.tee $7 f64.mul + f64.const -0.16666666666666632 f64.add f64.mul drop local.get $0 local.get $3 - f64.const 0.5 local.get $4 + f64.const 0.5 f64.mul local.get $1 local.get $7 @@ -9380,10 +9380,10 @@ local.set $3 local.get $4 local.get $3 - f64.const -0.16666666641626524 local.get $6 f64.const 0.008333329385889463 f64.mul + f64.const -0.16666666641626524 f64.add f64.mul f64.add @@ -9392,10 +9392,10 @@ local.get $6 f64.mul f64.mul - f64.const -1.9839334836096632e-04 local.get $6 f64.const 2.718311493989822e-06 f64.mul + f64.const -1.9839334836096632e-04 f64.add f64.mul f64.add @@ -9545,10 +9545,10 @@ local.get $4 f64.mul local.set $3 - f64.const 1 local.get $4 f64.const -0.499999997251031 f64.mul + f64.const 1 f64.add local.get $3 f64.const 0.04166662332373906 @@ -9557,10 +9557,10 @@ local.get $3 local.get $4 f64.mul - f64.const -0.001388676377460993 local.get $4 f64.const 2.439044879627741e-05 f64.mul + f64.const -0.001388676377460993 f64.add f64.mul f64.add @@ -9574,10 +9574,10 @@ local.get $3 f64.mul local.tee $3 - f64.const -0.16666666641626524 local.get $4 f64.const 0.008333329385889463 f64.mul + f64.const -0.16666666641626524 f64.add f64.mul f64.add @@ -9586,10 +9586,10 @@ local.get $4 f64.mul f64.mul - f64.const -1.9839334836096632e-04 local.get $4 f64.const 2.718311493989822e-06 f64.mul + f64.const -1.9839334836096632e-04 f64.add f64.mul f64.add @@ -9649,8 +9649,8 @@ return end local.get $2 - f64.const 2 local.get $1 + f64.const 2 f64.mul local.get $1 local.get $1 @@ -9678,8 +9678,8 @@ f64.const 1416.0996898839683 f64.sub call $~lib/math/NativeMath.exp - f64.const 2 local.get $2 + f64.const 2 f64.mul f64.const 2247116418577894884661631e283 f64.mul @@ -9737,8 +9737,8 @@ return end local.get $3 - f32.const 2 local.get $1 + f32.const 2 f32.mul local.get $1 local.get $1 @@ -9766,8 +9766,8 @@ f32.const 162.88958740234375 f32.sub call $~lib/math/NativeMathf.exp - f32.const 2 local.get $3 + f32.const 2 f32.mul f32.const 1661534994731144841129758e11 f32.mul @@ -9856,51 +9856,51 @@ local.get $1 local.get $4 local.get $5 - f64.const 0.13333333333320124 local.get $4 local.get $4 f64.mul local.tee $3 - f64.const 0.021869488294859542 local.get $3 - f64.const 3.5920791075913124e-03 local.get $3 - f64.const 5.880412408202641e-04 local.get $3 - f64.const 7.817944429395571e-05 local.get $3 f64.const -1.8558637485527546e-05 f64.mul + f64.const 7.817944429395571e-05 f64.add f64.mul + f64.const 5.880412408202641e-04 f64.add f64.mul + f64.const 3.5920791075913124e-03 f64.add f64.mul + f64.const 0.021869488294859542 f64.add f64.mul + f64.const 0.13333333333320124 f64.add local.get $4 - f64.const 0.05396825397622605 local.get $3 - f64.const 0.0088632398235993 local.get $3 - f64.const 1.4562094543252903e-03 local.get $3 - f64.const 2.464631348184699e-04 local.get $3 - f64.const 7.140724913826082e-05 local.get $3 f64.const 2.590730518636337e-05 f64.mul + f64.const 7.140724913826082e-05 f64.add f64.mul + f64.const 2.464631348184699e-04 f64.add f64.mul + f64.const 1.4562094543252903e-03 f64.add f64.mul + f64.const 0.0088632398235993 f64.add f64.mul + f64.const 0.05396825397622605 f64.add f64.mul f64.add @@ -9909,8 +9909,8 @@ f64.add f64.mul f64.add - f64.const 0.3333333333333341 local.get $5 + f64.const 0.3333333333333341 f64.mul f64.add local.tee $3 @@ -9929,7 +9929,6 @@ local.get $2 f64.convert_i32_s local.tee $4 - f64.const 2 local.get $0 local.get $1 local.get $1 @@ -9941,6 +9940,7 @@ local.get $3 f64.sub f64.sub + f64.const 2 f64.mul f64.sub f64.mul @@ -9963,7 +9963,6 @@ f64.reinterpret_i64 local.tee $4 local.get $5 - f64.const 1 local.get $4 local.get $1 i64.reinterpret_f64 @@ -9972,6 +9971,7 @@ f64.reinterpret_i64 local.tee $1 f64.mul + f64.const 1 f64.add local.get $4 local.get $3 @@ -10223,10 +10223,10 @@ local.set $3 local.get $5 local.get $3 - f64.const 0.3333313950307914 local.get $4 f64.const 0.13339200271297674 f64.mul + f64.const 0.3333313950307914 f64.add f64.mul f64.add @@ -10236,16 +10236,16 @@ f64.mul local.tee $3 f64.mul - f64.const 0.05338123784456704 local.get $4 f64.const 0.024528318116654728 f64.mul + f64.const 0.05338123784456704 f64.add local.get $3 - f64.const 0.002974357433599673 local.get $4 f64.const 0.009465647849436732 f64.mul + f64.const 0.002974357433599673 f64.add f64.mul f64.add @@ -10395,10 +10395,10 @@ f64.const -1 local.get $5 local.get $3 - f64.const 0.3333313950307914 local.get $4 f64.const 0.13339200271297674 f64.mul + f64.const 0.3333313950307914 f64.add f64.mul f64.add @@ -10408,16 +10408,16 @@ f64.mul local.tee $3 f64.mul - f64.const 0.05338123784456704 local.get $4 f64.const 0.024528318116654728 f64.mul + f64.const 0.05338123784456704 f64.add local.get $3 - f64.const 0.002974357433599673 local.get $4 f64.const 0.009465647849436732 f64.mul + f64.const 0.002974357433599673 f64.add f64.mul f64.add @@ -10470,8 +10470,8 @@ else f64.const 1 f64.const 2 - f64.const 2 local.get $1 + f64.const 2 f64.mul call $~lib/math/NativeMath.expm1 f64.const 2 @@ -10484,8 +10484,8 @@ i32.const 1070618798 i32.gt_u if (result f64) - f64.const 2 local.get $1 + f64.const 2 f64.mul call $~lib/math/NativeMath.expm1 local.tee $1 @@ -10498,8 +10498,8 @@ i32.const 1048576 i32.ge_u if (result f64) - f64.const -2 local.get $1 + f64.const -2 f64.mul call $~lib/math/NativeMath.expm1 local.tee $1 @@ -10550,16 +10550,16 @@ i32.const 1092616192 i32.gt_u if (result f32) - f32.const 1 f32.const 0 local.get $3 f32.div + f32.const 1 f32.add else f32.const 1 f32.const 2 - f32.const 2 local.get $3 + f32.const 2 f32.mul call $~lib/math/NativeMathf.expm1 f32.const 2 @@ -10572,8 +10572,8 @@ i32.const 1048757624 i32.gt_u if (result f32) - f32.const 2 local.get $3 + f32.const 2 f32.mul call $~lib/math/NativeMathf.expm1 local.tee $3 @@ -10586,8 +10586,8 @@ i32.const 8388608 i32.ge_u if (result f32) - f32.const -2 local.get $3 + f32.const -2 f32.mul call $~lib/math/NativeMathf.expm1 local.tee $3 @@ -10675,16 +10675,15 @@ local.tee $2 local.get $0 f64.mul - f64.const -0.16666666666666632 local.get $2 - f64.const 0.00833333333332249 local.get $2 - f64.const -1.984126982985795e-04 local.get $2 f64.const 2.7557313707070068e-06 f64.mul + f64.const -1.984126982985795e-04 f64.add f64.mul + f64.const 0.00833333333332249 f64.add local.get $2 local.get $2 @@ -10692,21 +10691,22 @@ f64.mul local.tee $4 f64.mul - f64.const -2.5050760253406863e-08 local.get $2 f64.const 1.58969099521155e-10 f64.mul + f64.const -2.5050760253406863e-08 f64.add f64.mul f64.add f64.mul + f64.const -0.16666666666666632 f64.add f64.mul f64.add global.set $~lib/math/NativeMath.sincos_sin f64.const 1 - f64.const 0.5 local.get $2 + f64.const 0.5 f64.mul local.tee $1 f64.sub @@ -10718,27 +10718,27 @@ f64.sub local.get $2 local.get $2 - f64.const 0.0416666666666666 local.get $2 - f64.const -0.001388888888887411 local.get $2 f64.const 2.480158728947673e-05 f64.mul + f64.const -0.001388888888887411 f64.add f64.mul + f64.const 0.0416666666666666 f64.add f64.mul local.get $4 local.get $4 f64.mul - f64.const -2.7557314351390663e-07 local.get $2 - f64.const 2.087572321298175e-09 local.get $2 f64.const -1.1359647557788195e-11 f64.mul + f64.const 2.087572321298175e-09 f64.add f64.mul + f64.const -2.7557314351390663e-07 f64.add f64.mul f64.add @@ -10897,19 +10897,19 @@ local.set $0 local.get $4 local.get $2 - f64.const 0.5 global.get $~lib/math/rempio2_y1 local.tee $7 + f64.const 0.5 f64.mul local.get $0 - f64.const 0.00833333333332249 local.get $2 - f64.const -1.984126982985795e-04 local.get $2 f64.const 2.7557313707070068e-06 f64.mul + f64.const -1.984126982985795e-04 f64.add f64.mul + f64.const 0.00833333333332249 f64.add local.get $2 local.get $2 @@ -10917,10 +10917,10 @@ f64.mul local.tee $1 f64.mul - f64.const -2.5050760253406863e-08 local.get $2 f64.const 1.58969099521155e-10 f64.mul + f64.const -2.5050760253406863e-08 f64.add f64.mul f64.add @@ -10937,8 +10937,8 @@ local.tee $8 local.set $0 f64.const 1 - f64.const 0.5 local.get $2 + f64.const 0.5 f64.mul local.tee $9 f64.sub @@ -10950,27 +10950,27 @@ f64.sub local.get $2 local.get $2 - f64.const 0.0416666666666666 local.get $2 - f64.const -0.001388888888887411 local.get $2 f64.const 2.480158728947673e-05 f64.mul + f64.const -0.001388888888887411 f64.add f64.mul + f64.const 0.0416666666666666 f64.add f64.mul local.get $1 local.get $1 f64.mul - f64.const -2.7557314351390663e-07 local.get $2 - f64.const 2.087572321298175e-09 local.get $2 f64.const -1.1359647557788195e-11 f64.mul + f64.const 2.087572321298175e-09 f64.add f64.mul + f64.const -2.7557314351390663e-07 f64.add f64.mul f64.add @@ -11037,11 +11037,11 @@ ) (func $~lib/math/dtoi32 (param $0 f64) (result i32) local.get $0 - f64.const 4294967296 local.get $0 f64.const 2.3283064365386963e-10 f64.mul f64.floor + f64.const 4294967296 f64.mul f64.sub i64.trunc_f64_s @@ -20189,9 +20189,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.9238795325112867 f64.const 0.39269908169872414 call $~lib/math/NativeMath.cos + f64.const 0.9238795325112867 f64.ne if i32.const 0 @@ -20201,9 +20201,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.9238795325112867 f64.const -0.39269908169872414 call $~lib/math/NativeMath.cos + f64.const 0.9238795325112867 f64.ne if i32.const 0 @@ -20225,9 +20225,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.9689124217106447 f64.const 0.25 call $~lib/math/NativeMath.cos + f64.const 0.9689124217106447 f64.ne if i32.const 0 @@ -20237,9 +20237,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.8775825618903728 f64.const 0.5 call $~lib/math/NativeMath.cos + f64.const 0.8775825618903728 f64.ne if i32.const 0 @@ -20249,9 +20249,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.7073882691671998 f64.const 0.785 call $~lib/math/NativeMath.cos + f64.const 0.7073882691671998 f64.ne if i32.const 0 @@ -20261,9 +20261,9 @@ call $~lib/builtins/abort unreachable end - f64.const 6.123233995736766e-17 f64.const 1.5707963267948966 call $~lib/math/NativeMath.cos + f64.const 6.123233995736766e-17 f64.ne if i32.const 0 @@ -20273,9 +20273,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.7071067811865474 f64.const 5.497787143782138 call $~lib/math/NativeMath.cos + f64.const 0.7071067811865474 f64.ne if i32.const 0 @@ -20285,9 +20285,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.7071067811865477 f64.const 7.0685834705770345 call $~lib/math/NativeMath.cos + f64.const 0.7071067811865477 f64.ne if i32.const 0 @@ -20297,9 +20297,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.7071067811865467 f64.const 8.63937979737193 call $~lib/math/NativeMath.cos + f64.const -0.7071067811865467 f64.ne if i32.const 0 @@ -20309,9 +20309,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.7071067811865471 f64.const 10.210176124166829 call $~lib/math/NativeMath.cos + f64.const -0.7071067811865471 f64.ne if i32.const 0 @@ -20321,9 +20321,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.9367521275331447 f64.const 1e6 call $~lib/math/NativeMath.cos + f64.const 0.9367521275331447 f64.ne if i32.const 0 @@ -20333,9 +20333,9 @@ call $~lib/builtins/abort unreachable end - f64.const -3.435757038074824e-12 f64.const 1647097.7583689587 call $~lib/math/NativeMath.cos + f64.const -3.435757038074824e-12 f64.ne if i32.const 0 @@ -41963,8 +41963,8 @@ unreachable end f64.const 2.3283064365386963e-10 - f64.const 2.3283064365386963e-10 call $~lib/math/NativeMath.sin + f64.const 2.3283064365386963e-10 f64.ne if i32.const 0 @@ -41975,8 +41975,8 @@ unreachable end f64.const -2.3283064365386963e-10 - f64.const -2.3283064365386963e-10 call $~lib/math/NativeMath.sin + f64.const -2.3283064365386963e-10 f64.ne if i32.const 0 @@ -41986,9 +41986,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.3826834323650898 f64.const 0.39269908169872414 call $~lib/math/NativeMath.sin + f64.const 0.3826834323650898 f64.ne if i32.const 0 @@ -41998,9 +41998,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.3826834323650898 f64.const -0.39269908169872414 call $~lib/math/NativeMath.sin + f64.const -0.3826834323650898 f64.ne if i32.const 0 @@ -42010,9 +42010,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.479425538604203 f64.const 0.5 call $~lib/math/NativeMath.sin + f64.const 0.479425538604203 f64.ne if i32.const 0 @@ -42022,9 +42022,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.479425538604203 f64.const -0.5 call $~lib/math/NativeMath.sin + f64.const -0.479425538604203 f64.ne if i32.const 0 @@ -42034,9 +42034,9 @@ call $~lib/builtins/abort unreachable end - f64.const 1 f64.const 1.5707963267948966 call $~lib/math/NativeMath.sin + f64.const 1 f64.ne if i32.const 0 @@ -42046,9 +42046,9 @@ call $~lib/builtins/abort unreachable end - f64.const -1 f64.const -1.5707963267948966 call $~lib/math/NativeMath.sin + f64.const -1 f64.ne if i32.const 0 @@ -42058,9 +42058,9 @@ call $~lib/builtins/abort unreachable end - f64.const 1.2246467991473532e-16 f64.const 3.141592653589793 call $~lib/math/NativeMath.sin + f64.const 1.2246467991473532e-16 f64.ne if i32.const 0 @@ -42070,9 +42070,9 @@ call $~lib/builtins/abort unreachable end - f64.const -7.047032979958965e-14 f64.const 6911.503837897545 call $~lib/math/NativeMath.sin + f64.const -7.047032979958965e-14 f64.ne if i32.const 0 @@ -42082,9 +42082,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.7071067811865477 f64.const 5.497787143782138 call $~lib/math/NativeMath.sin + f64.const -0.7071067811865477 f64.ne if i32.const 0 @@ -42094,9 +42094,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.7071067811865474 f64.const 7.0685834705770345 call $~lib/math/NativeMath.sin + f64.const 0.7071067811865474 f64.ne if i32.const 0 @@ -42106,9 +42106,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.7071067811865483 f64.const 8.63937979737193 call $~lib/math/NativeMath.sin + f64.const 0.7071067811865483 f64.ne if i32.const 0 @@ -42118,9 +42118,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.7071067811865479 f64.const 10.210176124166829 call $~lib/math/NativeMath.sin + f64.const -0.7071067811865479 f64.ne if i32.const 0 @@ -42130,9 +42130,9 @@ call $~lib/builtins/abort unreachable end - f64.const -3.2103381051568376e-11 f64.const 823549.6645826427 call $~lib/math/NativeMath.sin + f64.const -3.2103381051568376e-11 f64.ne if i32.const 0 @@ -42142,9 +42142,9 @@ call $~lib/builtins/abort unreachable end - f64.const 0.377820109360752 f64.const 1329227995784915872903807e12 call $~lib/math/NativeMath.sin + f64.const 0.377820109360752 f64.ne if i32.const 0 @@ -42154,9 +42154,9 @@ call $~lib/builtins/abort unreachable end - f64.const -0.377820109360752 f64.const -1329227995784915872903807e12 call $~lib/math/NativeMath.sin + f64.const -0.377820109360752 f64.ne if i32.const 0 diff --git a/tests/compiler/std/mod.optimized.wat b/tests/compiler/std/mod.optimized.wat index 17c732c475..74e16f90d7 100644 --- a/tests/compiler/std/mod.optimized.wat +++ b/tests/compiler/std/mod.optimized.wat @@ -220,8 +220,8 @@ f64.reinterpret_i64 return end - f64.const 0 local.get $0 + f64.const 0 f64.mul ) (func $std/mod/check (param $0 f64) (param $1 f64) (result i32) @@ -463,8 +463,8 @@ f32.reinterpret_i32 return end - f32.const 0 local.get $0 + f32.const 0 f32.mul ) (func $std/mod/test_fmodf (param $0 f32) (param $1 f32) (param $2 f32) (result i32) diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index a3e5c8a21d..efcadc7858 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -7732,9 +7732,9 @@ if (result i32) i32.const 0 else + local.get $1 local.get $0 f32.load - local.get $1 f32.eq end if @@ -8559,9 +8559,9 @@ if (result i32) i32.const 0 else + local.get $1 local.get $0 f64.load - local.get $1 f64.eq end if diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index c156b0630c..ffe86dbbc4 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -3546,8 +3546,8 @@ if local.get $3 call $~lib/rt/pure/__release - f64.const inf local.get $7 + f64.const inf f64.mul return end @@ -3979,7 +3979,6 @@ i32.const -14 i32.le_s if - f64.const 0.00004294967296 local.get $14 i64.const 6103515625 i64.rem_u @@ -3993,6 +3992,7 @@ i64.sub i64.shl f64.convert_i64_u + f64.const 0.00004294967296 f64.mul f64.nearest i64.trunc_f64_u @@ -7331,9 +7331,9 @@ local.tee $1 i32.trunc_f64_s local.tee $4 + local.get $1 local.get $4 f64.convert_i32_s - local.get $1 f64.ne i32.add i32.const 3 @@ -7963,9 +7963,6 @@ end i32.const 1296 call $~lib/string/String.__not - i32.eqz - i32.const 1 - i32.ne if i32.const 0 i32.const 1088 @@ -7976,9 +7973,6 @@ end i32.const 1328 call $~lib/string/String.__not - i32.eqz - i32.const 1 - i32.ne if i32.const 0 i32.const 1088 diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 3d7a75457b..577660b0fb 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -9580,8 +9580,8 @@ f32.reinterpret_i32 return end - f32.const 0 local.get $0 + f32.const 0 f32.mul ) (func $std/typedarray/testArrayEvery<~lib/typedarray/Float32Array,f32>~anonymous|0 (param $0 f32) (param $1 i32) (param $2 i32) (result i32) @@ -9809,8 +9809,8 @@ f64.reinterpret_i64 return end - f64.const 0 local.get $0 + f64.const 0 f64.mul ) (func $std/typedarray/testArrayEvery<~lib/typedarray/Float64Array,f64>~anonymous|0 (param $0 f64) (param $1 i32) (param $2 i32) (result i32) @@ -17551,13 +17551,13 @@ local.get $3 i32.lt_s if + local.get $1 local.get $4 local.get $2 i32.const 2 i32.shl i32.add f32.load - local.get $1 f32.eq if local.get $0 @@ -17620,13 +17620,13 @@ i32.const 0 i32.ge_s if + local.get $1 local.get $3 local.get $2 i32.const 2 i32.shl i32.add f32.load - local.get $1 f32.eq if local.get $0 @@ -18137,13 +18137,13 @@ local.get $3 i32.lt_s if + local.get $1 local.get $4 local.get $2 i32.const 3 i32.shl i32.add f64.load - local.get $1 f64.eq if local.get $0 @@ -18206,13 +18206,13 @@ i32.const 0 i32.ge_s if + local.get $1 local.get $3 local.get $2 i32.const 3 i32.shl i32.add f64.load - local.get $1 f64.eq if local.get $0 @@ -21342,9 +21342,9 @@ local.tee $1 i32.trunc_f64_s local.tee $4 + local.get $1 local.get $4 f64.convert_i32_s - local.get $1 f64.ne i32.add i32.const 3 @@ -35136,10 +35136,7 @@ call $~lib/rt/pure/__release i32.const 0 end - i32.const 0 - i32.ne - i32.const 1 - i32.ne + i32.eqz if i32.const 0 i32.const 1312 @@ -35228,10 +35225,7 @@ call $~lib/rt/pure/__release i32.const 0 end - i32.const 0 - i32.ne - i32.const 1 - i32.ne + i32.eqz if i32.const 0 i32.const 1312 diff --git a/tests/compiler/wasi/trace.optimized.wat b/tests/compiler/wasi/trace.optimized.wat index 2b9679f067..264ec7194d 100644 --- a/tests/compiler/wasi/trace.optimized.wat +++ b/tests/compiler/wasi/trace.optimized.wat @@ -1341,9 +1341,9 @@ local.tee $1 i32.trunc_f64_s local.tee $4 + local.get $1 local.get $4 f64.convert_i32_s - local.get $1 f64.ne i32.add i32.const 3 diff --git a/tests/features.json b/tests/features.json index aa20113fe6..1b6955a32d 100644 --- a/tests/features.json +++ b/tests/features.json @@ -22,7 +22,15 @@ "--enable reference-types" ], "v8_flags": [ - "--experimental-wasm-reftypes" + ] + }, + "gc": { + "asc_flags": [ + "--enable gc" + ], + "v8_flags": [ + "--experimental-wasm-anyref", + "--experimental-wasm-gc" ] }, "bigint-integration": {