From bb1609c9ea8051460ea6acbca50a204ffee3b5db Mon Sep 17 00:00:00 2001 From: dcode Date: Wed, 27 Mar 2019 14:43:35 +0100 Subject: [PATCH] baseline --- src/builtins.ts | 34 +- src/codegen/array.ts | 281 -- src/codegen/gc.ts | 156 - src/common.ts | 22 +- src/compiler.ts | 684 +++-- src/program.ts | 108 +- std/assembly/collector/README.md | 7 +- std/assembly/collector/dummy.ts | 18 +- std/assembly/collector/dummyrc.ts | 29 + std/assembly/collector/itcm.ts | 6 +- std/assembly/runtime.ts | 24 +- tests/compiler/call-super.optimized.wat | 4 +- tests/compiler/call-super.untouched.wat | 162 +- tests/compiler/constructor.optimized.wat | 4 +- tests/compiler/constructor.untouched.wat | 173 +- tests/compiler/exports.optimized.wat | 85 +- tests/compiler/exports.untouched.wat | 38 +- tests/compiler/gc/README.md | 1 + tests/compiler/gc/_dummy.ts | 47 + tests/compiler/gc/global-assign.optimized.wat | 251 ++ tests/compiler/gc/global-assign.ts | 21 + tests/compiler/gc/global-assign.untouched.wat | 331 +++ tests/compiler/gc/global-init.optimized.wat | 248 ++ tests/compiler/gc/global-init.ts | 18 + tests/compiler/gc/global-init.untouched.wat | 328 +++ tests/compiler/gc/rc/README.md | 1 + tests/compiler/gc/rc/_dummy.ts | 43 + .../gc/rc/global-assign.optimized.wat | 349 +++ tests/compiler/gc/rc/global-assign.ts | 24 + .../gc/rc/global-assign.untouched.wat | 425 +++ .../compiler/gc/rc/global-init.optimized.wat | 253 ++ tests/compiler/gc/rc/global-init.ts | 14 + .../compiler/gc/rc/global-init.untouched.wat | 324 +++ tests/compiler/getter-call.optimized.wat | 4 +- tests/compiler/getter-call.untouched.wat | 21 +- tests/compiler/inlining.optimized.wat | 4 +- tests/compiler/inlining.untouched.wat | 41 +- .../new-without-allocator.untouched.wat | 21 +- tests/compiler/number.optimized.wat | 8 +- tests/compiler/number.untouched.wat | 8 +- tests/compiler/object-literal.optimized.wat | 4 +- tests/compiler/object-literal.untouched.wat | 53 +- .../optional-typeparameters.optimized.wat | 4 +- .../optional-typeparameters.untouched.wat | 38 +- tests/compiler/simd.optimized.wat | 13 +- tests/compiler/simd.ts | 2 - tests/compiler/simd.untouched.wat | 695 +++-- .../compiler/std/array-literal.optimized.wat | 4 +- .../compiler/std/array-literal.untouched.wat | 139 +- tests/compiler/std/array.optimized.wat | 284 +- tests/compiler/std/array.untouched.wat | 1874 ++++-------- tests/compiler/std/arraybuffer.optimized.wat | 6 +- tests/compiler/std/arraybuffer.untouched.wat | 94 +- tests/compiler/std/dataview.optimized.wat | 4 +- tests/compiler/std/dataview.untouched.wat | 55 +- tests/compiler/std/date.optimized.wat | 4 +- tests/compiler/std/date.untouched.wat | 21 +- tests/compiler/std/gc-array.optimized.wat | 1954 ------------- tests/compiler/std/gc-array.ts | 24 - tests/compiler/std/gc-array.untouched.wat | 2540 ----------------- tests/compiler/std/gc-basics.optimized.wat | 481 ---- tests/compiler/std/gc-basics.ts | 35 - tests/compiler/std/gc-basics.untouched.wat | 629 ---- .../compiler/std/gc-integration.optimized.wat | 67 - tests/compiler/std/gc-integration.ts | 19 - .../compiler/std/gc-integration.untouched.wat | 81 - tests/compiler/std/gc-object.optimized.wat | 437 --- tests/compiler/std/gc-object.ts | 25 - tests/compiler/std/gc-object.untouched.wat | 569 ---- tests/compiler/std/map.optimized.wat | 4 +- tests/compiler/std/map.untouched.wat | 176 +- tests/compiler/std/new.optimized.wat | 4 +- tests/compiler/std/new.untouched.wat | 21 +- .../std/operator-overloading.optimized.wat | 4 +- .../std/operator-overloading.untouched.wat | 55 +- tests/compiler/std/runtime.optimized.wat | 49 +- tests/compiler/std/runtime.ts | 8 +- tests/compiler/std/runtime.untouched.wat | 56 +- tests/compiler/std/set.optimized.wat | 4 +- tests/compiler/std/set.untouched.wat | 176 +- tests/compiler/std/static-array.optimized.wat | 1307 ++++++++- tests/compiler/std/static-array.ts | 2 + tests/compiler/std/static-array.untouched.wat | 134 +- tests/compiler/std/string-utf8.optimized.wat | 4 +- tests/compiler/std/string-utf8.untouched.wat | 4 +- tests/compiler/std/string.optimized.wat | 10 +- tests/compiler/std/string.untouched.wat | 124 +- tests/compiler/std/symbol.optimized.wat | 4 +- tests/compiler/std/symbol.untouched.wat | 42 +- tests/compiler/std/typedarray.optimized.wat | 50 +- tests/compiler/std/typedarray.untouched.wat | 422 +-- 91 files changed, 6426 insertions(+), 11009 deletions(-) delete mode 100644 src/codegen/array.ts delete mode 100644 src/codegen/gc.ts create mode 100644 std/assembly/collector/dummyrc.ts create mode 100644 tests/compiler/gc/README.md create mode 100644 tests/compiler/gc/_dummy.ts create mode 100644 tests/compiler/gc/global-assign.optimized.wat create mode 100644 tests/compiler/gc/global-assign.ts create mode 100644 tests/compiler/gc/global-assign.untouched.wat create mode 100644 tests/compiler/gc/global-init.optimized.wat create mode 100644 tests/compiler/gc/global-init.ts create mode 100644 tests/compiler/gc/global-init.untouched.wat create mode 100644 tests/compiler/gc/rc/README.md create mode 100644 tests/compiler/gc/rc/_dummy.ts create mode 100644 tests/compiler/gc/rc/global-assign.optimized.wat create mode 100644 tests/compiler/gc/rc/global-assign.ts create mode 100644 tests/compiler/gc/rc/global-assign.untouched.wat create mode 100644 tests/compiler/gc/rc/global-init.optimized.wat create mode 100644 tests/compiler/gc/rc/global-init.ts create mode 100644 tests/compiler/gc/rc/global-init.untouched.wat delete mode 100644 tests/compiler/std/gc-array.optimized.wat delete mode 100644 tests/compiler/std/gc-array.ts delete mode 100644 tests/compiler/std/gc-array.untouched.wat delete mode 100644 tests/compiler/std/gc-basics.optimized.wat delete mode 100644 tests/compiler/std/gc-basics.ts delete mode 100644 tests/compiler/std/gc-basics.untouched.wat delete mode 100644 tests/compiler/std/gc-integration.optimized.wat delete mode 100644 tests/compiler/std/gc-integration.ts delete mode 100644 tests/compiler/std/gc-integration.untouched.wat delete mode 100644 tests/compiler/std/gc-object.optimized.wat delete mode 100644 tests/compiler/std/gc-object.ts delete mode 100644 tests/compiler/std/gc-object.untouched.wat diff --git a/src/builtins.ts b/src/builtins.ts index 55163dbf..5868befc 100644 --- a/src/builtins.ts +++ b/src/builtins.ts @@ -48,10 +48,7 @@ import { getConstValueI64Low, getConstValueI32, getConstValueF32, - getConstValueF64, - getBinaryOp, - getBinaryLeft, - getBinaryRight + getConstValueF64 } from "./module"; import { @@ -60,14 +57,11 @@ import { Class, Field, Global, - DecoratorFlags, - Local, - Program + DecoratorFlags } from "./program"; import { - FlowFlags, - Flow + FlowFlags } from "./flow"; import { @@ -478,10 +472,18 @@ export namespace BuiltinSymbols { export const memory_grow = "~lib/memory/memory.grow"; export const memory_copy = "~lib/memory/memory.copy"; export const memory_fill = "~lib/memory/memory.fill"; + export const memory_allocate = "~lib/memory/memory.allocate"; + export const memory_free = "~lib/memory/memory.free"; + export const memory_reset = "~lib/memory/memory.reset"; // std/runtime.ts - export const CLASSID = "~lib/runtime/CLASSID"; - export const ITERATEROOTS = "~lib/runtime/ITERATEROOTS"; + export const classId = "~lib/runtime/classId"; + export const iterateRoots = "~lib/runtime/iterateRoots"; + export const allocate = "~lib/runtime/allocate"; + export const reallocate = "~lib/runtime/reallocate"; + export const register = "~lib/runtime/register"; + export const discard = "~lib/runtime/discard"; + export const makeArray = "~lib/runtime/makeArray"; // std/typedarray.ts export const Int8Array = "~lib/typedarray/Int8Array"; @@ -495,6 +497,12 @@ export namespace BuiltinSymbols { export const Uint8ClampedArray = "~lib/typedarray/Uint8ClampedArray"; export const Float32Array = "~lib/typedarray/Float32Array"; export const Float64Array = "~lib/typedarray/Float64Array"; + + // compiler generated + export const started = "~lib/started"; + export const argc = "~lib/argc"; + export const setargc = "~lib/setargc"; + export const capabilities = "~lib/capabilities"; } /** Compiles a call to a built-in function. */ @@ -3607,7 +3615,7 @@ export function compileCall( // === Internal runtime ======================================================================= - case BuiltinSymbols.CLASSID: { + case BuiltinSymbols.classId: { let type = evaluateConstantType(compiler, typeArguments, operands, reportNode); compiler.currentType = Type.u32; if (!type) return module.createUnreachable(); @@ -3615,7 +3623,7 @@ export function compileCall( if (!classReference) return module.createUnreachable(); return module.createI32(classReference.id); } - case BuiltinSymbols.ITERATEROOTS: { + case BuiltinSymbols.iterateRoots: { if ( checkTypeAbsent(typeArguments, reportNode, prototype) | checkArgsRequired(operands, 1, reportNode, compiler) diff --git a/src/codegen/array.ts b/src/codegen/array.ts deleted file mode 100644 index 42d9e4e9..00000000 --- a/src/codegen/array.ts +++ /dev/null @@ -1,281 +0,0 @@ -// TBD: managed reference handling makes this cumbersome, and there is a binaryen pass that can -// help propagating constant offsets. ideally, using operator overloads would be enough because -// it's the most flexible way to do this. - -// import { Compiler, ConversionKind, WrapMode } from "../compiler"; -// import { Class, ElementKind, Field, Local } from "../program"; -// import { Expression } from "../ast"; -// import { Type, TypeFlags } from "../types"; -// import { ExpressionRef, getExpressionId, getBinaryOp, getBinaryLeft, getBinaryRight, getConstValueI32, ExpressionId, BinaryOp, NativeType, UnaryOp } from "../module"; -// import { BuiltinSymbols } from "../builtins"; - -// export function makeArrayGet( -// compiler: Compiler, -// target: Class, -// thisExpression: Expression, -// elementExpression: Expression, -// contextualType: Type -// ): ExpressionRef { -// var type = assert(compiler.program.determineBuiltinArrayType(target)); -// var module = compiler.module; -// var outType = ( -// type.is(TypeFlags.INTEGER) && -// contextualType.is(TypeFlags.INTEGER) && -// contextualType.size > type.size -// ) ? contextualType : type; - -// var dataStart = assert(target.lookupInSelf("dataStart")); -// assert(dataStart.kind == ElementKind.FIELD); -// var dataLength = assert(target.lookupInSelf("dataLength")); -// assert(dataLength.kind == ElementKind.FIELD); - -// // compile the index expression and shift it to become the actual byteOffset -// var dynamicOffset = compiler.compileExpression( -// elementExpression, -// Type.i32, -// ConversionKind.IMPLICIT, -// WrapMode.NONE -// ); -// var alignLog2 = type.alignLog2; -// if (alignLog2) { -// dynamicOffset = module.createBinary(BinaryOp.ShlI32, -// dynamicOffset, -// module.createI32(alignLog2) -// ); -// } - -// var usizeType = compiler.options.usizeType; -// var nativeSizeType = compiler.options.nativeSizeType; -// var ptrExpr: ExpressionRef; -// var constantOffset: i32 = 0; - -// // precompute byteOffset into a constant and a dynamic part -// dynamicOffset = module.precomputeExpression(dynamicOffset); -// if (getExpressionId(dynamicOffset) == ExpressionId.Const) { -// constantOffset = getConstValueI32(dynamicOffset); -// dynamicOffset = 0; -// } else if (getExpressionId(dynamicOffset) == ExpressionId.Binary) { -// if (getBinaryOp(dynamicOffset) == BinaryOp.AddI32) { -// let left = getBinaryLeft(dynamicOffset); -// let right = getBinaryRight(dynamicOffset); -// if (getExpressionId(left) == ExpressionId.Const) { -// constantOffset = getConstValueI32(left); -// dynamicOffset = right; -// } else if (getExpressionId(right) == ExpressionId.Const) { -// constantOffset = getConstValueI32(right); -// dynamicOffset = left; -// } -// } -// } -// // ptr = this.dataStart -// ptrExpr = module.createLoad(usizeType.byteSize, true, -// compiler.compileExpression( -// thisExpression, -// target.type, -// ConversionKind.IMPLICIT, -// WrapMode.NONE -// ), -// nativeSizeType, (dataStart).memoryOffset -// ); -// // ptr = ptr + dynamicOffset -// if (dynamicOffset) { -// if (nativeSizeType == NativeType.I64) { -// ptrExpr = module.createBinary(BinaryOp.AddI64, -// ptrExpr, -// module.createUnary(UnaryOp.ExtendU32, dynamicOffset) -// ); -// } else { -// ptrExpr = module.createBinary(BinaryOp.AddI32, -// ptrExpr, -// dynamicOffset -// ); -// } -// } - -// compiler.currentType = outType; -// return module.createLoad( -// type.byteSize, -// type.is(TypeFlags.SIGNED), -// ptrExpr, -// outType.toNativeType(), -// constantOffset -// ); -// } - -// export function makeArraySet( -// compiler: Compiler, -// target: Class, -// thisExpression: Expression, -// elementExpression: Expression, -// valueExpression: Expression, -// contextualType: Type -// ): ExpressionRef { -// var type = assert(compiler.program.determineBuiltinArrayType(target)); -// return makeArraySetWithValue( -// compiler, -// target, -// thisExpression, -// elementExpression, -// compiler.compileExpression( -// valueExpression, -// type.is(TypeFlags.INTEGER | TypeFlags.VALUE) -// ? type.is(TypeFlags.LONG) -// ? type.is(TypeFlags.SIGNED) -// ? Type.i64 -// : Type.u64 -// : type.is(TypeFlags.SIGNED) -// ? Type.i32 -// : Type.u32 -// : type, -// ConversionKind.IMPLICIT, -// WrapMode.NONE -// ), -// contextualType != Type.void -// ); -// } - -// export function makeArraySetWithValue( -// compiler: Compiler, -// target: Class, -// thisExpression: Expression, -// elementExpression: Expression, -// valueExpr: ExpressionRef, -// tee: bool -// ): ExpressionRef { -// var type = assert(compiler.program.determineBuiltinArrayType(target)); -// var module = compiler.module; - -// var dataStart = assert(target.lookupInSelf("dataStart")); -// assert(dataStart.kind == ElementKind.FIELD); -// var dataLength = assert(target.lookupInSelf("dataLength")); -// assert(dataLength.kind == ElementKind.FIELD); - -// var constantOffset: i32 = 0; -// var dynamicOffset = module.precomputeExpression( -// compiler.compileExpression( -// elementExpression, -// Type.i32, -// ConversionKind.IMPLICIT, -// WrapMode.NONE -// ) -// ); -// if (getExpressionId(dynamicOffset) == ExpressionId.Const) { -// constantOffset = getConstValueI32(dynamicOffset); -// dynamicOffset = 0; -// } else if (getExpressionId(dynamicOffset) == ExpressionId.Binary) { -// if (getBinaryOp(dynamicOffset) == BinaryOp.AddI32) { -// let left = getBinaryLeft(dynamicOffset); -// let right = getBinaryRight(dynamicOffset); -// if (getExpressionId(left) == ExpressionId.Const) { -// constantOffset = getConstValueI32(left); -// dynamicOffset = right; -// } else if (getExpressionId(right) == ExpressionId.Const) { -// constantOffset = getConstValueI32(right); -// dynamicOffset = left; -// } -// } -// } - -// var program = compiler.program; -// var isManaged = type.isManaged(program) && target.type.isManaged(program); -// var usizeType = compiler.options.usizeType; -// var nativeSizeType = compiler.options.nativeSizeType; -// var thisExpr = compiler.compileExpression( -// thisExpression, -// target.type, -// ConversionKind.IMPLICIT, -// WrapMode.NONE -// ); -// var tempThis: Local | null = null; -// if (isManaged) { -// tempThis = compiler.currentFlow.getTempLocal(target.type, false); -// thisExpr = module.createTeeLocal(tempThis.index, thisExpr); -// } -// var dataStartExpr = module.createLoad(usizeType.byteSize, true, -// thisExpr, nativeSizeType, (dataStart).memoryOffset -// ); - -// var typeAlignLog2 = type.alignLog2; -// constantOffset <<= typeAlignLog2; -// if (dynamicOffset) { -// if (typeAlignLog2) { -// dynamicOffset = module.createBinary(BinaryOp.ShlI32, -// dynamicOffset, -// module.createI32(typeAlignLog2) -// ); -// } -// if (nativeSizeType == NativeType.I64) { -// dataStartExpr = module.createBinary(BinaryOp.AddI64, -// dataStartExpr, -// module.createUnary(UnaryOp.ExtendU32, dynamicOffset) -// ); -// } else { -// dataStartExpr = module.createBinary(BinaryOp.AddI32, -// dataStartExpr, -// dynamicOffset -// ); -// } -// } - -// // handle Array: value = RETAIN(value, this) -// if (isManaged) { -// let program = compiler.program; -// let retainInstance = compiler.resolver.resolveFunction(assert(program.retainPrototype), [ type, target.type ]); -// if (!retainInstance) return module.createUnreachable(); -// valueExpr = compiler.makeCallInlinePrechecked(retainInstance, [ -// valueExpr, -// module.createGetLocal(assert(tempThis).index, nativeSizeType) -// ], 0, true); - -// // handle Uint8ClampedArray: value = ~(value >> 31) & (((255 - value) >> 31) | value) -// } else if (target.internalName == BuiltinSymbols.Uint8ClampedArray) { -// let tempLocal = compiler.currentFlow.getAndFreeTempLocal(Type.i32, true); -// valueExpr = module.createBinary(BinaryOp.AndI32, -// module.createBinary(BinaryOp.XorI32, -// module.createBinary(BinaryOp.ShrI32, -// module.createTeeLocal(tempLocal.index, valueExpr), -// module.createI32(31) -// ), -// module.createI32(-1) -// ), -// module.createBinary(BinaryOp.OrI32, -// module.createBinary(BinaryOp.ShrI32, -// module.createBinary(BinaryOp.SubI32, -// module.createI32(255), -// module.createGetLocal(tempLocal.index, NativeType.I32) -// ), -// module.createI32(31) -// ), -// module.createGetLocal(tempLocal.index, NativeType.I32) -// ) -// ); -// } -// assert(!tempThis); - -// var nativeType = type.toNativeType(); - -// if (!tee) { -// compiler.currentType = Type.void; -// return module.createStore( -// type.byteSize, -// dataStartExpr, -// valueExpr, -// nativeType, -// constantOffset -// ); -// } else { -// let flow = compiler.currentFlow; -// let tempLocal = flow.getAndFreeTempLocal(type, false); -// compiler.currentType = type; -// return module.createBlock(null, [ -// module.createStore( -// type.byteSize, -// dataStartExpr, -// module.createTeeLocal(tempLocal.index, valueExpr), -// nativeType, -// constantOffset -// ), -// module.createGetLocal(tempLocal.index, nativeType) -// ], nativeType); -// } -// } diff --git a/src/codegen/gc.ts b/src/codegen/gc.ts deleted file mode 100644 index 52dde000..00000000 --- a/src/codegen/gc.ts +++ /dev/null @@ -1,156 +0,0 @@ -import { Compiler } from "../compiler"; -import { ExpressionRef, NativeType, BinaryOp } from "../module"; -import { Local, Function, Class } from "../program"; -import { Type } from "../types"; - -/** Prepares the insertion of a reference into an _uninitialized_ parent using the GC interface. */ -export function makeInsertRef( - compiler: Compiler, - valueExpr: ExpressionRef, - tempParent: Local, - nullable: bool -): ExpressionRef { - var module = compiler.module; - var program = compiler.program; - var usizeType = compiler.options.usizeType; - var nativeSizeType = compiler.options.nativeSizeType; - var flow = compiler.currentFlow; - var tempValue = flow.getTempLocal(usizeType, false); - var handle: ExpressionRef; - var fn: Function | null; - if (fn = program.linkRef) { // tracing - handle = module.createCall(fn.internalName, [ - module.createGetLocal(tempValue.index, nativeSizeType), - module.createGetLocal(tempParent.index, nativeSizeType) - ], NativeType.None); - } else if (fn = program.retainRef) { // arc - handle = module.createCall(fn.internalName, [ - module.createGetLocal(tempValue.index, nativeSizeType) - ], NativeType.None); - } else { - assert(false); - return module.createUnreachable(); - } - flow.freeTempLocal(tempValue); - if (!compiler.compileFunction(fn)) return module.createUnreachable(); - // { - // [if (value !== null)] link/retain(value[, parent]) - // } -> value - return module.createBlock(null, [ - module.createSetLocal(tempValue.index, valueExpr), - nullable - ? module.createIf( - module.createGetLocal(tempValue.index, nativeSizeType), - handle - ) - : handle, - module.createGetLocal(tempValue.index, nativeSizeType) - ], nativeSizeType); -} - -/** Prepares the replaces a reference hold by an _initialized_ parent using the GC interface. */ -export function makeReplaceRef( - compiler: Compiler, - valueExpr: ExpressionRef, - oldValueExpr: ExpressionRef, - tempParent: Local, - nullable: bool -): ExpressionRef { - var module = compiler.module; - var program = compiler.program; - var usizeType = compiler.options.usizeType; - var nativeSizeType = compiler.options.nativeSizeType; - var flow = compiler.currentFlow; - var tempValue = flow.getTempLocal(usizeType, false); - var tempOldValue = flow.getTempLocal(usizeType, false); - var handleOld: ExpressionRef; - var handleNew: ExpressionRef; - var fn1: Function | null, fn2: Function | null; - if (fn1 = program.linkRef) { // tracing - fn2 = assert(program.unlinkRef); - handleOld = module.createCall(fn2.internalName, [ - module.createGetLocal(tempOldValue.index, nativeSizeType), - module.createGetLocal(tempParent.index, nativeSizeType) - ], NativeType.None); - handleNew = module.createCall(fn1.internalName, [ - module.createGetLocal(tempValue.index, nativeSizeType), - module.createGetLocal(tempParent.index, nativeSizeType) - ], NativeType.None); - } else if (fn1 = program.retainRef) { // arc - fn2 = assert(program.releaseRef); - handleOld = module.createCall(fn2.internalName, [ - module.createGetLocal(tempOldValue.index, nativeSizeType) - ], NativeType.None); - handleNew = module.createCall(fn1.internalName, [ - module.createGetLocal(tempValue.index, nativeSizeType) - ], NativeType.None); - } else { - assert(false); - return module.createUnreachable(); - } - flow.freeTempLocal(tempValue); - flow.freeTempLocal(tempOldValue); - if (!compiler.compileFunction(fn1) || !compiler.compileFunction(fn2)) return module.createUnreachable(); - // if (value != oldValue) { - // if (oldValue !== null) unlink/release(oldValue[, parent]) - // [if (value !== null)] link/retain(value[, parent]) - // } -> value - return module.createIf( - module.createBinary(nativeSizeType == NativeType.I32 ? BinaryOp.NeI32 : BinaryOp.NeI64, - module.createTeeLocal(tempValue.index, valueExpr), - module.createTeeLocal(tempOldValue.index, oldValueExpr) - ), - module.createBlock(null, [ - module.createIf( - module.createGetLocal(tempOldValue.index, nativeSizeType), - handleOld - ), - nullable - ? module.createIf( - module.createGetLocal(tempValue.index, nativeSizeType), - handleNew - ) - : handleNew, - module.createGetLocal(tempValue.index, nativeSizeType) - ], nativeSizeType), - module.createGetLocal(tempValue.index, nativeSizeType) - ); -} - -export function makeInstanceOfClass( - compiler: Compiler, - expr: ExpressionRef, - classInstance: Class -): ExpressionRef { - var module = compiler.module; - var flow = compiler.currentFlow; - var idTemp = flow.getTempLocal(Type.i32, false); - var idExpr = module.createLoad(4, false, - module.createBinary(BinaryOp.SubI32, - expr, - module.createI32(compiler.program.runtimeHeaderSize) - ), - NativeType.I32 - ); - var label = "instanceof_" + classInstance.name + "|" + flow.pushBreakLabel(); - var conditions: ExpressionRef[] = []; - conditions.push( - module.createDrop( // br_if returns the value too - module.createBreak(label, - module.createBinary(BinaryOp.EqI32, // classId == class.id - module.createTeeLocal(idTemp.index, idExpr), - module.createI32(classInstance.id) - ), - module.createI32(1) // ? true - ) - ) - ); - // TODO: insert conditions for all possible subclasses (i.e. cat is also animal) - // TODO: simplify if there are none - conditions.push( - module.createI32(0) // : false - ); - flow.freeTempLocal(idTemp); - flow.popBreakLabel(); - return module.createBlock(label, conditions, NativeType.I32); -} diff --git a/src/common.ts b/src/common.ts index 07fe82bd..8068571d 100644 --- a/src/common.ts +++ b/src/common.ts @@ -142,10 +142,6 @@ export namespace CommonSymbols { export const this_ = "this"; export const super_ = "super"; export const constructor = "constructor"; -} - -/** Common standard library symbols. */ -export namespace LibrarySymbols { // constants export const ASC_TARGET = "ASC_TARGET"; export const ASC_NO_TREESHAKING = "ASC_NO_TREESHAKING"; @@ -182,19 +178,11 @@ export namespace LibrarySymbols { export const Mathf = "Mathf"; // runtime export const abort = "abort"; - export const ALLOCATE = "ALLOCATE"; - export const ALLOCATE_UNMANAGED = "ALLOCATE_UNMANAGED"; - export const REALLOCATE = "REALLOCATE"; - export const DISCARD = "DISCARD"; - export const REGISTER = "REGISTER"; - export const RETAIN = "RETAIN"; - export const RELEASE = "RELEASE"; - export const MOVE = "MOVE"; - export const REPLACE = "REPLACE"; - export const MAKEARRAY = "MAKEARRAY"; - // other - export const length = "length"; - export const byteLength = "byteLength"; export const pow = "pow"; export const mod = "mod"; + export const allocate = "allocate"; + export const reallocate = "reallocate"; + export const register = "register"; + export const discard = "discard"; + export const makeArray = "makeArray"; } diff --git a/src/compiler.ts b/src/compiler.ts index 1f847cde..fc6b9555 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -46,7 +46,6 @@ import { STATIC_DELIMITER, GETTER_PREFIX, SETTER_PREFIX, - LibrarySymbols, CommonSymbols, INDEX_SUFFIX } from "./common"; @@ -171,8 +170,6 @@ import { makeMap } from "./util"; -import { makeInsertRef, makeReplaceRef } from "./codegen/gc"; - /** Compilation target. */ export enum Target { /** WebAssembly with 32-bit pointers. */ @@ -442,7 +439,7 @@ export class Compiler extends DiagnosticEmitter { // set up module exports for (let file of this.program.filesByName.values()) { - if (file.source.isEntry) this.makeModuleExports(file); + if (file.source.isEntry) this.ensureModuleExports(file); } // set up gc @@ -453,24 +450,24 @@ export class Compiler extends DiagnosticEmitter { if (program.options.isWasm64) capabilities |= Capability.WASM64; if (program.gcImplemented) capabilities |= Capability.GC; if (capabilities != 0) { - module.addGlobal(CompilerSymbols.capabilities, NativeType.I32, false, module.createI32(capabilities)); - module.addGlobalExport(CompilerSymbols.capabilities, ".capabilities"); + module.addGlobal(BuiltinSymbols.capabilities, NativeType.I32, false, module.createI32(capabilities)); + module.addGlobalExport(BuiltinSymbols.capabilities, ".capabilities"); } return module; } /** Applies the respective module exports for the specified file. */ - private makeModuleExports(file: File): void { + private ensureModuleExports(file: File): void { var members = file.exports; - if (members) for (let [name, member] of members) this.makeModuleExport(name, member); + if (members) for (let [name, member] of members) this.ensureModuleExport(name, member); var exportsStar = file.exportsStar; if (exportsStar) { - for (let i = 0, k = exportsStar.length; i < k; ++i) this.makeModuleExports(exportsStar[i]); + for (let i = 0, k = exportsStar.length; i < k; ++i) this.ensureModuleExports(exportsStar[i]); } } /** Applies the respective module export(s) for the specified element. */ - private makeModuleExport(name: string, element: Element, prefix: string = ""): void { + private ensureModuleExport(name: string, element: Element, prefix: string = ""): void { switch (element.kind) { // traverse instances @@ -483,7 +480,7 @@ export class Compiler extends DiagnosticEmitter { let fullName = instance.internalName; instanceName += fullName.substring(fullName.lastIndexOf("<")); } - this.makeModuleExport(instanceName, instance, prefix); + this.ensureModuleExport(instanceName, instance, prefix); } } break; @@ -497,7 +494,7 @@ export class Compiler extends DiagnosticEmitter { let fullName = instance.internalName; instanceName += fullName.substring(fullName.lastIndexOf("<")); } - this.makeModuleExport(instanceName, instance, prefix); + this.ensureModuleExport(instanceName, instance, prefix); } } break; @@ -505,8 +502,8 @@ export class Compiler extends DiagnosticEmitter { case ElementKind.PROPERTY_PROTOTYPE: { let getter = (element).getterPrototype; let setter = (element).setterPrototype; - if (getter) this.makeModuleExport(GETTER_PREFIX + name, getter, prefix); - if (setter) this.makeModuleExport(SETTER_PREFIX + name, setter, prefix); + if (getter) this.ensureModuleExport(GETTER_PREFIX + name, getter, prefix); + if (setter) this.ensureModuleExport(SETTER_PREFIX + name, setter, prefix); break; } @@ -547,9 +544,9 @@ export class Compiler extends DiagnosticEmitter { } case ElementKind.PROPERTY: { let getter = (element).getterInstance; - if (getter) this.makeModuleExport(GETTER_PREFIX + name, getter, prefix); + if (getter) this.ensureModuleExport(GETTER_PREFIX + name, getter, prefix); let setter = (element).setterInstance; - if (setter) this.makeModuleExport(SETTER_PREFIX + name, setter, prefix); + if (setter) this.ensureModuleExport(SETTER_PREFIX + name, setter, prefix); break; } case ElementKind.FIELD: { @@ -619,18 +616,18 @@ export class Compiler extends DiagnosticEmitter { ) { for (let member of members.values()) { if (!member.is(CommonFlags.EXPORT)) continue; - this.makeModuleExport(member.name, member, subPrefix); + this.ensureModuleExport(member.name, member, subPrefix); } } else { for (let member of members.values()) { if (member.is(CommonFlags.PRIVATE)) continue; - this.makeModuleExport(member.name, member, subPrefix); + this.ensureModuleExport(member.name, member, subPrefix); } } } } - // general + // === Elements ================================================================================= /** Compiles any element. */ compileElement(element: Element, compileMembers: bool = true): void { @@ -750,7 +747,7 @@ export class Compiler extends DiagnosticEmitter { } } - // globals + // === Globals ================================================================================== compileGlobal(global: Global): bool { if (global.is(CommonFlags.COMPILED)) return true; @@ -810,7 +807,8 @@ export class Compiler extends DiagnosticEmitter { // ambient builtins like 'HEAP_BASE' need to be resolved but are added explicitly if (global.is(CommonFlags.AMBIENT) && global.hasDecorator(DecoratorFlags.BUILTIN)) return true; - var nativeType = global.type.toNativeType(); + var type = global.type; + var nativeType = type.toNativeType(); var isDeclaredConstant = global.is(CommonFlags.CONST) || global.is(CommonFlags.STATIC | CommonFlags.READONLY); // handle imports @@ -852,7 +850,7 @@ export class Compiler extends DiagnosticEmitter { } initExpr = this.compileExpression( initializerNode, - global.type, + type, ConversionKind.IMPLICIT, WrapMode.WRAP, global @@ -915,7 +913,7 @@ export class Compiler extends DiagnosticEmitter { // initialize to zero if there's no initializer } else { - initExpr = global.type.toNativeZero(module); + initExpr = type.toNativeZero(module); } var internalName = global.internalName; @@ -927,16 +925,20 @@ export class Compiler extends DiagnosticEmitter { assert(findDecorator(DecoratorKind.INLINE, global.decoratorNodes)).range, "inline" ); } - module.addGlobal(internalName, nativeType, true, global.type.toNativeZero(module)); - this.currentBody.push(module.createSetGlobal(internalName, initExpr)); - + module.addGlobal(internalName, nativeType, true, type.toNativeZero(module)); + if (type.isManaged(this.program) && this.program.retainRef) { + initExpr = this.makeInsertRef(initExpr, null, type.is(TypeFlags.NULLABLE)); + } + this.currentBody.push( + module.createSetGlobal(internalName, initExpr) + ); } else if (!global.hasDecorator(DecoratorFlags.INLINE)) { // compile normally module.addGlobal(internalName, nativeType, !isDeclaredConstant, initExpr); } return true; } - // enums + // === Enums ==================================================================================== compileEnum(element: Enum): bool { if (element.is(CommonFlags.COMPILED)) return true; @@ -1030,7 +1032,7 @@ export class Compiler extends DiagnosticEmitter { return true; } - // functions + // === Functions ================================================================================ /** Resolves the specified type arguments prior to compiling the resulting function instance. */ compileFunctionUsingTypeArguments( @@ -1117,16 +1119,16 @@ export class Compiler extends DiagnosticEmitter { // make the main function call `start` implicitly, but only once if (instance.prototype == this.program.explicitStartFunction) { - module.addGlobal(CompilerSymbols.started, NativeType.I32, true, module.createI32(0)); + module.addGlobal(BuiltinSymbols.started, NativeType.I32, true, module.createI32(0)); stmts.unshift( module.createIf( module.createUnary( UnaryOp.EqzI32, - module.createGetGlobal(CompilerSymbols.started, NativeType.I32) + module.createGetGlobal(BuiltinSymbols.started, NativeType.I32) ), module.createBlock(null, [ module.createCall("start", null, NativeType.None), - module.createSetGlobal(CompilerSymbols.started, module.createI32(1)) + module.createSetGlobal(BuiltinSymbols.started, module.createI32(1)) ]) ) ); @@ -1156,7 +1158,7 @@ export class Compiler extends DiagnosticEmitter { module.createGetLocal(thisLocalIndex, nativeSizeType) ), module.createSetLocal(thisLocalIndex, - this.makeAllocation(classInstance) + this.makeAllocation(classInstance, instance.identifierNode) ) ) ); @@ -1265,7 +1267,7 @@ export class Compiler extends DiagnosticEmitter { return true; } - // classes + // === Classes ================================================================================== compileClassUsingTypeArguments( prototype: ClassPrototype, @@ -1384,7 +1386,7 @@ export class Compiler extends DiagnosticEmitter { ); } - // memory + // === Memory =================================================================================== /** Adds a static memory segment with the specified data. */ addMemorySegment(buffer: Uint8Array, alignment: i32 = 8): MemorySegment { @@ -1395,7 +1397,144 @@ export class Compiler extends DiagnosticEmitter { return segment; } - // function table + /** Ensures that the specified string exists in static memory and returns a pointer to it. */ + ensureStaticString(stringValue: string): ExpressionRef { + var program = this.program; + var rtHeaderSize = program.runtimeHeaderSize; + var stringInstance = assert(program.stringInstance); + var stringSegment: MemorySegment; + var segments = this.stringSegments; + if (segments.has(stringValue)) { + stringSegment = segments.get(stringValue)!; // reuse + } else { + let length = stringValue.length; + let buffer = new Uint8Array(rtHeaderSize + (length << 1)); + program.writeRuntimeHeader(buffer, 0, stringInstance, length << 1); + for (let i = 0; i < length; ++i) { + writeI16(stringValue.charCodeAt(i), buffer, rtHeaderSize + (i << 1)); + } + stringSegment = this.addMemorySegment(buffer); + segments.set(stringValue, stringSegment); + } + var ref = i64_add(stringSegment.offset, i64_new(rtHeaderSize)); + this.currentType = stringInstance.type; + if (this.options.isWasm64) { + return this.module.createI64(i64_low(ref), i64_high(ref)); + } else { + assert(i64_is_u32(ref)); + return this.module.createI32(i64_low(ref)); + } + } + + ensureStaticArrayBuffer(elementType: Type, values: ExpressionRef[]): MemorySegment { + var program = this.program; + var length = values.length; + var byteSize = elementType.byteSize; + var byteLength = length * byteSize; + var bufferInstance = assert(program.arrayBufferInstance); + var runtimeHeaderSize = program.runtimeHeaderSize; + + var buf = new Uint8Array(runtimeHeaderSize + byteLength); + program.writeRuntimeHeader(buf, 0, bufferInstance, byteLength); + var pos = runtimeHeaderSize; + var nativeType = elementType.toNativeType(); + switch (nativeType) { + case NativeType.I32: { + switch (byteSize) { + case 1: { + for (let i = 0; i < length; ++i) { + let value = values[i]; + assert(getExpressionType(value) == nativeType); + assert(getExpressionId(value) == ExpressionId.Const); + writeI8(getConstValueI32(value), buf, pos); + pos += 1; + } + break; + } + case 2: { + for (let i = 0; i < length; ++i) { + let value = values[i]; + assert(getExpressionType(value) == nativeType); + assert(getExpressionId(value) == ExpressionId.Const); + writeI16(getConstValueI32(value), buf, pos); + pos += 2; + } + break; + } + case 4: { + for (let i = 0; i < length; ++i) { + let value = values[i]; + assert(getExpressionType(value) == nativeType); + assert(getExpressionId(value) == ExpressionId.Const); + writeI32(getConstValueI32(value), buf, pos); + pos += 4; + } + break; + } + default: assert(false); + } + break; + } + case NativeType.I64: { + for (let i = 0; i < length; ++i) { + let value = values[i]; + assert(getExpressionType(value) == nativeType); + assert(getExpressionId(value) == ExpressionId.Const); + writeI64(i64_new(getConstValueI64Low(value), getConstValueI64High(value)), buf, pos); + pos += 8; + } + break; + } + case NativeType.F32: { + for (let i = 0; i < length; ++i) { + let value = values[i]; + assert(getExpressionType(value) == nativeType); + assert(getExpressionId(value) == ExpressionId.Const); + writeF32(getConstValueF32(value), buf, pos); + pos += 4; + } + break; + } + case NativeType.F64: { + for (let i = 0; i < length; ++i) { + let value = values[i]; + assert(getExpressionType(value) == nativeType); + assert(getExpressionId(value) == ExpressionId.Const); + writeF64(getConstValueF64(value), buf, pos); + pos += 8; + } + break; + } + default: assert(false); + } + assert(pos == buf.length); + + return this.addMemorySegment(buf); + } + + ensureStaticArrayHeader(elementType: Type, bufferSegment: MemorySegment): MemorySegment { + var program = this.program; + var runtimeHeaderSize = program.runtimeHeaderSize; + var arrayPrototype = assert(program.arrayPrototype); + var arrayInstance = assert(this.resolver.resolveClass(arrayPrototype, [ elementType ])); + var arrayInstanceSize = arrayInstance.currentMemoryOffset; + var bufferLength = bufferSegment.buffer.length - runtimeHeaderSize; + var arrayLength = i32(bufferLength / elementType.byteSize); + + var buf = new Uint8Array(runtimeHeaderSize + arrayInstanceSize); + program.writeRuntimeHeader(buf, 0, arrayInstance, arrayInstanceSize); + + var bufferAddress32 = i64_low(bufferSegment.offset) + runtimeHeaderSize; + assert(!program.options.isWasm64); // TODO + assert(arrayInstance.writeField("data", bufferAddress32, buf, runtimeHeaderSize)); + assert(arrayInstance.writeField("dataStart", bufferAddress32, buf, runtimeHeaderSize)); + assert(arrayInstance.writeField("dataLength", bufferLength, buf, runtimeHeaderSize)); + assert(arrayInstance.writeField("length_", arrayLength, buf, runtimeHeaderSize)); + + return this.addMemorySegment(buf); + } + + // === Table ==================================================================================== /** Ensures that a table entry exists for the specified function and returns its index. */ ensureFunctionTableEntry(func: Function): i32 { @@ -1414,7 +1553,7 @@ export class Compiler extends DiagnosticEmitter { return index; } - // statements + // === Statements =============================================================================== compileTopLevelStatement(statement: Statement, body: ExpressionRef[]): void { switch (statement.kind) { @@ -2286,7 +2425,7 @@ export class Compiler extends DiagnosticEmitter { ]); } - // expressions + // === Expressions ============================================================================== /** * Compiles the value of an inlined constant element. @@ -3685,7 +3824,7 @@ export class Compiler extends DiagnosticEmitter { rightExpr = this.compileExpression(right, Type.f32, ConversionKind.IMPLICIT, WrapMode.NONE); rightType = this.currentType; if (!(instance = this.f32PowInstance)) { - let namespace = this.program.lookupGlobal(LibrarySymbols.Mathf); + let namespace = this.program.lookupGlobal(CommonSymbols.Mathf); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3694,7 +3833,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get(LibrarySymbols.pow) : null; + let prototype = namespace.members ? namespace.members.get(CommonSymbols.pow) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3727,7 +3866,7 @@ export class Compiler extends DiagnosticEmitter { ); rightType = this.currentType; if (!(instance = this.f64PowInstance)) { - let namespace = this.program.lookupGlobal(LibrarySymbols.Math); + let namespace = this.program.lookupGlobal(CommonSymbols.Math); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3736,7 +3875,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get(LibrarySymbols.pow) : null; + let prototype = namespace.members ? namespace.members.get(CommonSymbols.pow) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3977,7 +4116,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F32: { let instance = this.f32ModInstance; if (!instance) { - let namespace = this.program.lookupGlobal(LibrarySymbols.Mathf); + let namespace = this.program.lookupGlobal(CommonSymbols.Mathf); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -3986,7 +4125,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get(LibrarySymbols.mod) : null; + let prototype = namespace.members ? namespace.members.get(CommonSymbols.mod) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4008,7 +4147,7 @@ export class Compiler extends DiagnosticEmitter { case TypeKind.F64: { let instance = this.f64ModInstance; if (!instance) { - let namespace = this.program.lookupGlobal(LibrarySymbols.Math); + let namespace = this.program.lookupGlobal(CommonSymbols.Math); if (!namespace) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -4017,7 +4156,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createUnreachable(); break; } - let prototype = namespace.members ? namespace.members.get(LibrarySymbols.mod) : null; + let prototype = namespace.members ? namespace.members.get(CommonSymbols.mod) : null; if (!prototype) { this.error( DiagnosticCode.Cannot_find_name_0, @@ -5017,20 +5156,33 @@ export class Compiler extends DiagnosticEmitter { return this.module.createTeeLocal(localIndex, valueExpr); } else { this.currentType = Type.void; - return this.module.createSetLocal(localIndex, valueExpr) + return this.module.createSetLocal(localIndex, valueExpr); } } makeGlobalAssignment(global: Global, valueExpr: ExpressionRef, tee: bool): ExpressionRef { - // TBD: use REPLACE macro to keep track of managed refcounts? currently this doesn't work - // because there isn't a parent ref here. a tracing GC wouldn't need the hook at all while - // a reference counting gc doesn't need a parent. + var module = this.module; var type = global.type; assert(type != Type.void); - valueExpr = this.ensureSmallIntegerWrap(valueExpr, type); // global values must be wrapped + var nativeType = type.toNativeType(); + + // MANAGED (reference counting) + if (type.isManaged(this.program)) { + if (this.program.retainRef) { + valueExpr = this.makeReplaceRef( + valueExpr, + module.createGetGlobal(global.internalName, nativeType), + null, + type.is(TypeFlags.NULLABLE) + ); + } + + // UNMANAGED + } else { + valueExpr = this.ensureSmallIntegerWrap(valueExpr, type); // global values must be wrapped + } + if (tee) { - let module = this.module; - let nativeType = type.toNativeType(); let tempValue = this.currentFlow.getAndFreeTempLocal(type, true); this.currentType = type; return module.createBlock(null, [ @@ -5064,7 +5216,7 @@ export class Compiler extends DiagnosticEmitter { expr = module.createBlock(null, [ module.createStore(fieldType.byteSize, module.createTeeLocal(tempThis.index, thisExpr), - makeReplaceRef(this, + this.makeReplaceRef( module.createTeeLocal(tempValue.index, valueExpr), module.createLoad(fieldType.byteSize, fieldType.is(TypeFlags.SIGNED), module.createGetLocal(tempThis.index, nativeThisType), @@ -5082,7 +5234,7 @@ export class Compiler extends DiagnosticEmitter { } else { // no need for a temp local expr = module.createStore(fieldType.byteSize, module.createTeeLocal(tempThis.index, thisExpr), - makeReplaceRef(this, + this.makeReplaceRef( valueExpr, module.createLoad(fieldType.byteSize, fieldType.is(TypeFlags.SIGNED), module.createGetLocal(tempThis.index, nativeThisType), @@ -5160,7 +5312,7 @@ export class Compiler extends DiagnosticEmitter { module.createIf( module.createGetLocal(thisLocal.index, nativeSizeType), module.createGetLocal(thisLocal.index, nativeSizeType), - this.makeAllocation(classInstance) + this.makeAllocation(classInstance, expression) ) ) ) @@ -5827,10 +5979,10 @@ export class Compiler extends DiagnosticEmitter { minArguments ? module.createBinary( BinaryOp.SubI32, - module.createGetGlobal(CompilerSymbols.argc, NativeType.I32), + module.createGetGlobal(BuiltinSymbols.argc, NativeType.I32), module.createI32(minArguments) ) - : module.createGetGlobal(CompilerSymbols.argc, NativeType.I32) + : module.createGetGlobal(BuiltinSymbols.argc, NativeType.I32) ) ]), module.createUnreachable() @@ -5891,30 +6043,29 @@ export class Compiler extends DiagnosticEmitter { if (!this.argcVar) { let module = this.module; this.argcVar = module.addGlobal( - CompilerSymbols.argc, + BuiltinSymbols.argc, NativeType.I32, true, module.createI32(0) ); } - return CompilerSymbols.argc; + return BuiltinSymbols.argc; } /** Makes sure that the argument count helper setter is present and returns its name. */ private ensureArgcSet(): string { - var internalName = CompilerSymbols.setargc; if (!this.argcSet) { let module = this.module; - this.argcSet = module.addFunction(internalName, + this.argcSet = module.addFunction(BuiltinSymbols.setargc, this.ensureFunctionType([ Type.u32 ], Type.void), null, module.createSetGlobal(this.ensureArgcVar(), module.createGetLocal(0, NativeType.I32) ) ); - module.addFunctionExport(internalName, ".setargc"); + module.addFunctionExport(BuiltinSymbols.setargc, ".setargc"); } - return internalName; + return BuiltinSymbols.setargc; } /** Creates a direct call to the specified function. */ @@ -6357,7 +6508,7 @@ export class Compiler extends DiagnosticEmitter { module.createGetLocal(thisLocal.index, nativeSizeType) ), module.createSetLocal(thisLocal.index, - this.makeAllocation(classInstance) + this.makeAllocation(classInstance, expression) ) ) ]; @@ -6605,147 +6756,10 @@ export class Compiler extends DiagnosticEmitter { return module.createUnreachable(); } - /** Ensures that the specified string exists in static memory and returns a pointer to it. */ - ensureStaticString(stringValue: string): ExpressionRef { - var program = this.program; - var rtHeaderSize = program.runtimeHeaderSize; - var stringInstance = assert(program.stringInstance); - var stringSegment: MemorySegment; - var segments = this.stringSegments; - if (segments.has(stringValue)) { - stringSegment = segments.get(stringValue)!; // reuse - } else { - let length = stringValue.length; - let buffer = new Uint8Array(rtHeaderSize + (length << 1)); - program.writeRuntimeHeader(buffer, 0, stringInstance, length << 1); - for (let i = 0; i < length; ++i) { - writeI16(stringValue.charCodeAt(i), buffer, rtHeaderSize + (i << 1)); - } - stringSegment = this.addMemorySegment(buffer); - segments.set(stringValue, stringSegment); - } - var ref = i64_add(stringSegment.offset, i64_new(rtHeaderSize)); - this.currentType = stringInstance.type; - if (this.options.isWasm64) { - return this.module.createI64(i64_low(ref), i64_high(ref)); - } else { - assert(i64_is_u32(ref)); - return this.module.createI32(i64_low(ref)); - } - } - compileStringLiteral(expression: StringLiteralExpression): ExpressionRef { return this.ensureStaticString(expression.value); } - ensureStaticArrayBuffer(elementType: Type, values: ExpressionRef[]): MemorySegment { - var program = this.program; - var length = values.length; - var byteSize = elementType.byteSize; - var byteLength = length * byteSize; - var bufferInstance = assert(program.arrayBufferInstance); - var runtimeHeaderSize = program.runtimeHeaderSize; - - var buf = new Uint8Array(runtimeHeaderSize + byteLength); - program.writeRuntimeHeader(buf, 0, bufferInstance, byteLength); - var pos = runtimeHeaderSize; - var nativeType = elementType.toNativeType(); - switch (nativeType) { - case NativeType.I32: { - switch (byteSize) { - case 1: { - for (let i = 0; i < length; ++i) { - let value = values[i]; - assert(getExpressionType(value) == nativeType); - assert(getExpressionId(value) == ExpressionId.Const); - writeI8(getConstValueI32(value), buf, pos); - pos += 1; - } - break; - } - case 2: { - for (let i = 0; i < length; ++i) { - let value = values[i]; - assert(getExpressionType(value) == nativeType); - assert(getExpressionId(value) == ExpressionId.Const); - writeI16(getConstValueI32(value), buf, pos); - pos += 2; - } - break; - } - case 4: { - for (let i = 0; i < length; ++i) { - let value = values[i]; - assert(getExpressionType(value) == nativeType); - assert(getExpressionId(value) == ExpressionId.Const); - writeI32(getConstValueI32(value), buf, pos); - pos += 4; - } - break; - } - default: assert(false); - } - break; - } - case NativeType.I64: { - for (let i = 0; i < length; ++i) { - let value = values[i]; - assert(getExpressionType(value) == nativeType); - assert(getExpressionId(value) == ExpressionId.Const); - writeI64(i64_new(getConstValueI64Low(value), getConstValueI64High(value)), buf, pos); - pos += 8; - } - break; - } - case NativeType.F32: { - for (let i = 0; i < length; ++i) { - let value = values[i]; - assert(getExpressionType(value) == nativeType); - assert(getExpressionId(value) == ExpressionId.Const); - writeF32(getConstValueF32(value), buf, pos); - pos += 4; - } - break; - } - case NativeType.F64: { - for (let i = 0; i < length; ++i) { - let value = values[i]; - assert(getExpressionType(value) == nativeType); - assert(getExpressionId(value) == ExpressionId.Const); - writeF64(getConstValueF64(value), buf, pos); - pos += 8; - } - break; - } - default: assert(false); - } - assert(pos == buf.length); - - return this.addMemorySegment(buf); - } - - ensureStaticArrayHeader(elementType: Type, bufferSegment: MemorySegment): MemorySegment { - var program = this.program; - var runtimeHeaderSize = program.runtimeHeaderSize; - var arrayPrototype = assert(program.arrayPrototype); - var arrayInstance = assert(this.resolver.resolveClass(arrayPrototype, [ elementType ])); - var arrayInstanceSize = arrayInstance.currentMemoryOffset; - var bufferLength = bufferSegment.buffer.length - runtimeHeaderSize; - var arrayLength = i32(bufferLength / elementType.byteSize); - - var buf = new Uint8Array(runtimeHeaderSize + arrayInstanceSize); - program.writeRuntimeHeader(buf, 0, arrayInstance, arrayInstanceSize); - - var bufferAddress32 = i64_low(bufferSegment.offset) + runtimeHeaderSize; - assert(!program.options.isWasm64); // TODO - assert(arrayInstance.writeField("data", bufferAddress32, buf, runtimeHeaderSize)); - assert(arrayInstance.writeField("dataStart", bufferAddress32, buf, runtimeHeaderSize)); - assert(arrayInstance.writeField("dataLength", bufferLength, buf, runtimeHeaderSize)); - assert(arrayInstance.writeField("length_", arrayLength, buf, runtimeHeaderSize)); - - return this.addMemorySegment(buf); - } - compileArrayLiteral( elementType: Type, expressions: (Expression | null)[], @@ -6804,19 +6818,19 @@ export class Compiler extends DiagnosticEmitter { // otherwise allocate a new array header and make it wrap a copy of the static buffer } else { - let makeArrayInstance = this.resolver.resolveFunction(assert(program.makeArrayPrototype), [ elementType ]); - if (!makeArrayInstance) { - this.currentType = arrayType; - return module.createUnreachable(); - } - let body = this.makeCallInlinePrechecked(makeArrayInstance, [ - this.module.createI32(length), + // makeArray(length, classId, alignLog2, staticBuffer) + let expr = this.makeCallDirect(assert(program.makeArrayInstance), [ + module.createI32(length), + module.createI32(arrayInstance.id), program.options.isWasm64 - ? this.module.createI64(i64_low(bufferAddress), i64_high(bufferAddress)) - : this.module.createI32(i64_low(bufferAddress)) - ], 0, true); + ? module.createI64(elementType.alignLog2) + : module.createI32(elementType.alignLog2), + program.options.isWasm64 + ? module.createI64(i64_low(bufferAddress), i64_high(bufferAddress)) + : module.createI32(i64_low(bufferAddress)) + ], reportNode); this.currentType = arrayType; - return body; + return expr; } } @@ -6834,18 +6848,21 @@ export class Compiler extends DiagnosticEmitter { var flow = this.currentFlow; var tempThis = flow.getTempLocal(arrayType, false); var tempDataStart = flow.getTempLocal(arrayBufferInstance.type); - var makeArrayInstance = this.resolver.resolveFunction(assert(program.makeArrayPrototype), [ elementType ]); - if (!makeArrayInstance) { - this.currentType = arrayType; - return module.createUnreachable(); - } + var makeArrayInstance = assert(program.makeArrayInstance); var stmts = new Array(); - // tempThis = MAKEARRAY(length) + // tempThis = makeArray(length, classId, alignLog2, source = 0) stmts.push( module.createSetLocal(tempThis.index, - this.makeCallInlinePrechecked(makeArrayInstance, [ - module.createI32(length) - ], 0, true), + this.makeCallDirect(makeArrayInstance, [ + module.createI32(length), + module.createI32(arrayInstance.id), + program.options.isWasm64 + ? module.createI64(elementType.alignLog2) + : module.createI32(elementType.alignLog2), + program.options.isWasm64 + ? module.createI64(0) + : module.createI32(0) + ], reportNode), ) ); // tempData = tempThis.dataStart @@ -6868,7 +6885,7 @@ export class Compiler extends DiagnosticEmitter { : elementType.toNativeZero(module); if (isManaged) { // value = link/retain(value[, tempThis]) - valueExpr = makeInsertRef(this, + valueExpr = this.makeInsertRef( valueExpr, tempThis, elementType.is(TypeFlags.NULLABLE) @@ -6970,12 +6987,13 @@ export class Compiler extends DiagnosticEmitter { // allocate a new instance first and assign 'this' to the temp. local exprs[0] = module.createSetLocal( tempLocal.index, - this.makeAllocation(classReference) + this.makeAllocation(classReference, expression) ); // once all field values have been set, return 'this' exprs[exprs.length - 1] = module.createGetLocal(tempLocal.index, this.options.nativeSizeType); + this.currentType = classReference.type; return module.createBlock(null, exprs, this.options.nativeSizeType); } @@ -7090,7 +7108,7 @@ export class Compiler extends DiagnosticEmitter { module.createGetLocal(0, nativeSizeType) ), module.createSetLocal(0, - this.makeAllocation(classInstance) + this.makeAllocation(classInstance, reportNode) ) ) ); @@ -7978,6 +7996,17 @@ export class Compiler extends DiagnosticEmitter { return expr; } + /** Adds the debug location of the specified expression at the specified range to the source map. */ + addDebugLocation(expr: ExpressionRef, range: Range): void { + var parentFunction = this.currentFlow.parentFunction; + var source = range.source; + if (source.debugInfoIndex < 0) source.debugInfoIndex = this.module.addDebugInfoFile(source.normalizedPath); + range.debugInfoRef = expr; + parentFunction.debugLocations.push(range); + } + + // === Specialized code generation ============================================================== + /** Creates a comparison whether an expression is 'false' in a broader sense. */ makeIsFalseish(expr: ExpressionRef, type: Type): ExpressionRef { var module = this.module; @@ -8055,49 +8084,41 @@ export class Compiler extends DiagnosticEmitter { } /** Makes an allocation suitable to hold the data of an instance of the given class. */ - makeAllocation(classInstance: Class): ExpressionRef { + makeAllocation(classInstance: Class, reportNode: Node): ExpressionRef { var program = this.program; assert(classInstance.program == program); var module = this.module; var options = this.options; var classType = classInstance.type; - var body: ExpressionRef; if (classInstance.hasDecorator(DecoratorFlags.UNMANAGED)) { - // ALLOCATE_UNMANAGED(sizeof()) - let allocateInstance = assert(program.allocateUnmanagedInstance); - body = this.makeCallInlinePrechecked(allocateInstance, [ + // memory.allocate(sizeof()) + this.currentType = classType; + return this.makeCallDirect(assert(program.memoryAllocateInstance), [ options.isWasm64 ? module.createI64(classInstance.currentMemoryOffset) : module.createI32(classInstance.currentMemoryOffset) - ], 0, true); - - this.currentType = classType; - return body; + ], reportNode); } else { - // REGISTER(ALLOCATE(sizeof())) - let allocateInstance = assert(program.allocateInstance); - let registerPrototype = assert(program.registerPrototype); - let registerInstance = this.resolver.resolveFunction(registerPrototype, [ classType ]); - if (!registerInstance) { - this.currentType = classType; - return module.createUnreachable(); - } - body = this.makeCallInlinePrechecked(registerInstance, [ - this.makeCallInlinePrechecked(allocateInstance, [ + // register(allocate(sizeof()), classId) + this.currentType = classType; + return this.makeCallDirect(assert(program.registerInstance), [ + this.makeCallDirect(assert(program.allocateInstance), [ options.isWasm64 ? module.createI64(classInstance.currentMemoryOffset) : module.createI32(classInstance.currentMemoryOffset) - ], 0, true) - ], 0, true); + ], reportNode), + module.createI32(classInstance.id) + ], reportNode); } - this.currentType = classType; - return body; } /** Makes the initializers for a class's fields. */ - makeFieldInitialization(classInstance: Class, stmts: ExpressionRef[] = []): ExpressionRef[] { + makeFieldInitialization( + classInstance: Class, + stmts: ExpressionRef[] = [] + ): ExpressionRef[] { var members = classInstance.members; if (!members) return []; @@ -8155,13 +8176,154 @@ export class Compiler extends DiagnosticEmitter { return stmts; } - /** Adds the debug location of the specified expression at the specified range to the source map. */ - addDebugLocation(expr: ExpressionRef, range: Range): void { - var parentFunction = this.currentFlow.parentFunction; - var source = range.source; - if (source.debugInfoIndex < 0) source.debugInfoIndex = this.module.addDebugInfoFile(source.normalizedPath); - range.debugInfoRef = expr; - parentFunction.debugLocations.push(range); + /** Prepares the insertion of a reference into an _uninitialized_ parent using the GC interface. */ + makeInsertRef( + valueExpr: ExpressionRef, + tempParent: Local | null, + nullable: bool + ): ExpressionRef { + var module = this.module; + var program = this.program; + var usizeType = this.options.usizeType; + var nativeSizeType = this.options.nativeSizeType; + var flow = this.currentFlow; + var tempValue = flow.getTempLocal(usizeType, false); + var handle: ExpressionRef; + var fn: Function | null; + if (fn = program.linkRef) { // tracing + handle = module.createCall(fn.internalName, [ + module.createGetLocal(tempValue.index, nativeSizeType), + module.createGetLocal(assert(tempParent).index, nativeSizeType) + ], NativeType.None); + } else if (fn = program.retainRef) { // arc + handle = module.createCall(fn.internalName, [ + module.createGetLocal(tempValue.index, nativeSizeType) + ], NativeType.None); + } else { + assert(false); + return module.createUnreachable(); + } + flow.freeTempLocal(tempValue); + if (!this.compileFunction(fn)) return module.createUnreachable(); + // { + // [if (value !== null)] link/retain(value[, parent]) + // } -> value + return module.createBlock(null, [ + module.createSetLocal(tempValue.index, valueExpr), + nullable + ? module.createIf( + module.createGetLocal(tempValue.index, nativeSizeType), + handle + ) + : handle, + module.createGetLocal(tempValue.index, nativeSizeType) + ], nativeSizeType); + } + + /** Prepares the replaces a reference hold by an _initialized_ parent using the GC interface. */ + makeReplaceRef( + valueExpr: ExpressionRef, + oldValueExpr: ExpressionRef, + tempParent: Local | null, + nullable: bool + ): ExpressionRef { + var module = this.module; + var program = this.program; + var usizeType = this.options.usizeType; + var nativeSizeType = this.options.nativeSizeType; + var flow = this.currentFlow; + var tempValue = flow.getTempLocal(usizeType, false); + var tempOldValue = flow.getTempLocal(usizeType, false); + var handleOld: ExpressionRef; + var handleNew: ExpressionRef; + var fn1: Function | null, fn2: Function | null; + if (fn1 = program.linkRef) { // tracing + tempParent = assert(tempParent); + fn2 = assert(program.unlinkRef); + handleOld = module.createCall(fn2.internalName, [ + module.createGetLocal(tempOldValue.index, nativeSizeType), + module.createGetLocal(tempParent.index, nativeSizeType) + ], NativeType.None); + handleNew = module.createCall(fn1.internalName, [ + module.createGetLocal(tempValue.index, nativeSizeType), + module.createGetLocal(tempParent.index, nativeSizeType) + ], NativeType.None); + } else if (fn1 = program.retainRef) { // arc + fn2 = assert(program.releaseRef); + handleOld = module.createCall(fn2.internalName, [ + module.createGetLocal(tempOldValue.index, nativeSizeType) + ], NativeType.None); + handleNew = module.createCall(fn1.internalName, [ + module.createGetLocal(tempValue.index, nativeSizeType) + ], NativeType.None); + } else { + assert(false); + return module.createUnreachable(); + } + flow.freeTempLocal(tempValue); + flow.freeTempLocal(tempOldValue); + if (!this.compileFunction(fn1) || !this.compileFunction(fn2)) return module.createUnreachable(); + // if (value != oldValue) { + // if (oldValue !== null) unlink/release(oldValue[, parent]) + // [if (value !== null)] link/retain(value[, parent]) + // } -> value + return module.createIf( + module.createBinary(nativeSizeType == NativeType.I32 ? BinaryOp.NeI32 : BinaryOp.NeI64, + module.createTeeLocal(tempValue.index, valueExpr), + module.createTeeLocal(tempOldValue.index, oldValueExpr) + ), + module.createBlock(null, [ + module.createIf( + module.createGetLocal(tempOldValue.index, nativeSizeType), + handleOld + ), + nullable + ? module.createIf( + module.createGetLocal(tempValue.index, nativeSizeType), + handleNew + ) + : handleNew, + module.createGetLocal(tempValue.index, nativeSizeType) + ], nativeSizeType), + module.createGetLocal(tempValue.index, nativeSizeType) + ); + } + + makeInstanceOfClass( + expr: ExpressionRef, + classInstance: Class + ): ExpressionRef { + var module = this.module; + var flow = this.currentFlow; + var idTemp = flow.getTempLocal(Type.i32, false); + var idExpr = module.createLoad(4, false, + module.createBinary(BinaryOp.SubI32, + expr, + module.createI32(this.program.runtimeHeaderSize) + ), + NativeType.I32 + ); + var label = "instanceof_" + classInstance.name + "|" + flow.pushBreakLabel(); + var conditions: ExpressionRef[] = []; + conditions.push( + module.createDrop( // br_if returns the value too + module.createBreak(label, + module.createBinary(BinaryOp.EqI32, // classId == class.id + module.createTeeLocal(idTemp.index, idExpr), + module.createI32(classInstance.id) + ), + module.createI32(1) // ? true + ) + ) + ); + // TODO: insert conditions for all possible subclasses (i.e. cat is also animal) + // TODO: simplify if there are none + conditions.push( + module.createI32(0) // : false + ); + flow.freeTempLocal(idTemp); + flow.popBreakLabel(); + return module.createBlock(label, conditions, NativeType.I32); } } @@ -8222,15 +8384,3 @@ function mangleImportName( var mangleImportName_moduleName: string; var mangleImportName_elementName: string; - -/** Special compiler symbols. */ -namespace CompilerSymbols { - /** Module started global. Used if an explicit start function is present. */ - export const started = "~lib/started"; - /** Argument count global. Used to call trampolines for varargs functions. */ - export const argc = "~lib/argc"; - /** Argument count setter. Exported for use by host calls. */ - export const setargc = "~lib/setargc"; - /** Module capabilities. Exported for evaluation by the host. */ - export const capabilities = "~lib/capabilities"; -} diff --git a/src/program.ts b/src/program.ts index db976f6f..9cff3fc7 100644 --- a/src/program.ts +++ b/src/program.ts @@ -13,8 +13,7 @@ import { INNER_DELIMITER, LIBRARY_SUBST, INDEX_SUFFIX, - CommonSymbols, - LibrarySymbols + CommonSymbols } from "./common"; import { @@ -355,18 +354,18 @@ export class Program extends DiagnosticEmitter { /** Abort function reference, if present. */ abortInstance: Function | null = null; - /** Runtime allocation macro. `ALLOCATE(payloadSize: usize): usize` */ + /** Runtime allocation function. `allocate(payloadSize: usize): usize` */ allocateInstance: Function | null = null; - /** Unmanaged allocation macro. `ALLOCATE_UNMANAGED(size: usize): usize` */ - allocateUnmanagedInstance: Function | null = null; - /** Runtime reallocation macro. `REALLOCATE(ref: usize, newPayloadSize: usize): usize` */ + /** Memory allocation function. `memory.allocate(size)` */ + memoryAllocateInstance: Function | null = null; + /** Runtime reallocation function. `reallocate(ref: usize, newPayloadSize: usize): usize` */ reallocateInstance: Function | null = null; - /** Runtime discard macro. `DISCARD(ref: usize): void` */ + /** Runtime discard function. `discard(ref: usize): void` */ discardInstance: Function | null = null; - /** Runtime register macro. `REGISTER(ref: usize): T` */ - registerPrototype: FunctionPrototype | null = null; - /** Runtime make array macro. `MAKEARRAY(capacity: i32, source: usize = 0): Array` */ - makeArrayPrototype: FunctionPrototype | null = null; + /** Runtime register function. `register(ref: usize, cid: u32): usize` */ + registerInstance: Function | null = null; + /** Runtime make array function. `makeArray(capacity: i32, source: usize = 0, cid: u32): usize` */ + makeArrayInstance: Function | null = null; linkRef: Function | null = null; unlinkRef: Function | null = null; @@ -542,25 +541,25 @@ export class Program extends DiagnosticEmitter { if (options.hasFeature(Feature.SIMD)) this.registerNativeType(CommonSymbols.v128, Type.v128); // register compiler hints - this.registerConstantInteger(LibrarySymbols.ASC_TARGET, Type.i32, + this.registerConstantInteger(CommonSymbols.ASC_TARGET, Type.i32, i64_new(options.isWasm64 ? 2 : 1)); - this.registerConstantInteger(LibrarySymbols.ASC_NO_ASSERT, Type.bool, + this.registerConstantInteger(CommonSymbols.ASC_NO_ASSERT, Type.bool, i64_new(options.noAssert ? 1 : 0, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_MEMORY_BASE, Type.i32, + this.registerConstantInteger(CommonSymbols.ASC_MEMORY_BASE, Type.i32, i64_new(options.memoryBase, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_OPTIMIZE_LEVEL, Type.i32, + this.registerConstantInteger(CommonSymbols.ASC_OPTIMIZE_LEVEL, Type.i32, i64_new(options.optimizeLevelHint, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_SHRINK_LEVEL, Type.i32, + this.registerConstantInteger(CommonSymbols.ASC_SHRINK_LEVEL, Type.i32, i64_new(options.shrinkLevelHint, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_MUTABLE_GLOBAL, Type.bool, + this.registerConstantInteger(CommonSymbols.ASC_FEATURE_MUTABLE_GLOBAL, Type.bool, i64_new(options.hasFeature(Feature.MUTABLE_GLOBAL) ? 1 : 0, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_SIGN_EXTENSION, Type.bool, + this.registerConstantInteger(CommonSymbols.ASC_FEATURE_SIGN_EXTENSION, Type.bool, i64_new(options.hasFeature(Feature.SIGN_EXTENSION) ? 1 : 0, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_BULK_MEMORY, Type.bool, + this.registerConstantInteger(CommonSymbols.ASC_FEATURE_BULK_MEMORY, Type.bool, i64_new(options.hasFeature(Feature.BULK_MEMORY) ? 1 : 0, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_SIMD, Type.bool, + this.registerConstantInteger(CommonSymbols.ASC_FEATURE_SIMD, Type.bool, i64_new(options.hasFeature(Feature.SIMD) ? 1 : 0, 0)); - this.registerConstantInteger(LibrarySymbols.ASC_FEATURE_THREADS, Type.bool, + this.registerConstantInteger(CommonSymbols.ASC_FEATURE_THREADS, Type.bool, i64_new(options.hasFeature(Feature.THREADS) ? 1 : 0, 0)); // remember deferred elements @@ -720,20 +719,20 @@ export class Program extends DiagnosticEmitter { } // register classes backing basic types - this.registerNativeTypeClass(TypeKind.I8, LibrarySymbols.I8); - this.registerNativeTypeClass(TypeKind.I16, LibrarySymbols.I16); - this.registerNativeTypeClass(TypeKind.I32, LibrarySymbols.I32); - this.registerNativeTypeClass(TypeKind.I64, LibrarySymbols.I64); - this.registerNativeTypeClass(TypeKind.ISIZE, LibrarySymbols.Isize); - this.registerNativeTypeClass(TypeKind.U8, LibrarySymbols.U8); - this.registerNativeTypeClass(TypeKind.U16, LibrarySymbols.U16); - this.registerNativeTypeClass(TypeKind.U32, LibrarySymbols.U32); - this.registerNativeTypeClass(TypeKind.U64, LibrarySymbols.U64); - this.registerNativeTypeClass(TypeKind.USIZE, LibrarySymbols.Usize); - this.registerNativeTypeClass(TypeKind.BOOL, LibrarySymbols.Bool); - this.registerNativeTypeClass(TypeKind.F32, LibrarySymbols.F32); - this.registerNativeTypeClass(TypeKind.F64, LibrarySymbols.F64); - if (options.hasFeature(Feature.SIMD)) this.registerNativeTypeClass(TypeKind.V128, LibrarySymbols.V128); + this.registerNativeTypeClass(TypeKind.I8, CommonSymbols.I8); + this.registerNativeTypeClass(TypeKind.I16, CommonSymbols.I16); + this.registerNativeTypeClass(TypeKind.I32, CommonSymbols.I32); + this.registerNativeTypeClass(TypeKind.I64, CommonSymbols.I64); + this.registerNativeTypeClass(TypeKind.ISIZE, CommonSymbols.Isize); + this.registerNativeTypeClass(TypeKind.U8, CommonSymbols.U8); + this.registerNativeTypeClass(TypeKind.U16, CommonSymbols.U16); + this.registerNativeTypeClass(TypeKind.U32, CommonSymbols.U32); + this.registerNativeTypeClass(TypeKind.U64, CommonSymbols.U64); + this.registerNativeTypeClass(TypeKind.USIZE, CommonSymbols.Usize); + this.registerNativeTypeClass(TypeKind.BOOL, CommonSymbols.Bool); + this.registerNativeTypeClass(TypeKind.F32, CommonSymbols.F32); + this.registerNativeTypeClass(TypeKind.F64, CommonSymbols.F64); + if (options.hasFeature(Feature.SIMD)) this.registerNativeTypeClass(TypeKind.V128, CommonSymbols.V128); // resolve base prototypes of derived classes var resolver = this.resolver; @@ -785,56 +784,56 @@ export class Program extends DiagnosticEmitter { } } - // register global library elements + // register library elements { let element: Element | null; - if (element = this.lookupGlobal(LibrarySymbols.ArrayBufferView)) { + if (element = this.lookupGlobal(CommonSymbols.ArrayBufferView)) { assert(element.kind == ElementKind.CLASS_PROTOTYPE); this.arrayBufferViewInstance = resolver.resolveClass(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.ArrayBuffer)) { + if (element = this.lookupGlobal(CommonSymbols.ArrayBuffer)) { assert(element.kind == ElementKind.CLASS_PROTOTYPE); this.arrayBufferInstance = resolver.resolveClass(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.String)) { + if (element = this.lookupGlobal(CommonSymbols.String)) { assert(element.kind == ElementKind.CLASS_PROTOTYPE); this.stringInstance = resolver.resolveClass(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.Array)) { + if (element = this.lookupGlobal(CommonSymbols.Array)) { assert(element.kind == ElementKind.CLASS_PROTOTYPE); this.arrayPrototype = element; } - if (element = this.lookupGlobal(LibrarySymbols.FixedArray)) { + if (element = this.lookupGlobal(CommonSymbols.FixedArray)) { assert(element.kind == ElementKind.CLASS_PROTOTYPE); this.fixedArrayPrototype = element; } - if (element = this.lookupGlobal(LibrarySymbols.abort)) { + if (element = this.lookupGlobal(CommonSymbols.abort)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); this.abortInstance = this.resolver.resolveFunction(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.ALLOCATE)) { + if (element = this.lookupGlobal(BuiltinSymbols.allocate)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); this.allocateInstance = this.resolver.resolveFunction(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.ALLOCATE_UNMANAGED)) { + if (element = this.lookupGlobal(BuiltinSymbols.memory_allocate)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - this.allocateUnmanagedInstance = this.resolver.resolveFunction(element, null); + this.memoryAllocateInstance = this.resolver.resolveFunction(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.REALLOCATE)) { + if (element = this.lookupGlobal(BuiltinSymbols.reallocate)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); this.reallocateInstance = this.resolver.resolveFunction(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.DISCARD)) { + if (element = this.lookupGlobal(BuiltinSymbols.discard)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); this.discardInstance = this.resolver.resolveFunction(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.REGISTER)) { + if (element = this.lookupGlobal(BuiltinSymbols.register)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - this.registerPrototype = element; + this.registerInstance = this.resolver.resolveFunction(element, null); } - if (element = this.lookupGlobal(LibrarySymbols.MAKEARRAY)) { + if (element = this.lookupGlobal(BuiltinSymbols.makeArray)) { assert(element.kind == ElementKind.FUNCTION_PROTOTYPE); - this.makeArrayPrototype = element; + this.makeArrayInstance = this.resolver.resolveFunction(element, null); } if (this.lookupGlobal("__ref_collect")) { if (element = this.lookupGlobal("__ref_link")) { @@ -970,6 +969,13 @@ export class Program extends DiagnosticEmitter { return null; } + /** Looks up the element of the specified name in the global scope. Errors if not present. */ + requireGlobal(name: string): Element { + var elements = this.elementsByName; + if (elements.has(name)) return elements.get(name)!; + throw new Error("missing global"); + } + /** Tries to locate a foreign file given its normalized path. */ private lookupForeignFile( /** Normalized path to the other file. */ diff --git a/std/assembly/collector/README.md b/std/assembly/collector/README.md index 7f66d802..c1d7ae40 100644 --- a/std/assembly/collector/README.md +++ b/std/assembly/collector/README.md @@ -7,7 +7,7 @@ Common ------ * **__ref_collect**()
- Triggers a full garbage collection cycle. + Triggers a full garbage collection cycle. Also indicates the presence of a GC. Tracing ------- @@ -24,14 +24,15 @@ Tracing Reference counting ------------------ +* **__ref_register**(ref: `usize`)
+ Sets up a new reference. Implementation is optional for reference counting GCs. + * **__ref_retain**(ref: `usize`)
Retains a reference, usually incrementing RC. * **__ref_release**(ref: `usize`)
Releases a reference, usually decrementing RC. -Reference counting may also implement `__ref_register` if necessary. - Typical patterns ---------------- diff --git a/std/assembly/collector/dummy.ts b/std/assembly/collector/dummy.ts index 86b5dd22..98690829 100644 --- a/std/assembly/collector/dummy.ts +++ b/std/assembly/collector/dummy.ts @@ -1,8 +1,8 @@ -// A dummy GC for looking at generated GC code without actually implementing it. +// A tracing dummy GC. // @ts-ignore: decorator @inline -const TRACE = false; +const TRACE = isDefined(GC_TRACE); // @ts-ignore: decorator @global @unsafe @@ -29,17 +29,3 @@ function __ref_link(ref: usize, parentRef: usize): void { function __ref_unlink(ref: usize, parentRef: usize): void { if (TRACE) trace("dummy.unlink", 2, ref, parentRef); } - -// Reference counting - -// // @ts-ignore: decorator -// @global @unsafe -// function __ref_retain(ref: usize): void { -// if (TRACE) trace("dummy.retain", 1, ref); -// } - -// // @ts-ignore: decorator -// @global @unsafe -// function __ref_release(ref: usize): void { -// if (TRACE) trace("dummy.release", 1, ref); -// } diff --git a/std/assembly/collector/dummyrc.ts b/std/assembly/collector/dummyrc.ts new file mode 100644 index 00000000..676e8deb --- /dev/null +++ b/std/assembly/collector/dummyrc.ts @@ -0,0 +1,29 @@ +// A reference counting dummy GC. + +// @ts-ignore: decorator +@inline +const TRACE = isDefined(GC_TRACE); + +// @ts-ignore: decorator +@global @unsafe +function __ref_register(ref: usize): void { + if (TRACE) trace("dummyrc.register", 1, ref); +} + +// @ts-ignore: decorator +@global @unsafe +function __ref_collect(): void { + if (TRACE) trace("dummyrc.collect"); +} + +// @ts-ignore: decorator +@global @unsafe +function __ref_retain(ref: usize): void { + if (TRACE) trace("dummyrc.retain", 1, ref); +} + +// @ts-ignore: decorator +@global @unsafe +function __ref_release(ref: usize): void { + if (TRACE) trace("dummyrc.release", 1, ref); +} diff --git a/std/assembly/collector/itcm.ts b/std/assembly/collector/itcm.ts index c38696b1..cd16fcf2 100644 --- a/std/assembly/collector/itcm.ts +++ b/std/assembly/collector/itcm.ts @@ -4,7 +4,7 @@ @inline const TRACE = false; -import { ITERATEROOTS, HEADER_SIZE } from "../runtime"; +import { iterateRoots, HEADER_SIZE } from "../runtime"; /** Collector states. */ const enum State { @@ -141,7 +141,7 @@ function step(): void { } case State.IDLE: { if (TRACE) trace("gc~step/IDLE"); - ITERATEROOTS((ref: usize): void => { + iterateRoots((ref: usize): void => { var obj = refToObj(ref); if (obj.color == white) obj.makeGray(); }); @@ -165,7 +165,7 @@ function step(): void { obj.hookFn(objToRef(obj)); } else { if (TRACE) trace("gc~step/MARK finish"); - ITERATEROOTS((ref: usize): void => { + iterateRoots((ref: usize): void => { var obj = refToObj(ref); if (obj.color == white) obj.makeGray(); }); diff --git a/std/assembly/runtime.ts b/std/assembly/runtime.ts index 3eb29c5a..2d253cce 100644 --- a/std/assembly/runtime.ts +++ b/std/assembly/runtime.ts @@ -39,12 +39,12 @@ export const HEADER_MAGIC: u32 = 0xA55E4B17; /** Gets the computed unique class id of a class type. */ // @ts-ignore: decorator @unsafe @builtin -export declare function CLASSID(): u32; +export declare function classId(): u32; /** Iterates over all root objects of a reference type. */ // @ts-ignore: decorator @unsafe @builtin -export declare function ITERATEROOTS(fn: (ref: usize) => void): void; +export declare function iterateRoots(fn: (ref: usize) => void): void; /** Adjusts an allocation to actual block size. Primarily targets TLSF. */ export function ADJUSTOBLOCK(payloadSize: usize): usize { @@ -78,16 +78,6 @@ function allocate(payloadSize: usize): usize { return changetype(header) + HEADER_SIZE; } -/** - * Allocates an unmanaged struct-like object. This is used by the compiler as an abstraction - * to memory.allocate just in case, and is usually not used directly. - */ -// @ts-ignore: decorator -@unsafe @inline -export function ALLOCATE_UNMANAGED(size: usize): usize { - return memory.allocate(size); -} - /** * Changes the size of a previously allocated, but not yet registered, runtime object, for * example when a pre-allocated buffer turned out to be too small or too large. This works by @@ -153,7 +143,7 @@ function reallocate(ref: usize, newPayloadSize: usize): usize { @unsafe @inline export function REGISTER(ref: usize): T { if (!isReference()) ERROR("reference expected"); - return changetype(register(ref, CLASSID())); + return changetype(register(ref, classId())); } function register(ref: usize, classId: u32): usize { @@ -199,13 +189,13 @@ function discard(ref: usize): void { // @ts-ignore: decorator @unsafe @inline export function MAKEARRAY(capacity: i32, source: usize = 0): Array { - return changetype>(makeArray(capacity, source, CLASSID(), alignof())); + return changetype>(makeArray(capacity, classId(), alignof(), source)); } -function makeArray(capacity: i32, source: usize, classId: u32, alignLog2: usize): usize { - var array = register(allocate(offsetof()), classId); +function makeArray(capacity: i32, cid: u32, alignLog2: usize, source: usize): usize { + var array = register(allocate(offsetof()), cid); var bufferSize = capacity << alignLog2; - var buffer = register(allocate(capacity << alignLog2), CLASSID()); + var buffer = register(allocate(capacity << alignLog2), classId()); changetype(array).data = changetype(buffer); // links changetype(array).dataStart = buffer; changetype(array).dataLength = bufferSize; diff --git a/tests/compiler/call-super.optimized.wat b/tests/compiler/call-super.optimized.wat index 5cb40526..00944eb6 100644 --- a/tests/compiler/call-super.optimized.wat +++ b/tests/compiler/call-super.optimized.wat @@ -106,7 +106,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -121,7 +121,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/call-super.untouched.wat b/tests/compiler/call-super.untouched.wat index 2f4427b6..f24e6291 100644 --- a/tests/compiler/call-super.untouched.wat +++ b/tests/compiler/call-super.untouched.wat @@ -140,7 +140,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -157,7 +157,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -168,23 +168,14 @@ local.get $0 ) (func $call-super/A#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -207,19 +198,12 @@ local.get $0 ) (func $call-super/B#constructor (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 8 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 + i32.const 8 + call $~lib/runtime/allocate i32.const 3 call $~lib/runtime/register end @@ -289,22 +273,13 @@ end ) (func $call-super/C#constructor (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 4 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 4 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -313,19 +288,12 @@ local.get $0 ) (func $call-super/D#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 8 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 + i32.const 8 + call $~lib/runtime/allocate i32.const 5 call $~lib/runtime/register end @@ -395,23 +363,14 @@ end ) (func $call-super/E#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 6 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 6 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -434,22 +393,13 @@ local.get $0 ) (func $call-super/F#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 8 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 7 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 7 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -493,22 +443,13 @@ end ) (func $call-super/G#constructor (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.6 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 8 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 8 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -517,22 +458,13 @@ local.get $0 ) (func $call-super/H#constructor (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.7 (result i32) - i32.const 8 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 9 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 9 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -576,22 +508,13 @@ end ) (func $call-super/I#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.8 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 10 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 10 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -600,22 +523,13 @@ local.get $0 ) (func $call-super/J#constructor (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.9 (result i32) - i32.const 8 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 11 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 11 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/constructor.optimized.wat b/tests/compiler/constructor.optimized.wat index ff0bacf7..334f69fe 100644 --- a/tests/compiler/constructor.optimized.wat +++ b/tests/compiler/constructor.optimized.wat @@ -116,7 +116,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -131,7 +131,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/constructor.untouched.wat b/tests/compiler/constructor.untouched.wat index 474bf559..b2da3141 100644 --- a/tests/compiler/constructor.untouched.wat +++ b/tests/compiler/constructor.untouched.wat @@ -150,7 +150,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -167,7 +167,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -178,43 +178,25 @@ local.get $0 ) (func $constructor/EmptyCtor#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 ) (func $constructor/EmptyCtorWithFieldInit#constructor (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 3 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -223,22 +205,13 @@ local.get $0 ) (func $constructor/EmptyCtorWithFieldNoInit#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 4 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 4 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -247,43 +220,25 @@ local.get $0 ) (func $constructor/None#constructor (; 8 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 5 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 5 + call $~lib/runtime/register local.set $0 end local.get $0 ) (func $constructor/JustFieldInit#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 6 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 6 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -292,22 +247,13 @@ local.get $0 ) (func $constructor/JustFieldNoInit#constructor (; 10 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 4 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 7 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 7 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -320,7 +266,6 @@ call $~lib/memory/memory.allocate ) (func $constructor/CtorConditionallyReturns#constructor (; 12 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) global.get $constructor/b if i32.const 0 @@ -330,40 +275,23 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.6 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 8 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 8 + call $~lib/runtime/register local.set $0 end local.get $0 ) (func $constructor/CtorAllocates#constructor (; 13 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.7 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 9 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 9 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -372,25 +300,16 @@ local.get $0 ) (func $constructor/CtorConditionallyAllocates#constructor (; 14 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) global.get $constructor/b if block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.8 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 10 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 10 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -400,18 +319,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.9 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 10 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 10 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/exports.optimized.wat b/tests/compiler/exports.optimized.wat index 59a6bda0..62811a34 100644 --- a/tests/compiler/exports.optimized.wat +++ b/tests/compiler/exports.optimized.wat @@ -41,7 +41,7 @@ (export "Car.getNumTires" (func $exports/Car.getNumTires)) (export "vehicles.Car#get:doors" (func $exports/Car#get:numDoors)) (export "vehicles.Car#set:doors" (func $exports/Car#set:numDoors)) - (export "vehicles.Car#constructor" (func $exports/Car#constructor|trampoline)) + (export "vehicles.Car#constructor" (func $exports/vehicles.Car#constructor|trampoline)) (export "vehicles.Car#get:numDoors" (func $exports/Car#get:numDoors)) (export "vehicles.Car#set:numDoors" (func $exports/Car#set:numDoors)) (export "vehicles.Car#openDoors" (func $exports/Car#openDoors)) @@ -124,15 +124,29 @@ global.set $~lib/allocator/arena/offset local.get $1 ) - (func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) + (func $~lib/runtime/allocate (; 5 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + i32.const 16 + call $~lib/memory/memory.allocate + local.tee $0 + i32.const -1520547049 + i32.store + local.get $0 + i32.const 4 + i32.store offset=4 + local.get $0 + i32.const 8 + i32.add + ) + (func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) local.get $0 i32.const 48 i32.le_u if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -140,45 +154,45 @@ local.get $0 i32.const 8 i32.sub - local.tee $1 + local.tee $2 i32.load i32.const -1520547049 i32.ne if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable end + local.get $2 local.get $1 - i32.const 1 i32.store local.get $0 ) - (func $exports/Car#get:numDoors (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $exports/Car#get:numDoors (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 i32.load ) - (func $exports/Car#set:numDoors (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $exports/Car#set:numDoors (; 8 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) local.get $0 local.get $1 i32.store ) - (func $exports/Car#openDoors (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $exports/Car#openDoors (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) nop ) - (func $start (; 9 ;) (type $FUNCSIG$v) + (func $start (; 10 ;) (type $FUNCSIG$v) i32.const 48 global.set $~lib/allocator/arena/startOffset global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset ) - (func $null (; 10 ;) (type $FUNCSIG$v) + (func $null (; 11 ;) (type $FUNCSIG$v) nop ) - (func $exports/subOpt|trampoline (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/subOpt|trampoline (; 12 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange @@ -196,11 +210,11 @@ local.get $1 i32.sub ) - (func $~lib/setargc (; 12 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/setargc (; 13 ;) (type $FUNCSIG$vi) (param $0 i32) local.get $0 global.set $~lib/argc ) - (func $exports/Car#constructor|trampoline (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $exports/Car#constructor|trampoline (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) block $1of1 block $0of1 block $outOfRange @@ -215,17 +229,36 @@ local.get $0 i32.eqz if - i32.const 16 - call $~lib/memory/memory.allocate - local.tee $0 - i32.const -1520547049 - i32.store - local.get $0 - i32.const 4 - i32.store offset=4 - local.get $0 - i32.const 8 - i32.add + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register + local.set $0 + end + local.get $0 + local.get $1 + i32.store + local.get $0 + local.get $1 + i32.store + local.get $0 + ) + (func $exports/vehicles.Car#constructor|trampoline (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + block $1of1 + block $0of1 + block $outOfRange + global.get $~lib/argc + br_table $0of1 $1of1 $outOfRange + end + unreachable + end + i32.const 2 + local.set $1 + end + local.get $0 + i32.eqz + if + call $~lib/runtime/allocate + i32.const 3 call $~lib/runtime/register local.set $0 end diff --git a/tests/compiler/exports.untouched.wat b/tests/compiler/exports.untouched.wat index 7582116c..189a9c0b 100644 --- a/tests/compiler/exports.untouched.wat +++ b/tests/compiler/exports.untouched.wat @@ -193,7 +193,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -210,7 +210,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -221,23 +221,14 @@ local.get $0 ) (func $exports/Car#constructor (; 9 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 4 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 - i32.const 1 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -265,23 +256,14 @@ global.get $exports/vehicles.Car.TIRES ) (func $exports/vehicles.Car#constructor (; 14 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 4 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 - i32.const 1 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/gc/README.md b/tests/compiler/gc/README.md new file mode 100644 index 00000000..5fa7126f --- /dev/null +++ b/tests/compiler/gc/README.md @@ -0,0 +1 @@ +Tracing GC tests diff --git a/tests/compiler/gc/_dummy.ts b/tests/compiler/gc/_dummy.ts new file mode 100644 index 00000000..6dde53b9 --- /dev/null +++ b/tests/compiler/gc/_dummy.ts @@ -0,0 +1,47 @@ +// A dummy tracing GC for testing. + +export var collect_count = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_collect(): void { + trace("gc.collect"); + collect_count++; +} + +export var register_count = 0; +export var register_ref: usize = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_register(ref: usize): void { + trace("gc.register", 1, ref); + register_count++; + register_ref = ref; +} + +export var link_count = 0; +export var link_ref: usize = 0; +export var link_parentRef: usize = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_link(ref: usize, parentRef: usize): void { + trace("gc.link", 2, ref, parentRef); + link_count++; + link_ref = ref; + link_parentRef = ref; +} + +export var unlink_count = 0; +export var unlink_ref: usize = 0; +export var unlink_parentRef: usize = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_unlink(ref: usize, parentRef: usize): void { + trace("gc.unlink", 2, ref, parentRef); + unlink_count++; + unlink_ref = ref; + unlink_parentRef = parentRef; +} diff --git a/tests/compiler/gc/global-assign.optimized.wat b/tests/compiler/gc/global-assign.optimized.wat new file mode 100644 index 00000000..d8e4d6a4 --- /dev/null +++ b/tests/compiler/gc/global-assign.optimized.wat @@ -0,0 +1,251 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$i (func (result i32))) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e") + (data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") + (data (i32.const 56) "\02\00\00\00\16") + (data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") + (data (i32.const 96) "\02\00\00\00&") + (data (i32.const 112) "g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/link_count (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_count (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $gc/global-assign/global (mut i32) (i32.const 0)) + (global $gc/global-assign/globalRef (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/global-assign/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.tee $1 + local.get $0 + i32.const 1 + local.get $0 + i32.const 1 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $0 + current_memory + local.tee $2 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $2 + local.get $0 + local.get $1 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $0 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + i32.const 16 + call $~lib/memory/memory.allocate + local.tee $0 + i32.const -1520547049 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 0 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 16 + i32.add + ) + (func $gc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/_dummy/register_count + local.get $0 + global.set $gc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 152 + i32.le_u + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load + i32.const -1520547049 + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.const 1 + i32.store + local.get $0 + call $gc/_dummy/__ref_register + local.get $0 + ) + (func $start:gc/global-assign (; 6 ;) (type $FUNCSIG$v) + i32.const 152 + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + call $~lib/runtime/allocate + call $~lib/runtime/register + global.set $gc/global-assign/global + global.get $gc/global-assign/global + global.set $gc/global-assign/globalRef + global.get $gc/_dummy/register_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 112 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + if + i32.const 0 + i32.const 112 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + if + i32.const 0 + i32.const 112 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + call $~lib/runtime/allocate + call $~lib/runtime/register + global.set $gc/global-assign/global + global.get $gc/_dummy/register_count + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 112 + i32.const 19 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + if + i32.const 0 + i32.const 112 + i32.const 20 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + if + i32.const 0 + i32.const 112 + i32.const 21 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/global-assign/main (; 7 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start:gc/global-assign + i32.const 1 + global.set $~lib/started + end + ) + (func $null (; 8 ;) (type $FUNCSIG$v) + nop + ) +) diff --git a/tests/compiler/gc/global-assign.ts b/tests/compiler/gc/global-assign.ts new file mode 100644 index 00000000..3240387d --- /dev/null +++ b/tests/compiler/gc/global-assign.ts @@ -0,0 +1,21 @@ +import "allocator/arena"; +import { register_count, link_count, unlink_count } from "./_dummy"; + +@start export function main(): void {} + +class Ref {} + +// should register only + +var global: Ref = new Ref(); +var globalRef = changetype(global); +assert(register_count == 1); +assert(link_count == 0); +assert(unlink_count == 0); + +// should register only + +global = new Ref(); +assert(register_count == 2); +assert(link_count == 0); +assert(unlink_count == 0); diff --git a/tests/compiler/gc/global-assign.untouched.wat b/tests/compiler/gc/global-assign.untouched.wat new file mode 100644 index 00000000..2587e1c8 --- /dev/null +++ b/tests/compiler/gc/global-assign.untouched.wat @@ -0,0 +1,331 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") + (data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00") + (data (i32.const 96) "\02\00\00\00&\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/_dummy/collect_count (mut i32) (i32.const 0)) + (global $gc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/link_count (mut i32) (i32.const 0)) + (global $gc/_dummy/link_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/link_parentRef (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_count (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_parentRef (mut i32) (i32.const 0)) + (global $~lib/runtime/HEADER_SIZE i32 (i32.const 16)) + (global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) + (global $gc/global-assign/global (mut i32) (i32.const 0)) + (global $gc/global-assign/globalRef (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 152)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/global-assign/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 1 + i32.const 32 + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.add + i32.const 1 + i32.sub + i32.clz + i32.sub + i32.shl + ) + (func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32) + local.get $0 + local.set $1 + local.get $1 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.set $2 + local.get $2 + local.get $1 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $3 + current_memory + local.set $4 + local.get $3 + local.get $4 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $3 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $5 + local.get $4 + local.tee $6 + local.get $5 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_s + select + local.set $6 + local.get $6 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $5 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $3 + global.set $~lib/allocator/arena/offset + local.get $2 + end + return + ) + (func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + call $~lib/runtime/ADJUSTOBLOCK + call $~lib/memory/memory.allocate + local.set $1 + local.get $1 + global.get $~lib/runtime/HEADER_MAGIC + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $1 + i32.const 0 + i32.store offset=8 + local.get $1 + i32.const 0 + i32.store offset=12 + local.get $1 + global.get $~lib/runtime/HEADER_SIZE + i32.add + ) + (func $gc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/_dummy/register_count + local.get $0 + global.set $gc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + local.get $0 + global.get $~lib/memory/HEAP_BASE + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + local.set $2 + local.get $2 + i32.load + global.get $~lib/runtime/HEADER_MAGIC + i32.eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + local.get $1 + i32.store + local.get $0 + call $gc/_dummy/__ref_register + local.get $0 + ) + (func $gc/global-assign/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register + local.set $0 + end + local.get $0 + ) + (func $start:gc/global-assign (; 8 ;) (type $FUNCSIG$v) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + i32.const 0 + call $gc/global-assign/Ref#constructor + global.set $gc/global-assign/global + global.get $gc/global-assign/global + global.set $gc/global-assign/globalRef + global.get $gc/_dummy/register_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 0 + call $gc/global-assign/Ref#constructor + global.set $gc/global-assign/global + global.get $gc/_dummy/register_count + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 19 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 20 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 21 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/global-assign/main (; 9 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 10 ;) (type $FUNCSIG$v) + call $start:gc/global-assign + ) + (func $null (; 11 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/gc/global-init.optimized.wat b/tests/compiler/gc/global-init.optimized.wat new file mode 100644 index 00000000..e986aa1e --- /dev/null +++ b/tests/compiler/gc/global-init.optimized.wat @@ -0,0 +1,248 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$i (func (result i32))) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e") + (data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") + (data (i32.const 56) "\02\00\00\00\16") + (data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") + (data (i32.const 96) "\02\00\00\00\"") + (data (i32.const 112) "g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/link_count (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_count (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $gc/global-init/global (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/global-init/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.tee $1 + local.get $0 + i32.const 1 + local.get $0 + i32.const 1 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $0 + current_memory + local.tee $2 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $2 + local.get $0 + local.get $1 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $0 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + i32.const 16 + call $~lib/memory/memory.allocate + local.tee $0 + i32.const -1520547049 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 0 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 16 + i32.add + ) + (func $gc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/_dummy/register_count + local.get $0 + global.set $gc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 148 + i32.le_u + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load + i32.const -1520547049 + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.const 1 + i32.store + local.get $0 + call $gc/_dummy/__ref_register + local.get $0 + ) + (func $start:gc/global-init (; 6 ;) (type $FUNCSIG$v) + i32.const 152 + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + call $~lib/runtime/allocate + call $~lib/runtime/register + global.set $gc/global-init/global + global.get $gc/_dummy/register_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 112 + i32.const 11 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + if + i32.const 0 + i32.const 112 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + if + i32.const 0 + i32.const 112 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + call $~lib/runtime/allocate + call $~lib/runtime/register + global.set $gc/global-init/global + global.get $gc/_dummy/register_count + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 112 + i32.const 16 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + if + i32.const 0 + i32.const 112 + i32.const 17 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + if + i32.const 0 + i32.const 112 + i32.const 18 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/global-init/main (; 7 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start:gc/global-init + i32.const 1 + global.set $~lib/started + end + ) + (func $null (; 8 ;) (type $FUNCSIG$v) + nop + ) +) diff --git a/tests/compiler/gc/global-init.ts b/tests/compiler/gc/global-init.ts new file mode 100644 index 00000000..9f89bc7a --- /dev/null +++ b/tests/compiler/gc/global-init.ts @@ -0,0 +1,18 @@ +import "allocator/arena"; +import { register_count, link_count, unlink_count } from "./_dummy"; + +@start export function main(): void {} + +class Ref {} + +// should register only + +var global: Ref = new Ref(); +assert(register_count == 1); +assert(link_count == 0); +assert(unlink_count == 0); + +global = new Ref(); +assert(register_count == 2); +assert(link_count == 0); +assert(unlink_count == 0); diff --git a/tests/compiler/gc/global-init.untouched.wat b/tests/compiler/gc/global-init.untouched.wat new file mode 100644 index 00000000..bf8afc5d --- /dev/null +++ b/tests/compiler/gc/global-init.untouched.wat @@ -0,0 +1,328 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") + (data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00") + (data (i32.const 96) "\02\00\00\00\"\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/_dummy/collect_count (mut i32) (i32.const 0)) + (global $gc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/link_count (mut i32) (i32.const 0)) + (global $gc/_dummy/link_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/link_parentRef (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_count (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_ref (mut i32) (i32.const 0)) + (global $gc/_dummy/unlink_parentRef (mut i32) (i32.const 0)) + (global $~lib/runtime/HEADER_SIZE i32 (i32.const 16)) + (global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) + (global $gc/global-init/global (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 148)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/global-init/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 1 + i32.const 32 + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.add + i32.const 1 + i32.sub + i32.clz + i32.sub + i32.shl + ) + (func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32) + local.get $0 + local.set $1 + local.get $1 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.set $2 + local.get $2 + local.get $1 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $3 + current_memory + local.set $4 + local.get $3 + local.get $4 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $3 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $5 + local.get $4 + local.tee $6 + local.get $5 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_s + select + local.set $6 + local.get $6 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $5 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $3 + global.set $~lib/allocator/arena/offset + local.get $2 + end + return + ) + (func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + call $~lib/runtime/ADJUSTOBLOCK + call $~lib/memory/memory.allocate + local.set $1 + local.get $1 + global.get $~lib/runtime/HEADER_MAGIC + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $1 + i32.const 0 + i32.store offset=8 + local.get $1 + i32.const 0 + i32.store offset=12 + local.get $1 + global.get $~lib/runtime/HEADER_SIZE + i32.add + ) + (func $gc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/_dummy/register_count + local.get $0 + global.set $gc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + local.get $0 + global.get $~lib/memory/HEAP_BASE + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + local.set $2 + local.get $2 + i32.load + global.get $~lib/runtime/HEADER_MAGIC + i32.eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + local.get $1 + i32.store + local.get $0 + call $gc/_dummy/__ref_register + local.get $0 + ) + (func $gc/global-init/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register + local.set $0 + end + local.get $0 + ) + (func $start:gc/global-init (; 8 ;) (type $FUNCSIG$v) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + i32.const 0 + call $gc/global-init/Ref#constructor + global.set $gc/global-init/global + global.get $gc/_dummy/register_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 11 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 0 + call $gc/global-init/Ref#constructor + global.set $gc/global-init/global + global.get $gc/_dummy/register_count + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 16 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/link_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 17 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/_dummy/unlink_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 18 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/global-init/main (; 9 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 10 ;) (type $FUNCSIG$v) + call $start:gc/global-init + ) + (func $null (; 11 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/gc/rc/README.md b/tests/compiler/gc/rc/README.md new file mode 100644 index 00000000..0e4679f8 --- /dev/null +++ b/tests/compiler/gc/rc/README.md @@ -0,0 +1 @@ +Reference counting GC tests diff --git a/tests/compiler/gc/rc/_dummy.ts b/tests/compiler/gc/rc/_dummy.ts new file mode 100644 index 00000000..74716fe3 --- /dev/null +++ b/tests/compiler/gc/rc/_dummy.ts @@ -0,0 +1,43 @@ +// A dummy reference counting GC for testing. + +export var collect_count = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_collect(): void { + trace("gc.collect"); + collect_count++; +} + +export var register_count = 0; +export var register_ref: usize = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_register(ref: usize): void { + trace("gc.register", 1, ref); + register_count++; + register_ref = ref; +} + +export var retain_count = 0; +export var retain_ref: usize = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_retain(ref: usize): void { + trace("gc.retain", 1, ref); + retain_count++; + retain_ref = ref; +} + +export var release_count = 0; +export var release_ref: usize = 0; + +// @ts-ignore: decorator +@global @unsafe +function __ref_release(ref: usize): void { + trace("gc.release", 1, ref); + release_count++; + release_ref = ref; +} diff --git a/tests/compiler/gc/rc/global-assign.optimized.wat b/tests/compiler/gc/rc/global-assign.optimized.wat new file mode 100644 index 00000000..b9ab6d27 --- /dev/null +++ b/tests/compiler/gc/rc/global-assign.optimized.wat @@ -0,0 +1,349 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$i (func (result i32))) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e") + (data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") + (data (i32.const 56) "\02\00\00\00\16") + (data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") + (data (i32.const 96) "\02\00\00\00\12") + (data (i32.const 112) "g\00c\00.\00r\00e\00t\00a\00i\00n") + (data (i32.const 136) "\02\00\00\00,") + (data (i32.const 152) "g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s") + (data (i32.const 200) "\02\00\00\00\14") + (data (i32.const 216) "g\00c\00.\00r\00e\00l\00e\00a\00s\00e") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/rc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_ref (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $gc/rc/global-assign/global (mut i32) (i32.const 0)) + (global $gc/rc/global-assign/globalRef (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/rc/global-assign/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.tee $1 + local.get $0 + i32.const 1 + local.get $0 + i32.const 1 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $0 + current_memory + local.tee $2 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $2 + local.get $0 + local.get $1 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $0 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + i32.const 16 + call $~lib/memory/memory.allocate + local.tee $0 + i32.const -1520547049 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 0 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 16 + i32.add + ) + (func $gc/rc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/register_count + local.get $0 + global.set $gc/rc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 236 + i32.le_u + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load + i32.const -1520547049 + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.const 1 + i32.store + local.get $0 + call $gc/rc/_dummy/__ref_register + local.get $0 + ) + (func $gc/rc/_dummy/__ref_retain (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 112 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/retain_count + local.get $0 + global.set $gc/rc/_dummy/retain_ref + ) + (func $gc/rc/_dummy/__ref_release (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 216 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/release_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/release_count + local.get $0 + global.set $gc/rc/_dummy/release_ref + ) + (func $start:gc/rc/global-assign (; 8 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + i32.const 240 + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + call $~lib/runtime/allocate + call $~lib/runtime/register + local.tee $0 + call $gc/rc/_dummy/__ref_retain + local.get $0 + global.set $gc/rc/global-assign/global + global.get $gc/rc/global-assign/global + global.set $gc/rc/global-assign/globalRef + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_ref + global.get $gc/rc/global-assign/globalRef + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_count + if + i32.const 0 + i32.const 152 + i32.const 15 + i32.const 0 + call $~lib/env/abort + unreachable + end + call $~lib/runtime/allocate + call $~lib/runtime/register + local.tee $0 + global.get $gc/rc/global-assign/global + local.tee $1 + i32.ne + if + local.get $1 + if + local.get $1 + call $gc/rc/_dummy/__ref_release + end + local.get $0 + call $gc/rc/_dummy/__ref_retain + end + local.get $0 + global.set $gc/rc/global-assign/global + global.get $gc/rc/_dummy/register_count + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 20 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_count + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 21 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_ref + global.get $gc/rc/global-assign/global + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 22 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 23 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_ref + global.get $gc/rc/global-assign/globalRef + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 24 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/rc/global-assign/main (; 9 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start:gc/rc/global-assign + i32.const 1 + global.set $~lib/started + end + ) + (func $null (; 10 ;) (type $FUNCSIG$v) + nop + ) +) diff --git a/tests/compiler/gc/rc/global-assign.ts b/tests/compiler/gc/rc/global-assign.ts new file mode 100644 index 00000000..6fb0bb40 --- /dev/null +++ b/tests/compiler/gc/rc/global-assign.ts @@ -0,0 +1,24 @@ +import "allocator/arena"; +import { register_count, retain_count, retain_ref, release_count, release_ref } from "./_dummy"; + +@start export function main(): void {} + +class Ref {} + +// should register and retain + +var global: Ref = new Ref(); +var globalRef = changetype(global); +assert(register_count == 1); +assert(retain_count == 1); +assert(retain_ref == globalRef); +assert(release_count == 0); + +// should register, release old and retain new + +global = new Ref(); +assert(register_count == 2); +assert(retain_count == 2); +assert(retain_ref == changetype(global)); +assert(release_count == 1); +assert(release_ref == globalRef); diff --git a/tests/compiler/gc/rc/global-assign.untouched.wat b/tests/compiler/gc/rc/global-assign.untouched.wat new file mode 100644 index 00000000..41567e39 --- /dev/null +++ b/tests/compiler/gc/rc/global-assign.untouched.wat @@ -0,0 +1,425 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") + (data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00") + (data (i32.const 96) "\02\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00t\00a\00i\00n\00") + (data (i32.const 136) "\02\00\00\00,\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00a\00s\00s\00i\00g\00n\00.\00t\00s\00") + (data (i32.const 200) "\02\00\00\00\14\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00l\00e\00a\00s\00e\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/rc/_dummy/collect_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_ref (mut i32) (i32.const 0)) + (global $~lib/runtime/HEADER_SIZE i32 (i32.const 16)) + (global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) + (global $gc/rc/global-assign/global (mut i32) (i32.const 0)) + (global $gc/rc/global-assign/globalRef (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 236)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/rc/global-assign/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 1 + i32.const 32 + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.add + i32.const 1 + i32.sub + i32.clz + i32.sub + i32.shl + ) + (func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32) + local.get $0 + local.set $1 + local.get $1 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.set $2 + local.get $2 + local.get $1 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $3 + current_memory + local.set $4 + local.get $3 + local.get $4 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $3 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $5 + local.get $4 + local.tee $6 + local.get $5 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_s + select + local.set $6 + local.get $6 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $5 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $3 + global.set $~lib/allocator/arena/offset + local.get $2 + end + return + ) + (func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + call $~lib/runtime/ADJUSTOBLOCK + call $~lib/memory/memory.allocate + local.set $1 + local.get $1 + global.get $~lib/runtime/HEADER_MAGIC + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $1 + i32.const 0 + i32.store offset=8 + local.get $1 + i32.const 0 + i32.store offset=12 + local.get $1 + global.get $~lib/runtime/HEADER_SIZE + i32.add + ) + (func $gc/rc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/register_count + local.get $0 + global.set $gc/rc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + local.get $0 + global.get $~lib/memory/HEAP_BASE + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + local.set $2 + local.get $2 + i32.load + global.get $~lib/runtime/HEADER_MAGIC + i32.eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + local.get $1 + i32.store + local.get $0 + call $gc/rc/_dummy/__ref_register + local.get $0 + ) + (func $gc/rc/global-assign/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register + local.set $0 + end + local.get $0 + ) + (func $gc/rc/_dummy/__ref_retain (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 112 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/retain_count + local.get $0 + global.set $gc/rc/_dummy/retain_ref + ) + (func $gc/rc/_dummy/__ref_release (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 216 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/release_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/release_count + local.get $0 + global.set $gc/rc/_dummy/release_ref + ) + (func $start:gc/rc/global-assign (; 10 ;) (type $FUNCSIG$v) + (local $0 i32) + (local $1 i32) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + block (result i32) + i32.const 0 + call $gc/rc/global-assign/Ref#constructor + local.set $0 + local.get $0 + call $gc/rc/_dummy/__ref_retain + local.get $0 + end + global.set $gc/rc/global-assign/global + global.get $gc/rc/global-assign/global + global.set $gc/rc/global-assign/globalRef + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_ref + global.get $gc/rc/global-assign/globalRef + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 15 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 0 + call $gc/rc/global-assign/Ref#constructor + local.tee $0 + global.get $gc/rc/global-assign/global + local.tee $1 + i32.ne + if (result i32) + local.get $1 + if + local.get $1 + call $gc/rc/_dummy/__ref_release + end + local.get $0 + call $gc/rc/_dummy/__ref_retain + local.get $0 + else + local.get $0 + end + global.set $gc/rc/global-assign/global + global.get $gc/rc/_dummy/register_count + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 20 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_count + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 21 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_ref + global.get $gc/rc/global-assign/global + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 22 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 23 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_ref + global.get $gc/rc/global-assign/globalRef + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 24 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/rc/global-assign/main (; 11 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 12 ;) (type $FUNCSIG$v) + call $start:gc/rc/global-assign + ) + (func $null (; 13 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/gc/rc/global-init.optimized.wat b/tests/compiler/gc/rc/global-init.optimized.wat new file mode 100644 index 00000000..57902cd9 --- /dev/null +++ b/tests/compiler/gc/rc/global-init.optimized.wat @@ -0,0 +1,253 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$i (func (result i32))) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e") + (data (i32.const 24) "~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") + (data (i32.const 56) "\02\00\00\00\16") + (data (i32.const 72) "g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r") + (data (i32.const 96) "\02\00\00\00\12") + (data (i32.const 112) "g\00c\00.\00r\00e\00t\00a\00i\00n") + (data (i32.const 136) "\02\00\00\00(") + (data (i32.const 152) "g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/rc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_count (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $gc/rc/global-init/global (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/rc/global-init/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.tee $1 + local.get $0 + i32.const 1 + local.get $0 + i32.const 1 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $0 + current_memory + local.tee $2 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $2 + local.get $0 + local.get $1 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $0 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $~lib/runtime/allocate (; 3 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + i32.const 16 + call $~lib/memory/memory.allocate + local.tee $0 + i32.const -1520547049 + i32.store + local.get $0 + i32.const 0 + i32.store offset=4 + local.get $0 + i32.const 0 + i32.store offset=8 + local.get $0 + i32.const 0 + i32.store offset=12 + local.get $0 + i32.const 16 + i32.add + ) + (func $gc/rc/_dummy/__ref_register (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/register_count + local.get $0 + global.set $gc/rc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 192 + i32.le_u + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 16 + i32.sub + local.tee $1 + i32.load + i32.const -1520547049 + i32.ne + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $1 + i32.const 1 + i32.store + local.get $0 + call $gc/rc/_dummy/__ref_register + local.get $0 + ) + (func $gc/rc/_dummy/__ref_retain (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 112 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/retain_count + local.get $0 + global.set $gc/rc/_dummy/retain_ref + ) + (func $start:gc/rc/global-init (; 7 ;) (type $FUNCSIG$v) + (local $0 i32) + i32.const 192 + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + call $~lib/runtime/allocate + call $~lib/runtime/register + local.tee $0 + call $gc/rc/_dummy/__ref_retain + local.get $0 + global.set $gc/rc/global-init/global + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 11 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_ref + global.get $gc/rc/global-init/global + i32.ne + if + i32.const 0 + i32.const 152 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_count + if + i32.const 0 + i32.const 152 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/rc/global-init/main (; 8 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start:gc/rc/global-init + i32.const 1 + global.set $~lib/started + end + ) + (func $null (; 9 ;) (type $FUNCSIG$v) + nop + ) +) diff --git a/tests/compiler/gc/rc/global-init.ts b/tests/compiler/gc/rc/global-init.ts new file mode 100644 index 00000000..46c36ba5 --- /dev/null +++ b/tests/compiler/gc/rc/global-init.ts @@ -0,0 +1,14 @@ +import "allocator/arena"; +import { register_count, retain_count, retain_ref, release_count } from "./_dummy"; + +@start export function main(): void {} + +class Ref {} + +// should register and retain, with nothing to release + +var global = new Ref(); +assert(register_count == 1); +assert(retain_count == 1); +assert(retain_ref == changetype(global)); +assert(release_count == 0); diff --git a/tests/compiler/gc/rc/global-init.untouched.wat b/tests/compiler/gc/rc/global-init.untouched.wat new file mode 100644 index 00000000..38a1a428 --- /dev/null +++ b/tests/compiler/gc/rc/global-init.untouched.wat @@ -0,0 +1,324 @@ +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$viiddddd (func (param i32 i32 f64 f64 f64 f64 f64))) + (type $FUNCSIG$v (func)) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (import "env" "trace" (func $~lib/env/trace (param i32 i32 f64 f64 f64 f64 f64))) + (memory $0 1) + (data (i32.const 8) "\02\00\00\00\1e\00\00\00\00\00\00\00\00\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") + (data (i32.const 56) "\02\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00g\00i\00s\00t\00e\00r\00") + (data (i32.const 96) "\02\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00g\00c\00.\00r\00e\00t\00a\00i\00n\00") + (data (i32.const 136) "\02\00\00\00(\00\00\00\00\00\00\00\00\00\00\00g\00c\00/\00r\00c\00/\00g\00l\00o\00b\00a\00l\00-\00i\00n\00i\00t\00.\00t\00s\00") + (table $0 1 funcref) + (elem (i32.const 0) $null) + (global $gc/rc/_dummy/collect_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/register_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/register_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/retain_ref (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_count (mut i32) (i32.const 0)) + (global $gc/rc/_dummy/release_ref (mut i32) (i32.const 0)) + (global $~lib/runtime/HEADER_SIZE i32 (i32.const 16)) + (global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (global $~lib/ASC_NO_ASSERT i32 (i32.const 0)) + (global $gc/rc/global-init/global (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 192)) + (global $~lib/capabilities i32 (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (export "main" (func $gc/rc/global-init/main)) + (export ".capabilities" (global $~lib/capabilities)) + (func $~lib/runtime/ADJUSTOBLOCK (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 1 + i32.const 32 + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.add + i32.const 1 + i32.sub + i32.clz + i32.sub + i32.shl + ) + (func $~lib/memory/memory.allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32) + local.get $0 + local.set $1 + local.get $1 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.set $2 + local.get $2 + local.get $1 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $3 + current_memory + local.set $4 + local.get $3 + local.get $4 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $3 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $5 + local.get $4 + local.tee $6 + local.get $5 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_s + select + local.set $6 + local.get $6 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $5 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $3 + global.set $~lib/allocator/arena/offset + local.get $2 + end + return + ) + (func $~lib/runtime/allocate (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + call $~lib/runtime/ADJUSTOBLOCK + call $~lib/memory/memory.allocate + local.set $1 + local.get $1 + global.get $~lib/runtime/HEADER_MAGIC + i32.store + local.get $1 + local.get $0 + i32.store offset=4 + local.get $1 + i32.const 0 + i32.store offset=8 + local.get $1 + i32.const 0 + i32.store offset=12 + local.get $1 + global.get $~lib/runtime/HEADER_SIZE + i32.add + ) + (func $gc/rc/_dummy/__ref_register (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 72 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/register_count + local.get $0 + global.set $gc/rc/_dummy/register_ref + ) + (func $~lib/runtime/register (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + local.get $0 + global.get $~lib/memory/HEAP_BASE + i32.gt_u + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 151 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $0 + global.get $~lib/runtime/HEADER_SIZE + i32.sub + local.set $2 + local.get $2 + i32.load + global.get $~lib/runtime/HEADER_MAGIC + i32.eq + i32.eqz + if + i32.const 0 + i32.const 24 + i32.const 153 + i32.const 4 + call $~lib/env/abort + unreachable + end + local.get $2 + local.get $1 + i32.store + local.get $0 + call $gc/rc/_dummy/__ref_register + local.get $0 + ) + (func $gc/rc/global-init/Ref#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register + local.set $0 + end + local.get $0 + ) + (func $gc/rc/_dummy/__ref_retain (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) + i32.const 112 + i32.const 1 + local.get $0 + f64.convert_i32_u + f64.const 0 + f64.const 0 + f64.const 0 + f64.const 0 + call $~lib/env/trace + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.add + global.set $gc/rc/_dummy/retain_count + local.get $0 + global.set $gc/rc/_dummy/retain_ref + ) + (func $start:gc/rc/global-init (; 9 ;) (type $FUNCSIG$v) + (local $0 i32) + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + block (result i32) + i32.const 0 + call $gc/rc/global-init/Ref#constructor + local.set $0 + local.get $0 + call $gc/rc/_dummy/__ref_retain + local.get $0 + end + global.set $gc/rc/global-init/global + global.get $gc/rc/_dummy/register_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 11 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_count + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/retain_ref + global.get $gc/rc/global-init/global + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 13 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $gc/rc/_dummy/release_count + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 152 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $gc/rc/global-init/main (; 10 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 11 ;) (type $FUNCSIG$v) + call $start:gc/rc/global-init + ) + (func $null (; 12 ;) (type $FUNCSIG$v) + ) +) diff --git a/tests/compiler/getter-call.optimized.wat b/tests/compiler/getter-call.optimized.wat index 29a6fcb3..1550e69e 100644 --- a/tests/compiler/getter-call.optimized.wat +++ b/tests/compiler/getter-call.optimized.wat @@ -85,7 +85,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -100,7 +100,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/getter-call.untouched.wat b/tests/compiler/getter-call.untouched.wat index 5eb46ec0..f2e5837d 100644 --- a/tests/compiler/getter-call.untouched.wat +++ b/tests/compiler/getter-call.untouched.wat @@ -142,7 +142,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -159,7 +159,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -170,22 +170,13 @@ local.get $0 ) (func $getter-call/C#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/inlining.optimized.wat b/tests/compiler/inlining.optimized.wat index 7af4956e..33619e1a 100644 --- a/tests/compiler/inlining.optimized.wat +++ b/tests/compiler/inlining.optimized.wat @@ -131,7 +131,7 @@ if i32.const 0 i32.const 48 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -146,7 +146,7 @@ if i32.const 0 i32.const 48 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/inlining.untouched.wat b/tests/compiler/inlining.untouched.wat index 3037ca0b..e3d45a84 100644 --- a/tests/compiler/inlining.untouched.wat +++ b/tests/compiler/inlining.untouched.wat @@ -406,7 +406,7 @@ if i32.const 0 i32.const 48 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -423,7 +423,7 @@ if i32.const 0 i32.const 48 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -439,7 +439,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) block $inlining/Bar#constructor|inlined.0 (result i32) i32.const 0 local.set $1 @@ -450,14 +449,8 @@ if (result i32) local.get $1 else - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 16 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 16 + call $~lib/runtime/allocate i32.const 2 call $~lib/runtime/register end @@ -468,18 +461,10 @@ local.get $3 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 8 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 3 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $3 end local.get $3 @@ -506,8 +491,8 @@ i32.store offset=12 local.get $1 end - local.set $5 - local.get $5 + local.set $4 + local.get $4 i32.load i32.const 1 i32.eq @@ -520,7 +505,7 @@ call $~lib/env/abort unreachable end - local.get $5 + local.get $4 i32.load offset=4 i32.const 2 i32.eq @@ -533,7 +518,7 @@ call $~lib/env/abort unreachable end - local.get $5 + local.get $4 i32.load offset=8 i32.const 3 i32.eq @@ -546,7 +531,7 @@ call $~lib/env/abort unreachable end - local.get $5 + local.get $4 i32.load offset=12 i32.const 4 i32.eq diff --git a/tests/compiler/new-without-allocator.untouched.wat b/tests/compiler/new-without-allocator.untouched.wat index 5652461f..1716c926 100644 --- a/tests/compiler/new-without-allocator.untouched.wat +++ b/tests/compiler/new-without-allocator.untouched.wat @@ -56,7 +56,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -73,7 +73,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -84,22 +84,13 @@ local.get $0 ) (func $new-without-allocator/A#constructor (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/number.optimized.wat b/tests/compiler/number.optimized.wat index 339d2c67..85118b4a 100644 --- a/tests/compiler/number.optimized.wat +++ b/tests/compiler/number.optimized.wat @@ -303,7 +303,7 @@ if i32.const 0 i32.const 464 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -318,7 +318,7 @@ if i32.const 0 i32.const 464 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -2516,7 +2516,7 @@ if i32.const 0 i32.const 464 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -2530,7 +2530,7 @@ if i32.const 0 i32.const 464 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/number.untouched.wat b/tests/compiler/number.untouched.wat index 327dd38b..09fe06e6 100644 --- a/tests/compiler/number.untouched.wat +++ b/tests/compiler/number.untouched.wat @@ -400,7 +400,7 @@ if i32.const 0 i32.const 464 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -417,7 +417,7 @@ if i32.const 0 i32.const 464 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -3549,7 +3549,7 @@ if i32.const 0 i32.const 464 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -3566,7 +3566,7 @@ if i32.const 0 i32.const 464 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/object-literal.optimized.wat b/tests/compiler/object-literal.optimized.wat index ff4f0679..67841af0 100644 --- a/tests/compiler/object-literal.optimized.wat +++ b/tests/compiler/object-literal.optimized.wat @@ -107,7 +107,7 @@ if i32.const 0 i32.const 48 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -122,7 +122,7 @@ if i32.const 0 i32.const 48 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/object-literal.untouched.wat b/tests/compiler/object-literal.untouched.wat index 6f455277..42ecc4cc 100644 --- a/tests/compiler/object-literal.untouched.wat +++ b/tests/compiler/object-literal.untouched.wat @@ -143,7 +143,7 @@ if i32.const 0 i32.const 48 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -160,7 +160,7 @@ if i32.const 0 i32.const 48 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -337,7 +337,6 @@ (local $0 i32) (local $1 i32) (local $2 i32) - (local $3 i32) global.get $~lib/memory/HEAP_BASE i32.const 7 i32.add @@ -349,18 +348,10 @@ global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset block (result i32) - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 8 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 2 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 2 + call $~lib/runtime/register local.set $0 local.get $0 i32.const 1 @@ -372,18 +363,10 @@ end call $object-literal/bar block (result i32) - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 4 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 - i32.const 3 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $1 local.get $1 i32.const 2 @@ -392,18 +375,10 @@ end call $object-literal/bar2 block (result i32) - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 4 - local.set $3 - local.get $3 - call $~lib/runtime/allocate - end - local.set $3 - local.get $3 - i32.const 3 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $2 local.get $2 i32.const 3 diff --git a/tests/compiler/optional-typeparameters.optimized.wat b/tests/compiler/optional-typeparameters.optimized.wat index 3b464167..fa432d29 100644 --- a/tests/compiler/optional-typeparameters.optimized.wat +++ b/tests/compiler/optional-typeparameters.optimized.wat @@ -100,7 +100,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -115,7 +115,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/optional-typeparameters.untouched.wat b/tests/compiler/optional-typeparameters.untouched.wat index 0ce99141..324a9f1e 100644 --- a/tests/compiler/optional-typeparameters.untouched.wat +++ b/tests/compiler/optional-typeparameters.untouched.wat @@ -149,7 +149,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -166,7 +166,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -177,22 +177,13 @@ local.get $0 ) (func $optional-typeparameters/TestConcrete#constructor (; 7 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -203,22 +194,13 @@ i32.add ) (func $optional-typeparameters/TestDerived#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 3 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/simd.optimized.wat b/tests/compiler/simd.optimized.wat index 2505ac86..73244308 100644 --- a/tests/compiler/simd.optimized.wat +++ b/tests/compiler/simd.optimized.wat @@ -1,21 +1,12 @@ (module (type $FUNCSIG$v (func)) (memory $0 1) - (data (i32.const 8) "\07\00\00\00s\00i\00m\00d\00.\00t\00s") + (data (i32.const 8) "\01\00\00\00\0e\00\00\00s\00i\00m\00d\00.\00t\00s") (table $0 1 funcref) - (elem (i32.const 0) $null) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) + (elem (i32.const 0) $start) (export "memory" (memory $0)) (export "table" (table $0)) - (start $start) (func $start (; 0 ;) (type $FUNCSIG$v) - i32.const 32 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $null (; 1 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/simd.ts b/tests/compiler/simd.ts index 677f9585..d3642682 100644 --- a/tests/compiler/simd.ts +++ b/tests/compiler/simd.ts @@ -1,7 +1,5 @@ // hint: asc tests/compiler/simd --enable simd --validate -import "allocator/arena"; - function test_v128(): void { // equality and inequality assert( diff --git a/tests/compiler/simd.untouched.wat b/tests/compiler/simd.untouched.wat index 9781a39e..6b4e6206 100644 --- a/tests/compiler/simd.untouched.wat +++ b/tests/compiler/simd.untouched.wat @@ -3,29 +3,15 @@ (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) (memory $0 1) - (data (i32.const 8) "\07\00\00\00s\00i\00m\00d\00.\00t\00s\00") + (data (i32.const 8) "\01\00\00\00\0e\00\00\00s\00i\00m\00d\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $~lib/ASC_FEATURE_SIMD i32 (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 28)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 32)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) - (func $start:~lib/allocator/arena (; 1 ;) (type $FUNCSIG$v) - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $simd/test_v128 (; 2 ;) (type $FUNCSIG$v) + (func $simd/test_v128 (; 1 ;) (type $FUNCSIG$v) v128.const i32 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d v128.const i32 0x04030201 0x08070605 0x0c0b0a09 0x100f0e0d i8x16.eq @@ -35,8 +21,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 7 + i32.const 16 + i32.const 5 i32.const 2 call $~lib/env/abort unreachable @@ -50,8 +36,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 12 + i32.const 16 + i32.const 10 i32.const 2 call $~lib/env/abort unreachable @@ -67,8 +53,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 18 + i32.const 16 + i32.const 16 i32.const 2 call $~lib/env/abort unreachable @@ -84,8 +70,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 25 + i32.const 16 + i32.const 23 i32.const 2 call $~lib/env/abort unreachable @@ -101,8 +87,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 32 + i32.const 16 + i32.const 30 i32.const 2 call $~lib/env/abort unreachable @@ -117,8 +103,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 39 + i32.const 16 + i32.const 37 i32.const 2 call $~lib/env/abort unreachable @@ -135,14 +121,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 45 + i32.const 16 + i32.const 43 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_i8x16 (; 3 ;) (type $FUNCSIG$v) + (func $simd/test_i8x16 (; 2 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) (local $2 v128) @@ -161,8 +147,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 62 + i32.const 16 + i32.const 60 i32.const 2 call $~lib/env/abort unreachable @@ -179,8 +165,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 64 + i32.const 16 + i32.const 62 i32.const 2 call $~lib/env/abort unreachable @@ -198,8 +184,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 66 + i32.const 16 + i32.const 64 i32.const 2 call $~lib/env/abort unreachable @@ -215,8 +201,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 67 + i32.const 16 + i32.const 65 i32.const 2 call $~lib/env/abort unreachable @@ -232,8 +218,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 68 + i32.const 16 + i32.const 66 i32.const 2 call $~lib/env/abort unreachable @@ -248,8 +234,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 69 + i32.const 16 + i32.const 67 i32.const 2 call $~lib/env/abort unreachable @@ -265,8 +251,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 74 + i32.const 16 + i32.const 72 i32.const 2 call $~lib/env/abort unreachable @@ -282,8 +268,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 75 + i32.const 16 + i32.const 73 i32.const 2 call $~lib/env/abort unreachable @@ -297,8 +283,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 76 + i32.const 16 + i32.const 74 i32.const 2 call $~lib/env/abort unreachable @@ -314,8 +300,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 77 + i32.const 16 + i32.const 75 i32.const 2 call $~lib/env/abort unreachable @@ -331,8 +317,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 82 + i32.const 16 + i32.const 80 i32.const 2 call $~lib/env/abort unreachable @@ -350,8 +336,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 87 + i32.const 16 + i32.const 85 i32.const 2 call $~lib/env/abort unreachable @@ -369,8 +355,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 93 + i32.const 16 + i32.const 91 i32.const 2 call $~lib/env/abort unreachable @@ -388,8 +374,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 99 + i32.const 16 + i32.const 97 i32.const 2 call $~lib/env/abort unreachable @@ -407,8 +393,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 105 + i32.const 16 + i32.const 103 i32.const 2 call $~lib/env/abort unreachable @@ -426,8 +412,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 111 + i32.const 16 + i32.const 109 i32.const 2 call $~lib/env/abort unreachable @@ -445,8 +431,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 112 + i32.const 16 + i32.const 110 i32.const 2 call $~lib/env/abort unreachable @@ -464,8 +450,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 113 + i32.const 16 + i32.const 111 i32.const 2 call $~lib/env/abort unreachable @@ -479,8 +465,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 114 + i32.const 16 + i32.const 112 i32.const 2 call $~lib/env/abort unreachable @@ -495,8 +481,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 115 + i32.const 16 + i32.const 113 i32.const 2 call $~lib/env/abort unreachable @@ -527,8 +513,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 120 + i32.const 16 + i32.const 118 i32.const 2 call $~lib/env/abort unreachable @@ -544,8 +530,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 121 + i32.const 16 + i32.const 119 i32.const 2 call $~lib/env/abort unreachable @@ -561,8 +547,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 122 + i32.const 16 + i32.const 120 i32.const 2 call $~lib/env/abort unreachable @@ -578,8 +564,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 123 + i32.const 16 + i32.const 121 i32.const 2 call $~lib/env/abort unreachable @@ -595,8 +581,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 124 + i32.const 16 + i32.const 122 i32.const 2 call $~lib/env/abort unreachable @@ -612,8 +598,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 125 + i32.const 16 + i32.const 123 i32.const 2 call $~lib/env/abort unreachable @@ -629,8 +615,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 126 + i32.const 16 + i32.const 124 i32.const 2 call $~lib/env/abort unreachable @@ -646,8 +632,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 127 + i32.const 16 + i32.const 125 i32.const 2 call $~lib/env/abort unreachable @@ -663,8 +649,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 128 + i32.const 16 + i32.const 126 i32.const 2 call $~lib/env/abort unreachable @@ -680,14 +666,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 129 + i32.const 16 + i32.const 127 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_i16x8 (; 4 ;) (type $FUNCSIG$v) + (func $simd/test_i16x8 (; 3 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) (local $2 v128) @@ -706,8 +692,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 134 + i32.const 16 + i32.const 132 i32.const 2 call $~lib/env/abort unreachable @@ -724,8 +710,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 136 + i32.const 16 + i32.const 134 i32.const 2 call $~lib/env/abort unreachable @@ -743,8 +729,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 138 + i32.const 16 + i32.const 136 i32.const 2 call $~lib/env/abort unreachable @@ -760,8 +746,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 139 + i32.const 16 + i32.const 137 i32.const 2 call $~lib/env/abort unreachable @@ -777,8 +763,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 140 + i32.const 16 + i32.const 138 i32.const 2 call $~lib/env/abort unreachable @@ -793,8 +779,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 141 + i32.const 16 + i32.const 139 i32.const 2 call $~lib/env/abort unreachable @@ -810,8 +796,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 146 + i32.const 16 + i32.const 144 i32.const 2 call $~lib/env/abort unreachable @@ -827,8 +813,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 147 + i32.const 16 + i32.const 145 i32.const 2 call $~lib/env/abort unreachable @@ -842,8 +828,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 148 + i32.const 16 + i32.const 146 i32.const 2 call $~lib/env/abort unreachable @@ -859,8 +845,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 149 + i32.const 16 + i32.const 147 i32.const 2 call $~lib/env/abort unreachable @@ -876,8 +862,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 154 + i32.const 16 + i32.const 152 i32.const 2 call $~lib/env/abort unreachable @@ -895,8 +881,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 159 + i32.const 16 + i32.const 157 i32.const 2 call $~lib/env/abort unreachable @@ -914,8 +900,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 165 + i32.const 16 + i32.const 163 i32.const 2 call $~lib/env/abort unreachable @@ -933,8 +919,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 171 + i32.const 16 + i32.const 169 i32.const 2 call $~lib/env/abort unreachable @@ -952,8 +938,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 177 + i32.const 16 + i32.const 175 i32.const 2 call $~lib/env/abort unreachable @@ -971,8 +957,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 183 + i32.const 16 + i32.const 181 i32.const 2 call $~lib/env/abort unreachable @@ -990,8 +976,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 184 + i32.const 16 + i32.const 182 i32.const 2 call $~lib/env/abort unreachable @@ -1009,8 +995,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 185 + i32.const 16 + i32.const 183 i32.const 2 call $~lib/env/abort unreachable @@ -1024,8 +1010,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 186 + i32.const 16 + i32.const 184 i32.const 2 call $~lib/env/abort unreachable @@ -1040,8 +1026,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 187 + i32.const 16 + i32.const 185 i32.const 2 call $~lib/env/abort unreachable @@ -1072,8 +1058,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 192 + i32.const 16 + i32.const 190 i32.const 2 call $~lib/env/abort unreachable @@ -1089,8 +1075,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 193 + i32.const 16 + i32.const 191 i32.const 2 call $~lib/env/abort unreachable @@ -1106,8 +1092,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 194 + i32.const 16 + i32.const 192 i32.const 2 call $~lib/env/abort unreachable @@ -1123,8 +1109,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 195 + i32.const 16 + i32.const 193 i32.const 2 call $~lib/env/abort unreachable @@ -1140,8 +1126,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 196 + i32.const 16 + i32.const 194 i32.const 2 call $~lib/env/abort unreachable @@ -1157,8 +1143,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 197 + i32.const 16 + i32.const 195 i32.const 2 call $~lib/env/abort unreachable @@ -1174,8 +1160,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 198 + i32.const 16 + i32.const 196 i32.const 2 call $~lib/env/abort unreachable @@ -1191,8 +1177,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 199 + i32.const 16 + i32.const 197 i32.const 2 call $~lib/env/abort unreachable @@ -1208,8 +1194,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 200 + i32.const 16 + i32.const 198 i32.const 2 call $~lib/env/abort unreachable @@ -1225,14 +1211,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 201 + i32.const 16 + i32.const 199 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_i32x4 (; 5 ;) (type $FUNCSIG$v) + (func $simd/test_i32x4 (; 4 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) (local $2 v128) @@ -1251,8 +1237,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 206 + i32.const 16 + i32.const 204 i32.const 2 call $~lib/env/abort unreachable @@ -1269,8 +1255,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 208 + i32.const 16 + i32.const 206 i32.const 2 call $~lib/env/abort unreachable @@ -1288,8 +1274,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 210 + i32.const 16 + i32.const 208 i32.const 2 call $~lib/env/abort unreachable @@ -1305,8 +1291,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 211 + i32.const 16 + i32.const 209 i32.const 2 call $~lib/env/abort unreachable @@ -1322,8 +1308,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 212 + i32.const 16 + i32.const 210 i32.const 2 call $~lib/env/abort unreachable @@ -1338,8 +1324,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 213 + i32.const 16 + i32.const 211 i32.const 2 call $~lib/env/abort unreachable @@ -1351,8 +1337,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 218 + i32.const 16 + i32.const 216 i32.const 2 call $~lib/env/abort unreachable @@ -1364,8 +1350,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 219 + i32.const 16 + i32.const 217 i32.const 2 call $~lib/env/abort unreachable @@ -1381,8 +1367,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 220 + i32.const 16 + i32.const 218 i32.const 2 call $~lib/env/abort unreachable @@ -1398,8 +1384,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 225 + i32.const 16 + i32.const 223 i32.const 2 call $~lib/env/abort unreachable @@ -1417,8 +1403,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 230 + i32.const 16 + i32.const 228 i32.const 2 call $~lib/env/abort unreachable @@ -1436,8 +1422,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 231 + i32.const 16 + i32.const 229 i32.const 2 call $~lib/env/abort unreachable @@ -1455,8 +1441,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 232 + i32.const 16 + i32.const 230 i32.const 2 call $~lib/env/abort unreachable @@ -1470,8 +1456,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 233 + i32.const 16 + i32.const 231 i32.const 2 call $~lib/env/abort unreachable @@ -1486,8 +1472,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 234 + i32.const 16 + i32.const 232 i32.const 2 call $~lib/env/abort unreachable @@ -1518,8 +1504,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 239 + i32.const 16 + i32.const 237 i32.const 2 call $~lib/env/abort unreachable @@ -1535,8 +1521,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 240 + i32.const 16 + i32.const 238 i32.const 2 call $~lib/env/abort unreachable @@ -1552,8 +1538,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 241 + i32.const 16 + i32.const 239 i32.const 2 call $~lib/env/abort unreachable @@ -1569,8 +1555,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 242 + i32.const 16 + i32.const 240 i32.const 2 call $~lib/env/abort unreachable @@ -1586,8 +1572,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 243 + i32.const 16 + i32.const 241 i32.const 2 call $~lib/env/abort unreachable @@ -1603,8 +1589,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 244 + i32.const 16 + i32.const 242 i32.const 2 call $~lib/env/abort unreachable @@ -1620,8 +1606,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 245 + i32.const 16 + i32.const 243 i32.const 2 call $~lib/env/abort unreachable @@ -1637,8 +1623,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 246 + i32.const 16 + i32.const 244 i32.const 2 call $~lib/env/abort unreachable @@ -1654,8 +1640,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 247 + i32.const 16 + i32.const 245 i32.const 2 call $~lib/env/abort unreachable @@ -1671,8 +1657,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 248 + i32.const 16 + i32.const 246 i32.const 2 call $~lib/env/abort unreachable @@ -1689,8 +1675,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 249 + i32.const 16 + i32.const 247 i32.const 2 call $~lib/env/abort unreachable @@ -1707,14 +1693,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 254 + i32.const 16 + i32.const 252 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_i64x2 (; 6 ;) (type $FUNCSIG$v) + (func $simd/test_i64x2 (; 5 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) (local $2 v128) @@ -1729,8 +1715,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 263 + i32.const 16 + i32.const 261 i32.const 2 call $~lib/env/abort unreachable @@ -1747,8 +1733,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 265 + i32.const 16 + i32.const 263 i32.const 2 call $~lib/env/abort unreachable @@ -1766,8 +1752,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 267 + i32.const 16 + i32.const 265 i32.const 2 call $~lib/env/abort unreachable @@ -1783,8 +1769,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 268 + i32.const 16 + i32.const 266 i32.const 2 call $~lib/env/abort unreachable @@ -1799,8 +1785,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 269 + i32.const 16 + i32.const 267 i32.const 2 call $~lib/env/abort unreachable @@ -1812,8 +1798,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 274 + i32.const 16 + i32.const 272 i32.const 2 call $~lib/env/abort unreachable @@ -1825,8 +1811,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 275 + i32.const 16 + i32.const 273 i32.const 2 call $~lib/env/abort unreachable @@ -1842,8 +1828,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 276 + i32.const 16 + i32.const 274 i32.const 2 call $~lib/env/abort unreachable @@ -1859,8 +1845,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 281 + i32.const 16 + i32.const 279 i32.const 2 call $~lib/env/abort unreachable @@ -1878,8 +1864,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 286 + i32.const 16 + i32.const 284 i32.const 2 call $~lib/env/abort unreachable @@ -1897,8 +1883,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 287 + i32.const 16 + i32.const 285 i32.const 2 call $~lib/env/abort unreachable @@ -1916,8 +1902,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 288 + i32.const 16 + i32.const 286 i32.const 2 call $~lib/env/abort unreachable @@ -1931,8 +1917,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 289 + i32.const 16 + i32.const 287 i32.const 2 call $~lib/env/abort unreachable @@ -1947,8 +1933,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 290 + i32.const 16 + i32.const 288 i32.const 2 call $~lib/env/abort unreachable @@ -1965,8 +1951,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 291 + i32.const 16 + i32.const 289 i32.const 2 call $~lib/env/abort unreachable @@ -1983,14 +1969,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 296 + i32.const 16 + i32.const 294 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_f32x4 (; 7 ;) (type $FUNCSIG$v) + (func $simd/test_f32x4 (; 6 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) (local $2 v128) @@ -2010,8 +1996,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 305 + i32.const 16 + i32.const 303 i32.const 2 call $~lib/env/abort unreachable @@ -2028,8 +2014,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 307 + i32.const 16 + i32.const 305 i32.const 2 call $~lib/env/abort unreachable @@ -2047,8 +2033,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 309 + i32.const 16 + i32.const 307 i32.const 2 call $~lib/env/abort unreachable @@ -2064,8 +2050,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 310 + i32.const 16 + i32.const 308 i32.const 2 call $~lib/env/abort unreachable @@ -2081,8 +2067,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 311 + i32.const 16 + i32.const 309 i32.const 2 call $~lib/env/abort unreachable @@ -2102,8 +2088,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 313 + i32.const 16 + i32.const 311 i32.const 2 call $~lib/env/abort unreachable @@ -2119,8 +2105,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 314 + i32.const 16 + i32.const 312 i32.const 2 call $~lib/env/abort unreachable @@ -2135,8 +2121,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 315 + i32.const 16 + i32.const 313 i32.const 2 call $~lib/env/abort unreachable @@ -2148,8 +2134,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 316 + i32.const 16 + i32.const 314 i32.const 2 call $~lib/env/abort unreachable @@ -2161,8 +2147,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 317 + i32.const 16 + i32.const 315 i32.const 2 call $~lib/env/abort unreachable @@ -2178,8 +2164,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 318 + i32.const 16 + i32.const 316 i32.const 2 call $~lib/env/abort unreachable @@ -2195,8 +2181,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 323 + i32.const 16 + i32.const 321 i32.const 2 call $~lib/env/abort unreachable @@ -2226,8 +2212,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 332 + i32.const 16 + i32.const 330 i32.const 2 call $~lib/env/abort unreachable @@ -2243,8 +2229,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 333 + i32.const 16 + i32.const 331 i32.const 2 call $~lib/env/abort unreachable @@ -2260,8 +2246,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 334 + i32.const 16 + i32.const 332 i32.const 2 call $~lib/env/abort unreachable @@ -2277,8 +2263,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 335 + i32.const 16 + i32.const 333 i32.const 2 call $~lib/env/abort unreachable @@ -2294,8 +2280,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 336 + i32.const 16 + i32.const 334 i32.const 2 call $~lib/env/abort unreachable @@ -2311,8 +2297,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 337 + i32.const 16 + i32.const 335 i32.const 2 call $~lib/env/abort unreachable @@ -2328,8 +2314,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 338 + i32.const 16 + i32.const 336 i32.const 2 call $~lib/env/abort unreachable @@ -2345,8 +2331,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 339 + i32.const 16 + i32.const 337 i32.const 2 call $~lib/env/abort unreachable @@ -2361,8 +2347,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 340 + i32.const 16 + i32.const 338 i32.const 2 call $~lib/env/abort unreachable @@ -2377,8 +2363,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 341 + i32.const 16 + i32.const 339 i32.const 2 call $~lib/env/abort unreachable @@ -2395,8 +2381,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 342 + i32.const 16 + i32.const 340 i32.const 2 call $~lib/env/abort unreachable @@ -2413,14 +2399,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 347 + i32.const 16 + i32.const 345 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_f64x2 (; 8 ;) (type $FUNCSIG$v) + (func $simd/test_f64x2 (; 7 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) (local $2 v128) @@ -2440,8 +2426,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 356 + i32.const 16 + i32.const 354 i32.const 2 call $~lib/env/abort unreachable @@ -2458,8 +2444,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 358 + i32.const 16 + i32.const 356 i32.const 2 call $~lib/env/abort unreachable @@ -2477,8 +2463,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 360 + i32.const 16 + i32.const 358 i32.const 2 call $~lib/env/abort unreachable @@ -2494,8 +2480,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 361 + i32.const 16 + i32.const 359 i32.const 2 call $~lib/env/abort unreachable @@ -2511,8 +2497,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 362 + i32.const 16 + i32.const 360 i32.const 2 call $~lib/env/abort unreachable @@ -2532,8 +2518,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 364 + i32.const 16 + i32.const 362 i32.const 2 call $~lib/env/abort unreachable @@ -2549,8 +2535,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 365 + i32.const 16 + i32.const 363 i32.const 2 call $~lib/env/abort unreachable @@ -2565,8 +2551,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 366 + i32.const 16 + i32.const 364 i32.const 2 call $~lib/env/abort unreachable @@ -2578,8 +2564,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 367 + i32.const 16 + i32.const 365 i32.const 2 call $~lib/env/abort unreachable @@ -2591,8 +2577,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 368 + i32.const 16 + i32.const 366 i32.const 2 call $~lib/env/abort unreachable @@ -2608,8 +2594,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 369 + i32.const 16 + i32.const 367 i32.const 2 call $~lib/env/abort unreachable @@ -2625,8 +2611,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 374 + i32.const 16 + i32.const 372 i32.const 2 call $~lib/env/abort unreachable @@ -2656,8 +2642,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 383 + i32.const 16 + i32.const 381 i32.const 2 call $~lib/env/abort unreachable @@ -2673,8 +2659,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 384 + i32.const 16 + i32.const 382 i32.const 2 call $~lib/env/abort unreachable @@ -2690,8 +2676,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 385 + i32.const 16 + i32.const 383 i32.const 2 call $~lib/env/abort unreachable @@ -2707,8 +2693,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 386 + i32.const 16 + i32.const 384 i32.const 2 call $~lib/env/abort unreachable @@ -2724,8 +2710,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 387 + i32.const 16 + i32.const 385 i32.const 2 call $~lib/env/abort unreachable @@ -2741,8 +2727,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 388 + i32.const 16 + i32.const 386 i32.const 2 call $~lib/env/abort unreachable @@ -2758,8 +2744,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 389 + i32.const 16 + i32.const 387 i32.const 2 call $~lib/env/abort unreachable @@ -2775,8 +2761,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 390 + i32.const 16 + i32.const 388 i32.const 2 call $~lib/env/abort unreachable @@ -2791,8 +2777,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 391 + i32.const 16 + i32.const 389 i32.const 2 call $~lib/env/abort unreachable @@ -2807,8 +2793,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 392 + i32.const 16 + i32.const 390 i32.const 2 call $~lib/env/abort unreachable @@ -2825,8 +2811,8 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 393 + i32.const 16 + i32.const 391 i32.const 2 call $~lib/env/abort unreachable @@ -2843,14 +2829,14 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 398 + i32.const 16 + i32.const 396 i32.const 2 call $~lib/env/abort unreachable end ) - (func $simd/test_v8x16 (; 9 ;) (type $FUNCSIG$v) + (func $simd/test_v8x16 (; 8 ;) (type $FUNCSIG$v) (local $0 v128) (local $1 v128) v128.const i32 0x03020100 0x07060504 0x0b0a0908 0x0f0e0d0c @@ -2868,29 +2854,26 @@ i32.eqz if i32.const 0 - i32.const 8 - i32.const 408 + i32.const 16 + i32.const 406 i32.const 2 call $~lib/env/abort unreachable end ) - (func $start:simd (; 10 ;) (type $FUNCSIG$v) - call $start:~lib/allocator/arena - block - call $simd/test_v128 - call $simd/test_i8x16 - call $simd/test_i16x8 - call $simd/test_i32x4 - call $simd/test_i64x2 - call $simd/test_f32x4 - call $simd/test_f64x2 - call $simd/test_v8x16 - end + (func $start:simd (; 9 ;) (type $FUNCSIG$v) + call $simd/test_v128 + call $simd/test_i8x16 + call $simd/test_i16x8 + call $simd/test_i32x4 + call $simd/test_i64x2 + call $simd/test_f32x4 + call $simd/test_f64x2 + call $simd/test_v8x16 ) - (func $start (; 11 ;) (type $FUNCSIG$v) + (func $start (; 10 ;) (type $FUNCSIG$v) call $start:simd ) - (func $null (; 12 ;) (type $FUNCSIG$v) + (func $null (; 11 ;) (type $FUNCSIG$v) ) ) diff --git a/tests/compiler/std/array-literal.optimized.wat b/tests/compiler/std/array-literal.optimized.wat index a38833e0..e513bbdf 100644 --- a/tests/compiler/std/array-literal.optimized.wat +++ b/tests/compiler/std/array-literal.optimized.wat @@ -177,7 +177,7 @@ if i32.const 0 i32.const 296 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -192,7 +192,7 @@ if i32.const 0 i32.const 296 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/array-literal.untouched.wat b/tests/compiler/std/array-literal.untouched.wat index 5ff0a182..6aa27f82 100644 --- a/tests/compiler/std/array-literal.untouched.wat +++ b/tests/compiler/std/array-literal.untouched.wat @@ -234,7 +234,7 @@ if i32.const 0 i32.const 296 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -251,7 +251,7 @@ if i32.const 0 i32.const 296 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -1710,15 +1710,15 @@ (local $9 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl local.set $5 local.get $0 - local.get $3 + local.get $2 i32.shl call $~lib/runtime/allocate i32.const 1 @@ -1756,32 +1756,23 @@ local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if local.get $6 - local.get $1 + local.get $3 local.get $5 call $~lib/memory/memory.copy end local.get $4 ) (func $std/array-literal/Ref#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 5 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 5 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -1791,22 +1782,13 @@ i32.load offset=12 ) (func $std/array-literal/RefWithCtor#constructor (; 19 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 7 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 7 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -1819,7 +1801,6 @@ (local $0 i32) (local $1 i32) (local $2 i32) - (local $3 i32) global.get $std/array-literal/staticArrayI8 call $~lib/array/Array#get:length i32.const 3 @@ -1954,17 +1935,11 @@ global.get $~lib/allocator/arena/startOffset global.set $~lib/allocator/arena/offset block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 3 - local.set $2 - i32.const 0 - local.set $3 - local.get $2 - local.get $3 - i32.const 2 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 2 + i32.const 0 + i32.const 0 + call $~lib/runtime/makeArray local.set $0 local.get $0 i32.load offset=4 @@ -1977,9 +1952,9 @@ global.get $std/array-literal/i i32.const 1 i32.add - local.tee $3 + local.tee $2 global.set $std/array-literal/i - local.get $3 + local.get $2 end i32.store8 offset=1 local.get $1 @@ -1987,9 +1962,9 @@ global.get $std/array-literal/i i32.const 1 i32.add - local.tee $3 + local.tee $2 global.set $std/array-literal/i - local.get $3 + local.get $2 end i32.store8 offset=2 local.get $0 @@ -2053,17 +2028,11 @@ i32.const 0 global.set $std/array-literal/i block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 3 - local.set $3 - i32.const 0 - local.set $2 - local.get $3 - local.get $2 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 4 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $1 local.get $1 i32.load offset=4 @@ -2150,17 +2119,11 @@ unreachable end block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 3 - local.set $2 - i32.const 0 - local.set $3 - local.get $2 - local.get $3 - i32.const 6 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 6 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $0 local.get $0 i32.load offset=4 @@ -2169,33 +2132,33 @@ block (result i32) i32.const 0 call $std/array-literal/Ref#constructor - local.set $3 - local.get $3 + local.set $2 + local.get $2 local.get $0 call $~lib/collector/dummy/__ref_link - local.get $3 + local.get $2 end i32.store local.get $1 block (result i32) i32.const 0 call $std/array-literal/Ref#constructor - local.set $3 - local.get $3 + local.set $2 + local.get $2 local.get $0 call $~lib/collector/dummy/__ref_link - local.get $3 + local.get $2 end i32.store offset=4 local.get $1 block (result i32) i32.const 0 call $std/array-literal/Ref#constructor - local.set $3 - local.get $3 + local.set $2 + local.get $2 local.get $0 call $~lib/collector/dummy/__ref_link - local.get $3 + local.get $2 end i32.store offset=8 local.get $0 @@ -2215,17 +2178,11 @@ unreachable end block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 3 - local.set $3 - i32.const 0 - local.set $2 - local.get $3 - local.get $2 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 8 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $1 local.get $1 i32.load offset=4 diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index 77219d56..d24bd4a6 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -787,7 +787,7 @@ if i32.const 0 i32.const 24 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -802,7 +802,7 @@ if i32.const 0 i32.const 24 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -845,7 +845,7 @@ if i32.const 0 i32.const 24 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable @@ -2071,39 +2071,39 @@ (local $5 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl - local.tee $3 + local.tee $2 call $~lib/runtime/allocate i32.const 2 call $~lib/runtime/register local.tee $5 - local.tee $2 + local.tee $1 local.get $4 i32.load i32.ne drop local.get $4 - local.get $2 + local.get $1 i32.store local.get $4 local.get $5 i32.store offset=4 local.get $4 - local.get $3 + local.get $2 i32.store offset=8 local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if local.get $5 - local.get $1 local.get $3 + local.get $2 call $~lib/memory/memory.copy end local.get $4 @@ -2396,7 +2396,7 @@ if i32.const 0 i32.const 24 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -2540,9 +2540,9 @@ select local.tee $3 i32.add - i32.const 0 i32.const 4 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $4 i32.load offset=4 @@ -2969,9 +2969,9 @@ i32.gt_s select local.tee $2 - i32.const 0 i32.const 4 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $5 i32.load offset=4 @@ -3460,9 +3460,9 @@ local.get $0 i32.load offset=12 local.tee $3 - i32.const 0 i32.const 9 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $4 i32.load offset=4 @@ -3550,9 +3550,9 @@ local.get $0 i32.load offset=12 local.tee $4 - i32.const 0 i32.const 4 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray i32.load offset=4 local.set $5 @@ -3624,9 +3624,9 @@ (local $4 i32) (local $5 i32) i32.const 0 - i32.const 0 i32.const 4 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.set $4 local.get $0 @@ -5381,9 +5381,9 @@ unreachable end local.get $0 - i32.const 0 i32.const 4 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $0 i32.load offset=4 @@ -5572,9 +5572,9 @@ (func $~lib/array/Array.create> (; 99 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) i32.const 512 - i32.const 0 i32.const 11 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $0 i32.load offset=4 @@ -5832,9 +5832,9 @@ (func $~lib/array/Array.create> (; 107 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) i32.const 512 - i32.const 0 i32.const 12 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $0 i32.load offset=4 @@ -6123,9 +6123,9 @@ (func $~lib/array/Array.create (; 115 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) i32.const 400 - i32.const 0 i32.const 15 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $0 i32.load offset=4 @@ -6385,7 +6385,7 @@ if i32.const 0 i32.const 24 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -6399,7 +6399,7 @@ if i32.const 0 i32.const 24 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable @@ -10094,9 +10094,9 @@ call $~lib/array/Array#fill global.get $std/array/arr8 i32.const 5 - i32.const 248 i32.const 7 i32.const 0 + i32.const 248 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -10115,9 +10115,9 @@ call $~lib/array/Array#fill global.get $std/array/arr8 i32.const 5 - i32.const 320 i32.const 7 i32.const 0 + i32.const 320 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -10136,9 +10136,9 @@ call $~lib/array/Array#fill global.get $std/array/arr8 i32.const 5 - i32.const 344 i32.const 7 i32.const 0 + i32.const 344 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -10157,9 +10157,9 @@ call $~lib/array/Array#fill global.get $std/array/arr8 i32.const 5 - i32.const 368 i32.const 7 i32.const 0 + i32.const 368 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -10178,9 +10178,9 @@ call $~lib/array/Array#fill global.get $std/array/arr8 i32.const 5 - i32.const 392 i32.const 7 i32.const 0 + i32.const 392 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -10199,9 +10199,9 @@ call $~lib/array/Array#fill global.get $std/array/arr32 i32.const 5 - i32.const 488 i32.const 8 i32.const 2 + i32.const 488 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10221,9 +10221,9 @@ call $~lib/array/Array#fill global.get $std/array/arr32 i32.const 5 - i32.const 528 i32.const 8 i32.const 2 + i32.const 528 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10243,9 +10243,9 @@ call $~lib/array/Array#fill global.get $std/array/arr32 i32.const 5 - i32.const 568 i32.const 8 i32.const 2 + i32.const 568 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10265,9 +10265,9 @@ call $~lib/array/Array#fill global.get $std/array/arr32 i32.const 5 - i32.const 608 i32.const 8 i32.const 2 + i32.const 608 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10287,9 +10287,9 @@ call $~lib/array/Array#fill global.get $std/array/arr32 i32.const 5 - i32.const 648 i32.const 8 i32.const 2 + i32.const 648 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10636,9 +10636,9 @@ end global.get $std/array/out i32.const 0 - i32.const 688 i32.const 4 i32.const 2 + i32.const 688 call $~lib/runtime/makeArray call $~lib/array/Array#concat drop @@ -10895,9 +10895,9 @@ unreachable end i32.const 5 - i32.const 752 i32.const 4 i32.const 2 + i32.const 752 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -10906,9 +10906,9 @@ i32.const 2147483647 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 792 i32.const 4 i32.const 2 + i32.const 792 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10922,9 +10922,9 @@ unreachable end i32.const 5 - i32.const 832 i32.const 4 i32.const 2 + i32.const 832 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -10933,9 +10933,9 @@ i32.const 2147483647 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 872 i32.const 4 i32.const 2 + i32.const 872 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10949,9 +10949,9 @@ unreachable end i32.const 5 - i32.const 912 i32.const 4 i32.const 2 + i32.const 912 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -10960,9 +10960,9 @@ i32.const 2147483647 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 952 i32.const 4 i32.const 2 + i32.const 952 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -10976,9 +10976,9 @@ unreachable end i32.const 5 - i32.const 992 i32.const 4 i32.const 2 + i32.const 992 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -10987,9 +10987,9 @@ i32.const 2147483647 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1032 i32.const 4 i32.const 2 + i32.const 1032 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11003,9 +11003,9 @@ unreachable end i32.const 5 - i32.const 1072 i32.const 4 i32.const 2 + i32.const 1072 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11014,9 +11014,9 @@ i32.const 4 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1112 i32.const 4 i32.const 2 + i32.const 1112 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11030,9 +11030,9 @@ unreachable end i32.const 5 - i32.const 1152 i32.const 4 i32.const 2 + i32.const 1152 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11041,9 +11041,9 @@ i32.const 4 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1192 i32.const 4 i32.const 2 + i32.const 1192 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11057,9 +11057,9 @@ unreachable end i32.const 5 - i32.const 1232 i32.const 4 i32.const 2 + i32.const 1232 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11068,9 +11068,9 @@ i32.const 4 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1272 i32.const 4 i32.const 2 + i32.const 1272 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11084,9 +11084,9 @@ unreachable end i32.const 5 - i32.const 1312 i32.const 4 i32.const 2 + i32.const 1312 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11095,9 +11095,9 @@ i32.const 2147483647 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1352 i32.const 4 i32.const 2 + i32.const 1352 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11111,9 +11111,9 @@ unreachable end i32.const 5 - i32.const 1392 i32.const 4 i32.const 2 + i32.const 1392 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11122,9 +11122,9 @@ i32.const -1 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1432 i32.const 4 i32.const 2 + i32.const 1432 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11138,9 +11138,9 @@ unreachable end i32.const 5 - i32.const 1472 i32.const 4 i32.const 2 + i32.const 1472 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11149,9 +11149,9 @@ i32.const -2 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1512 i32.const 4 i32.const 2 + i32.const 1512 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11165,9 +11165,9 @@ unreachable end i32.const 5 - i32.const 1552 i32.const 4 i32.const 2 + i32.const 1552 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11176,9 +11176,9 @@ i32.const -1 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1592 i32.const 4 i32.const 2 + i32.const 1592 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -11192,9 +11192,9 @@ unreachable end i32.const 5 - i32.const 1632 i32.const 4 i32.const 2 + i32.const 1632 call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr @@ -11203,9 +11203,9 @@ i32.const 2147483647 call $~lib/array/Array#copyWithin i32.const 5 - i32.const 1672 i32.const 4 i32.const 2 + i32.const 1672 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12031,9 +12031,9 @@ i32.const 2147483647 call $~lib/array/Array#splice i32.const 5 - i32.const 1784 i32.const 4 i32.const 2 + i32.const 1784 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12048,9 +12048,9 @@ end global.get $std/array/sarr i32.const 0 - i32.const 1824 i32.const 4 i32.const 2 + i32.const 1824 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12064,9 +12064,9 @@ unreachable end i32.const 5 - i32.const 1840 i32.const 4 i32.const 2 + i32.const 1840 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12074,9 +12074,9 @@ i32.const 2147483647 call $~lib/array/Array#splice i32.const 3 - i32.const 1880 i32.const 4 i32.const 2 + i32.const 1880 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12091,9 +12091,9 @@ end global.get $std/array/sarr i32.const 2 - i32.const 1912 i32.const 4 i32.const 2 + i32.const 1912 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12107,9 +12107,9 @@ unreachable end i32.const 5 - i32.const 1936 i32.const 4 i32.const 2 + i32.const 1936 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12117,9 +12117,9 @@ i32.const 2 call $~lib/array/Array#splice i32.const 2 - i32.const 1976 i32.const 4 i32.const 2 + i32.const 1976 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12134,9 +12134,9 @@ end global.get $std/array/sarr i32.const 3 - i32.const 2000 i32.const 4 i32.const 2 + i32.const 2000 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12150,9 +12150,9 @@ unreachable end i32.const 5 - i32.const 2032 i32.const 4 i32.const 2 + i32.const 2032 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12160,9 +12160,9 @@ i32.const 1 call $~lib/array/Array#splice i32.const 1 - i32.const 2072 i32.const 4 i32.const 2 + i32.const 2072 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12177,9 +12177,9 @@ end global.get $std/array/sarr i32.const 4 - i32.const 2096 i32.const 4 i32.const 2 + i32.const 2096 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12193,9 +12193,9 @@ unreachable end i32.const 5 - i32.const 2128 i32.const 4 i32.const 2 + i32.const 2128 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12203,9 +12203,9 @@ i32.const 2147483647 call $~lib/array/Array#splice i32.const 1 - i32.const 2168 i32.const 4 i32.const 2 + i32.const 2168 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12220,9 +12220,9 @@ end global.get $std/array/sarr i32.const 4 - i32.const 2192 i32.const 4 i32.const 2 + i32.const 2192 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12236,9 +12236,9 @@ unreachable end i32.const 5 - i32.const 2224 i32.const 4 i32.const 2 + i32.const 2224 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12246,9 +12246,9 @@ i32.const 2147483647 call $~lib/array/Array#splice i32.const 2 - i32.const 2264 i32.const 4 i32.const 2 + i32.const 2264 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12263,9 +12263,9 @@ end global.get $std/array/sarr i32.const 3 - i32.const 2288 i32.const 4 i32.const 2 + i32.const 2288 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12279,9 +12279,9 @@ unreachable end i32.const 5 - i32.const 2320 i32.const 4 i32.const 2 + i32.const 2320 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12289,9 +12289,9 @@ i32.const 1 call $~lib/array/Array#splice i32.const 1 - i32.const 2360 i32.const 4 i32.const 2 + i32.const 2360 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12306,9 +12306,9 @@ end global.get $std/array/sarr i32.const 4 - i32.const 2384 i32.const 4 i32.const 2 + i32.const 2384 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12322,9 +12322,9 @@ unreachable end i32.const 5 - i32.const 2416 i32.const 4 i32.const 2 + i32.const 2416 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12332,9 +12332,9 @@ i32.const 1 call $~lib/array/Array#splice i32.const 1 - i32.const 2456 i32.const 4 i32.const 2 + i32.const 2456 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12349,9 +12349,9 @@ end global.get $std/array/sarr i32.const 4 - i32.const 2480 i32.const 4 i32.const 2 + i32.const 2480 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12365,9 +12365,9 @@ unreachable end i32.const 5 - i32.const 2512 i32.const 4 i32.const 2 + i32.const 2512 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12375,9 +12375,9 @@ i32.const -1 call $~lib/array/Array#splice i32.const 0 - i32.const 2552 i32.const 4 i32.const 2 + i32.const 2552 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12392,9 +12392,9 @@ end global.get $std/array/sarr i32.const 5 - i32.const 2568 i32.const 4 i32.const 2 + i32.const 2568 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12408,9 +12408,9 @@ unreachable end i32.const 5 - i32.const 2608 i32.const 4 i32.const 2 + i32.const 2608 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12418,9 +12418,9 @@ i32.const -2 call $~lib/array/Array#splice i32.const 0 - i32.const 2648 i32.const 4 i32.const 2 + i32.const 2648 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12435,9 +12435,9 @@ end global.get $std/array/sarr i32.const 5 - i32.const 2664 i32.const 4 i32.const 2 + i32.const 2664 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12451,9 +12451,9 @@ unreachable end i32.const 5 - i32.const 2704 i32.const 4 i32.const 2 + i32.const 2704 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12461,9 +12461,9 @@ i32.const 0 call $~lib/array/Array#splice i32.const 0 - i32.const 2744 i32.const 4 i32.const 2 + i32.const 2744 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12478,9 +12478,9 @@ end global.get $std/array/sarr i32.const 5 - i32.const 2760 i32.const 4 i32.const 2 + i32.const 2760 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12494,9 +12494,9 @@ unreachable end i32.const 5 - i32.const 2800 i32.const 4 i32.const 2 + i32.const 2800 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12504,9 +12504,9 @@ i32.const 0 call $~lib/array/Array#splice i32.const 0 - i32.const 2840 i32.const 4 i32.const 2 + i32.const 2840 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12521,9 +12521,9 @@ end global.get $std/array/sarr i32.const 5 - i32.const 2856 i32.const 4 i32.const 2 + i32.const 2856 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12537,9 +12537,9 @@ unreachable end i32.const 5 - i32.const 2896 i32.const 4 i32.const 2 + i32.const 2896 call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr @@ -12547,9 +12547,9 @@ i32.const 5 call $~lib/array/Array#splice i32.const 0 - i32.const 2936 i32.const 4 i32.const 2 + i32.const 2936 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -12564,9 +12564,9 @@ end global.get $std/array/sarr i32.const 5 - i32.const 2952 i32.const 4 i32.const 2 + i32.const 2952 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -13668,9 +13668,9 @@ call $~lib/array/Array#sort global.get $std/array/f32ArrayTyped i32.const 8 - i32.const 3304 i32.const 9 i32.const 2 + i32.const 3304 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -13704,9 +13704,9 @@ call $~lib/array/Array#sort global.get $std/array/f64ArrayTyped i32.const 8 - i32.const 3464 i32.const 10 i32.const 3 + i32.const 3464 call $~lib/runtime/makeArray call $std/array/isArraysEqual i32.eqz @@ -13741,9 +13741,9 @@ drop global.get $std/array/i32ArrayTyped i32.const 5 - i32.const 3616 i32.const 4 i32.const 2 + i32.const 3616 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -13779,9 +13779,9 @@ drop global.get $std/array/u32ArrayTyped i32.const 5 - i32.const 3728 i32.const 8 i32.const 2 + i32.const 3728 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -13815,9 +13815,9 @@ call $std/array/assertSortedDefault global.get $std/array/reversed1 i32.const 1 - i32.const 4056 i32.const 4 i32.const 2 + i32.const 4056 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -13834,9 +13834,9 @@ call $std/array/assertSortedDefault global.get $std/array/reversed2 i32.const 2 - i32.const 4080 i32.const 4 i32.const 2 + i32.const 4080 call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual @@ -13995,9 +13995,9 @@ local.get $0 call $std/array/assertSorted> i32.const 2 - i32.const 4552 i32.const 16 i32.const 0 + i32.const 4552 call $~lib/runtime/makeArray call $~lib/array/Array#join_bool i32.const 4576 @@ -14012,9 +14012,9 @@ unreachable end i32.const 3 - i32.const 5120 i32.const 4 i32.const 2 + i32.const 5120 call $~lib/runtime/makeArray i32.const 4200 call $~lib/array/Array#join @@ -14030,9 +14030,9 @@ unreachable end i32.const 3 - i32.const 5240 i32.const 8 i32.const 2 + i32.const 5240 call $~lib/runtime/makeArray i32.const 5216 call $~lib/array/Array#join @@ -14048,9 +14048,9 @@ unreachable end i32.const 2 - i32.const 5320 i32.const 4 i32.const 2 + i32.const 5320 call $~lib/runtime/makeArray i32.const 5296 call $~lib/array/Array#join @@ -14066,9 +14066,9 @@ unreachable end i32.const 6 - i32.const 6672 i32.const 10 i32.const 3 + i32.const 6672 call $~lib/runtime/makeArray call $~lib/array/Array#join_flt i32.const 6736 @@ -14083,9 +14083,9 @@ unreachable end i32.const 3 - i32.const 6888 i32.const 15 i32.const 2 + i32.const 6888 call $~lib/runtime/makeArray i32.const 4200 call $~lib/array/Array#join @@ -14101,19 +14101,19 @@ unreachable end i32.const 3 - i32.const 0 i32.const 20 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $0 i32.load offset=4 - local.tee $1 + local.tee $2 call $std/array/Ref#constructor i32.store - local.get $1 + local.get $2 i32.const 0 i32.store offset=4 - local.get $1 + local.get $2 call $std/array/Ref#constructor i32.store offset=8 local.get $0 @@ -14184,9 +14184,9 @@ unreachable end i32.const 3 - i32.const 7128 i32.const 21 i32.const 0 + i32.const 7128 call $~lib/runtime/makeArray call $~lib/array/Array#join_int i32.const 7152 @@ -14201,9 +14201,9 @@ unreachable end i32.const 3 - i32.const 7208 i32.const 22 i32.const 1 + i32.const 7208 call $~lib/runtime/makeArray call $~lib/array/Array#join_int i32.const 7232 @@ -14218,9 +14218,9 @@ unreachable end i32.const 3 - i32.const 7312 i32.const 17 i32.const 3 + i32.const 7312 call $~lib/runtime/makeArray call $~lib/array/Array#join_int i32.const 7352 @@ -14235,9 +14235,9 @@ unreachable end i32.const 4 - i32.const 7464 i32.const 23 i32.const 3 + i32.const 7464 call $~lib/runtime/makeArray call $~lib/array/Array#join_int i32.const 7512 @@ -14265,9 +14265,9 @@ unreachable end i32.const 4 - i32.const 7744 i32.const 15 i32.const 2 + i32.const 7744 call $~lib/runtime/makeArray call $~lib/array/Array#toString i32.const 7776 @@ -14282,27 +14282,27 @@ unreachable end i32.const 2 - i32.const 0 i32.const 11 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray - local.tee $0 + local.tee $2 i32.load offset=4 - local.tee $1 + local.tee $0 + i32.const 2 + i32.const 4 i32.const 2 i32.const 7832 - i32.const 4 - i32.const 2 call $~lib/runtime/makeArray i32.store - local.get $1 + local.get $0 i32.const 2 - i32.const 7856 i32.const 4 i32.const 2 + i32.const 7856 call $~lib/runtime/makeArray i32.store offset=4 - local.get $0 + local.get $2 global.set $std/array/subarr32 global.get $std/array/subarr32 call $~lib/array/Array>#join_arr @@ -14318,24 +14318,24 @@ unreachable end i32.const 2 - i32.const 0 i32.const 24 i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $0 i32.load offset=4 - local.tee $1 + local.tee $2 i32.const 2 - i32.const 7936 i32.const 7 i32.const 0 + i32.const 7936 call $~lib/runtime/makeArray i32.store - local.get $1 + local.get $2 i32.const 2 - i32.const 7960 i32.const 7 i32.const 0 + i32.const 7960 call $~lib/runtime/makeArray i32.store offset=4 local.get $0 @@ -14354,30 +14354,30 @@ unreachable end i32.const 1 - i32.const 0 i32.const 26 i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray + local.tee $0 + i32.load offset=4 + local.set $2 + i32.const 1 + i32.const 25 + i32.const 2 + i32.const 0 call $~lib/runtime/makeArray local.tee $1 i32.load offset=4 - local.set $0 i32.const 1 - i32.const 0 - i32.const 25 - i32.const 2 - call $~lib/runtime/makeArray - local.tee $2 - i32.load offset=4 - i32.const 1 - i32.const 8056 i32.const 8 i32.const 2 + i32.const 8056 call $~lib/runtime/makeArray i32.store - local.get $0 local.get $2 - i32.store local.get $1 + i32.store + local.get $0 global.set $std/array/subarrU32 global.get $std/array/subarrU32 call $~lib/array/Array>>#join_arr diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index bdfc3fb5..e917b4f7 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -685,7 +685,7 @@ if i32.const 0 i32.const 24 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -702,7 +702,7 @@ if i32.const 0 i32.const 24 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -766,7 +766,7 @@ if i32.const 0 i32.const 24 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable @@ -782,18 +782,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 12 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 3 - call $~lib/runtime/register - end + i32.const 12 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -838,19 +830,12 @@ local.get $0 ) (func $~lib/array/Array#constructor (; 12 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 16 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 16 + call $~lib/runtime/allocate i32.const 4 call $~lib/runtime/register end @@ -887,22 +872,13 @@ end ) (func $std/array/P#constructor (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER

|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 5 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 5 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -918,19 +894,12 @@ end ) (func $~lib/typedarray/Uint8Array#constructor (; 17 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 6 call $~lib/runtime/register end @@ -2487,15 +2456,15 @@ (local $9 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl local.set $5 local.get $0 - local.get $3 + local.get $2 i32.shl call $~lib/runtime/allocate i32.const 2 @@ -2533,10 +2502,10 @@ local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if local.get $6 - local.get $1 + local.get $3 local.get $5 call $~lib/memory/memory.copy end @@ -2898,7 +2867,7 @@ if i32.const 0 i32.const 24 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -3126,9 +3095,9 @@ i32.const 0 local.set $4 local.get $5 - local.get $4 i32.const 4 i32.const 2 + local.get $4 call $~lib/runtime/makeArray end local.set $6 @@ -3672,15 +3641,15 @@ i32.gt_s select local.set $2 - block $~lib/runtime/MAKEARRAY|inlined.26 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) local.get $2 local.set $5 i32.const 0 local.set $4 local.get $5 - local.get $4 i32.const 4 i32.const 2 + local.get $4 call $~lib/runtime/makeArray end local.set $6 @@ -4264,9 +4233,9 @@ i32.const 0 local.set $3 local.get $4 - local.get $3 i32.const 9 i32.const 2 + local.get $3 call $~lib/runtime/makeArray end local.set $5 @@ -4379,15 +4348,15 @@ local.get $0 i32.load offset=12 local.set $2 - block $~lib/runtime/MAKEARRAY|inlined.65 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) local.get $2 local.set $4 i32.const 0 local.set $3 local.get $4 - local.get $3 i32.const 4 i32.const 2 + local.get $3 call $~lib/runtime/makeArray end local.set $5 @@ -4475,15 +4444,15 @@ (local $4 i32) (local $5 i32) (local $6 i32) - block $~lib/runtime/MAKEARRAY|inlined.66 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) i32.const 0 local.set $3 i32.const 0 local.set $2 local.get $3 - local.get $2 i32.const 4 i32.const 2 + local.get $2 call $~lib/runtime/makeArray end local.set $4 @@ -7273,15 +7242,15 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.68 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) local.get $0 local.set $2 i32.const 0 local.set $1 local.get $2 - local.get $1 i32.const 4 i32.const 2 + local.get $1 call $~lib/runtime/makeArray end local.set $3 @@ -7541,9 +7510,9 @@ i32.const 0 local.set $1 local.get $2 - local.get $1 i32.const 11 i32.const 2 + local.get $1 call $~lib/runtime/makeArray end local.set $3 @@ -7982,9 +7951,9 @@ i32.const 0 local.set $1 local.get $2 - local.get $1 i32.const 12 i32.const 2 + local.get $1 call $~lib/runtime/makeArray end local.set $3 @@ -8000,22 +7969,13 @@ local.get $3 ) (func $std/array/Proxy#constructor (; 167 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 4 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 - i32.const 13 - call $~lib/runtime/register - end + i32.const 4 + call $~lib/runtime/allocate + i32.const 13 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -8963,9 +8923,9 @@ i32.const 0 local.set $1 local.get $2 - local.get $1 i32.const 15 i32.const 2 + local.get $1 call $~lib/runtime/makeArray end local.set $3 @@ -9003,7 +8963,7 @@ i32.const 4200 return end - block $~lib/runtime/ALLOCATE|inlined.6 (result i32) + block $~lib/runtime/ALLOCATE|inlined.1 (result i32) i32.const 2 local.set $2 local.get $2 @@ -9060,7 +9020,7 @@ i32.const 4200 return end - block $~lib/runtime/ALLOCATE|inlined.7 (result i32) + block $~lib/runtime/ALLOCATE|inlined.2 (result i32) local.get $4 local.set $5 local.get $5 @@ -9718,7 +9678,7 @@ local.get $0 return end - block $~lib/runtime/ALLOCATE|inlined.9 (result i32) + block $~lib/runtime/ALLOCATE|inlined.4 (result i32) local.get $3 local.set $4 local.get $4 @@ -9748,7 +9708,7 @@ if i32.const 0 i32.const 24 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -9765,7 +9725,7 @@ if i32.const 0 i32.const 24 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable @@ -9824,7 +9784,7 @@ local.get $5 i32.add local.set $6 - block $~lib/runtime/ALLOCATE|inlined.8 (result i32) + block $~lib/runtime/ALLOCATE|inlined.3 (result i32) local.get $6 i32.const 1 i32.shl @@ -10207,7 +10167,7 @@ local.get $1 i32.add local.set $2 - block $~lib/runtime/ALLOCATE|inlined.10 (result i32) + block $~lib/runtime/ALLOCATE|inlined.5 (result i32) local.get $2 i32.const 1 i32.shl @@ -10350,7 +10310,7 @@ i32.const 11 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.11 (result i32) + block $~lib/runtime/ALLOCATE|inlined.6 (result i32) local.get $5 i32.const 1 i32.shl @@ -10473,7 +10433,7 @@ local.get $0 call $~lib/util/number/decimalCount32 local.set $1 - block $~lib/runtime/ALLOCATE|inlined.12 (result i32) + block $~lib/runtime/ALLOCATE|inlined.7 (result i32) local.get $1 i32.const 1 i32.shl @@ -10590,7 +10550,7 @@ i32.const 10 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.13 (result i32) + block $~lib/runtime/ALLOCATE|inlined.8 (result i32) local.get $5 i32.const 1 i32.shl @@ -12095,7 +12055,7 @@ select return end - block $~lib/runtime/ALLOCATE|inlined.14 (result i32) + block $~lib/runtime/ALLOCATE|inlined.9 (result i32) i32.const 28 i32.const 1 i32.shl @@ -12239,7 +12199,7 @@ i32.const 28 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.15 (result i32) + block $~lib/runtime/ALLOCATE|inlined.10 (result i32) local.get $5 i32.const 1 i32.shl @@ -12429,7 +12389,7 @@ end i32.const 0 local.set $9 - block $~lib/runtime/ALLOCATE|inlined.16 (result i32) + block $~lib/runtime/ALLOCATE|inlined.11 (result i32) local.get $5 local.get $4 local.get $2 @@ -12546,22 +12506,13 @@ return ) (func $std/array/Ref#constructor (; 238 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.17 (result i32) - i32.const 0 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 19 - call $~lib/runtime/register - end + i32.const 0 + call $~lib/runtime/allocate + i32.const 19 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -12608,7 +12559,7 @@ i32.const 15 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.18 (result i32) + block $~lib/runtime/ALLOCATE|inlined.12 (result i32) local.get $5 i32.const 1 i32.shl @@ -12867,7 +12818,7 @@ i32.const 11 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.19 (result i32) + block $~lib/runtime/ALLOCATE|inlined.13 (result i32) local.get $5 i32.const 1 i32.shl @@ -13076,7 +13027,7 @@ i32.const 10 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.20 (result i32) + block $~lib/runtime/ALLOCATE|inlined.14 (result i32) local.get $5 i32.const 1 i32.shl @@ -13411,7 +13362,7 @@ local.get $2 call $~lib/util/number/decimalCount32 local.set $3 - block $~lib/runtime/ALLOCATE|inlined.21 (result i32) + block $~lib/runtime/ALLOCATE|inlined.15 (result i32) local.get $3 i32.const 1 i32.shl @@ -13436,7 +13387,7 @@ local.get $0 call $~lib/util/number/decimalCount64 local.set $3 - block $~lib/runtime/ALLOCATE|inlined.22 (result i32) + block $~lib/runtime/ALLOCATE|inlined.16 (result i32) local.get $3 i32.const 1 i32.shl @@ -13581,7 +13532,7 @@ i32.const 20 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.23 (result i32) + block $~lib/runtime/ALLOCATE|inlined.17 (result i32) local.get $5 i32.const 1 i32.shl @@ -13733,7 +13684,7 @@ local.get $1 i32.add local.set $4 - block $~lib/runtime/ALLOCATE|inlined.24 (result i32) + block $~lib/runtime/ALLOCATE|inlined.18 (result i32) local.get $4 i32.const 1 i32.shl @@ -13760,7 +13711,7 @@ local.get $1 i32.add local.set $4 - block $~lib/runtime/ALLOCATE|inlined.25 (result i32) + block $~lib/runtime/ALLOCATE|inlined.19 (result i32) local.get $4 i32.const 1 i32.shl @@ -13933,7 +13884,7 @@ i32.const 21 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.26 (result i32) + block $~lib/runtime/ALLOCATE|inlined.20 (result i32) local.get $5 i32.const 1 i32.shl @@ -14128,7 +14079,7 @@ end i32.const 0 local.set $9 - block $~lib/runtime/ALLOCATE|inlined.27 (result i32) + block $~lib/runtime/ALLOCATE|inlined.21 (result i32) local.get $5 local.get $4 local.get $2 @@ -14465,7 +14416,7 @@ i32.const 10 i32.add local.set $5 - block $~lib/runtime/ALLOCATE|inlined.28 (result i32) + block $~lib/runtime/ALLOCATE|inlined.22 (result i32) local.get $5 i32.const 1 i32.shl @@ -14919,7 +14870,6 @@ (local $2 i32) (local $3 i32) (local $4 i32) - (local $5 i32) global.get $~lib/memory/HEAP_BASE i32.const 7 i32.add @@ -15022,17 +14972,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr8 - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 5 - local.set $0 - i32.const 248 - local.set $1 - local.get $0 - local.get $1 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 7 + i32.const 0 + i32.const 248 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15051,17 +14995,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr8 - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 5 - local.set $1 - i32.const 320 - local.set $0 - local.get $1 - local.get $0 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 7 + i32.const 0 + i32.const 320 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15080,17 +15018,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr8 - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 5 - local.set $0 - i32.const 344 - local.set $1 - local.get $0 - local.get $1 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 7 + i32.const 0 + i32.const 344 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15109,17 +15041,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr8 - block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) - i32.const 5 - local.set $1 - i32.const 368 - local.set $0 - local.get $1 - local.get $0 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 7 + i32.const 0 + i32.const 368 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15138,17 +15064,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr8 - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) - i32.const 5 - local.set $0 - i32.const 392 - local.set $1 - local.get $0 - local.get $1 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 7 + i32.const 0 + i32.const 392 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15167,17 +15087,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr32 - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 5 - local.set $1 - i32.const 488 - local.set $0 - local.get $1 - local.get $0 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 8 + i32.const 2 + i32.const 488 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15196,17 +15110,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr32 - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 5 - local.set $0 - i32.const 528 - local.set $1 - local.get $0 - local.get $1 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 8 + i32.const 2 + i32.const 528 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15225,17 +15133,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr32 - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 5 - local.set $1 - i32.const 568 - local.set $0 - local.get $1 - local.get $0 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 8 + i32.const 2 + i32.const 568 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15254,17 +15156,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr32 - block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) - i32.const 5 - local.set $0 - i32.const 608 - local.set $1 - local.get $0 - local.get $1 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 8 + i32.const 2 + i32.const 608 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15283,17 +15179,11 @@ call $~lib/array/Array#fill drop global.get $std/array/arr32 - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) - i32.const 5 - local.set $1 - i32.const 648 - local.set $0 - local.get $1 - local.get $0 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 8 + i32.const 2 + i32.const 648 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15638,17 +15528,11 @@ unreachable end global.get $std/array/out - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 0 - local.set $0 - i32.const 688 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 688 + call $~lib/runtime/makeArray call $~lib/array/Array#concat drop global.get $std/array/arr @@ -15917,34 +15801,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 5 - local.set $1 - i32.const 752 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 752 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 0 i32.const 3 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) - i32.const 5 - local.set $0 - i32.const 792 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 792 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15956,34 +15828,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) - i32.const 5 - local.set $1 - i32.const 832 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 832 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 1 i32.const 3 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.5 (result i32) - i32.const 5 - local.set $0 - i32.const 872 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 872 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -15995,34 +15855,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.6 (result i32) - i32.const 5 - local.set $1 - i32.const 912 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 912 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 1 i32.const 2 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.7 (result i32) - i32.const 5 - local.set $0 - i32.const 952 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 952 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16034,34 +15882,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.8 (result i32) - i32.const 5 - local.set $1 - i32.const 992 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 992 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 2 i32.const 2 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.9 (result i32) - i32.const 5 - local.set $0 - i32.const 1032 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1032 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16073,34 +15909,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.10 (result i32) - i32.const 5 - local.set $1 - i32.const 1072 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1072 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 0 i32.const 3 i32.const 4 call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.11 (result i32) - i32.const 5 - local.set $0 - i32.const 1112 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1112 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16112,34 +15936,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.12 (result i32) - i32.const 5 - local.set $1 - i32.const 1152 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1152 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 1 i32.const 3 i32.const 4 call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.13 (result i32) - i32.const 5 - local.set $0 - i32.const 1192 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1192 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16151,34 +15963,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.14 (result i32) - i32.const 5 - local.set $1 - i32.const 1232 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1232 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 1 i32.const 2 i32.const 4 call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.15 (result i32) - i32.const 5 - local.set $0 - i32.const 1272 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1272 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16190,34 +15990,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.16 (result i32) - i32.const 5 - local.set $1 - i32.const 1312 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1312 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 0 i32.const -2 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.17 (result i32) - i32.const 5 - local.set $0 - i32.const 1352 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1352 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16229,34 +16017,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.18 (result i32) - i32.const 5 - local.set $1 - i32.const 1392 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1392 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const 0 i32.const -2 i32.const -1 call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.19 (result i32) - i32.const 5 - local.set $0 - i32.const 1432 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1432 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16268,34 +16044,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.20 (result i32) - i32.const 5 - local.set $1 - i32.const 1472 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1472 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const -4 i32.const -3 i32.const -2 call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.21 (result i32) - i32.const 5 - local.set $0 - i32.const 1512 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1512 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16307,34 +16071,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.22 (result i32) - i32.const 5 - local.set $1 - i32.const 1552 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1552 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const -4 i32.const -3 i32.const -1 call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.23 (result i32) - i32.const 5 - local.set $0 - i32.const 1592 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1592 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -16346,34 +16098,22 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.24 (result i32) - i32.const 5 - local.set $1 - i32.const 1632 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1632 + call $~lib/runtime/makeArray global.set $std/array/cwArr global.get $std/array/cwArr i32.const -4 i32.const -3 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#copyWithin - block $~lib/runtime/MAKEARRAY|inlined.25 (result i32) - i32.const 5 - local.set $0 - i32.const 1672 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1672 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17233,17 +16973,11 @@ i32.const 0 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.27 (result i32) - i32.const 5 - local.set $1 - i32.const 1784 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1784 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17256,17 +16990,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.28 (result i32) - i32.const 0 - local.set $0 - i32.const 1824 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 1824 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17278,33 +17006,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.29 (result i32) - i32.const 5 - local.set $1 - i32.const 1840 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1840 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 2 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.30 (result i32) - i32.const 3 - local.set $0 - i32.const 1880 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 4 + i32.const 2 + i32.const 1880 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17317,17 +17033,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.31 (result i32) - i32.const 2 - local.set $1 - i32.const 1912 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 1912 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17339,33 +17049,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.32 (result i32) - i32.const 5 - local.set $0 - i32.const 1936 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 1936 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 2 i32.const 2 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.33 (result i32) - i32.const 2 - local.set $1 - i32.const 1976 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 1976 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17378,17 +17076,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.34 (result i32) - i32.const 3 - local.set $0 - i32.const 2000 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 4 + i32.const 2 + i32.const 2000 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17400,33 +17092,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.35 (result i32) - i32.const 5 - local.set $1 - i32.const 2032 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2032 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 0 i32.const 1 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.36 (result i32) - i32.const 1 - local.set $0 - i32.const 2072 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 4 + i32.const 2 + i32.const 2072 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17439,17 +17119,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.37 (result i32) - i32.const 4 - local.set $1 - i32.const 2096 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 4 + i32.const 4 + i32.const 2 + i32.const 2096 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17461,33 +17135,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.38 (result i32) - i32.const 5 - local.set $0 - i32.const 2128 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2128 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const -1 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.39 (result i32) - i32.const 1 - local.set $1 - i32.const 2168 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 4 + i32.const 2 + i32.const 2168 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17500,17 +17162,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.40 (result i32) - i32.const 4 - local.set $0 - i32.const 2192 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 4 + i32.const 4 + i32.const 2 + i32.const 2192 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17522,33 +17178,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.41 (result i32) - i32.const 5 - local.set $1 - i32.const 2224 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2224 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const -2 global.get $~lib/builtins/i32.MAX_VALUE call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.42 (result i32) - i32.const 2 - local.set $0 - i32.const 2264 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 2264 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17561,17 +17205,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.43 (result i32) - i32.const 3 - local.set $1 - i32.const 2288 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 4 + i32.const 2 + i32.const 2288 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17583,33 +17221,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.44 (result i32) - i32.const 5 - local.set $0 - i32.const 2320 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2320 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const -2 i32.const 1 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.45 (result i32) - i32.const 1 - local.set $1 - i32.const 2360 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 4 + i32.const 2 + i32.const 2360 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17622,17 +17248,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.46 (result i32) - i32.const 4 - local.set $0 - i32.const 2384 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 4 + i32.const 4 + i32.const 2 + i32.const 2384 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17644,33 +17264,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.47 (result i32) - i32.const 5 - local.set $1 - i32.const 2416 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2416 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const -7 i32.const 1 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.48 (result i32) - i32.const 1 - local.set $0 - i32.const 2456 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 4 + i32.const 2 + i32.const 2456 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17683,17 +17291,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.49 (result i32) - i32.const 4 - local.set $1 - i32.const 2480 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 4 + i32.const 4 + i32.const 2 + i32.const 2480 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17705,33 +17307,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.50 (result i32) - i32.const 5 - local.set $0 - i32.const 2512 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2512 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const -2 i32.const -1 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.51 (result i32) - i32.const 0 - local.set $1 - i32.const 2552 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 2552 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17744,17 +17334,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.52 (result i32) - i32.const 5 - local.set $0 - i32.const 2568 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2568 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17766,33 +17350,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.53 (result i32) - i32.const 5 - local.set $1 - i32.const 2608 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2608 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 1 i32.const -2 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.54 (result i32) - i32.const 0 - local.set $0 - i32.const 2648 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 2648 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17805,17 +17377,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.55 (result i32) - i32.const 5 - local.set $1 - i32.const 2664 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2664 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17827,33 +17393,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.56 (result i32) - i32.const 5 - local.set $0 - i32.const 2704 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2704 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 4 i32.const 0 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.57 (result i32) - i32.const 0 - local.set $1 - i32.const 2744 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 2744 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17866,17 +17420,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.58 (result i32) - i32.const 5 - local.set $0 - i32.const 2760 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2760 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17888,33 +17436,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.59 (result i32) - i32.const 5 - local.set $1 - i32.const 2800 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2800 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 7 i32.const 0 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.60 (result i32) - i32.const 0 - local.set $0 - i32.const 2840 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 2840 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17927,17 +17463,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.61 (result i32) - i32.const 5 - local.set $1 - i32.const 2856 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2856 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17949,33 +17479,21 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.62 (result i32) - i32.const 5 - local.set $0 - i32.const 2896 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2896 + call $~lib/runtime/makeArray global.set $std/array/sarr global.get $std/array/sarr i32.const 7 i32.const 5 call $~lib/array/Array#splice - block $~lib/runtime/MAKEARRAY|inlined.63 (result i32) - i32.const 0 - local.set $1 - i32.const 2936 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 0 + i32.const 4 + i32.const 2 + i32.const 2936 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -17988,17 +17506,11 @@ unreachable end global.get $std/array/sarr - block $~lib/runtime/MAKEARRAY|inlined.64 (result i32) - i32.const 5 - local.set $0 - i32.const 2952 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 2952 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -18552,9 +18064,9 @@ end block $break|0 i32.const 0 - local.set $1 + local.set $0 loop $repeat|0 - local.get $1 + local.get $0 i32.const 100 i32.lt_s i32.eqz @@ -18562,10 +18074,10 @@ global.get $std/array/arr call $~lib/array/Array#pop drop - local.get $1 + local.get $0 i32.const 1 i32.add - local.set $1 + local.set $0 br $repeat|0 unreachable end @@ -19196,17 +18708,11 @@ end drop global.get $std/array/f32ArrayTyped - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 8 - local.set $1 - i32.const 3304 - local.set $0 - local.get $1 - local.get $0 - i32.const 9 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 8 + i32.const 9 + i32.const 2 + i32.const 3304 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -19227,17 +18733,11 @@ end drop global.get $std/array/f64ArrayTyped - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 8 - local.set $0 - i32.const 3464 - local.set $1 - local.get $0 - local.get $1 - i32.const 10 - i32.const 3 - call $~lib/runtime/makeArray - end + i32.const 8 + i32.const 10 + i32.const 3 + i32.const 3464 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -19258,17 +18758,11 @@ end drop global.get $std/array/i32ArrayTyped - block $~lib/runtime/MAKEARRAY|inlined.67 (result i32) - i32.const 5 - local.set $1 - i32.const 3616 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 4 + i32.const 2 + i32.const 3616 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -19289,17 +18783,11 @@ end drop global.get $std/array/u32ArrayTyped - block $~lib/runtime/MAKEARRAY|inlined.5 (result i32) - i32.const 5 - local.set $0 - i32.const 3728 - local.set $1 - local.get $0 - local.get $1 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 8 + i32.const 2 + i32.const 3728 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -19331,17 +18819,11 @@ global.get $std/array/reversed1 call $std/array/assertSortedDefault global.get $std/array/reversed1 - block $~lib/runtime/MAKEARRAY|inlined.69 (result i32) - i32.const 1 - local.set $1 - i32.const 4056 - local.set $0 - local.get $1 - local.get $0 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 4 + i32.const 2 + i32.const 4056 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -19356,17 +18838,11 @@ global.get $std/array/reversed2 call $std/array/assertSortedDefault global.get $std/array/reversed2 - block $~lib/runtime/MAKEARRAY|inlined.70 (result i32) - i32.const 2 - local.set $0 - i32.const 4080 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 4080 + call $~lib/runtime/makeArray i32.const 0 call $std/array/isArraysEqual i32.eqz @@ -19515,17 +18991,11 @@ i32.const 0 call $std/array/assertSorted|trampoline end - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 2 - local.set $0 - i32.const 4552 - local.set $1 - local.get $0 - local.get $1 - i32.const 16 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 16 + i32.const 0 + i32.const 4552 + call $~lib/runtime/makeArray i32.const 4528 call $~lib/array/Array#join i32.const 4576 @@ -19539,17 +19009,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.72 (result i32) - i32.const 3 - local.set $0 - i32.const 5120 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 4 + i32.const 2 + i32.const 5120 + call $~lib/runtime/makeArray i32.const 4200 call $~lib/array/Array#join i32.const 5152 @@ -19563,17 +19027,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.7 (result i32) - i32.const 3 - local.set $0 - i32.const 5240 - local.set $1 - local.get $0 - local.get $1 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 8 + i32.const 2 + i32.const 5240 + call $~lib/runtime/makeArray i32.const 5216 call $~lib/array/Array#join i32.const 5152 @@ -19587,17 +19045,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.74 (result i32) - i32.const 2 - local.set $0 - i32.const 5320 - local.set $1 - local.get $0 - local.get $1 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 5320 + call $~lib/runtime/makeArray i32.const 5296 call $~lib/array/Array#join i32.const 5344 @@ -19611,17 +19063,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 6 - local.set $0 - i32.const 6672 - local.set $1 - local.get $0 - local.get $1 - i32.const 10 - i32.const 3 - call $~lib/runtime/makeArray - end + i32.const 6 + i32.const 10 + i32.const 3 + i32.const 6672 + call $~lib/runtime/makeArray i32.const 5472 call $~lib/array/Array#join i32.const 6736 @@ -19635,17 +19081,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 3 - local.set $0 - i32.const 6888 - local.set $1 - local.get $0 - local.get $1 - i32.const 15 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 15 + i32.const 2 + i32.const 6888 + call $~lib/runtime/makeArray i32.const 4200 call $~lib/array/Array#join i32.const 6832 @@ -19660,63 +19100,57 @@ unreachable end block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 3 - local.set $2 - i32.const 0 - local.set $3 - local.get $2 - local.get $3 - i32.const 20 - i32.const 2 - call $~lib/runtime/makeArray - end - local.set $1 - local.get $1 - i32.load offset=4 + i32.const 3 + i32.const 20 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $0 local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 block (result i32) i32.const 0 call $std/array/Ref#constructor - local.set $3 - local.get $3 + local.set $2 + local.get $2 if - local.get $3 - local.get $1 + local.get $2 + local.get $0 call $~lib/collector/dummy/__ref_link end - local.get $3 + local.get $2 end i32.store - local.get $0 + local.get $1 block (result i32) i32.const 0 - local.set $3 - local.get $3 + local.set $2 + local.get $2 if - local.get $3 - local.get $1 + local.get $2 + local.get $0 call $~lib/collector/dummy/__ref_link end - local.get $3 + local.get $2 end i32.store offset=4 - local.get $0 + local.get $1 block (result i32) i32.const 0 call $std/array/Ref#constructor - local.set $3 - local.get $3 + local.set $2 + local.get $2 if - local.get $3 - local.get $1 + local.get $2 + local.get $0 call $~lib/collector/dummy/__ref_link end - local.get $3 + local.get $2 end i32.store offset=8 - local.get $1 + local.get $0 end global.set $std/array/refArr global.get $std/array/refArr @@ -19785,17 +19219,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 3 - local.set $1 - i32.const 7128 - local.set $0 - local.get $1 - local.get $0 - i32.const 21 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 21 + i32.const 0 + i32.const 7128 + call $~lib/runtime/makeArray call $~lib/array/Array#toString i32.const 7152 call $~lib/string/String.__eq @@ -19808,17 +19236,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 3 - local.set $1 - i32.const 7208 - local.set $0 - local.get $1 - local.get $0 - i32.const 22 - i32.const 1 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 22 + i32.const 1 + i32.const 7208 + call $~lib/runtime/makeArray call $~lib/array/Array#toString i32.const 7232 call $~lib/string/String.__eq @@ -19831,17 +19253,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 3 - local.set $1 - i32.const 7312 - local.set $0 - local.get $1 - local.get $0 - i32.const 17 - i32.const 3 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 17 + i32.const 3 + i32.const 7312 + call $~lib/runtime/makeArray call $~lib/array/Array#toString i32.const 7352 call $~lib/string/String.__eq @@ -19854,17 +19270,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 4 - local.set $1 - i32.const 7464 - local.set $0 - local.get $1 - local.get $0 - i32.const 23 - i32.const 3 - call $~lib/runtime/makeArray - end + i32.const 4 + i32.const 23 + i32.const 3 + i32.const 7464 + call $~lib/runtime/makeArray call $~lib/array/Array#toString i32.const 7512 call $~lib/string/String.__eq @@ -19890,17 +19300,11 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) - i32.const 4 - local.set $1 - i32.const 7744 - local.set $0 - local.get $1 - local.get $0 - i32.const 15 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 4 + i32.const 15 + i32.const 2 + i32.const 7744 + call $~lib/runtime/makeArray call $~lib/array/Array#toString i32.const 7776 call $~lib/string/String.__eq @@ -19914,54 +19318,36 @@ unreachable end block (result i32) - block $~lib/runtime/MAKEARRAY>|inlined.1 (result i32) - i32.const 2 - local.set $3 - i32.const 0 - local.set $2 - local.get $3 - local.get $2 - i32.const 11 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 11 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $1 local.get $1 i32.load offset=4 local.set $0 local.get $0 block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.76 (result i32) - i32.const 2 - local.set $2 - i32.const 7832 - local.set $3 - local.get $2 - local.get $3 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end - local.set $3 - local.get $3 + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 7832 + call $~lib/runtime/makeArray + local.set $2 + local.get $2 local.get $1 call $~lib/collector/dummy/__ref_link - local.get $3 + local.get $2 end i32.store local.get $0 block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.77 (result i32) - i32.const 2 - local.set $3 - i32.const 7856 - local.set $2 - local.get $3 - local.get $2 - i32.const 4 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 4 + i32.const 2 + i32.const 7856 + call $~lib/runtime/makeArray local.set $2 local.get $2 local.get $1 @@ -19986,62 +19372,44 @@ unreachable end block (result i32) - block $~lib/runtime/MAKEARRAY>|inlined.0 (result i32) - i32.const 2 - local.set $2 - i32.const 0 - local.set $3 - local.get $2 - local.get $3 - i32.const 24 - i32.const 2 - call $~lib/runtime/makeArray - end - local.set $1 - local.get $1 - i32.load offset=4 + i32.const 2 + i32.const 24 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $0 local.get $0 + i32.load offset=4 + local.set $1 + local.get $1 block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.6 (result i32) - i32.const 2 - local.set $3 - i32.const 7936 - local.set $2 - local.get $3 - local.get $2 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 7 + i32.const 0 + i32.const 7936 + call $~lib/runtime/makeArray local.set $2 local.get $2 - local.get $1 + local.get $0 call $~lib/collector/dummy/__ref_link local.get $2 end i32.store - local.get $0 + local.get $1 block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.7 (result i32) - i32.const 2 - local.set $2 - i32.const 7960 - local.set $3 - local.get $2 - local.get $3 - i32.const 7 - i32.const 0 - call $~lib/runtime/makeArray - end - local.set $3 - local.get $3 - local.get $1 + i32.const 2 + i32.const 7 + i32.const 0 + i32.const 7960 + call $~lib/runtime/makeArray + local.set $2 + local.get $2 + local.get $0 call $~lib/collector/dummy/__ref_link - local.get $3 + local.get $2 end i32.store offset=4 - local.get $1 + local.get $0 end global.set $std/array/subarr8 global.get $std/array/subarr8 @@ -20058,17 +19426,11 @@ unreachable end block (result i32) - block $~lib/runtime/MAKEARRAY>>|inlined.0 (result i32) - i32.const 1 - local.set $3 - i32.const 0 - local.set $2 - local.get $3 - local.get $2 - i32.const 26 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 26 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $0 local.get $0 i32.load offset=4 @@ -20076,48 +19438,36 @@ local.get $1 block (result i32) block (result i32) - block $~lib/runtime/MAKEARRAY>|inlined.1 (result i32) - i32.const 1 - local.set $4 - i32.const 0 - local.set $5 - local.get $4 - local.get $5 - i32.const 25 - i32.const 2 - call $~lib/runtime/makeArray - end - local.set $3 - local.get $3 - i32.load offset=4 + i32.const 1 + i32.const 25 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $2 local.get $2 + i32.load offset=4 + local.set $3 + local.get $3 block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.11 (result i32) - i32.const 1 - local.set $5 - i32.const 8056 - local.set $4 - local.get $5 - local.get $4 - i32.const 8 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 8 + i32.const 2 + i32.const 8056 + call $~lib/runtime/makeArray local.set $4 local.get $4 - local.get $3 + local.get $2 call $~lib/collector/dummy/__ref_link local.get $4 end i32.store - local.get $3 + local.get $2 end - local.set $2 - local.get $2 + local.set $3 + local.get $3 local.get $0 call $~lib/collector/dummy/__ref_link - local.get $2 + local.get $3 end i32.store local.get $0 diff --git a/tests/compiler/std/arraybuffer.optimized.wat b/tests/compiler/std/arraybuffer.optimized.wat index 22b3f93c..263dfcf8 100644 --- a/tests/compiler/std/arraybuffer.optimized.wat +++ b/tests/compiler/std/arraybuffer.optimized.wat @@ -326,7 +326,7 @@ if i32.const 0 i32.const 64 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -341,7 +341,7 @@ if i32.const 0 i32.const 64 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -1547,7 +1547,7 @@ if i32.const 0 i32.const 64 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/arraybuffer.untouched.wat b/tests/compiler/std/arraybuffer.untouched.wat index 2e376b9a..1198df61 100644 --- a/tests/compiler/std/arraybuffer.untouched.wat +++ b/tests/compiler/std/arraybuffer.untouched.wat @@ -408,7 +408,7 @@ if i32.const 0 i32.const 64 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -425,7 +425,7 @@ if i32.const 0 i32.const 64 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -2037,7 +2037,6 @@ ) (func $~lib/runtime/ArrayBufferView#constructor (; 16 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) local.get $1 global.get $~lib/runtime/MAX_BYTELENGTH local.get $2 @@ -2046,7 +2045,7 @@ if i32.const 0 i32.const 64 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable @@ -2062,18 +2061,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 12 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 3 - call $~lib/runtime/register - end + i32.const 12 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -2098,19 +2089,12 @@ local.get $0 ) (func $~lib/typedarray/Uint8Array#constructor (; 17 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 4 call $~lib/runtime/register end @@ -2126,15 +2110,15 @@ (local $6 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl local.set $5 local.get $0 - local.get $3 + local.get $2 i32.shl call $~lib/runtime/allocate i32.const 2 @@ -2152,29 +2136,22 @@ local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if local.get $6 - local.get $1 + local.get $3 local.get $5 call $~lib/memory/memory.copy end local.get $4 ) (func $~lib/typedarray/Int32Array#constructor (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 6 call $~lib/runtime/register end @@ -2186,7 +2163,6 @@ ) (func $~lib/dataview/DataView#constructor (; 20 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) - (local $5 i32) local.get $3 global.get $~lib/builtins/i32.MIN_VALUE i32.eq @@ -2219,18 +2195,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 12 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 7 - call $~lib/runtime/register - end + i32.const 12 + call $~lib/runtime/allocate + i32.const 7 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -2249,9 +2217,9 @@ local.get $1 local.get $2 i32.add - local.set $5 + local.set $4 local.get $0 - local.get $5 + local.get $4 i32.store offset=4 local.get $0 local.get $3 @@ -2263,8 +2231,6 @@ i32.load ) (func $start:std/arraybuffer (; 22 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) global.get $~lib/memory/HEAP_BASE i32.const 7 i32.add @@ -2524,17 +2490,11 @@ i32.const 1 call $~lib/typedarray/Uint8Array#constructor global.set $std/arraybuffer/arr8 - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 2 - local.set $0 - i32.const 152 - local.set $1 - local.get $0 - local.get $1 - i32.const 5 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 2 + i32.const 5 + i32.const 2 + i32.const 152 + call $~lib/runtime/makeArray call $~lib/arraybuffer/ArrayBuffer.isView> i32.eqz i32.eqz diff --git a/tests/compiler/std/dataview.optimized.wat b/tests/compiler/std/dataview.optimized.wat index fd7eadd7..6cb289f8 100644 --- a/tests/compiler/std/dataview.optimized.wat +++ b/tests/compiler/std/dataview.optimized.wat @@ -164,7 +164,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -179,7 +179,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/dataview.untouched.wat b/tests/compiler/std/dataview.untouched.wat index 01e8b4d8..20171a35 100644 --- a/tests/compiler/std/dataview.untouched.wat +++ b/tests/compiler/std/dataview.untouched.wat @@ -414,7 +414,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -431,7 +431,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -476,7 +476,6 @@ ) (func $~lib/runtime/ArrayBufferView#constructor (; 7 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) local.get $1 global.get $~lib/runtime/MAX_BYTELENGTH local.get $2 @@ -485,7 +484,7 @@ if i32.const 0 i32.const 16 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable @@ -501,18 +500,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 12 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 3 - call $~lib/runtime/register - end + i32.const 12 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -537,19 +528,12 @@ local.get $0 ) (func $~lib/typedarray/Uint8Array#constructor (; 8 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 4 call $~lib/runtime/register end @@ -587,7 +571,6 @@ ) (func $~lib/dataview/DataView#constructor (; 11 ;) (type $FUNCSIG$iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (local $4 i32) - (local $5 i32) local.get $3 global.get $~lib/builtins/i32.MIN_VALUE i32.eq @@ -620,18 +603,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 12 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 5 - call $~lib/runtime/register - end + i32.const 12 + call $~lib/runtime/allocate + i32.const 5 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -650,9 +625,9 @@ local.get $1 local.get $2 i32.add - local.set $5 + local.set $4 local.get $0 - local.get $5 + local.get $4 i32.store offset=4 local.get $0 local.get $3 diff --git a/tests/compiler/std/date.optimized.wat b/tests/compiler/std/date.optimized.wat index 9bcf0e67..31f28644 100644 --- a/tests/compiler/std/date.optimized.wat +++ b/tests/compiler/std/date.optimized.wat @@ -89,7 +89,7 @@ if i32.const 0 i32.const 48 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -104,7 +104,7 @@ if i32.const 0 i32.const 48 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/date.untouched.wat b/tests/compiler/std/date.untouched.wat index 023d2cec..057f6d40 100644 --- a/tests/compiler/std/date.untouched.wat +++ b/tests/compiler/std/date.untouched.wat @@ -149,7 +149,7 @@ if i32.const 0 i32.const 48 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -166,7 +166,7 @@ if i32.const 0 i32.const 48 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -177,23 +177,14 @@ local.get $0 ) (func $~lib/date/Date#constructor (; 7 ;) (type $FUNCSIG$iij) (param $0 i32) (param $1 i64) (result i32) - (local $2 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 8 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 - i32.const 2 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 2 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/std/gc-array.optimized.wat b/tests/compiler/std/gc-array.optimized.wat deleted file mode 100644 index 00336ae3..00000000 --- a/tests/compiler/std/gc-array.optimized.wat +++ /dev/null @@ -1,1954 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 16) "\01") - (data (i32.const 40) "\02\00\00\00\00\00\00\00\18") - (data (i32.const 64) "\05\00\00\00\00\00\00\00\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s") - (data (i32.const 112) "\05\00\00\00\00\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s") - (table $0 7 funcref) - (elem (i32.const 0) $null $~lib/arraybuffer/ArrayBuffer~gc $~lib/array/Array~gc $~lib/collector/itcm/__gc_mark $~lib/arraybuffer/ArrayBuffer~gc $~lib/arraybuffer/ArrayBuffer~gc $~lib/allocator/arena/__memory_free) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $std/gc-array/arr (mut i32) (i32.const 48)) - (global $~lib/argc (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "main" (func $std/gc-array/main)) - (func $~lib/arraybuffer/ArrayBuffer~gc (; 1 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 2 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $1 - i32.load - i32.const 3 - i32.and - local.get $0 - i32.or - i32.store - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $2 - i32.load - i32.const 3 - i32.and - local.get $1 - i32.or - i32.store - local.get $0 - local.get $1 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - global.get $~lib/collector/itcm/iter - local.get $0 - i32.eq - if - local.get $0 - i32.load offset=4 - global.set $~lib/collector/itcm/iter - end - local.get $0 - i32.load - i32.const -4 - i32.and - local.tee $2 - local.get $0 - i32.load offset=4 - local.tee $1 - i32.store offset=4 - local.get $1 - local.get $1 - i32.load - i32.const 3 - i32.and - local.get $2 - i32.or - i32.store - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load - i32.const -4 - i32.and - i32.const 2 - i32.or - i32.store - ) - (func $~lib/collector/itcm/__gc_mark (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - if - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - i32.load - i32.const 3 - i32.and - i32.eq - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#makeGray - end - end - ) - (func $~lib/array/Array~gc (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - i32.load - local.tee $2 - call $~lib/collector/itcm/__gc_mark - local.get $0 - i32.load offset=4 - i32.const 2 - i32.shl - local.set $0 - loop $continue|0 - local.get $1 - local.get $0 - i32.lt_u - if - local.get $1 - local.get $2 - i32.add - i32.load offset=8 - call $~lib/collector/itcm/__gc_mark - local.get $1 - i32.const 4 - i32.add - local.set $1 - br $continue|0 - end - end - ) - (func $~lib/allocator/arena/__memory_allocate (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - global.get $~lib/allocator/arena/offset - local.tee $1 - local.get $0 - i32.const 1 - local.get $0 - i32.const 1 - i32.gt_u - select - i32.add - i32.const 7 - i32.add - i32.const -8 - i32.and - local.tee $2 - current_memory - local.tee $3 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $3 - local.get $2 - local.get $1 - i32.sub - i32.const 65535 - i32.add - i32.const -65536 - i32.and - i32.const 16 - i32.shr_u - local.tee $0 - local.get $3 - local.get $0 - i32.gt_s - select - grow_memory - i32.const 0 - i32.lt_s - if - local.get $0 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $2 - global.set $~lib/allocator/arena/offset - local.get $1 - ) - (func $~lib/allocator/arena/__memory_free (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/collector/itcm/step (; 8 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case3|0 - block $case2|0 - block $case1|0 - global.get $~lib/collector/itcm/state - local.tee $0 - if - local.get $0 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $break|0 - end - i32.const 16 - call $~lib/allocator/arena/__memory_allocate - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - local.tee $0 - i32.const -1 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - i32.const 16 - call $~lib/allocator/arena/__memory_allocate - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - local.tee $0 - i32.const -1 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - global.get $std/gc-array/arr - i32.const 3 - call_indirect (type $FUNCSIG$vi) - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - end - global.get $~lib/collector/itcm/iter - i32.load - i32.const -4 - i32.and - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/collector/itcm/white - i32.eqz - local.get $0 - i32.load - i32.const -4 - i32.and - i32.or - i32.store - i32.const 1 - global.set $~lib/argc - local.get $0 - i32.const 16 - i32.add - local.get $0 - i32.load offset=8 - call_indirect (type $FUNCSIG$vi) - else - global.get $std/gc-array/arr - i32.const 3 - call_indirect (type $FUNCSIG$vi) - global.get $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/iter - i32.load - i32.const -4 - i32.and - i32.eq - if - global.get $~lib/collector/itcm/fromSpace - local.set $0 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/fromSpace - local.get $0 - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/white - i32.eqz - global.set $~lib/collector/itcm/white - local.get $0 - i32.load - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - end - end - br $break|0 - end - global.get $~lib/collector/itcm/iter - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - i32.load - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - else - global.get $~lib/collector/itcm/toSpace - local.tee $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - ) - (func $~lib/collector/itcm/__gc_collect (; 9 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case1|0 - global.get $~lib/collector/itcm/state - local.tee $0 - i32.eqz - br_if $case1|0 - local.get $0 - i32.const 1 - i32.eq - br_if $case1|0 - br $break|0 - end - call $~lib/collector/itcm/step - end - loop $continue|1 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|1 - end - end - ) - (func $~lib/collector/itcm/__gc_allocate (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - i32.const 1073741808 - i32.gt_u - if - unreachable - end - call $~lib/collector/itcm/step - local.get $0 - i32.const 16 - i32.add - call $~lib/allocator/arena/__memory_allocate - local.tee $0 - local.get $1 - i32.store offset=8 - local.get $0 - global.get $~lib/collector/itcm/white - local.get $0 - i32.load - i32.const -4 - i32.and - i32.or - i32.store - global.get $~lib/collector/itcm/fromSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - i32.const 16 - i32.add - ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.const 1073741816 - i32.gt_u - if - i32.const 0 - i32.const 120 - i32.const 26 - i32.const 2 - call $~lib/env/abort - unreachable - end - i32.const 1 - i32.const 32 - local.get $0 - i32.const 7 - i32.add - i32.clz - i32.sub - i32.shl - i32.const 6 - call $~lib/collector/itcm/__gc_allocate - local.tee $1 - local.get $0 - i32.store - local.get $1 - ) - (func $~lib/internal/memory/memcpy (; 12 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - loop $continue|0 - local.get $1 - i32.const 3 - i32.and - local.get $2 - local.get $2 - select - if - local.get $0 - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - br $continue|0 - end - end - local.get $0 - i32.const 3 - i32.and - i32.eqz - if - loop $continue|1 - local.get $2 - i32.const 16 - i32.ge_u - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 8 - i32.add - i32.load - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 12 - i32.add - i32.load - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|1 - end - end - local.get $2 - i32.const 8 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $1 - i32.const 8 - i32.add - local.set $1 - local.get $0 - i32.const 8 - i32.add - local.set $0 - end - local.get $2 - i32.const 4 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $1 - i32.const 4 - i32.add - local.set $1 - local.get $0 - i32.const 4 - i32.add - local.set $0 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $0 - local.get $1 - i32.load16_u - i32.store16 - local.get $1 - i32.const 2 - i32.add - local.set $1 - local.get $0 - i32.const 2 - i32.add - local.set $0 - end - local.get $2 - i32.const 1 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - end - return - end - local.get $2 - i32.const 32 - i32.ge_u - if - block $break|2 - block $case2|2 - block $case1|2 - local.get $0 - i32.const 3 - i32.and - local.tee $3 - i32.const 1 - i32.ne - if - local.get $3 - i32.const 2 - i32.eq - br_if $case1|2 - local.get $3 - i32.const 3 - i32.eq - br_if $case2|2 - br $break|2 - end - local.get $1 - i32.load - local.set $5 - local.get $0 - local.get $1 - local.tee $3 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $1 - local.set $0 - local.get $1 - local.get $3 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - local.get $2 - i32.const 3 - i32.sub - local.set $2 - loop $continue|3 - local.get $2 - i32.const 17 - i32.ge_u - if - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.load - local.tee $3 - i32.const 8 - i32.shl - local.get $5 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 5 - i32.add - i32.load - local.tee $5 - i32.const 8 - i32.shl - local.get $3 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 9 - i32.add - i32.load - local.tee $3 - i32.const 8 - i32.shl - local.get $5 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 13 - i32.add - i32.load - local.tee $5 - i32.const 8 - i32.shl - local.get $3 - i32.const 24 - i32.shr_u - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|3 - end - end - br $break|2 - end - local.get $1 - i32.load - local.set $5 - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - local.get $2 - i32.const 2 - i32.sub - local.set $2 - loop $continue|4 - local.get $2 - i32.const 18 - i32.ge_u - if - local.get $0 - local.get $1 - i32.const 2 - i32.add - i32.load - local.tee $3 - i32.const 16 - i32.shl - local.get $5 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 6 - i32.add - i32.load - local.tee $5 - i32.const 16 - i32.shl - local.get $3 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 10 - i32.add - i32.load - local.tee $3 - i32.const 16 - i32.shl - local.get $5 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 14 - i32.add - i32.load - local.tee $5 - i32.const 16 - i32.shl - local.get $3 - i32.const 16 - i32.shr_u - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|4 - end - end - br $break|2 - end - local.get $1 - i32.load - local.set $5 - local.get $0 - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - loop $continue|5 - local.get $2 - i32.const 19 - i32.ge_u - if - local.get $0 - local.get $1 - i32.const 3 - i32.add - i32.load - local.tee $3 - i32.const 24 - i32.shl - local.get $5 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 7 - i32.add - i32.load - local.tee $5 - i32.const 24 - i32.shl - local.get $3 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 11 - i32.add - i32.load - local.tee $3 - i32.const 24 - i32.shl - local.get $5 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 15 - i32.add - i32.load - local.tee $5 - i32.const 24 - i32.shl - local.get $3 - i32.const 8 - i32.shr_u - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - br $continue|5 - end - end - end - end - local.get $2 - i32.const 16 - i32.and - if - local.get $0 - local.get $1 - local.tee $3 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $1 - local.set $0 - local.get $1 - local.get $3 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 8 - i32.and - if - local.get $0 - local.get $1 - local.tee $3 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $1 - local.set $0 - local.get $1 - local.get $3 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 4 - i32.and - if - local.get $0 - local.get $1 - local.tee $3 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $1 - local.set $0 - local.get $1 - local.get $3 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $3 - local.set $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - local.get $0 - i32.const 1 - i32.add - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - i32.const 1 - i32.add - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 1 - i32.and - if - local.get $0 - local.get $1 - i32.load8_u - i32.store8 - end - ) - (func $~lib/internal/memory/memmove (; 13 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - local.get $0 - local.get $1 - i32.eq - if - return - end - local.get $1 - local.get $2 - i32.add - local.get $0 - i32.le_u - local.tee $3 - i32.eqz - if - local.get $0 - local.get $2 - i32.add - local.get $1 - i32.le_u - local.set $3 - end - local.get $3 - if - local.get $0 - local.get $1 - local.get $2 - call $~lib/internal/memory/memcpy - return - end - local.get $0 - local.get $1 - i32.lt_u - if - local.get $1 - i32.const 7 - i32.and - local.get $0 - i32.const 7 - i32.and - i32.eq - if - loop $continue|0 - local.get $0 - i32.const 7 - i32.and - if - local.get $2 - i32.eqz - if - return - end - local.get $2 - i32.const 1 - i32.sub - local.set $2 - local.get $0 - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - br $continue|0 - end - end - loop $continue|1 - local.get $2 - i32.const 8 - i32.ge_u - if - local.get $0 - local.get $1 - i64.load - i64.store - local.get $2 - i32.const 8 - i32.sub - local.set $2 - local.get $0 - i32.const 8 - i32.add - local.set $0 - local.get $1 - i32.const 8 - i32.add - local.set $1 - br $continue|1 - end - end - end - loop $continue|2 - local.get $2 - if - local.get $0 - local.tee $4 - i32.const 1 - i32.add - local.set $0 - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $4 - local.get $3 - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - br $continue|2 - end - end - else - local.get $1 - i32.const 7 - i32.and - local.get $0 - i32.const 7 - i32.and - i32.eq - if - loop $continue|3 - local.get $0 - local.get $2 - i32.add - i32.const 7 - i32.and - if - local.get $2 - i32.eqz - if - return - end - local.get $2 - i32.const 1 - i32.sub - local.tee $2 - local.get $0 - i32.add - local.get $1 - local.get $2 - i32.add - i32.load8_u - i32.store8 - br $continue|3 - end - end - loop $continue|4 - local.get $2 - i32.const 8 - i32.ge_u - if - local.get $2 - i32.const 8 - i32.sub - local.tee $2 - local.get $0 - i32.add - local.get $1 - local.get $2 - i32.add - i64.load - i64.store - br $continue|4 - end - end - end - loop $continue|5 - local.get $2 - if - local.get $2 - i32.const 1 - i32.sub - local.tee $2 - local.get $0 - i32.add - local.get $1 - local.get $2 - i32.add - i32.load8_u - i32.store8 - br $continue|5 - end - end - end - ) - (func $~lib/internal/memory/memset (; 14 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $1 - i32.eqz - if - return - end - local.get $0 - i32.const 0 - i32.store8 - local.get $0 - local.get $1 - i32.add - i32.const 1 - i32.sub - i32.const 0 - i32.store8 - local.get $1 - i32.const 2 - i32.le_u - if - return - end - local.get $0 - i32.const 1 - i32.add - i32.const 0 - i32.store8 - local.get $0 - i32.const 2 - i32.add - i32.const 0 - i32.store8 - local.get $0 - local.get $1 - i32.add - local.tee $2 - i32.const 2 - i32.sub - i32.const 0 - i32.store8 - local.get $2 - i32.const 3 - i32.sub - i32.const 0 - i32.store8 - local.get $1 - i32.const 6 - i32.le_u - if - return - end - local.get $0 - i32.const 3 - i32.add - i32.const 0 - i32.store8 - local.get $0 - local.get $1 - i32.add - i32.const 4 - i32.sub - i32.const 0 - i32.store8 - local.get $1 - i32.const 8 - i32.le_u - if - return - end - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.tee $2 - local.get $0 - i32.add - local.tee $0 - i32.const 0 - i32.store - local.get $1 - local.get $2 - i32.sub - i32.const -4 - i32.and - local.tee $1 - local.get $0 - i32.add - i32.const 4 - i32.sub - i32.const 0 - i32.store - local.get $1 - i32.const 8 - i32.le_u - if - return - end - local.get $0 - i32.const 4 - i32.add - i32.const 0 - i32.store - local.get $0 - i32.const 8 - i32.add - i32.const 0 - i32.store - local.get $0 - local.get $1 - i32.add - local.tee $2 - i32.const 12 - i32.sub - i32.const 0 - i32.store - local.get $2 - i32.const 8 - i32.sub - i32.const 0 - i32.store - local.get $1 - i32.const 24 - i32.le_u - if - return - end - local.get $0 - i32.const 12 - i32.add - i32.const 0 - i32.store - local.get $0 - i32.const 16 - i32.add - i32.const 0 - i32.store - local.get $0 - i32.const 20 - i32.add - i32.const 0 - i32.store - local.get $0 - i32.const 24 - i32.add - i32.const 0 - i32.store - local.get $0 - local.get $1 - i32.add - local.tee $2 - i32.const 28 - i32.sub - i32.const 0 - i32.store - local.get $2 - i32.const 24 - i32.sub - i32.const 0 - i32.store - local.get $2 - i32.const 20 - i32.sub - i32.const 0 - i32.store - local.get $2 - i32.const 16 - i32.sub - i32.const 0 - i32.store - local.get $0 - i32.const 4 - i32.and - i32.const 24 - i32.add - local.tee $2 - local.get $0 - i32.add - local.set $0 - local.get $1 - local.get $2 - i32.sub - local.set $1 - loop $continue|0 - local.get $1 - i32.const 32 - i32.ge_u - if - local.get $0 - i64.const 0 - i64.store - local.get $0 - i32.const 8 - i32.add - i64.const 0 - i64.store - local.get $0 - i32.const 16 - i32.add - i64.const 0 - i64.store - local.get $0 - i32.const 24 - i32.add - i64.const 0 - i64.store - local.get $1 - i32.const 32 - i32.sub - local.set $1 - local.get $0 - i32.const 32 - i32.add - local.set $0 - br $continue|0 - end - end - ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $1 - local.get $0 - i32.load - local.tee $2 - i32.gt_s - if - local.get $1 - i32.const 1073741816 - i32.gt_s - if - i32.const 0 - i32.const 120 - i32.const 40 - i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $1 - i32.const 1 - i32.const 32 - local.get $2 - i32.const 7 - i32.add - i32.clz - i32.sub - i32.shl - i32.const 8 - i32.sub - i32.le_s - if - local.get $0 - local.get $1 - i32.store - else - local.get $1 - call $~lib/internal/arraybuffer/allocateUnsafe - local.tee $3 - i32.const 8 - i32.add - local.get $0 - i32.const 8 - i32.add - local.get $2 - call $~lib/internal/memory/memmove - local.get $3 - local.set $0 - end - local.get $0 - i32.const 8 - i32.add - local.get $2 - i32.add - local.get $1 - local.get $2 - i32.sub - call $~lib/internal/memory/memset - else - local.get $1 - local.get $2 - i32.lt_s - if - local.get $1 - i32.const 0 - i32.lt_s - if - i32.const 0 - i32.const 120 - i32.const 62 - i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $0 - local.get $1 - i32.store - end - end - local.get $0 - ) - (func $~lib/collector/itcm/__gc_link (; 16 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - global.get $~lib/collector/itcm/white - i32.eqz - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load - i32.const 3 - i32.and - i32.eq - local.tee $0 - if (result i32) - global.get $~lib/collector/itcm/white - local.get $1 - i32.const 16 - i32.sub - i32.load - i32.const 3 - i32.and - i32.eq - else - local.get $0 - end - if - local.get $2 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/array/Array#__set (; 17 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - local.get $1 - local.get $0 - i32.load - local.tee $3 - i32.load - i32.const 2 - i32.shr_u - i32.ge_u - if - local.get $1 - i32.const 268435454 - i32.ge_u - if - i32.const 0 - i32.const 72 - i32.const 107 - i32.const 41 - call $~lib/env/abort - unreachable - end - local.get $0 - local.get $3 - local.get $1 - i32.const 1 - i32.add - local.tee $4 - i32.const 2 - i32.shl - call $~lib/internal/arraybuffer/reallocateUnsafe - local.tee $3 - i32.store - local.get $0 - local.get $4 - i32.store offset=4 - end - local.get $3 - local.get $1 - i32.const 2 - i32.shl - i32.add - local.get $2 - i32.store offset=8 - local.get $0 - local.get $2 - call $~lib/collector/itcm/__gc_link - ) - (func $start:std/gc-array (; 18 ;) (type $FUNCSIG$v) - i32.const 184 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/collector/itcm/__gc_collect - global.get $std/gc-array/arr - i32.const 0 - i32.const 0 - i32.const 4 - call $~lib/collector/itcm/__gc_allocate - call $~lib/array/Array#__set - call $~lib/collector/itcm/__gc_collect - global.get $std/gc-array/arr - i32.const 1 - i32.const 0 - i32.const 4 - call $~lib/collector/itcm/__gc_allocate - call $~lib/array/Array#__set - call $~lib/collector/itcm/__gc_collect - global.get $std/gc-array/arr - i32.const 0 - i32.const 0 - i32.const 4 - call $~lib/collector/itcm/__gc_allocate - call $~lib/array/Array#__set - call $~lib/collector/itcm/__gc_collect - ) - (func $std/gc-array/main (; 19 ;) (type $FUNCSIG$i) (result i32) - global.get $~lib/started - i32.eqz - if - call $start:std/gc-array - i32.const 1 - global.set $~lib/started - end - i32.const 0 - ) - (func $null (; 20 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/std/gc-array.ts b/tests/compiler/std/gc-array.ts deleted file mode 100644 index f42c59d2..00000000 --- a/tests/compiler/std/gc-array.ts +++ /dev/null @@ -1,24 +0,0 @@ -import "allocator/arena"; -import "collector/itcm"; - -class Foo { -} - -var arr: Foo[] = []; - -gc.collect(); // should do nothing - -arr[0] = {}; - -gc.collect(); // should do nothing - -arr[1] = {}; - -gc.collect(); // should do nothing - -arr[0] = {}; - -gc.collect(); // should collect the old one - -@start -export function main(): i32 { return 0; } diff --git a/tests/compiler/std/gc-array.untouched.wat b/tests/compiler/std/gc-array.untouched.wat deleted file mode 100644 index 87e67dd5..00000000 --- a/tests/compiler/std/gc-array.untouched.wat +++ /dev/null @@ -1,2540 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$viii (func (param i32 i32 i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00") - (data (i32.const 32) "\00\00\00\00\00\00\00\00\02\00\00\00\00\00\00\00\18\00\00\00\00\00\00\00") - (data (i32.const 56) "\00\00\00\00\00\00\00\00\05\00\00\00\00\00\00\00\0d\00\00\00~\00l\00i\00b\00/\00a\00r\00r\00a\00y\00.\00t\00s\00") - (data (i32.const 104) "\00\00\00\00\00\00\00\00\05\00\00\00\00\00\00\00\1c\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00a\00r\00r\00a\00y\00b\00u\00f\00f\00e\00r\00.\00t\00s\00") - (table $0 7 funcref) - (elem (i32.const 0) $null $~lib/arraybuffer/ArrayBuffer~gc $~lib/array/Array~gc $~lib/collector/itcm/__gc_mark $std/gc-array/Foo~gc $~lib/string/String~gc $~lib/internal/arraybuffer/__gc) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $std/gc-array/arr (mut i32) (i32.const 48)) - (global $~lib/argc (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 180)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "main" (func $std/gc-array/main)) - (func $start:~lib/allocator/arena (; 1 ;) (type $FUNCSIG$v) - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $~lib/arraybuffer/ArrayBuffer~gc (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 3 - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - local.get $0 - i32.load - i32.const 3 - i32.and - i32.or - i32.store - ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - local.set $1 - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $0 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $0 - local.get $1 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/collector/itcm/iter - i32.eq - if - local.get $0 - i32.load offset=4 - global.set $~lib/collector/itcm/iter - end - local.get $0 - call $~lib/collector/itcm/ManagedObject#unlink - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.const 2 - i32.or - i32.store - ) - (func $~lib/collector/itcm/__gc_mark (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - local.get $0 - if - block $~lib/collector/itcm/refToObj|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - i32.const 16 - i32.sub - end - local.set $1 - local.get $1 - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - if - local.get $1 - call $~lib/collector/itcm/ManagedObject#makeGray - end - end - ) - (func $~lib/array/Array~gc (; 10 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.load - local.set $1 - local.get $1 - call $~lib/collector/itcm/__gc_mark - i32.const 0 - local.set $2 - local.get $0 - i32.load offset=4 - i32.const 2 - i32.shl - local.set $3 - block $break|0 - loop $continue|0 - local.get $2 - local.get $3 - i32.lt_u - if - block - local.get $1 - local.get $2 - i32.add - i32.load offset=8 - call $~lib/collector/itcm/__gc_mark - local.get $2 - i32.const 4 - i32.add - local.set $2 - end - br $continue|0 - end - end - end - ) - (func $~lib/allocator/arena/__memory_allocate (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - global.get $~lib/allocator/arena/offset - local.set $1 - local.get $1 - local.get $0 - local.tee $2 - i32.const 1 - local.tee $3 - local.get $2 - local.get $3 - i32.gt_u - select - i32.add - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.set $4 - current_memory - local.set $5 - local.get $4 - local.get $5 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $4 - local.get $1 - i32.sub - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $2 - local.get $5 - local.tee $3 - local.get $2 - local.tee $6 - local.get $3 - local.get $6 - i32.gt_s - select - local.set $3 - local.get $3 - grow_memory - i32.const 0 - i32.lt_s - if - local.get $2 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $4 - global.set $~lib/allocator/arena/offset - local.get $1 - ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 12 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 13 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.or - i32.store - ) - (func $~lib/allocator/arena/__memory_free (; 14 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/collector/itcm/step (; 15 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - block $break|0 - block $case3|0 - block $case2|0 - block $case1|0 - block $case0|0 - global.get $~lib/collector/itcm/state - local.set $1 - local.get $1 - i32.const 0 - i32.eq - br_if $case0|0 - local.get $1 - i32.const 1 - i32.eq - br_if $case1|0 - local.get $1 - i32.const 2 - i32.eq - br_if $case2|0 - local.get $1 - i32.const 3 - i32.eq - br_if $case3|0 - br $break|0 - end - block - block $~lib/memory/memory.allocate|inlined.0 (result i32) - i32.const 16 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.0 - end - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - i32.const -1 - i32.store offset=8 - global.get $~lib/collector/itcm/fromSpace - call $~lib/collector/itcm/ManagedObjectList#clear - block $~lib/memory/memory.allocate|inlined.1 (result i32) - i32.const 16 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.1 - end - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - i32.const -1 - i32.store offset=8 - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - block - i32.const 3 - call $~iterateRoots - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - unreachable - end - unreachable - end - block - global.get $~lib/collector/itcm/iter - call $~lib/collector/itcm/ManagedObject#get:next - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/collector/itcm/white - i32.eqz - call $~lib/collector/itcm/ManagedObject#set:color - i32.const 1 - global.set $~lib/argc - block $~lib/collector/itcm/objToRef|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - i32.const 16 - i32.add - end - local.get $0 - i32.load offset=8 - call_indirect (type $FUNCSIG$vi) - else - i32.const 3 - call $~iterateRoots - global.get $~lib/collector/itcm/iter - call $~lib/collector/itcm/ManagedObject#get:next - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.eq - if - global.get $~lib/collector/itcm/fromSpace - local.set $1 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/fromSpace - local.get $1 - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/white - i32.eqz - global.set $~lib/collector/itcm/white - local.get $1 - call $~lib/collector/itcm/ManagedObject#get:next - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - end - end - br $break|0 - unreachable - end - unreachable - end - block - global.get $~lib/collector/itcm/iter - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.ge_u - if - block $~lib/memory/memory.free|inlined.0 - local.get $0 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_free - br $~lib/memory/memory.free|inlined.0 - end - end - else - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - i32.const 1 - global.set $~lib/collector/itcm/state - end - br $break|0 - unreachable - end - unreachable - end - ) - (func $~lib/collector/itcm/__gc_collect (; 16 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case1|0 - block $case0|0 - global.get $~lib/collector/itcm/state - local.set $0 - local.get $0 - i32.const 0 - i32.eq - br_if $case0|0 - local.get $0 - i32.const 1 - i32.eq - br_if $case1|0 - br $break|0 - end - end - call $~lib/collector/itcm/step - end - block $break|1 - loop $continue|1 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|1 - end - end - end - ) - (func $~lib/gc/gc.collect (; 17 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/__gc_collect - return - ) - (func $~lib/collector/itcm/__gc_allocate (; 18 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741824 - i32.const 16 - i32.sub - i32.gt_u - if - unreachable - end - call $~lib/collector/itcm/step - block $~lib/memory/memory.allocate|inlined.2 (result i32) - i32.const 16 - local.get $0 - i32.add - local.set $2 - local.get $2 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.2 - end - local.set $3 - local.get $3 - local.get $1 - i32.store offset=8 - local.get $3 - global.get $~lib/collector/itcm/white - call $~lib/collector/itcm/ManagedObject#set:color - global.get $~lib/collector/itcm/fromSpace - local.get $3 - call $~lib/collector/itcm/ManagedObjectList#push - block $~lib/collector/itcm/objToRef|inlined.1 (result i32) - local.get $3 - local.set $2 - local.get $2 - i32.const 16 - i32.add - end - ) - (func $std/gc-array/Foo~gc (; 19 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $~lib/string/String~gc (; 20 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $~lib/internal/arraybuffer/computeSize (; 21 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - i32.const 1 - i32.const 32 - local.get $0 - i32.const 8 - i32.add - i32.const 1 - i32.sub - i32.clz - i32.sub - i32.shl - ) - (func $~lib/internal/arraybuffer/__gc (; 22 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/internal/arraybuffer/allocateUnsafe (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - local.get $0 - i32.const 1073741816 - i32.le_u - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 26 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - call $~lib/internal/arraybuffer/computeSize - i32.const 6 - call $~lib/collector/itcm/__gc_allocate - local.set $1 - local.get $1 - local.get $0 - i32.store - local.get $1 - ) - (func $~lib/internal/memory/memcpy (; 24 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - block $break|0 - loop $continue|0 - local.get $2 - if (result i32) - local.get $1 - i32.const 3 - i32.and - else - local.get $2 - end - if - block - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - end - br $continue|0 - end - end - end - local.get $0 - i32.const 3 - i32.and - i32.const 0 - i32.eq - if - block $break|1 - loop $continue|1 - local.get $2 - i32.const 16 - i32.ge_u - if - block - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $1 - i32.const 8 - i32.add - i32.load - i32.store - local.get $0 - i32.const 12 - i32.add - local.get $1 - i32.const 12 - i32.add - i32.load - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|1 - end - end - end - local.get $2 - i32.const 8 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.get $1 - i32.const 4 - i32.add - i32.load - i32.store - local.get $0 - i32.const 8 - i32.add - local.set $0 - local.get $1 - i32.const 8 - i32.add - local.set $1 - end - local.get $2 - i32.const 4 - i32.and - if - local.get $0 - local.get $1 - i32.load - i32.store - local.get $0 - i32.const 4 - i32.add - local.set $0 - local.get $1 - i32.const 4 - i32.add - local.set $1 - end - local.get $2 - i32.const 2 - i32.and - if - local.get $0 - local.get $1 - i32.load16_u - i32.store16 - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $1 - i32.const 2 - i32.add - local.set $1 - end - local.get $2 - i32.const 1 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - return - end - local.get $2 - i32.const 32 - i32.ge_u - if - block $break|2 - block $case2|2 - block $case1|2 - block $case0|2 - local.get $0 - i32.const 3 - i32.and - local.set $5 - local.get $5 - i32.const 1 - i32.eq - br_if $case0|2 - local.get $5 - i32.const 2 - i32.eq - br_if $case1|2 - local.get $5 - i32.const 3 - i32.eq - br_if $case2|2 - br $break|2 - end - block - local.get $1 - i32.load - local.set $3 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 3 - i32.sub - local.set $2 - block $break|3 - loop $continue|3 - local.get $2 - i32.const 17 - i32.ge_u - if - block - local.get $1 - i32.const 1 - i32.add - i32.load - local.set $4 - local.get $0 - local.get $3 - i32.const 24 - i32.shr_u - local.get $4 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 5 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.const 24 - i32.shr_u - local.get $3 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 9 - i32.add - i32.load - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.get $3 - i32.const 24 - i32.shr_u - local.get $4 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 13 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.const 24 - i32.shr_u - local.get $3 - i32.const 8 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|3 - end - end - end - br $break|2 - unreachable - end - unreachable - end - block - local.get $1 - i32.load - local.set $3 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 2 - i32.sub - local.set $2 - block $break|4 - loop $continue|4 - local.get $2 - i32.const 18 - i32.ge_u - if - block - local.get $1 - i32.const 2 - i32.add - i32.load - local.set $4 - local.get $0 - local.get $3 - i32.const 16 - i32.shr_u - local.get $4 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 6 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.const 16 - i32.shr_u - local.get $3 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 10 - i32.add - i32.load - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.get $3 - i32.const 16 - i32.shr_u - local.get $4 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 14 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.const 16 - i32.shr_u - local.get $3 - i32.const 16 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|4 - end - end - end - br $break|2 - unreachable - end - unreachable - end - block - local.get $1 - i32.load - local.set $3 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - block $break|5 - loop $continue|5 - local.get $2 - i32.const 19 - i32.ge_u - if - block - local.get $1 - i32.const 3 - i32.add - i32.load - local.set $4 - local.get $0 - local.get $3 - i32.const 8 - i32.shr_u - local.get $4 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 7 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.const 8 - i32.shr_u - local.get $3 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 11 - i32.add - i32.load - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.get $3 - i32.const 8 - i32.shr_u - local.get $4 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 15 - i32.add - i32.load - local.set $3 - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.const 8 - i32.shr_u - local.get $3 - i32.const 24 - i32.shl - i32.or - i32.store - local.get $1 - i32.const 16 - i32.add - local.set $1 - local.get $0 - i32.const 16 - i32.add - local.set $0 - local.get $2 - i32.const 16 - i32.sub - local.set $2 - end - br $continue|5 - end - end - end - br $break|2 - unreachable - end - unreachable - end - end - local.get $2 - i32.const 16 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 8 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 4 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 2 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - local.get $2 - i32.const 1 - i32.and - if - block (result i32) - local.get $0 - local.tee $5 - i32.const 1 - i32.add - local.set $0 - local.get $5 - end - block (result i32) - local.get $1 - local.tee $5 - i32.const 1 - i32.add - local.set $1 - local.get $5 - end - i32.load8_u - i32.store8 - end - ) - (func $~lib/internal/memory/memmove (; 25 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - local.get $0 - local.get $1 - i32.eq - if - return - end - local.get $1 - local.get $2 - i32.add - local.get $0 - i32.le_u - local.tee $3 - if (result i32) - local.get $3 - else - local.get $0 - local.get $2 - i32.add - local.get $1 - i32.le_u - end - if - local.get $0 - local.get $1 - local.get $2 - call $~lib/internal/memory/memcpy - return - end - local.get $0 - local.get $1 - i32.lt_u - if - local.get $1 - i32.const 7 - i32.and - local.get $0 - i32.const 7 - i32.and - i32.eq - if - block $break|0 - loop $continue|0 - local.get $0 - i32.const 7 - i32.and - if - block - local.get $2 - i32.eqz - if - return - end - local.get $2 - i32.const 1 - i32.sub - local.set $2 - block (result i32) - local.get $0 - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - end - block (result i32) - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - end - i32.load8_u - i32.store8 - end - br $continue|0 - end - end - end - block $break|1 - loop $continue|1 - local.get $2 - i32.const 8 - i32.ge_u - if - block - local.get $0 - local.get $1 - i64.load - i64.store - local.get $2 - i32.const 8 - i32.sub - local.set $2 - local.get $0 - i32.const 8 - i32.add - local.set $0 - local.get $1 - i32.const 8 - i32.add - local.set $1 - end - br $continue|1 - end - end - end - end - block $break|2 - loop $continue|2 - local.get $2 - if - block - block (result i32) - local.get $0 - local.tee $3 - i32.const 1 - i32.add - local.set $0 - local.get $3 - end - block (result i32) - local.get $1 - local.tee $3 - i32.const 1 - i32.add - local.set $1 - local.get $3 - end - i32.load8_u - i32.store8 - local.get $2 - i32.const 1 - i32.sub - local.set $2 - end - br $continue|2 - end - end - end - else - local.get $1 - i32.const 7 - i32.and - local.get $0 - i32.const 7 - i32.and - i32.eq - if - block $break|3 - loop $continue|3 - local.get $0 - local.get $2 - i32.add - i32.const 7 - i32.and - if - block - local.get $2 - i32.eqz - if - return - end - local.get $0 - local.get $2 - i32.const 1 - i32.sub - local.tee $2 - i32.add - local.get $1 - local.get $2 - i32.add - i32.load8_u - i32.store8 - end - br $continue|3 - end - end - end - block $break|4 - loop $continue|4 - local.get $2 - i32.const 8 - i32.ge_u - if - block - local.get $2 - i32.const 8 - i32.sub - local.set $2 - local.get $0 - local.get $2 - i32.add - local.get $1 - local.get $2 - i32.add - i64.load - i64.store - end - br $continue|4 - end - end - end - end - block $break|5 - loop $continue|5 - local.get $2 - if - local.get $0 - local.get $2 - i32.const 1 - i32.sub - local.tee $2 - i32.add - local.get $1 - local.get $2 - i32.add - i32.load8_u - i32.store8 - br $continue|5 - end - end - end - end - ) - (func $~lib/internal/memory/memset (; 26 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i64) - local.get $2 - i32.eqz - if - return - end - local.get $0 - local.get $1 - i32.store8 - local.get $0 - local.get $2 - i32.add - i32.const 1 - i32.sub - local.get $1 - i32.store8 - local.get $2 - i32.const 2 - i32.le_u - if - return - end - local.get $0 - i32.const 1 - i32.add - local.get $1 - i32.store8 - local.get $0 - i32.const 2 - i32.add - local.get $1 - i32.store8 - local.get $0 - local.get $2 - i32.add - i32.const 2 - i32.sub - local.get $1 - i32.store8 - local.get $0 - local.get $2 - i32.add - i32.const 3 - i32.sub - local.get $1 - i32.store8 - local.get $2 - i32.const 6 - i32.le_u - if - return - end - local.get $0 - i32.const 3 - i32.add - local.get $1 - i32.store8 - local.get $0 - local.get $2 - i32.add - i32.const 4 - i32.sub - local.get $1 - i32.store8 - local.get $2 - i32.const 8 - i32.le_u - if - return - end - i32.const 0 - local.get $0 - i32.sub - i32.const 3 - i32.and - local.set $3 - local.get $0 - local.get $3 - i32.add - local.set $0 - local.get $2 - local.get $3 - i32.sub - local.set $2 - local.get $2 - i32.const -4 - i32.and - local.set $2 - i32.const -1 - i32.const 255 - i32.div_u - local.get $1 - i32.const 255 - i32.and - i32.mul - local.set $4 - local.get $0 - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 4 - i32.sub - local.get $4 - i32.store - local.get $2 - i32.const 8 - i32.le_u - if - return - end - local.get $0 - i32.const 4 - i32.add - local.get $4 - i32.store - local.get $0 - i32.const 8 - i32.add - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 12 - i32.sub - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 8 - i32.sub - local.get $4 - i32.store - local.get $2 - i32.const 24 - i32.le_u - if - return - end - local.get $0 - i32.const 12 - i32.add - local.get $4 - i32.store - local.get $0 - i32.const 16 - i32.add - local.get $4 - i32.store - local.get $0 - i32.const 20 - i32.add - local.get $4 - i32.store - local.get $0 - i32.const 24 - i32.add - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 28 - i32.sub - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 24 - i32.sub - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 20 - i32.sub - local.get $4 - i32.store - local.get $0 - local.get $2 - i32.add - i32.const 16 - i32.sub - local.get $4 - i32.store - i32.const 24 - local.get $0 - i32.const 4 - i32.and - i32.add - local.set $3 - local.get $0 - local.get $3 - i32.add - local.set $0 - local.get $2 - local.get $3 - i32.sub - local.set $2 - local.get $4 - i64.extend_i32_u - local.get $4 - i64.extend_i32_u - i64.const 32 - i64.shl - i64.or - local.set $5 - block $break|0 - loop $continue|0 - local.get $2 - i32.const 32 - i32.ge_u - if - block - local.get $0 - local.get $5 - i64.store - local.get $0 - i32.const 8 - i32.add - local.get $5 - i64.store - local.get $0 - i32.const 16 - i32.add - local.get $5 - i64.store - local.get $0 - i32.const 24 - i32.add - local.get $5 - i64.store - local.get $2 - i32.const 32 - i32.sub - local.set $2 - local.get $0 - i32.const 32 - i32.add - local.set $0 - end - br $continue|0 - end - end - end - ) - (func $~lib/internal/arraybuffer/reallocateUnsafe (; 27 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - local.get $0 - i32.load - local.set $2 - local.get $1 - local.get $2 - i32.gt_s - if - local.get $1 - i32.const 1073741816 - i32.le_s - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 40 - i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $1 - local.get $2 - call $~lib/internal/arraybuffer/computeSize - i32.const 8 - i32.sub - i32.le_s - if - local.get $0 - local.get $1 - i32.store - else - local.get $1 - call $~lib/internal/arraybuffer/allocateUnsafe - local.set $3 - block $~lib/memory/memory.copy|inlined.0 - local.get $3 - i32.const 8 - i32.add - local.set $4 - local.get $0 - i32.const 8 - i32.add - local.set $5 - local.get $2 - local.set $6 - local.get $4 - local.get $5 - local.get $6 - call $~lib/internal/memory/memmove - end - local.get $3 - local.set $0 - end - block $~lib/memory/memory.fill|inlined.0 - local.get $0 - i32.const 8 - i32.add - local.get $2 - i32.add - local.set $3 - i32.const 0 - local.set $6 - local.get $1 - local.get $2 - i32.sub - local.set $5 - local.get $3 - local.get $6 - local.get $5 - call $~lib/internal/memory/memset - end - else - local.get $1 - local.get $2 - i32.lt_s - if - local.get $1 - i32.const 0 - i32.ge_s - i32.eqz - if - i32.const 0 - i32.const 120 - i32.const 62 - i32.const 4 - call $~lib/env/abort - unreachable - end - local.get $0 - local.get $1 - i32.store - end - end - local.get $0 - ) - (func $~lib/collector/itcm/__gc_link (; 28 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - (local $3 i32) - block $~lib/collector/itcm/refToObj|inlined.1 (result i32) - local.get $0 - local.set $2 - local.get $2 - i32.const 16 - i32.sub - end - local.set $3 - local.get $3 - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eqz - i32.eq - local.tee $2 - if (result i32) - block $~lib/collector/itcm/refToObj|inlined.3 (result i32) - local.get $1 - local.set $2 - local.get $2 - i32.const 16 - i32.sub - end - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - else - local.get $2 - end - if - local.get $3 - call $~lib/collector/itcm/ManagedObject#makeGray - end - ) - (func $~lib/array/Array#__set (; 29 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - local.get $0 - i32.load - local.set $3 - local.get $3 - i32.load - i32.const 2 - i32.shr_u - local.set $4 - local.get $1 - local.get $4 - i32.ge_u - if - local.get $1 - i32.const 268435454 - i32.ge_u - if - i32.const 0 - i32.const 72 - i32.const 107 - i32.const 41 - call $~lib/env/abort - unreachable - end - local.get $3 - local.get $1 - i32.const 1 - i32.add - i32.const 2 - i32.shl - call $~lib/internal/arraybuffer/reallocateUnsafe - local.set $3 - local.get $0 - local.get $3 - i32.store - local.get $0 - local.get $1 - i32.const 1 - i32.add - i32.store offset=4 - end - block $~lib/internal/arraybuffer/STORE|inlined.0 - local.get $3 - local.set $5 - local.get $1 - local.set $6 - local.get $2 - local.set $7 - i32.const 0 - local.set $8 - local.get $5 - local.get $6 - i32.const 2 - i32.shl - i32.add - local.get $8 - i32.add - local.get $7 - i32.store offset=8 - end - local.get $0 - local.get $2 - call $~lib/collector/itcm/__gc_link - ) - (func $start:std/gc-array (; 30 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - call $start:~lib/allocator/arena - call $~lib/gc/gc.collect - global.get $std/gc-array/arr - i32.const 0 - block (result i32) - i32.const 0 - i32.const 4 - call $~lib/collector/itcm/__gc_allocate - local.set $0 - local.get $0 - end - call $~lib/array/Array#__set - call $~lib/gc/gc.collect - global.get $std/gc-array/arr - i32.const 1 - block (result i32) - i32.const 0 - i32.const 4 - call $~lib/collector/itcm/__gc_allocate - local.set $1 - local.get $1 - end - call $~lib/array/Array#__set - call $~lib/gc/gc.collect - global.get $std/gc-array/arr - i32.const 0 - block (result i32) - i32.const 0 - i32.const 4 - call $~lib/collector/itcm/__gc_allocate - local.set $2 - local.get $2 - end - call $~lib/array/Array#__set - call $~lib/gc/gc.collect - ) - (func $std/gc-array/main (; 31 ;) (type $FUNCSIG$i) (result i32) - global.get $~lib/started - i32.eqz - if - call $start - i32.const 1 - global.set $~lib/started - end - i32.const 0 - ) - (func $start (; 32 ;) (type $FUNCSIG$v) - call $start:std/gc-array - ) - (func $null (; 33 ;) (type $FUNCSIG$v) - ) - (func $~iterateRoots (; 34 ;) (type $FUNCSIG$vi) (param $0 i32) - global.get $std/gc-array/arr - local.get $0 - call_indirect (type $FUNCSIG$vi) - ) -) diff --git a/tests/compiler/std/gc-basics.optimized.wat b/tests/compiler/std/gc-basics.optimized.wat deleted file mode 100644 index 5e8cf42e..00000000 --- a/tests/compiler/std/gc-basics.optimized.wat +++ /dev/null @@ -1,481 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 16) "\03\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s") - (table $0 4 funcref) - (elem (i32.const 0) $null $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark $~lib/string/String~gc) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~lib/argc (mut i32) (i32.const 0)) - (global $std/gc-basics/obj (mut i32) (i32.const 0)) - (global $std/gc-basics/obj2 (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "main" (func $std/gc-basics/main)) - (func $std/gc-basics/MyObject_visit (; 1 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - global.get $~lib/allocator/arena/offset - local.tee $1 - local.get $0 - i32.const 1 - local.get $0 - i32.const 1 - i32.gt_u - select - i32.add - i32.const 7 - i32.add - i32.const -8 - i32.and - local.tee $2 - current_memory - local.tee $3 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $3 - local.get $2 - local.get $1 - i32.sub - i32.const 65535 - i32.add - i32.const -65536 - i32.and - i32.const 16 - i32.shr_u - local.tee $0 - local.get $3 - local.get $0 - i32.gt_s - select - grow_memory - i32.const 0 - i32.lt_s - if - local.get $0 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $2 - global.set $~lib/allocator/arena/offset - local.get $1 - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 3 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $1 - i32.load - i32.const 3 - i32.and - local.get $0 - i32.or - i32.store - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $2 - i32.load - i32.const 3 - i32.and - local.get $1 - i32.or - i32.store - local.get $0 - local.get $1 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - global.get $~lib/collector/itcm/iter - local.get $0 - i32.eq - if - local.get $0 - i32.load offset=4 - global.set $~lib/collector/itcm/iter - end - local.get $0 - i32.load - i32.const -4 - i32.and - local.tee $2 - local.get $0 - i32.load offset=4 - local.tee $1 - i32.store offset=4 - local.get $1 - local.get $1 - i32.load - i32.const 3 - i32.and - local.get $2 - i32.or - i32.store - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load - i32.const -4 - i32.and - i32.const 2 - i32.or - i32.store - ) - (func $~lib/collector/itcm/__gc_mark (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - if - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - i32.load - i32.const 3 - i32.and - i32.eq - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#makeGray - end - end - ) - (func $~lib/collector/itcm/step (; 6 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case3|0 - block $case2|0 - block $case1|0 - global.get $~lib/collector/itcm/state - local.tee $0 - if - local.get $0 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $break|0 - end - i32.const 16 - call $~lib/allocator/arena/__memory_allocate - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - local.tee $0 - i32.const -1 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - i32.const 16 - call $~lib/allocator/arena/__memory_allocate - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - local.tee $0 - i32.const -1 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - global.get $std/gc-basics/obj - i32.const 2 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-basics/obj2 - i32.const 2 - call_indirect (type $FUNCSIG$vi) - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - end - global.get $~lib/collector/itcm/iter - i32.load - i32.const -4 - i32.and - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/collector/itcm/white - i32.eqz - local.get $0 - i32.load - i32.const -4 - i32.and - i32.or - i32.store - i32.const 1 - global.set $~lib/argc - local.get $0 - i32.const 16 - i32.add - local.get $0 - i32.load offset=8 - call_indirect (type $FUNCSIG$vi) - else - global.get $std/gc-basics/obj - i32.const 2 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-basics/obj2 - i32.const 2 - call_indirect (type $FUNCSIG$vi) - global.get $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/iter - i32.load - i32.const -4 - i32.and - i32.eq - if - global.get $~lib/collector/itcm/fromSpace - local.set $0 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/fromSpace - local.get $0 - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/white - i32.eqz - global.set $~lib/collector/itcm/white - local.get $0 - i32.load - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - end - end - br $break|0 - end - global.get $~lib/collector/itcm/iter - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - i32.load - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - else - global.get $~lib/collector/itcm/toSpace - local.tee $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - ) - (func $~lib/collector/itcm/__gc_allocate (; 7 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - call $~lib/collector/itcm/step - i32.const 20 - call $~lib/allocator/arena/__memory_allocate - local.tee $0 - i32.const 1 - i32.store offset=8 - local.get $0 - global.get $~lib/collector/itcm/white - local.get $0 - i32.load - i32.const -4 - i32.and - i32.or - i32.store - global.get $~lib/collector/itcm/fromSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - i32.const 16 - i32.add - ) - (func $~lib/string/String~gc (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $~lib/collector/itcm/__gc_collect (; 9 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case1|0 - global.get $~lib/collector/itcm/state - local.tee $0 - i32.eqz - br_if $case1|0 - local.get $0 - i32.const 1 - i32.eq - br_if $case1|0 - br $break|0 - end - call $~lib/collector/itcm/step - end - loop $continue|1 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|1 - end - end - ) - (func $start:std/gc-basics (; 10 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - i32.const 64 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $~lib/collector/itcm/__gc_allocate - global.set $std/gc-basics/obj - global.get $std/gc-basics/obj - local.tee $0 - i32.const 123 - i32.store - local.get $0 - i32.const 16 - i32.sub - local.tee $1 - i32.load offset=4 - local.set $2 - block (result i32) - local.get $1 - i32.load - i32.const -4 - i32.and - local.tee $3 - i32.const 0 - i32.ne - local.tee $0 - if - local.get $2 - i32.const 0 - i32.ne - local.set $0 - end - local.get $0 - end - if (result i32) - local.get $2 - local.get $3 - i32.eq - else - local.get $0 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 19 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $1 - i32.load offset=8 - i32.const 1 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 21 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $1 - i32.load offset=12 - if - i32.const 0 - i32.const 24 - i32.const 23 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $1 - i32.load offset=16 - i32.const 123 - i32.ne - if - i32.const 0 - i32.const 24 - i32.const 25 - i32.const 2 - call $~lib/env/abort - unreachable - end - call $~lib/collector/itcm/__gc_collect - i32.const 0 - global.set $std/gc-basics/obj - call $~lib/collector/itcm/__gc_collect - ) - (func $std/gc-basics/main (; 11 ;) (type $FUNCSIG$i) (result i32) - global.get $~lib/started - i32.eqz - if - call $start:std/gc-basics - i32.const 1 - global.set $~lib/started - end - i32.const 0 - ) - (func $null (; 12 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/std/gc-basics.ts b/tests/compiler/std/gc-basics.ts deleted file mode 100644 index fc79941f..00000000 --- a/tests/compiler/std/gc-basics.ts +++ /dev/null @@ -1,35 +0,0 @@ -import "allocator/arena"; -import "collector/itcm"; - -// a class to test with -class MyObject { - a: u32; -} -function MyObject_visit(ref: usize): void {} // function table index == classId ? - -// allocate a managed instance -var obj: MyObject | null = changetype(__gc_allocate(offsetof(), MyObject_visit)); -obj.a = 123; - -// check header -{ - let head = changetype(obj) - 16; - let next = load(head, 0) & ~3; - let prev = load(head, 4); - assert(next != 0 && prev != 0 && next == prev); - let visitFn = load(head, 8); - assert(visitFn == changetype(MyObject_visit)); - let unused = load(head, 12); - assert(unused == 0); - let a = load(head, 16); - assert(a == 123); -} - -gc.collect(); // should keep 'obj' because it's a referenced root (see trace output) -obj = null; -gc.collect(); // should free 'obj' because it isn't referenced anymore (see trace output) - -var obj2: MyObject; // should also iterate globals defined late - -@start -export function main(): i32 { return 0; } diff --git a/tests/compiler/std/gc-basics.untouched.wat b/tests/compiler/std/gc-basics.untouched.wat deleted file mode 100644 index e24be9c9..00000000 --- a/tests/compiler/std/gc-basics.untouched.wat +++ /dev/null @@ -1,629 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\00\00\00\00\00\00\00\00\03\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s\00") - (table $0 4 funcref) - (elem (i32.const 0) $null $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark $~lib/string/String~gc) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~lib/argc (mut i32) (i32.const 0)) - (global $std/gc-basics/obj (mut i32) (i32.const 0)) - (global $std/gc-basics/obj2 (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 60)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "main" (func $std/gc-basics/main)) - (func $start:~lib/allocator/arena (; 1 ;) (type $FUNCSIG$v) - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $std/gc-basics/MyObject_visit (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - global.get $~lib/allocator/arena/offset - local.set $1 - local.get $1 - local.get $0 - local.tee $2 - i32.const 1 - local.tee $3 - local.get $2 - local.get $3 - i32.gt_u - select - i32.add - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.set $4 - current_memory - local.set $5 - local.get $4 - local.get $5 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $4 - local.get $1 - i32.sub - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $2 - local.get $5 - local.tee $3 - local.get $2 - local.tee $6 - local.get $3 - local.get $6 - i32.gt_s - select - local.set $3 - local.get $3 - grow_memory - i32.const 0 - i32.lt_s - if - local.get $2 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $4 - global.set $~lib/allocator/arena/offset - local.get $1 - ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 4 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 3 - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 6 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - local.get $0 - i32.load - i32.const 3 - i32.and - i32.or - i32.store - ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - local.set $1 - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 9 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $0 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $0 - local.get $1 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 10 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/collector/itcm/iter - i32.eq - if - local.get $0 - i32.load offset=4 - global.set $~lib/collector/itcm/iter - end - local.get $0 - call $~lib/collector/itcm/ManagedObject#unlink - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.const 2 - i32.or - i32.store - ) - (func $~lib/collector/itcm/__gc_mark (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - local.get $0 - if - block $~lib/collector/itcm/refToObj|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - i32.const 16 - i32.sub - end - local.set $1 - local.get $1 - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - if - local.get $1 - call $~lib/collector/itcm/ManagedObject#makeGray - end - end - ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 12 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.or - i32.store - ) - (func $~lib/allocator/arena/__memory_free (; 13 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/collector/itcm/step (; 14 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - block $break|0 - block $case3|0 - block $case2|0 - block $case1|0 - block $case0|0 - global.get $~lib/collector/itcm/state - local.set $1 - local.get $1 - i32.const 0 - i32.eq - br_if $case0|0 - local.get $1 - i32.const 1 - i32.eq - br_if $case1|0 - local.get $1 - i32.const 2 - i32.eq - br_if $case2|0 - local.get $1 - i32.const 3 - i32.eq - br_if $case3|0 - br $break|0 - end - block - block $~lib/memory/memory.allocate|inlined.0 (result i32) - i32.const 16 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.0 - end - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - i32.const -1 - i32.store offset=8 - global.get $~lib/collector/itcm/fromSpace - call $~lib/collector/itcm/ManagedObjectList#clear - block $~lib/memory/memory.allocate|inlined.1 (result i32) - i32.const 16 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.1 - end - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - i32.const -1 - i32.store offset=8 - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - block - i32.const 2 - call $~iterateRoots - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - unreachable - end - unreachable - end - block - global.get $~lib/collector/itcm/iter - call $~lib/collector/itcm/ManagedObject#get:next - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/collector/itcm/white - i32.eqz - call $~lib/collector/itcm/ManagedObject#set:color - i32.const 1 - global.set $~lib/argc - block $~lib/collector/itcm/objToRef|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - i32.const 16 - i32.add - end - local.get $0 - i32.load offset=8 - call_indirect (type $FUNCSIG$vi) - else - i32.const 2 - call $~iterateRoots - global.get $~lib/collector/itcm/iter - call $~lib/collector/itcm/ManagedObject#get:next - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.eq - if - global.get $~lib/collector/itcm/fromSpace - local.set $1 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/fromSpace - local.get $1 - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/white - i32.eqz - global.set $~lib/collector/itcm/white - local.get $1 - call $~lib/collector/itcm/ManagedObject#get:next - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - end - end - br $break|0 - unreachable - end - unreachable - end - block - global.get $~lib/collector/itcm/iter - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.ge_u - if - block $~lib/memory/memory.free|inlined.0 - local.get $0 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_free - br $~lib/memory/memory.free|inlined.0 - end - end - else - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - i32.const 1 - global.set $~lib/collector/itcm/state - end - br $break|0 - unreachable - end - unreachable - end - ) - (func $~lib/collector/itcm/__gc_allocate (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741824 - i32.const 16 - i32.sub - i32.gt_u - if - unreachable - end - call $~lib/collector/itcm/step - block $~lib/memory/memory.allocate|inlined.2 (result i32) - i32.const 16 - local.get $0 - i32.add - local.set $2 - local.get $2 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.2 - end - local.set $3 - local.get $3 - local.get $1 - i32.store offset=8 - local.get $3 - global.get $~lib/collector/itcm/white - call $~lib/collector/itcm/ManagedObject#set:color - global.get $~lib/collector/itcm/fromSpace - local.get $3 - call $~lib/collector/itcm/ManagedObjectList#push - block $~lib/collector/itcm/objToRef|inlined.1 (result i32) - local.get $3 - local.set $2 - local.get $2 - i32.const 16 - i32.add - end - ) - (func $~lib/string/String~gc (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $~lib/collector/itcm/__gc_collect (; 17 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case1|0 - block $case0|0 - global.get $~lib/collector/itcm/state - local.set $0 - local.get $0 - i32.const 0 - i32.eq - br_if $case0|0 - local.get $0 - i32.const 1 - i32.eq - br_if $case1|0 - br $break|0 - end - end - call $~lib/collector/itcm/step - end - block $break|1 - loop $continue|1 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|1 - end - end - end - ) - (func $~lib/gc/gc.collect (; 18 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/__gc_collect - return - ) - (func $start:std/gc-basics (; 19 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - call $start:~lib/allocator/arena - i32.const 4 - i32.const 1 - call $~lib/collector/itcm/__gc_allocate - global.set $std/gc-basics/obj - global.get $std/gc-basics/obj - i32.const 123 - i32.store - block - global.get $std/gc-basics/obj - i32.const 16 - i32.sub - local.set $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.set $1 - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - i32.const 0 - i32.ne - local.tee $3 - if (result i32) - local.get $2 - i32.const 0 - i32.ne - else - local.get $3 - end - local.tee $3 - if (result i32) - local.get $1 - local.get $2 - i32.eq - else - local.get $3 - end - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 19 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.load offset=8 - local.set $3 - local.get $3 - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 21 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.load offset=12 - local.set $4 - local.get $4 - i32.const 0 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 23 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.load offset=16 - local.set $5 - local.get $5 - i32.const 123 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 24 - i32.const 25 - i32.const 2 - call $~lib/env/abort - unreachable - end - end - call $~lib/gc/gc.collect - i32.const 0 - global.set $std/gc-basics/obj - call $~lib/gc/gc.collect - ) - (func $std/gc-basics/main (; 20 ;) (type $FUNCSIG$i) (result i32) - global.get $~lib/started - i32.eqz - if - call $start - i32.const 1 - global.set $~lib/started - end - i32.const 0 - ) - (func $start (; 21 ;) (type $FUNCSIG$v) - call $start:std/gc-basics - ) - (func $null (; 22 ;) (type $FUNCSIG$v) - ) - (func $~iterateRoots (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) - global.get $std/gc-basics/obj - local.get $0 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-basics/obj2 - local.get $0 - call_indirect (type $FUNCSIG$vi) - ) -) diff --git a/tests/compiler/std/gc-integration.optimized.wat b/tests/compiler/std/gc-integration.optimized.wat deleted file mode 100644 index e8848207..00000000 --- a/tests/compiler/std/gc-integration.optimized.wat +++ /dev/null @@ -1,67 +0,0 @@ -(module - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\15\00\00\00s\00t\00d\00/\00g\00c\00-\00i\00n\00t\00e\00g\00r\00a\00t\00i\00o\00n\00.\00t\00s") - (table $0 2 funcref) - (elem (i32.const 0) $null $start:std/gc-integration~anonymous|0) - (global $std/gc-integration/B.d (mut i32) (i32.const 16)) - (global $std/gc-integration/a_ref (mut i32) (i32.const 24)) - (global $std/gc-integration/b_ref (mut i32) (i32.const 32)) - (global $std/gc-integration/i (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (start $start) - (func $start:std/gc-integration~anonymous|0 (; 1 ;) (type $FUNCSIG$vi) (param $0 i32) - global.get $std/gc-integration/i - i32.const 1 - i32.add - global.set $std/gc-integration/i - local.get $0 - global.get $std/gc-integration/i - i32.const 3 - i32.shl - i32.ne - if - i32.const 0 - i32.const 8 - i32.const 18 - i32.const 42 - call $~lib/env/abort - unreachable - end - ) - (func $start:std/gc-integration (; 2 ;) (type $FUNCSIG$v) - i32.const 8 - i32.const 1 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/B.d - i32.const 1 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/a_ref - i32.const 1 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/b_ref - i32.const 1 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/i - i32.const 4 - i32.ne - if - i32.const 0 - i32.const 8 - i32.const 19 - i32.const 0 - call $~lib/env/abort - unreachable - end - ) - (func $start (; 3 ;) (type $FUNCSIG$v) - call $start:std/gc-integration - ) - (func $null (; 4 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/std/gc-integration.ts b/tests/compiler/std/gc-integration.ts deleted file mode 100644 index f8963875..00000000 --- a/tests/compiler/std/gc-integration.ts +++ /dev/null @@ -1,19 +0,0 @@ -// declare classes to test with -class A {} -class B { - static readonly c: B = changetype(8); // static root, readonly - static d: A = changetype(16); // static root, writable -} - -// make sure static properties are compiled -B.c; -B.d; - -// declare roots -var no_ref: usize = 64; // NOT a root, basic value -var a_ref: A | null = changetype(24); // global root, nullable -var b_ref: B = changetype(32); // global root, non-nullable - -var i: i32 = 0; -__rt_iterateroots((ref: usize): void => { assert(ref == ++i << 3); }); -assert(i == 4); diff --git a/tests/compiler/std/gc-integration.untouched.wat b/tests/compiler/std/gc-integration.untouched.wat deleted file mode 100644 index 7bd4f80b..00000000 --- a/tests/compiler/std/gc-integration.untouched.wat +++ /dev/null @@ -1,81 +0,0 @@ -(module - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) - (type $FUNCSIG$v (func)) - (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 8) "\15\00\00\00s\00t\00d\00/\00g\00c\00-\00i\00n\00t\00e\00g\00r\00a\00t\00i\00o\00n\00.\00t\00s\00") - (table $0 2 funcref) - (elem (i32.const 0) $null $start:std/gc-integration~anonymous|0) - (global $std/gc-integration/B.c i32 (i32.const 8)) - (global $std/gc-integration/B.d (mut i32) (i32.const 16)) - (global $std/gc-integration/no_ref (mut i32) (i32.const 64)) - (global $std/gc-integration/a_ref (mut i32) (i32.const 24)) - (global $std/gc-integration/b_ref (mut i32) (i32.const 32)) - (global $std/gc-integration/i (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 56)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (start $start) - (func $start:std/gc-integration~anonymous|0 (; 1 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - block (result i32) - global.get $std/gc-integration/i - i32.const 1 - i32.add - global.set $std/gc-integration/i - global.get $std/gc-integration/i - end - i32.const 3 - i32.shl - i32.eq - i32.eqz - if - i32.const 0 - i32.const 8 - i32.const 18 - i32.const 42 - call $~lib/env/abort - unreachable - end - ) - (func $start:std/gc-integration (; 2 ;) (type $FUNCSIG$v) - global.get $std/gc-integration/B.c - drop - global.get $std/gc-integration/B.d - drop - i32.const 1 - call $~iterateRoots - global.get $std/gc-integration/i - i32.const 4 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 8 - i32.const 19 - i32.const 0 - call $~lib/env/abort - unreachable - end - ) - (func $start (; 3 ;) (type $FUNCSIG$v) - call $start:std/gc-integration - ) - (func $null (; 4 ;) (type $FUNCSIG$v) - ) - (func $~iterateRoots (; 5 ;) (type $FUNCSIG$vi) (param $0 i32) - global.get $std/gc-integration/B.c - local.get $0 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/B.d - local.get $0 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/a_ref - local.get $0 - call_indirect (type $FUNCSIG$vi) - global.get $std/gc-integration/b_ref - local.get $0 - call_indirect (type $FUNCSIG$vi) - ) -) diff --git a/tests/compiler/std/gc-object.optimized.wat b/tests/compiler/std/gc-object.optimized.wat deleted file mode 100644 index 96919b6e..00000000 --- a/tests/compiler/std/gc-object.optimized.wat +++ /dev/null @@ -1,437 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (type $FUNCSIG$i (func (result i32))) - (memory $0 0) - (table $0 4 funcref) - (elem (i32.const 0) $null $~lib/collector/itcm/__gc_mark $std/gc-object/Base~gc $std/gc-object/Custom~gc) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~lib/argc (mut i32) (i32.const 0)) - (global $std/gc-object/obj (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "main" (func $std/gc-object/main)) - (func $~lib/allocator/arena/__memory_allocate (; 0 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - global.get $~lib/allocator/arena/offset - local.tee $1 - local.get $0 - i32.const 1 - local.get $0 - i32.const 1 - i32.gt_u - select - i32.add - i32.const 7 - i32.add - i32.const -8 - i32.and - local.tee $2 - current_memory - local.tee $3 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $3 - local.get $2 - local.get $1 - i32.sub - i32.const 65535 - i32.add - i32.const -65536 - i32.and - i32.const 16 - i32.shr_u - local.tee $0 - local.get $3 - local.get $0 - i32.gt_s - select - grow_memory - i32.const 0 - i32.lt_s - if - local.get $0 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $2 - global.set $~lib/allocator/arena/offset - local.get $1 - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 1 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $1 - i32.load - i32.const 3 - i32.and - local.get $0 - i32.or - i32.store - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $2 - i32.load - i32.const 3 - i32.and - local.get $1 - i32.or - i32.store - local.get $0 - local.get $1 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - global.get $~lib/collector/itcm/iter - local.get $0 - i32.eq - if - local.get $0 - i32.load offset=4 - global.set $~lib/collector/itcm/iter - end - local.get $0 - i32.load - i32.const -4 - i32.and - local.tee $2 - local.get $0 - i32.load offset=4 - local.tee $1 - i32.store offset=4 - local.get $1 - local.get $1 - i32.load - i32.const 3 - i32.and - local.get $2 - i32.or - i32.store - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load - i32.const -4 - i32.and - i32.const 2 - i32.or - i32.store - ) - (func $~lib/collector/itcm/__gc_mark (; 3 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - if - global.get $~lib/collector/itcm/white - local.get $0 - i32.const 16 - i32.sub - local.tee $0 - i32.load - i32.const 3 - i32.and - i32.eq - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#makeGray - end - end - ) - (func $~lib/collector/itcm/step (; 4 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case3|0 - block $case2|0 - block $case1|0 - global.get $~lib/collector/itcm/state - local.tee $0 - if - local.get $0 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $break|0 - end - i32.const 16 - call $~lib/allocator/arena/__memory_allocate - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - local.tee $0 - i32.const -1 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - i32.const 16 - call $~lib/allocator/arena/__memory_allocate - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - local.tee $0 - i32.const -1 - i32.store offset=8 - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - global.get $std/gc-object/obj - i32.const 1 - call_indirect (type $FUNCSIG$vi) - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - end - global.get $~lib/collector/itcm/iter - i32.load - i32.const -4 - i32.and - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/collector/itcm/white - i32.eqz - local.get $0 - i32.load - i32.const -4 - i32.and - i32.or - i32.store - i32.const 1 - global.set $~lib/argc - local.get $0 - i32.const 16 - i32.add - local.get $0 - i32.load offset=8 - call_indirect (type $FUNCSIG$vi) - else - global.get $std/gc-object/obj - i32.const 1 - call_indirect (type $FUNCSIG$vi) - global.get $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/iter - i32.load - i32.const -4 - i32.and - i32.eq - if - global.get $~lib/collector/itcm/fromSpace - local.set $0 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/fromSpace - local.get $0 - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/white - i32.eqz - global.set $~lib/collector/itcm/white - local.get $0 - i32.load - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - end - end - br $break|0 - end - global.get $~lib/collector/itcm/iter - local.tee $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - i32.load - i32.const -4 - i32.and - global.set $~lib/collector/itcm/iter - else - global.get $~lib/collector/itcm/toSpace - local.tee $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - ) - (func $~lib/collector/itcm/__gc_allocate (; 5 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - local.get $0 - i32.const 1073741808 - i32.gt_u - if - unreachable - end - call $~lib/collector/itcm/step - local.get $0 - i32.const 16 - i32.add - call $~lib/allocator/arena/__memory_allocate - local.tee $0 - local.get $1 - i32.store offset=8 - local.get $0 - global.get $~lib/collector/itcm/white - local.get $0 - i32.load - i32.const -4 - i32.and - i32.or - i32.store - global.get $~lib/collector/itcm/fromSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - i32.const 16 - i32.add - ) - (func $std/gc-object/Base~gc (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $std/gc-object/Custom~gc (; 7 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - i32.const 2 - call_indirect (type $FUNCSIG$vi) - local.get $0 - i32.load - call $~lib/collector/itcm/__gc_mark - local.get $0 - i32.load offset=4 - call $~lib/collector/itcm/__gc_mark - ) - (func $std/gc-object/Custom#constructor (; 8 ;) (type $FUNCSIG$i) (result i32) - (local $0 i32) - i32.const 8 - i32.const 3 - call $~lib/collector/itcm/__gc_allocate - local.tee $0 - i32.eqz - if - i32.const 0 - i32.const 2 - call $~lib/collector/itcm/__gc_allocate - local.set $0 - end - local.get $0 - i32.const 0 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - ) - (func $~lib/collector/itcm/__gc_collect (; 9 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case1|0 - global.get $~lib/collector/itcm/state - local.tee $0 - i32.eqz - br_if $case1|0 - local.get $0 - i32.const 1 - i32.eq - br_if $case1|0 - br $break|0 - end - call $~lib/collector/itcm/step - end - loop $continue|1 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|1 - end - end - ) - (func $start:std/gc-object (; 10 ;) (type $FUNCSIG$v) - (local $0 i32) - i32.const 8 - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - call $std/gc-object/Custom#constructor - global.set $std/gc-object/obj - call $~lib/collector/itcm/__gc_collect - global.get $std/gc-object/obj - local.tee $0 - local.get $0 - i32.store - call $~lib/collector/itcm/__gc_collect - i32.const 0 - global.set $std/gc-object/obj - call $~lib/collector/itcm/__gc_collect - ) - (func $std/gc-object/main (; 11 ;) (type $FUNCSIG$v) - global.get $~lib/started - i32.eqz - if - call $start:std/gc-object - i32.const 1 - global.set $~lib/started - end - ) - (func $null (; 12 ;) (type $FUNCSIG$v) - nop - ) -) diff --git a/tests/compiler/std/gc-object.ts b/tests/compiler/std/gc-object.ts deleted file mode 100644 index 9a96a6a1..00000000 --- a/tests/compiler/std/gc-object.ts +++ /dev/null @@ -1,25 +0,0 @@ -import "allocator/arena"; -import "collector/itcm"; - -class Base { -} - -class Custom extends Base { - a: Custom; - b: Base; -} - -var obj: Custom | null = new Custom(); - -gc.collect(); - -obj.a = obj; - -gc.collect(); - -obj = null; - -gc.collect(); - -@start -export function main(): void {} diff --git a/tests/compiler/std/gc-object.untouched.wat b/tests/compiler/std/gc-object.untouched.wat deleted file mode 100644 index afb65dc8..00000000 --- a/tests/compiler/std/gc-object.untouched.wat +++ /dev/null @@ -1,569 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $FUNCSIG$ii (func (param i32) (result i32))) - (type $FUNCSIG$vi (func (param i32))) - (type $FUNCSIG$vii (func (param i32 i32))) - (memory $0 0) - (table $0 4 funcref) - (elem (i32.const 0) $null $~lib/collector/itcm/__gc_mark $std/gc-object/Base~gc $std/gc-object/Custom~gc) - (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) - (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/state (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/white (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/fromSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/toSpace (mut i32) (i32.const 0)) - (global $~lib/collector/itcm/iter (mut i32) (i32.const 0)) - (global $~lib/argc (mut i32) (i32.const 0)) - (global $std/gc-object/obj (mut i32) (i32.const 0)) - (global $~lib/started (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 8)) - (export "memory" (memory $0)) - (export "table" (table $0)) - (export "main" (func $std/gc-object/main)) - (func $start:~lib/allocator/arena (; 0 ;) (type $FUNCSIG$v) - global.get $~lib/memory/HEAP_BASE - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - global.set $~lib/allocator/arena/startOffset - global.get $~lib/allocator/arena/startOffset - global.set $~lib/allocator/arena/offset - ) - (func $~lib/allocator/arena/__memory_allocate (; 1 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - (local $6 i32) - local.get $0 - i32.const 1073741824 - i32.gt_u - if - unreachable - end - global.get $~lib/allocator/arena/offset - local.set $1 - local.get $1 - local.get $0 - local.tee $2 - i32.const 1 - local.tee $3 - local.get $2 - local.get $3 - i32.gt_u - select - i32.add - i32.const 7 - i32.add - i32.const 7 - i32.const -1 - i32.xor - i32.and - local.set $4 - current_memory - local.set $5 - local.get $4 - local.get $5 - i32.const 16 - i32.shl - i32.gt_u - if - local.get $4 - local.get $1 - i32.sub - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $2 - local.get $5 - local.tee $3 - local.get $2 - local.tee $6 - local.get $3 - local.get $6 - i32.gt_s - select - local.set $3 - local.get $3 - grow_memory - i32.const 0 - i32.lt_s - if - local.get $2 - grow_memory - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $4 - global.set $~lib/allocator/arena/offset - local.get $1 - ) - (func $~lib/collector/itcm/ManagedObjectList#clear (; 2 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - local.get $0 - i32.store - local.get $0 - local.get $0 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#get:color (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 3 - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#get:next (; 4 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - ) - (func $~lib/collector/itcm/ManagedObject#set:next (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $1 - local.get $0 - i32.load - i32.const 3 - i32.and - i32.or - i32.store - ) - (func $~lib/collector/itcm/ManagedObject#unlink (; 6 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - (local $2 i32) - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - local.set $1 - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - ) - (func $~lib/collector/itcm/ManagedObjectList#push (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.load offset=4 - local.set $2 - local.get $1 - local.get $0 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $1 - local.get $2 - i32.store offset=4 - local.get $2 - local.get $1 - call $~lib/collector/itcm/ManagedObject#set:next - local.get $0 - local.get $1 - i32.store offset=4 - ) - (func $~lib/collector/itcm/ManagedObject#makeGray (; 8 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - global.get $~lib/collector/itcm/iter - i32.eq - if - local.get $0 - i32.load offset=4 - global.set $~lib/collector/itcm/iter - end - local.get $0 - call $~lib/collector/itcm/ManagedObject#unlink - global.get $~lib/collector/itcm/toSpace - local.get $0 - call $~lib/collector/itcm/ManagedObjectList#push - local.get $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - i32.const 2 - i32.or - i32.store - ) - (func $~lib/collector/itcm/__gc_mark (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) - (local $1 i32) - local.get $0 - if - block $~lib/collector/itcm/refToObj|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - i32.const 16 - i32.sub - end - local.set $1 - local.get $1 - call $~lib/collector/itcm/ManagedObject#get:color - global.get $~lib/collector/itcm/white - i32.eq - if - local.get $1 - call $~lib/collector/itcm/ManagedObject#makeGray - end - end - ) - (func $~lib/collector/itcm/ManagedObject#set:color (; 10 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - local.get $0 - i32.load - i32.const 3 - i32.const -1 - i32.xor - i32.and - local.get $1 - i32.or - i32.store - ) - (func $~lib/allocator/arena/__memory_free (; 11 ;) (type $FUNCSIG$vi) (param $0 i32) - nop - ) - (func $~lib/collector/itcm/step (; 12 ;) (type $FUNCSIG$v) - (local $0 i32) - (local $1 i32) - block $break|0 - block $case3|0 - block $case2|0 - block $case1|0 - block $case0|0 - global.get $~lib/collector/itcm/state - local.set $1 - local.get $1 - i32.const 0 - i32.eq - br_if $case0|0 - local.get $1 - i32.const 1 - i32.eq - br_if $case1|0 - local.get $1 - i32.const 2 - i32.eq - br_if $case2|0 - local.get $1 - i32.const 3 - i32.eq - br_if $case3|0 - br $break|0 - end - block - block $~lib/memory/memory.allocate|inlined.0 (result i32) - i32.const 16 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.0 - end - global.set $~lib/collector/itcm/fromSpace - global.get $~lib/collector/itcm/fromSpace - i32.const -1 - i32.store offset=8 - global.get $~lib/collector/itcm/fromSpace - call $~lib/collector/itcm/ManagedObjectList#clear - block $~lib/memory/memory.allocate|inlined.1 (result i32) - i32.const 16 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.1 - end - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/toSpace - i32.const -1 - i32.store offset=8 - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/iter - i32.const 1 - global.set $~lib/collector/itcm/state - end - end - block - i32.const 1 - call $~iterateRoots - i32.const 2 - global.set $~lib/collector/itcm/state - br $break|0 - unreachable - end - unreachable - end - block - global.get $~lib/collector/itcm/iter - call $~lib/collector/itcm/ManagedObject#get:next - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/collector/itcm/white - i32.eqz - call $~lib/collector/itcm/ManagedObject#set:color - i32.const 1 - global.set $~lib/argc - block $~lib/collector/itcm/objToRef|inlined.0 (result i32) - local.get $0 - local.set $1 - local.get $1 - i32.const 16 - i32.add - end - local.get $0 - i32.load offset=8 - call_indirect (type $FUNCSIG$vi) - else - i32.const 1 - call $~iterateRoots - global.get $~lib/collector/itcm/iter - call $~lib/collector/itcm/ManagedObject#get:next - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.eq - if - global.get $~lib/collector/itcm/fromSpace - local.set $1 - global.get $~lib/collector/itcm/toSpace - global.set $~lib/collector/itcm/fromSpace - local.get $1 - global.set $~lib/collector/itcm/toSpace - global.get $~lib/collector/itcm/white - i32.eqz - global.set $~lib/collector/itcm/white - local.get $1 - call $~lib/collector/itcm/ManagedObject#get:next - global.set $~lib/collector/itcm/iter - i32.const 3 - global.set $~lib/collector/itcm/state - end - end - br $break|0 - unreachable - end - unreachable - end - block - global.get $~lib/collector/itcm/iter - local.set $0 - local.get $0 - global.get $~lib/collector/itcm/toSpace - i32.ne - if - local.get $0 - call $~lib/collector/itcm/ManagedObject#get:next - global.set $~lib/collector/itcm/iter - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.ge_u - if - block $~lib/memory/memory.free|inlined.0 - local.get $0 - local.set $1 - local.get $1 - call $~lib/allocator/arena/__memory_free - br $~lib/memory/memory.free|inlined.0 - end - end - else - global.get $~lib/collector/itcm/toSpace - call $~lib/collector/itcm/ManagedObjectList#clear - i32.const 1 - global.set $~lib/collector/itcm/state - end - br $break|0 - unreachable - end - unreachable - end - ) - (func $~lib/collector/itcm/__gc_allocate (; 13 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741824 - i32.const 16 - i32.sub - i32.gt_u - if - unreachable - end - call $~lib/collector/itcm/step - block $~lib/memory/memory.allocate|inlined.2 (result i32) - i32.const 16 - local.get $0 - i32.add - local.set $2 - local.get $2 - call $~lib/allocator/arena/__memory_allocate - br $~lib/memory/memory.allocate|inlined.2 - end - local.set $3 - local.get $3 - local.get $1 - i32.store offset=8 - local.get $3 - global.get $~lib/collector/itcm/white - call $~lib/collector/itcm/ManagedObject#set:color - global.get $~lib/collector/itcm/fromSpace - local.get $3 - call $~lib/collector/itcm/ManagedObjectList#push - block $~lib/collector/itcm/objToRef|inlined.1 (result i32) - local.get $3 - local.set $2 - local.get $2 - i32.const 16 - i32.add - end - ) - (func $std/gc-object/Base~gc (; 14 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - call $~lib/collector/itcm/__gc_mark - ) - (func $std/gc-object/Base#constructor (; 15 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 2 - call $~lib/collector/itcm/__gc_allocate - local.set $0 - end - local.get $0 - ) - (func $std/gc-object/Custom~gc (; 16 ;) (type $FUNCSIG$vi) (param $0 i32) - local.get $0 - i32.eqz - if - return - end - local.get $0 - i32.const 2 - call_indirect (type $FUNCSIG$vi) - local.get $0 - i32.load - call $~lib/collector/itcm/__gc_mark - local.get $0 - i32.load offset=4 - call $~lib/collector/itcm/__gc_mark - ) - (func $std/gc-object/Custom#constructor (; 17 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 8 - i32.const 3 - call $~lib/collector/itcm/__gc_allocate - local.set $0 - end - local.get $0 - call $std/gc-object/Base#constructor - local.set $0 - local.get $0 - i32.const 0 - i32.store - local.get $0 - i32.const 0 - i32.store offset=4 - local.get $0 - ) - (func $~lib/collector/itcm/__gc_collect (; 18 ;) (type $FUNCSIG$v) - (local $0 i32) - block $break|0 - block $case1|0 - block $case0|0 - global.get $~lib/collector/itcm/state - local.set $0 - local.get $0 - i32.const 0 - i32.eq - br_if $case0|0 - local.get $0 - i32.const 1 - i32.eq - br_if $case1|0 - br $break|0 - end - end - call $~lib/collector/itcm/step - end - block $break|1 - loop $continue|1 - global.get $~lib/collector/itcm/state - i32.const 1 - i32.ne - if - call $~lib/collector/itcm/step - br $continue|1 - end - end - end - ) - (func $~lib/gc/gc.collect (; 19 ;) (type $FUNCSIG$v) - call $~lib/collector/itcm/__gc_collect - return - ) - (func $start:std/gc-object (; 20 ;) (type $FUNCSIG$v) - call $start:~lib/allocator/arena - i32.const 0 - call $std/gc-object/Custom#constructor - global.set $std/gc-object/obj - call $~lib/gc/gc.collect - global.get $std/gc-object/obj - global.get $std/gc-object/obj - i32.store - call $~lib/gc/gc.collect - i32.const 0 - global.set $std/gc-object/obj - call $~lib/gc/gc.collect - ) - (func $std/gc-object/main (; 21 ;) (type $FUNCSIG$v) - global.get $~lib/started - i32.eqz - if - call $start - i32.const 1 - global.set $~lib/started - end - ) - (func $start (; 22 ;) (type $FUNCSIG$v) - call $start:std/gc-object - ) - (func $null (; 23 ;) (type $FUNCSIG$v) - ) - (func $~iterateRoots (; 24 ;) (type $FUNCSIG$vi) (param $0 i32) - global.get $std/gc-object/obj - local.get $0 - call_indirect (type $FUNCSIG$vi) - ) -) diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index b7a0b6e4..085c417c 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -135,7 +135,7 @@ if i32.const 0 i32.const 24 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -150,7 +150,7 @@ if i32.const 0 i32.const 24 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index 0a468993..8e434e9b 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -167,7 +167,7 @@ if i32.const 0 i32.const 24 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -184,7 +184,7 @@ if i32.const 0 i32.const 24 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -467,7 +467,7 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) + block $~lib/runtime/ALLOCATE|inlined.0 (result i32) local.get $1 local.set $2 local.get $2 @@ -562,23 +562,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -1528,23 +1519,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 22 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 4 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 4 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -2463,23 +2445,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 5 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 5 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -3444,23 +3417,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 43 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 6 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 6 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -4379,23 +4343,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 53 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 7 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 7 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -5332,23 +5287,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 64 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.6 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 8 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 8 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -6243,23 +6189,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 74 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.7 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 9 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 9 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -7252,23 +7189,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 85 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.8 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 10 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 10 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -8173,23 +8101,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 95 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.9 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 11 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 11 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -9099,23 +9018,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 105 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.10 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 12 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 12 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/std/new.optimized.wat b/tests/compiler/std/new.optimized.wat index 85bcd14f..fd7b8f26 100644 --- a/tests/compiler/std/new.optimized.wat +++ b/tests/compiler/std/new.optimized.wat @@ -84,7 +84,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -99,7 +99,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/new.untouched.wat b/tests/compiler/std/new.untouched.wat index 460fb5f8..01cbdc14 100644 --- a/tests/compiler/std/new.untouched.wat +++ b/tests/compiler/std/new.untouched.wat @@ -142,7 +142,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -159,7 +159,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -170,24 +170,15 @@ local.get $0 ) (func $std/new/AClass#constructor (; 5 ;) (type $FUNCSIG$iif) (param $0 i32) (param $1 f32) (result i32) - (local $2 i32) local.get $0 block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 8 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 - i32.const 1 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/std/operator-overloading.optimized.wat b/tests/compiler/std/operator-overloading.optimized.wat index 5a73a2f5..2582c455 100644 --- a/tests/compiler/std/operator-overloading.optimized.wat +++ b/tests/compiler/std/operator-overloading.optimized.wat @@ -167,7 +167,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -182,7 +182,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/operator-overloading.untouched.wat b/tests/compiler/std/operator-overloading.untouched.wat index e3c97224..0d5539cd 100644 --- a/tests/compiler/std/operator-overloading.untouched.wat +++ b/tests/compiler/std/operator-overloading.untouched.wat @@ -210,7 +210,7 @@ if i32.const 0 i32.const 16 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -227,7 +227,7 @@ if i32.const 0 i32.const 16 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -238,22 +238,13 @@ local.get $0 ) (func $std/operator-overloading/Tester#constructor (; 5 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 8 - local.set $3 - local.get $3 - call $~lib/runtime/allocate - end - local.set $3 - local.get $3 - i32.const 1 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -1820,22 +1811,13 @@ call $std/operator-overloading/Tester#constructor ) (func $std/operator-overloading/TesterInlineStatic#constructor (; 34 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 8 - local.set $3 - local.get $3 - call $~lib/runtime/allocate - end - local.set $3 - local.get $3 - i32.const 3 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -1847,22 +1829,13 @@ local.get $0 ) (func $std/operator-overloading/TesterInlineInstance#constructor (; 35 ;) (type $FUNCSIG$iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 8 - local.set $3 - local.get $3 - call $~lib/runtime/allocate - end - local.set $3 - local.get $3 - i32.const 4 - call $~lib/runtime/register - end + i32.const 8 + call $~lib/runtime/allocate + i32.const 4 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/std/runtime.optimized.wat b/tests/compiler/std/runtime.optimized.wat index 0c5eca59..f15914c5 100644 --- a/tests/compiler/std/runtime.optimized.wat +++ b/tests/compiler/std/runtime.optimized.wat @@ -38,11 +38,12 @@ (global $std/runtime/ref4 (mut i32) (i32.const 0)) (global $std/runtime/header4 (mut i32) (i32.const 0)) (global $std/runtime/ref5 (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (global $~lib/capabilities i32 (i32.const 2)) (export "memory" (memory $0)) (export "table" (table $0)) + (export "main" (func $std/runtime/main)) (export ".capabilities" (global $~lib/capabilities)) - (start $start) (func $~lib/allocator/tlsf/Root#setSLMap (; 2 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) local.get $1 i32.const 22 @@ -2616,7 +2617,7 @@ if i32.const 0 i32.const 232 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -2653,7 +2654,7 @@ if i32.const 0 i32.const 232 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -2668,7 +2669,7 @@ if i32.const 0 i32.const 232 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable @@ -2684,7 +2685,7 @@ if i32.const 0 i32.const 232 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -2699,7 +2700,7 @@ if i32.const 0 i32.const 232 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -2750,7 +2751,7 @@ else i32.const 0 i32.const 88 - i32.const 34 + i32.const 36 i32.const 2 call $~lib/env/abort unreachable @@ -2861,7 +2862,7 @@ if i32.const 0 i32.const 88 - i32.const 49 + i32.const 51 i32.const 0 call $~lib/env/abort unreachable @@ -2873,7 +2874,7 @@ if i32.const 0 i32.const 88 - i32.const 50 + i32.const 52 i32.const 0 call $~lib/env/abort unreachable @@ -2887,7 +2888,7 @@ if i32.const 0 i32.const 88 - i32.const 51 + i32.const 53 i32.const 0 call $~lib/env/abort unreachable @@ -2899,7 +2900,7 @@ if i32.const 0 i32.const 88 - i32.const 52 + i32.const 54 i32.const 0 call $~lib/env/abort unreachable @@ -2914,7 +2915,7 @@ if i32.const 0 i32.const 88 - i32.const 54 + i32.const 56 i32.const 0 call $~lib/env/abort unreachable @@ -2930,7 +2931,7 @@ if i32.const 0 i32.const 88 - i32.const 56 + i32.const 58 i32.const 0 call $~lib/env/abort unreachable @@ -2946,7 +2947,7 @@ if i32.const 0 i32.const 88 - i32.const 59 + i32.const 61 i32.const 0 call $~lib/env/abort unreachable @@ -2962,7 +2963,7 @@ if i32.const 0 i32.const 88 - i32.const 63 + i32.const 65 i32.const 0 call $~lib/env/abort unreachable @@ -2978,7 +2979,7 @@ if i32.const 0 i32.const 88 - i32.const 65 + i32.const 67 i32.const 0 call $~lib/env/abort unreachable @@ -2990,7 +2991,7 @@ if i32.const 0 i32.const 88 - i32.const 66 + i32.const 68 i32.const 0 call $~lib/env/abort unreachable @@ -3007,7 +3008,7 @@ if i32.const 0 i32.const 88 - i32.const 69 + i32.const 71 i32.const 0 call $~lib/env/abort unreachable @@ -3023,14 +3024,20 @@ if i32.const 0 i32.const 88 - i32.const 70 + i32.const 72 i32.const 0 call $~lib/env/abort unreachable end ) - (func $start (; 26 ;) (type $FUNCSIG$v) - call $start:std/runtime + (func $std/runtime/main (; 26 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start:std/runtime + i32.const 1 + global.set $~lib/started + end ) (func $null (; 27 ;) (type $FUNCSIG$v) nop diff --git a/tests/compiler/std/runtime.ts b/tests/compiler/std/runtime.ts index 50a0bdc9..b83875c7 100644 --- a/tests/compiler/std/runtime.ts +++ b/tests/compiler/std/runtime.ts @@ -1,5 +1,7 @@ import "allocator/tlsf"; -import { CLASSID, ADJUSTOBLOCK, ALLOCATE, REALLOCATE, REGISTER, DISCARD, HEADER, HEADER_SIZE, HEADER_MAGIC } from "runtime"; +import { classId, ADJUSTOBLOCK, ALLOCATE, REALLOCATE, REGISTER, DISCARD, HEADER, HEADER_SIZE, HEADER_MAGIC } from "runtime"; + +@start export function main(): void {} var register_ref: usize = 0; @@ -23,7 +25,7 @@ var link_parentRef: usize = 0; class A {} class B {} -assert(CLASSID() != CLASSID()); +assert(classId() != classId()); function isPowerOf2(x: i32): bool { return x != 0 && (x & (x - 1)) == 0; @@ -62,7 +64,7 @@ var ref4 = ALLOCATE(barrier1); REGISTER(ref4); // should call __gc_register assert(register_ref == ref4); var header4 = changetype

(register_ref - HEADER_SIZE); -assert(header4.classId == CLASSID()); +assert(header4.classId == classId()); assert(header4.payloadSize == barrier1); var ref5 = ALLOCATE(10); diff --git a/tests/compiler/std/runtime.untouched.wat b/tests/compiler/std/runtime.untouched.wat index b1e3fdc5..57b6b1c6 100644 --- a/tests/compiler/std/runtime.untouched.wat +++ b/tests/compiler/std/runtime.untouched.wat @@ -53,12 +53,13 @@ (global $std/runtime/ref4 (mut i32) (i32.const 0)) (global $std/runtime/header4 (mut i32) (i32.const 0)) (global $std/runtime/ref5 (mut i32) (i32.const 0)) + (global $~lib/started (mut i32) (i32.const 0)) (global $~lib/memory/HEAP_BASE i32 (i32.const 264)) (global $~lib/capabilities i32 (i32.const 2)) (export "memory" (memory $0)) (export "table" (table $0)) + (export "main" (func $std/runtime/main)) (export ".capabilities" (global $~lib/capabilities)) - (start $start) (func $start:~lib/allocator/tlsf (; 2 ;) (type $FUNCSIG$v) i32.const 1 global.get $~lib/allocator/tlsf/SL_BITS @@ -3303,7 +3304,7 @@ if i32.const 0 i32.const 232 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -3345,7 +3346,7 @@ if i32.const 0 i32.const 232 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -3362,7 +3363,7 @@ if i32.const 0 i32.const 232 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable @@ -3379,7 +3380,7 @@ if i32.const 0 i32.const 232 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -3396,7 +3397,7 @@ if i32.const 0 i32.const 232 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -3433,7 +3434,7 @@ if i32.const 0 i32.const 88 - i32.const 26 + i32.const 28 i32.const 0 call $~lib/env/abort unreachable @@ -3446,7 +3447,7 @@ if i32.const 0 i32.const 88 - i32.const 32 + i32.const 34 i32.const 0 call $~lib/env/abort unreachable @@ -3467,7 +3468,7 @@ if i32.const 0 i32.const 88 - i32.const 34 + i32.const 36 i32.const 2 call $~lib/env/abort unreachable @@ -3574,7 +3575,7 @@ if i32.const 0 i32.const 88 - i32.const 49 + i32.const 51 i32.const 0 call $~lib/env/abort unreachable @@ -3587,7 +3588,7 @@ if i32.const 0 i32.const 88 - i32.const 50 + i32.const 52 i32.const 0 call $~lib/env/abort unreachable @@ -3607,7 +3608,7 @@ if i32.const 0 i32.const 88 - i32.const 51 + i32.const 53 i32.const 0 call $~lib/env/abort unreachable @@ -3620,7 +3621,7 @@ if i32.const 0 i32.const 88 - i32.const 52 + i32.const 54 i32.const 0 call $~lib/env/abort unreachable @@ -3642,7 +3643,7 @@ if i32.const 0 i32.const 88 - i32.const 54 + i32.const 56 i32.const 0 call $~lib/env/abort unreachable @@ -3659,7 +3660,7 @@ if i32.const 0 i32.const 88 - i32.const 56 + i32.const 58 i32.const 0 call $~lib/env/abort unreachable @@ -3684,7 +3685,7 @@ if i32.const 0 i32.const 88 - i32.const 59 + i32.const 61 i32.const 0 call $~lib/env/abort unreachable @@ -3711,7 +3712,7 @@ if i32.const 0 i32.const 88 - i32.const 63 + i32.const 65 i32.const 0 call $~lib/env/abort unreachable @@ -3728,7 +3729,7 @@ if i32.const 0 i32.const 88 - i32.const 65 + i32.const 67 i32.const 0 call $~lib/env/abort unreachable @@ -3741,7 +3742,7 @@ if i32.const 0 i32.const 88 - i32.const 66 + i32.const 68 i32.const 0 call $~lib/env/abort unreachable @@ -3761,7 +3762,7 @@ if i32.const 0 i32.const 88 - i32.const 69 + i32.const 71 i32.const 0 call $~lib/env/abort unreachable @@ -3774,15 +3775,24 @@ if i32.const 0 i32.const 88 - i32.const 70 + i32.const 72 i32.const 0 call $~lib/env/abort unreachable end ) - (func $start (; 35 ;) (type $FUNCSIG$v) + (func $std/runtime/main (; 35 ;) (type $FUNCSIG$v) + global.get $~lib/started + i32.eqz + if + call $start + i32.const 1 + global.set $~lib/started + end + ) + (func $start (; 36 ;) (type $FUNCSIG$v) call $start:std/runtime ) - (func $null (; 36 ;) (type $FUNCSIG$v) + (func $null (; 37 ;) (type $FUNCSIG$v) ) ) diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index 5bf37495..9253add8 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -131,7 +131,7 @@ if i32.const 0 i32.const 24 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -146,7 +146,7 @@ if i32.const 0 i32.const 24 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index 9bef69a8..a966c053 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -167,7 +167,7 @@ if i32.const 0 i32.const 24 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -184,7 +184,7 @@ if i32.const 0 i32.const 24 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -467,7 +467,7 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) + block $~lib/runtime/ALLOCATE|inlined.0 (result i32) local.get $1 local.set $2 local.get $2 @@ -562,23 +562,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 1 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 1 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -1391,23 +1382,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 21 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 4 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 4 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -2205,23 +2187,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 30 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 5 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 5 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -3049,23 +3022,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 40 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 6 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 6 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -3863,23 +3827,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 49 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 7 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 7 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -4711,23 +4666,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 59 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.6 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 8 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 8 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -5517,23 +5463,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 68 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.7 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 9 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 9 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -6414,23 +6351,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 78 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.8 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 10 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 10 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -7223,23 +7151,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 87 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.9 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 11 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 11 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -8036,23 +7955,14 @@ i32.store offset=20 ) (func $~lib/set/Set#constructor (; 96 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.10 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 12 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 12 + call $~lib/runtime/register local.set $0 end local.get $0 diff --git a/tests/compiler/std/static-array.optimized.wat b/tests/compiler/std/static-array.optimized.wat index c2e05786..dff911d9 100644 --- a/tests/compiler/std/static-array.optimized.wat +++ b/tests/compiler/std/static-array.optimized.wat @@ -1,8 +1,9 @@ (module + (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$viiii (func (param i32 i32 i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) + (type $FUNCSIG$viii (func (param i32 i32 i32))) (type $FUNCSIG$v (func)) - (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$vii (func (param i32 i32))) (type $FUNCSIG$ji (func (param i32) (result i64))) (type $FUNCSIG$fi (func (param i32) (result f32))) @@ -23,6 +24,8 @@ (data (i32.const 272) "\06\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") (table $0 1 funcref) (elem (i32.const 0) $null) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -49,7 +52,1160 @@ i32.add i32.load ) - (func $~lib/memory/memory.fill (; 2 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/memory/memory.allocate (; 2 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.tee $1 + local.get $0 + i32.const 1 + local.get $0 + i32.const 1 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee $0 + current_memory + local.tee $2 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $2 + local.get $0 + local.get $1 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $3 + local.get $2 + local.get $3 + i32.gt_s + select + grow_memory + i32.const 0 + i32.lt_s + if + local.get $3 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $0 + global.set $~lib/allocator/arena/offset + local.get $1 + ) + (func $~lib/util/memory/memcpy (; 3 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + loop $continue|0 + local.get $1 + i32.const 3 + i32.and + local.get $2 + local.get $2 + select + if + local.get $0 + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + br $continue|0 + end + end + local.get $0 + i32.const 3 + i32.and + i32.eqz + if + loop $continue|1 + local.get $2 + i32.const 16 + i32.ge_u + if + local.get $0 + local.get $1 + i32.load + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 4 + i32.add + i32.load + i32.store + local.get $0 + i32.const 8 + i32.add + local.get $1 + i32.const 8 + i32.add + i32.load + i32.store + local.get $0 + i32.const 12 + i32.add + local.get $1 + i32.const 12 + i32.add + i32.load + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|1 + end + end + local.get $2 + i32.const 8 + i32.and + if + local.get $0 + local.get $1 + i32.load + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 4 + i32.add + i32.load + i32.store + local.get $1 + i32.const 8 + i32.add + local.set $1 + local.get $0 + i32.const 8 + i32.add + local.set $0 + end + local.get $2 + i32.const 4 + i32.and + if + local.get $0 + local.get $1 + i32.load + i32.store + local.get $1 + i32.const 4 + i32.add + local.set $1 + local.get $0 + i32.const 4 + i32.add + local.set $0 + end + local.get $2 + i32.const 2 + i32.and + if + local.get $0 + local.get $1 + i32.load16_u + i32.store16 + local.get $1 + i32.const 2 + i32.add + local.set $1 + local.get $0 + i32.const 2 + i32.add + local.set $0 + end + local.get $2 + i32.const 1 + i32.and + if + local.get $0 + local.get $1 + i32.load8_u + i32.store8 + end + return + end + local.get $2 + i32.const 32 + i32.ge_u + if + block $break|2 + block $case2|2 + block $case1|2 + local.get $0 + i32.const 3 + i32.and + local.tee $3 + i32.const 1 + i32.ne + if + local.get $3 + i32.const 2 + i32.eq + br_if $case1|2 + local.get $3 + i32.const 3 + i32.eq + br_if $case2|2 + br $break|2 + end + local.get $1 + i32.load + local.set $5 + local.get $0 + local.get $1 + local.tee $3 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $1 + local.set $0 + local.get $1 + local.get $3 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + local.get $2 + i32.const 3 + i32.sub + local.set $2 + loop $continue|3 + local.get $2 + i32.const 17 + i32.ge_u + if + local.get $0 + local.get $1 + i32.const 1 + i32.add + i32.load + local.tee $3 + i32.const 8 + i32.shl + local.get $5 + i32.const 24 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 5 + i32.add + i32.load + local.tee $5 + i32.const 8 + i32.shl + local.get $3 + i32.const 24 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 8 + i32.add + local.get $1 + i32.const 9 + i32.add + i32.load + local.tee $3 + i32.const 8 + i32.shl + local.get $5 + i32.const 24 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 12 + i32.add + local.get $1 + i32.const 13 + i32.add + i32.load + local.tee $5 + i32.const 8 + i32.shl + local.get $3 + i32.const 24 + i32.shr_u + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|3 + end + end + br $break|2 + end + local.get $1 + i32.load + local.set $5 + local.get $0 + local.get $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + local.get $2 + i32.const 2 + i32.sub + local.set $2 + loop $continue|4 + local.get $2 + i32.const 18 + i32.ge_u + if + local.get $0 + local.get $1 + i32.const 2 + i32.add + i32.load + local.tee $3 + i32.const 16 + i32.shl + local.get $5 + i32.const 16 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 6 + i32.add + i32.load + local.tee $5 + i32.const 16 + i32.shl + local.get $3 + i32.const 16 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 8 + i32.add + local.get $1 + i32.const 10 + i32.add + i32.load + local.tee $3 + i32.const 16 + i32.shl + local.get $5 + i32.const 16 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 12 + i32.add + local.get $1 + i32.const 14 + i32.add + i32.load + local.tee $5 + i32.const 16 + i32.shl + local.get $3 + i32.const 16 + i32.shr_u + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|4 + end + end + br $break|2 + end + local.get $1 + i32.load + local.set $5 + local.get $0 + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + loop $continue|5 + local.get $2 + i32.const 19 + i32.ge_u + if + local.get $0 + local.get $1 + i32.const 3 + i32.add + i32.load + local.tee $3 + i32.const 24 + i32.shl + local.get $5 + i32.const 8 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 4 + i32.add + local.get $1 + i32.const 7 + i32.add + i32.load + local.tee $5 + i32.const 24 + i32.shl + local.get $3 + i32.const 8 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 8 + i32.add + local.get $1 + i32.const 11 + i32.add + i32.load + local.tee $3 + i32.const 24 + i32.shl + local.get $5 + i32.const 8 + i32.shr_u + i32.or + i32.store + local.get $0 + i32.const 12 + i32.add + local.get $1 + i32.const 15 + i32.add + i32.load + local.tee $5 + i32.const 24 + i32.shl + local.get $3 + i32.const 8 + i32.shr_u + i32.or + i32.store + local.get $1 + i32.const 16 + i32.add + local.set $1 + local.get $0 + i32.const 16 + i32.add + local.set $0 + local.get $2 + i32.const 16 + i32.sub + local.set $2 + br $continue|5 + end + end + end + end + local.get $2 + i32.const 16 + i32.and + if + local.get $0 + local.get $1 + local.tee $3 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $1 + local.set $0 + local.get $1 + local.get $3 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 8 + i32.and + if + local.get $0 + local.get $1 + local.tee $3 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $1 + local.set $0 + local.get $1 + local.get $3 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 4 + i32.and + if + local.get $0 + local.get $1 + local.tee $3 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $1 + local.set $0 + local.get $1 + local.get $3 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $3 + local.set $0 + local.get $3 + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 2 + i32.and + if + local.get $0 + local.get $1 + i32.load8_u + i32.store8 + local.get $0 + i32.const 1 + i32.add + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + i32.const 1 + i32.add + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + end + local.get $2 + i32.const 1 + i32.and + if + local.get $0 + local.get $1 + i32.load8_u + i32.store8 + end + ) + (func $~lib/memory/memory.copy (; 4 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) + (local $3 i32) + (local $4 i32) + block $~lib/util/memory/memmove|inlined.0 + local.get $0 + local.get $1 + i32.eq + br_if $~lib/util/memory/memmove|inlined.0 + local.get $1 + local.get $2 + i32.add + local.get $0 + i32.le_u + local.tee $3 + i32.eqz + if + local.get $0 + local.get $2 + i32.add + local.get $1 + i32.le_u + local.set $3 + end + local.get $3 + if + local.get $0 + local.get $1 + local.get $2 + call $~lib/util/memory/memcpy + br $~lib/util/memory/memmove|inlined.0 + end + local.get $0 + local.get $1 + i32.lt_u + if + local.get $1 + i32.const 7 + i32.and + local.get $0 + i32.const 7 + i32.and + i32.eq + if + loop $continue|0 + local.get $0 + i32.const 7 + i32.and + if + local.get $2 + i32.eqz + br_if $~lib/util/memory/memmove|inlined.0 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + local.get $0 + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + br $continue|0 + end + end + loop $continue|1 + local.get $2 + i32.const 8 + i32.ge_u + if + local.get $0 + local.get $1 + i64.load + i64.store + local.get $2 + i32.const 8 + i32.sub + local.set $2 + local.get $0 + i32.const 8 + i32.add + local.set $0 + local.get $1 + i32.const 8 + i32.add + local.set $1 + br $continue|1 + end + end + end + loop $continue|2 + local.get $2 + if + local.get $0 + local.tee $4 + i32.const 1 + i32.add + local.set $0 + local.get $1 + local.tee $3 + i32.const 1 + i32.add + local.set $1 + local.get $4 + local.get $3 + i32.load8_u + i32.store8 + local.get $2 + i32.const 1 + i32.sub + local.set $2 + br $continue|2 + end + end + else + local.get $1 + i32.const 7 + i32.and + local.get $0 + i32.const 7 + i32.and + i32.eq + if + loop $continue|3 + local.get $0 + local.get $2 + i32.add + i32.const 7 + i32.and + if + local.get $2 + i32.eqz + br_if $~lib/util/memory/memmove|inlined.0 + local.get $2 + i32.const 1 + i32.sub + local.tee $2 + local.get $0 + i32.add + local.get $1 + local.get $2 + i32.add + i32.load8_u + i32.store8 + br $continue|3 + end + end + loop $continue|4 + local.get $2 + i32.const 8 + i32.ge_u + if + local.get $2 + i32.const 8 + i32.sub + local.tee $2 + local.get $0 + i32.add + local.get $1 + local.get $2 + i32.add + i64.load + i64.store + br $continue|4 + end + end + end + loop $continue|5 + local.get $2 + if + local.get $2 + i32.const 1 + i32.sub + local.tee $2 + local.get $0 + i32.add + local.get $1 + local.get $2 + i32.add + i32.load8_u + i32.store8 + br $continue|5 + end + end + end + end + ) + (func $~lib/memory/memory.fill (; 5 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) block $~lib/util/memory/memset|inlined.0 local.get $1 @@ -260,9 +1416,11 @@ end end ) - (func $~lib/runtime/reallocate (; 3 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/runtime/reallocate (; 6 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) + (local $4 i32) + (local $5 i32) local.get $0 i32.const 8 i32.sub @@ -293,9 +1451,50 @@ i32.clz i32.sub i32.shl + local.tee $4 i32.lt_u if - unreachable + local.get $4 + call $~lib/memory/memory.allocate + local.tee $4 + local.get $3 + i32.load + i32.store + local.get $4 + i32.const 8 + i32.add + local.tee $5 + local.get $0 + local.get $2 + call $~lib/memory/memory.copy + local.get $2 + local.get $5 + i32.add + local.get $1 + local.get $2 + i32.sub + call $~lib/memory/memory.fill + local.get $3 + i32.load + i32.const -1520547049 + i32.eq + if + local.get $0 + i32.const 312 + i32.le_u + if + i32.const 0 + i32.const 280 + i32.const 115 + i32.const 8 + call $~lib/env/abort + unreachable + end + end + local.get $4 + local.set $3 + local.get $5 + local.set $0 else local.get $0 local.get $2 @@ -311,7 +1510,7 @@ i32.store offset=4 local.get $0 ) - (func $~lib/array/ensureCapacity (; 4 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) + (func $~lib/array/ensureCapacity (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) i32.const 1 @@ -359,7 +1558,7 @@ i32.store offset=8 end ) - (func $~lib/array/Array#__set (; 5 ;) (type $FUNCSIG$v) + (func $~lib/array/Array#__set (; 8 ;) (type $FUNCSIG$v) (local $0 i32) i32.const 44 i32.load @@ -380,7 +1579,7 @@ i32.store end ) - (func $~lib/array/Array#__get (; 6 ;) (type $FUNCSIG$ji) (param $0 i32) (result i64) + (func $~lib/array/Array#__get (; 9 ;) (type $FUNCSIG$ji) (param $0 i32) (result i64) local.get $0 i32.const 88 i32.load @@ -403,7 +1602,7 @@ i32.add i64.load ) - (func $~lib/array/Array#__set (; 7 ;) (type $FUNCSIG$v) + (func $~lib/array/Array#__set (; 10 ;) (type $FUNCSIG$v) (local $0 i32) i32.const 92 i32.load @@ -424,7 +1623,7 @@ i32.store end ) - (func $~lib/array/Array#__get (; 8 ;) (type $FUNCSIG$fi) (param $0 i32) (result f32) + (func $~lib/array/Array#__get (; 11 ;) (type $FUNCSIG$fi) (param $0 i32) (result f32) local.get $0 i32.const 128 i32.load @@ -447,7 +1646,7 @@ i32.add f32.load ) - (func $~lib/array/Array#__set (; 9 ;) (type $FUNCSIG$v) + (func $~lib/array/Array#__set (; 12 ;) (type $FUNCSIG$v) (local $0 i32) i32.const 132 i32.load @@ -468,7 +1667,7 @@ i32.store end ) - (func $~lib/array/Array#__get (; 10 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) + (func $~lib/array/Array#__get (; 13 ;) (type $FUNCSIG$di) (param $0 i32) (result f64) local.get $0 i32.const 176 i32.load @@ -491,7 +1690,7 @@ i32.add f64.load ) - (func $~lib/array/Array#__set (; 11 ;) (type $FUNCSIG$v) + (func $~lib/array/Array#__set (; 14 ;) (type $FUNCSIG$v) (local $0 i32) i32.const 180 i32.load @@ -512,35 +1711,11 @@ i32.store end ) - (func $start:std/static-array (; 12 ;) (type $FUNCSIG$v) + (func $start:std/static-array (; 15 ;) (type $FUNCSIG$v) i32.const 44 i32.load i32.const 2 i32.ne - if - i32.const 0 - i32.const 192 - i32.const 6 - i32.const 0 - call $~lib/env/abort - unreachable - end - i32.const 0 - call $~lib/array/Array#__get - i32.const 1 - i32.ne - if - i32.const 0 - i32.const 192 - i32.const 7 - i32.const 0 - call $~lib/env/abort - unreachable - end - i32.const 1 - call $~lib/array/Array#__get - i32.const 2 - i32.ne if i32.const 0 i32.const 192 @@ -549,9 +1724,20 @@ call $~lib/env/abort unreachable end - call $~lib/array/Array#__set i32.const 0 call $~lib/array/Array#__get + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 192 + i32.const 9 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 1 + call $~lib/array/Array#__get i32.const 2 i32.ne if @@ -562,6 +1748,23 @@ call $~lib/env/abort unreachable end + i32.const 312 + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset + call $~lib/array/Array#__set + i32.const 0 + call $~lib/array/Array#__get + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 192 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end i32.const 92 i32.load i32.const 2 @@ -569,7 +1772,7 @@ if i32.const 0 i32.const 192 - i32.const 12 + i32.const 14 i32.const 0 call $~lib/env/abort unreachable @@ -581,7 +1784,7 @@ if i32.const 0 i32.const 192 - i32.const 13 + i32.const 15 i32.const 0 call $~lib/env/abort unreachable @@ -593,7 +1796,7 @@ if i32.const 0 i32.const 192 - i32.const 14 + i32.const 16 i32.const 0 call $~lib/env/abort unreachable @@ -606,7 +1809,7 @@ if i32.const 0 i32.const 192 - i32.const 16 + i32.const 18 i32.const 0 call $~lib/env/abort unreachable @@ -618,7 +1821,7 @@ if i32.const 0 i32.const 192 - i32.const 18 + i32.const 20 i32.const 0 call $~lib/env/abort unreachable @@ -630,7 +1833,7 @@ if i32.const 0 i32.const 192 - i32.const 19 + i32.const 21 i32.const 0 call $~lib/env/abort unreachable @@ -642,7 +1845,7 @@ if i32.const 0 i32.const 192 - i32.const 20 + i32.const 22 i32.const 0 call $~lib/env/abort unreachable @@ -655,7 +1858,7 @@ if i32.const 0 i32.const 192 - i32.const 22 + i32.const 24 i32.const 0 call $~lib/env/abort unreachable @@ -667,7 +1870,7 @@ if i32.const 0 i32.const 192 - i32.const 24 + i32.const 26 i32.const 0 call $~lib/env/abort unreachable @@ -679,7 +1882,7 @@ if i32.const 0 i32.const 192 - i32.const 25 + i32.const 27 i32.const 0 call $~lib/env/abort unreachable @@ -691,7 +1894,7 @@ if i32.const 0 i32.const 192 - i32.const 26 + i32.const 28 i32.const 0 call $~lib/env/abort unreachable @@ -704,16 +1907,16 @@ if i32.const 0 i32.const 192 - i32.const 28 + i32.const 30 i32.const 0 call $~lib/env/abort unreachable end ) - (func $start (; 13 ;) (type $FUNCSIG$v) + (func $start (; 16 ;) (type $FUNCSIG$v) call $start:std/static-array ) - (func $null (; 14 ;) (type $FUNCSIG$v) + (func $null (; 17 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/static-array.ts b/tests/compiler/std/static-array.ts index 4fee0db3..851e8198 100644 --- a/tests/compiler/std/static-array.ts +++ b/tests/compiler/std/static-array.ts @@ -1,3 +1,5 @@ +import "allocator/arena"; // assignment checks for possible resize + const i: i32[] = [1, 2]; const I: i64[] = [3, 4]; const f: f32[] = [1.5, 2.5]; diff --git a/tests/compiler/std/static-array.untouched.wat b/tests/compiler/std/static-array.untouched.wat index 170389a6..ef7fc737 100644 --- a/tests/compiler/std/static-array.untouched.wat +++ b/tests/compiler/std/static-array.untouched.wat @@ -33,6 +33,8 @@ (global $~lib/runtime/HEADER_SIZE i32 (i32.const 8)) (global $~lib/runtime/HEADER_MAGIC i32 (i32.const -1520547049)) (global $~lib/runtime/MAX_BYTELENGTH i32 (i32.const 1073741816)) + (global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0)) + (global $~lib/allocator/arena/offset (mut i32) (i32.const 0)) (global $~lib/memory/HEAP_BASE i32 (i32.const 312)) (export "memory" (memory $0)) (export "table" (table $0)) @@ -82,7 +84,89 @@ i32.shl ) (func $~lib/memory/memory.allocate (; 5 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - unreachable + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + block $~lib/allocator/arena/__memory_allocate|inlined.0 (result i32) + local.get $0 + local.set $1 + local.get $1 + i32.const 1073741824 + i32.gt_u + if + unreachable + end + global.get $~lib/allocator/arena/offset + local.set $2 + local.get $2 + local.get $1 + local.tee $3 + i32.const 1 + local.tee $4 + local.get $3 + local.get $4 + i32.gt_u + select + i32.add + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + local.set $3 + current_memory + local.set $4 + local.get $3 + local.get $4 + i32.const 16 + i32.shl + i32.gt_u + if + local.get $3 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $5 + local.get $4 + local.tee $6 + local.get $5 + local.tee $7 + local.get $6 + local.get $7 + i32.gt_s + select + local.set $6 + local.get $6 + grow_memory + i32.const 0 + i32.lt_s + if + local.get $5 + grow_memory + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $3 + global.set $~lib/allocator/arena/offset + local.get $2 + end + return ) (func $~lib/util/memory/memcpy (; 6 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) @@ -1774,7 +1858,9 @@ end ) (func $~lib/memory/memory.free (; 9 ;) (type $FUNCSIG$vi) (param $0 i32) - nop + (local $1 i32) + local.get $0 + local.set $1 ) (func $~lib/runtime/reallocate (; 10 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) @@ -1841,7 +1927,7 @@ if i32.const 0 i32.const 280 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -2180,7 +2266,7 @@ if i32.const 0 i32.const 192 - i32.const 6 + i32.const 8 i32.const 0 call $~lib/env/abort unreachable @@ -2194,7 +2280,7 @@ if i32.const 0 i32.const 192 - i32.const 7 + i32.const 9 i32.const 0 call $~lib/env/abort unreachable @@ -2208,11 +2294,21 @@ if i32.const 0 i32.const 192 - i32.const 8 + i32.const 10 i32.const 0 call $~lib/env/abort unreachable end + global.get $~lib/memory/HEAP_BASE + i32.const 7 + i32.add + i32.const 7 + i32.const -1 + i32.xor + i32.and + global.set $~lib/allocator/arena/startOffset + global.get $~lib/allocator/arena/startOffset + global.set $~lib/allocator/arena/offset global.get $std/static-array/i i32.const 0 i32.const 2 @@ -2226,7 +2322,7 @@ if i32.const 0 i32.const 192 - i32.const 10 + i32.const 12 i32.const 0 call $~lib/env/abort unreachable @@ -2239,7 +2335,7 @@ if i32.const 0 i32.const 192 - i32.const 12 + i32.const 14 i32.const 0 call $~lib/env/abort unreachable @@ -2253,7 +2349,7 @@ if i32.const 0 i32.const 192 - i32.const 13 + i32.const 15 i32.const 0 call $~lib/env/abort unreachable @@ -2267,7 +2363,7 @@ if i32.const 0 i32.const 192 - i32.const 14 + i32.const 16 i32.const 0 call $~lib/env/abort unreachable @@ -2285,7 +2381,7 @@ if i32.const 0 i32.const 192 - i32.const 16 + i32.const 18 i32.const 0 call $~lib/env/abort unreachable @@ -2298,7 +2394,7 @@ if i32.const 0 i32.const 192 - i32.const 18 + i32.const 20 i32.const 0 call $~lib/env/abort unreachable @@ -2312,7 +2408,7 @@ if i32.const 0 i32.const 192 - i32.const 19 + i32.const 21 i32.const 0 call $~lib/env/abort unreachable @@ -2326,7 +2422,7 @@ if i32.const 0 i32.const 192 - i32.const 20 + i32.const 22 i32.const 0 call $~lib/env/abort unreachable @@ -2344,7 +2440,7 @@ if i32.const 0 i32.const 192 - i32.const 22 + i32.const 24 i32.const 0 call $~lib/env/abort unreachable @@ -2357,7 +2453,7 @@ if i32.const 0 i32.const 192 - i32.const 24 + i32.const 26 i32.const 0 call $~lib/env/abort unreachable @@ -2371,7 +2467,7 @@ if i32.const 0 i32.const 192 - i32.const 25 + i32.const 27 i32.const 0 call $~lib/env/abort unreachable @@ -2385,7 +2481,7 @@ if i32.const 0 i32.const 192 - i32.const 26 + i32.const 28 i32.const 0 call $~lib/env/abort unreachable @@ -2403,7 +2499,7 @@ if i32.const 0 i32.const 192 - i32.const 28 + i32.const 30 i32.const 0 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string-utf8.optimized.wat b/tests/compiler/std/string-utf8.optimized.wat index b4144633..0f0e29d9 100644 --- a/tests/compiler/std/string-utf8.optimized.wat +++ b/tests/compiler/std/string-utf8.optimized.wat @@ -1514,7 +1514,7 @@ if i32.const 0 i32.const 136 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -1529,7 +1529,7 @@ if i32.const 0 i32.const 136 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string-utf8.untouched.wat b/tests/compiler/std/string-utf8.untouched.wat index 07c3f866..fb86de89 100644 --- a/tests/compiler/std/string-utf8.untouched.wat +++ b/tests/compiler/std/string-utf8.untouched.wat @@ -1928,7 +1928,7 @@ if i32.const 0 i32.const 136 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -1945,7 +1945,7 @@ if i32.const 0 i32.const 136 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 98c1e44b..cf7ff82d 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -444,7 +444,7 @@ if i32.const 0 i32.const 120 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -459,7 +459,7 @@ if i32.const 0 i32.const 120 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -3289,7 +3289,7 @@ if i32.const 0 i32.const 120 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -5235,7 +5235,7 @@ if i32.const 0 i32.const 120 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -5249,7 +5249,7 @@ if i32.const 0 i32.const 120 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 3a3b500d..691b2a94 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -366,7 +366,7 @@ if i32.const 0 i32.const 120 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -383,7 +383,7 @@ if i32.const 0 i32.const 120 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -3505,15 +3505,15 @@ (local $9 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl local.set $5 local.get $0 - local.get $3 + local.get $2 i32.shl call $~lib/runtime/allocate i32.const 3 @@ -3551,10 +3551,10 @@ local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if local.get $6 - local.get $1 + local.get $3 local.get $5 call $~lib/memory/memory.copy end @@ -3893,7 +3893,7 @@ if i32.const 0 i32.const 120 - i32.const 125 + i32.const 115 i32.const 8 call $~lib/env/abort unreachable @@ -4123,9 +4123,9 @@ i32.const 0 local.set $3 local.get $4 + i32.const 2 + i32.const 2 local.get $3 - i32.const 2 - i32.const 2 call $~lib/runtime/makeArray end return @@ -4135,17 +4135,11 @@ i32.eq if block (result i32) - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 1 - local.set $5 - i32.const 0 - local.set $6 - local.get $5 - local.get $6 - i32.const 2 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 1 + i32.const 2 + i32.const 2 + i32.const 0 + call $~lib/runtime/makeArray local.set $3 local.get $3 i32.load offset=4 @@ -4153,11 +4147,11 @@ local.get $4 block (result i32) local.get $0 - local.set $6 - local.get $6 + local.set $5 + local.get $5 local.get $3 call $~lib/collector/dummy/__ref_link - local.get $6 + local.get $5 end i32.store local.get $3 @@ -4166,10 +4160,10 @@ end local.get $0 call $~lib/string/String#get:length - local.set $7 + local.set $6 local.get $1 call $~lib/string/String#get:length - local.set $8 + local.set $7 local.get $2 i32.const 0 i32.lt_s @@ -4177,26 +4171,26 @@ global.get $~lib/builtins/i32.MAX_VALUE local.set $2 end - local.get $8 + local.get $7 i32.eqz if - local.get $7 + local.get $6 i32.eqz if - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) i32.const 0 local.set $3 i32.const 0 local.set $4 local.get $3 + i32.const 2 + i32.const 2 local.get $4 - i32.const 2 - i32.const 2 call $~lib/runtime/makeArray end return end - local.get $7 + local.get $6 local.tee $4 local.get $2 local.tee $3 @@ -4204,16 +4198,16 @@ local.get $3 i32.lt_s select - local.set $7 - block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) - local.get $7 + local.set $6 + block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) + local.get $6 local.set $3 i32.const 0 local.set $4 local.get $3 + i32.const 2 + i32.const 2 local.get $4 - i32.const 2 - i32.const 2 call $~lib/runtime/makeArray end local.set $4 @@ -4222,10 +4216,10 @@ local.set $3 block $break|0 i32.const 0 - local.set $6 + local.set $5 loop $repeat|0 + local.get $5 local.get $6 - local.get $7 i32.lt_s i32.eqz br_if $break|0 @@ -4237,35 +4231,35 @@ local.get $9 call $~lib/runtime/allocate end - local.set $5 - local.get $5 + local.set $8 + local.get $8 i32.const 1 call $~lib/runtime/register end - local.set $5 - local.get $5 + local.set $8 + local.get $8 local.get $0 - local.get $6 + local.get $5 i32.const 1 i32.shl i32.add i32.load16_u i32.store16 local.get $3 - local.get $6 + local.get $5 i32.const 2 i32.shl i32.add - local.get $5 + local.get $8 i32.store - local.get $5 + local.get $8 local.get $4 call $~lib/collector/dummy/__ref_link end - local.get $6 + local.get $5 i32.const 1 i32.add - local.set $6 + local.set $5 br $repeat|0 unreachable end @@ -4274,18 +4268,18 @@ local.get $4 return else - local.get $7 + local.get $6 i32.eqz if - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) i32.const 1 local.set $4 i32.const 0 local.set $3 local.get $4 + i32.const 2 + i32.const 2 local.get $3 - i32.const 2 - i32.const 2 call $~lib/runtime/makeArray end local.set $3 @@ -4297,15 +4291,15 @@ return end end - block $~lib/runtime/MAKEARRAY|inlined.5 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) i32.const 0 local.set $4 i32.const 0 local.set $3 local.get $4 + i32.const 2 + i32.const 2 local.get $3 - i32.const 2 - i32.const 2 call $~lib/runtime/makeArray end local.set $10 @@ -4362,8 +4356,8 @@ local.get $10 block $~lib/runtime/REGISTER|inlined.8 (result i32) local.get $4 - local.set $6 - local.get $6 + local.set $5 + local.get $5 i32.const 1 call $~lib/runtime/register end @@ -4386,7 +4380,7 @@ return end local.get $11 - local.get $8 + local.get $7 i32.add local.set $12 end @@ -4397,15 +4391,15 @@ local.get $12 i32.eqz if - block $~lib/runtime/MAKEARRAY|inlined.6 (result i32) + block $~lib/runtime/MAKEARRAY|inlined.5 (result i32) i32.const 1 local.set $4 i32.const 0 local.set $3 local.get $4 + i32.const 2 + i32.const 2 local.get $3 - i32.const 2 - i32.const 2 call $~lib/runtime/makeArray end local.set $3 @@ -4416,7 +4410,7 @@ local.get $3 return end - local.get $7 + local.get $6 local.get $12 i32.sub local.set $14 @@ -6711,7 +6705,7 @@ if i32.const 0 i32.const 120 - i32.const 185 + i32.const 175 i32.const 4 call $~lib/env/abort unreachable @@ -6728,7 +6722,7 @@ if i32.const 0 i32.const 120 - i32.const 187 + i32.const 177 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index c5763b4b..5bb97e79 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -144,7 +144,7 @@ if i32.const 0 i32.const 72 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -159,7 +159,7 @@ if i32.const 0 i32.const 72 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index efdc7242..8c3296f7 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -201,7 +201,7 @@ if i32.const 0 i32.const 72 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -218,7 +218,7 @@ if i32.const 0 i32.const 72 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -499,7 +499,7 @@ call $~lib/env/abort unreachable end - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) + block $~lib/runtime/ALLOCATE|inlined.0 (result i32) local.get $1 local.set $2 local.get $2 @@ -545,23 +545,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 9 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.0 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 2 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 2 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -614,23 +605,14 @@ i32.store offset=20 ) (func $~lib/map/Map#constructor (; 11 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) - (local $1 i32) block (result i32) local.get $0 i32.eqz if - block $~lib/runtime/REGISTER>|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 24 - local.set $1 - local.get $1 - call $~lib/runtime/allocate - end - local.set $1 - local.get $1 - i32.const 4 - call $~lib/runtime/register - end + i32.const 24 + call $~lib/runtime/allocate + i32.const 4 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -3036,7 +3018,7 @@ i32.const 160 return end - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) + block $~lib/runtime/ALLOCATE|inlined.1 (result i32) local.get $4 local.set $5 local.get $5 diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 6dd36466..e3a5e1ec 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -439,7 +439,7 @@ if i32.const 0 i32.const 80 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -454,7 +454,7 @@ if i32.const 0 i32.const 80 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -497,7 +497,7 @@ if i32.const 0 i32.const 80 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable @@ -3055,26 +3055,26 @@ (local $5 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl local.tee $5 call $~lib/runtime/allocate i32.const 2 call $~lib/runtime/register - local.tee $3 - local.set $2 + local.tee $2 + local.set $1 local.get $4 i32.load drop local.get $4 - local.get $2 + local.get $1 i32.store local.get $4 - local.get $3 + local.get $2 i32.store offset=4 local.get $4 local.get $5 @@ -3082,10 +3082,10 @@ local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if + local.get $2 local.get $3 - local.get $1 local.get $5 call $~lib/memory/memory.copy end @@ -13038,9 +13038,9 @@ call $~lib/typedarray/Int8Array#fill global.get $std/typedarray/arr8 i32.const 5 - i32.const 240 i32.const 15 i32.const 0 + i32.const 240 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13059,9 +13059,9 @@ call $~lib/typedarray/Int8Array#fill global.get $std/typedarray/arr8 i32.const 5 - i32.const 312 i32.const 15 i32.const 0 + i32.const 312 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13080,9 +13080,9 @@ call $~lib/typedarray/Int8Array#fill global.get $std/typedarray/arr8 i32.const 5 - i32.const 336 i32.const 15 i32.const 0 + i32.const 336 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13101,9 +13101,9 @@ call $~lib/typedarray/Int8Array#fill global.get $std/typedarray/arr8 i32.const 5 - i32.const 360 i32.const 15 i32.const 0 + i32.const 360 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13122,9 +13122,9 @@ call $~lib/typedarray/Int8Array#fill global.get $std/typedarray/arr8 i32.const 5 - i32.const 384 i32.const 15 i32.const 0 + i32.const 384 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13188,9 +13188,9 @@ end global.get $std/typedarray/sub8 i32.const 3 - i32.const 408 i32.const 15 i32.const 0 + i32.const 408 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13204,9 +13204,9 @@ end global.get $std/typedarray/arr8 i32.const 5 - i32.const 432 i32.const 15 i32.const 0 + i32.const 432 call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz @@ -13248,9 +13248,9 @@ call $~lib/typedarray/Int32Array#fill global.get $std/typedarray/arr32 i32.const 5 - i32.const 456 i32.const 16 i32.const 2 + i32.const 456 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz @@ -13269,9 +13269,9 @@ call $~lib/typedarray/Int32Array#fill global.get $std/typedarray/arr32 i32.const 5 - i32.const 496 i32.const 16 i32.const 2 + i32.const 496 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz @@ -13290,9 +13290,9 @@ call $~lib/typedarray/Int32Array#fill global.get $std/typedarray/arr32 i32.const 5 - i32.const 536 i32.const 16 i32.const 2 + i32.const 536 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz @@ -13311,9 +13311,9 @@ call $~lib/typedarray/Int32Array#fill global.get $std/typedarray/arr32 i32.const 5 - i32.const 576 i32.const 16 i32.const 2 + i32.const 576 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz @@ -13332,9 +13332,9 @@ call $~lib/typedarray/Int32Array#fill global.get $std/typedarray/arr32 i32.const 5 - i32.const 616 i32.const 16 i32.const 2 + i32.const 616 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz @@ -13400,9 +13400,9 @@ end global.get $std/typedarray/sub32 i32.const 3 - i32.const 656 i32.const 16 i32.const 2 + i32.const 656 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz @@ -13416,9 +13416,9 @@ end global.get $std/typedarray/arr32 i32.const 5 - i32.const 688 i32.const 16 i32.const 2 + i32.const 688 call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz diff --git a/tests/compiler/std/typedarray.untouched.wat b/tests/compiler/std/typedarray.untouched.wat index 768405ab..11b32d90 100644 --- a/tests/compiler/std/typedarray.untouched.wat +++ b/tests/compiler/std/typedarray.untouched.wat @@ -498,7 +498,7 @@ if i32.const 0 i32.const 80 - i32.const 161 + i32.const 151 i32.const 4 call $~lib/env/abort unreachable @@ -515,7 +515,7 @@ if i32.const 0 i32.const 80 - i32.const 163 + i32.const 153 i32.const 4 call $~lib/env/abort unreachable @@ -579,7 +579,7 @@ if i32.const 0 i32.const 80 - i32.const 244 + i32.const 234 i32.const 57 call $~lib/env/abort unreachable @@ -595,18 +595,10 @@ local.get $0 i32.eqz if - block $~lib/runtime/REGISTER|inlined.0 (result i32) - block $~lib/runtime/ALLOCATE|inlined.1 (result i32) - i32.const 12 - local.set $4 - local.get $4 - call $~lib/runtime/allocate - end - local.set $4 - local.get $4 - i32.const 3 - call $~lib/runtime/register - end + i32.const 12 + call $~lib/runtime/allocate + i32.const 3 + call $~lib/runtime/register local.set $0 end local.get $0 @@ -651,19 +643,12 @@ local.get $0 ) (func $~lib/typedarray/Int8Array#constructor (; 11 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.2 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 4 call $~lib/runtime/register end @@ -689,19 +674,12 @@ call $~lib/runtime/ArrayBufferView#get:byteLength ) (func $~lib/typedarray/Uint8Array#constructor (; 15 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.3 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 5 call $~lib/runtime/register end @@ -716,19 +694,12 @@ call $~lib/runtime/ArrayBufferView#get:byteLength ) (func $~lib/typedarray/Uint8ClampedArray#constructor (; 17 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.4 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 6 call $~lib/runtime/register end @@ -743,19 +714,12 @@ call $~lib/runtime/ArrayBufferView#get:byteLength ) (func $~lib/typedarray/Int16Array#constructor (; 19 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.5 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 7 call $~lib/runtime/register end @@ -772,19 +736,12 @@ i32.shr_u ) (func $~lib/typedarray/Uint16Array#constructor (; 21 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.6 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 8 call $~lib/runtime/register end @@ -801,19 +758,12 @@ i32.shr_u ) (func $~lib/typedarray/Int32Array#constructor (; 23 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.7 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 9 call $~lib/runtime/register end @@ -830,19 +780,12 @@ i32.shr_u ) (func $~lib/typedarray/Uint32Array#constructor (; 25 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.8 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 10 call $~lib/runtime/register end @@ -859,19 +802,12 @@ i32.shr_u ) (func $~lib/typedarray/Int64Array#constructor (; 27 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.9 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 11 call $~lib/runtime/register end @@ -888,19 +824,12 @@ i32.shr_u ) (func $~lib/typedarray/Uint64Array#constructor (; 29 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.10 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 12 call $~lib/runtime/register end @@ -917,19 +846,12 @@ i32.shr_u ) (func $~lib/typedarray/Float32Array#constructor (; 31 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.11 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 13 call $~lib/runtime/register end @@ -946,19 +868,12 @@ i32.shr_u ) (func $~lib/typedarray/Float64Array#constructor (; 33 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) local.get $0 if (result i32) local.get $0 else - block $~lib/runtime/ALLOCATE|inlined.12 (result i32) - i32.const 12 - local.set $2 - local.get $2 - call $~lib/runtime/allocate - end - local.set $2 - local.get $2 + i32.const 12 + call $~lib/runtime/allocate i32.const 14 call $~lib/runtime/register end @@ -1608,8 +1523,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.13 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.1 (result i32) i32.const 12 local.set $8 local.get $8 @@ -1769,8 +1684,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.14 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.2 (result i32) i32.const 12 local.set $8 local.get $8 @@ -3987,15 +3902,15 @@ (local $9 i32) i32.const 16 call $~lib/runtime/allocate - local.get $2 + local.get $1 call $~lib/runtime/register local.set $4 local.get $0 - local.get $3 + local.get $2 i32.shl local.set $5 local.get $0 - local.get $3 + local.get $2 i32.shl call $~lib/runtime/allocate i32.const 2 @@ -4033,10 +3948,10 @@ local.get $4 local.get $0 i32.store offset=12 - local.get $1 + local.get $3 if local.get $6 - local.get $1 + local.get $3 local.get $5 call $~lib/memory/memory.copy end @@ -4220,8 +4135,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.15 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.3 (result i32) i32.const 12 local.set $8 local.get $8 @@ -15189,8 +15104,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.16 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.4 (result i32) i32.const 12 local.set $8 local.get $8 @@ -15554,8 +15469,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.17 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.5 (result i32) i32.const 12 local.set $8 local.get $8 @@ -15919,8 +15834,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.18 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.6 (result i32) i32.const 12 local.set $8 local.get $8 @@ -16290,8 +16205,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.19 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.7 (result i32) i32.const 12 local.set $8 local.get $8 @@ -16877,8 +16792,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.20 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.8 (result i32) i32.const 12 local.set $8 local.get $8 @@ -17236,8 +17151,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.21 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.9 (result i32) i32.const 12 local.set $8 local.get $8 @@ -17598,8 +17513,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.22 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.10 (result i32) i32.const 12 local.set $8 local.get $8 @@ -17960,8 +17875,8 @@ select local.set $3 end - block $~lib/runtime/REGISTER|inlined.1 (result i32) - block $~lib/runtime/ALLOCATE|inlined.23 (result i32) + block $~lib/runtime/REGISTER|inlined.0 (result i32) + block $~lib/runtime/ALLOCATE|inlined.11 (result i32) i32.const 12 local.set $8 local.get $8 @@ -18400,7 +18315,6 @@ ) (func $start:std/typedarray (; 378 ;) (type $FUNCSIG$v) (local $0 i32) - (local $1 i32) global.get $~lib/typedarray/Int8Array.BYTES_PER_ELEMENT i32.const 1 i32.eq @@ -18933,17 +18847,11 @@ call $~lib/typedarray/Int8Array#fill drop global.get $std/typedarray/arr8 - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 5 - local.set $0 - i32.const 240 - local.set $1 - local.get $0 - local.get $1 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 15 + i32.const 0 + i32.const 240 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -18961,17 +18869,11 @@ call $~lib/typedarray/Int8Array#fill drop global.get $std/typedarray/arr8 - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 5 - local.set $1 - i32.const 312 - local.set $0 - local.get $1 - local.get $0 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 15 + i32.const 0 + i32.const 312 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -18989,17 +18891,11 @@ call $~lib/typedarray/Int8Array#fill drop global.get $std/typedarray/arr8 - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 5 - local.set $0 - i32.const 336 - local.set $1 - local.get $0 - local.get $1 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 15 + i32.const 0 + i32.const 336 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -19017,17 +18913,11 @@ call $~lib/typedarray/Int8Array#fill drop global.get $std/typedarray/arr8 - block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) - i32.const 5 - local.set $1 - i32.const 360 - local.set $0 - local.get $1 - local.get $0 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 15 + i32.const 0 + i32.const 360 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -19045,17 +18935,11 @@ call $~lib/typedarray/Int8Array#fill drop global.get $std/typedarray/arr8 - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) - i32.const 5 - local.set $0 - i32.const 384 - local.set $1 - local.get $0 - local.get $1 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 15 + i32.const 0 + i32.const 384 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -19117,17 +19001,11 @@ unreachable end global.get $std/typedarray/sub8 - block $~lib/runtime/MAKEARRAY|inlined.5 (result i32) - i32.const 3 - local.set $1 - i32.const 408 - local.set $0 - local.get $1 - local.get $0 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 15 + i32.const 0 + i32.const 408 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -19139,17 +19017,11 @@ unreachable end global.get $std/typedarray/arr8 - block $~lib/runtime/MAKEARRAY|inlined.6 (result i32) - i32.const 5 - local.set $0 - i32.const 432 - local.set $1 - local.get $0 - local.get $1 - i32.const 15 - i32.const 0 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 15 + i32.const 0 + i32.const 432 + call $~lib/runtime/makeArray call $std/typedarray/isInt8ArrayEqual i32.eqz if @@ -19191,17 +19063,11 @@ call $~lib/typedarray/Int32Array#fill drop global.get $std/typedarray/arr32 - block $~lib/runtime/MAKEARRAY|inlined.0 (result i32) - i32.const 5 - local.set $1 - i32.const 456 - local.set $0 - local.get $1 - local.get $0 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 16 + i32.const 2 + i32.const 456 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if @@ -19219,17 +19085,11 @@ call $~lib/typedarray/Int32Array#fill drop global.get $std/typedarray/arr32 - block $~lib/runtime/MAKEARRAY|inlined.1 (result i32) - i32.const 5 - local.set $0 - i32.const 496 - local.set $1 - local.get $0 - local.get $1 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 16 + i32.const 2 + i32.const 496 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if @@ -19247,17 +19107,11 @@ call $~lib/typedarray/Int32Array#fill drop global.get $std/typedarray/arr32 - block $~lib/runtime/MAKEARRAY|inlined.2 (result i32) - i32.const 5 - local.set $1 - i32.const 536 - local.set $0 - local.get $1 - local.get $0 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 16 + i32.const 2 + i32.const 536 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if @@ -19275,17 +19129,11 @@ call $~lib/typedarray/Int32Array#fill drop global.get $std/typedarray/arr32 - block $~lib/runtime/MAKEARRAY|inlined.3 (result i32) - i32.const 5 - local.set $0 - i32.const 576 - local.set $1 - local.get $0 - local.get $1 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 16 + i32.const 2 + i32.const 576 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if @@ -19303,17 +19151,11 @@ call $~lib/typedarray/Int32Array#fill drop global.get $std/typedarray/arr32 - block $~lib/runtime/MAKEARRAY|inlined.4 (result i32) - i32.const 5 - local.set $1 - i32.const 616 - local.set $0 - local.get $1 - local.get $0 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 16 + i32.const 2 + i32.const 616 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if @@ -19379,17 +19221,11 @@ unreachable end global.get $std/typedarray/sub32 - block $~lib/runtime/MAKEARRAY|inlined.5 (result i32) - i32.const 3 - local.set $0 - i32.const 656 - local.set $1 - local.get $0 - local.get $1 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 3 + i32.const 16 + i32.const 2 + i32.const 656 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if @@ -19401,17 +19237,11 @@ unreachable end global.get $std/typedarray/arr32 - block $~lib/runtime/MAKEARRAY|inlined.6 (result i32) - i32.const 5 - local.set $1 - i32.const 688 - local.set $0 - local.get $1 - local.get $0 - i32.const 16 - i32.const 2 - call $~lib/runtime/makeArray - end + i32.const 5 + i32.const 16 + i32.const 2 + i32.const 688 + call $~lib/runtime/makeArray call $std/typedarray/isInt32ArrayEqual i32.eqz if